/* =====================================================
   AI Air Canvas - Minimal Style
   Clean, functional design
   ===================================================== */

:root {
    --bg-dark: #111;
    --bg-panel: #1a1a1a;
    --border-color: #333;
    --text-primary: #fff;
    --text-muted: #888;
    --accent: #fff;
    --header-height: 50px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* Welcome Page */
.welcome-page {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #0a0a0f 0%, #1a1a2e 50%, #0a0a0f 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    overflow-y: auto;
    padding: 2rem;
}

.welcome-page.hidden {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.welcome-container {
    max-width: 800px;
    width: 100%;
    text-align: center;
    padding-top: 2rem;
    padding-bottom: 2rem;
}

.welcome-header {
    margin-bottom: 2.5rem;
}

.welcome-title {
    font-size: 3.5rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    animation: shimmer 3s ease-in-out infinite;
    background: linear-gradient(135deg, #a855f7 0%, #ec4899 50%, #f97316 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-title .title-emoji {
    -webkit-text-fill-color: initial;
}

@keyframes shimmer {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.8;
    }
}

.welcome-subtitle {
    font-size: 1.15rem;
    color: var(--text-muted);
    font-weight: 400;
}

.manual-section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.manual-section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    color: var(--text-primary);
}

.gesture-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
}

.gesture-card {
    padding: 1.25rem 1rem;
    background: rgba(168, 85, 247, 0.08);
    border-radius: 12px;
    border: 1px solid rgba(168, 85, 247, 0.2);
    transition: transform 0.2s ease, background 0.2s ease;
}

.gesture-card:hover {
    transform: translateY(-4px);
    background: rgba(168, 85, 247, 0.12);
}

.gesture-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}

.gesture-card h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: var(--text-primary);
}

.gesture-card p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.keyboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
}

.key-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.key-item kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    padding: 0.35rem 0.6rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    font-family: 'Inter', monospace;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
}

.key-item span {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.welcome-note {
    margin: 1.5rem 0;
    padding: 0.75rem 1rem;
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid rgba(251, 191, 36, 0.25);
    border-radius: 8px;
}

.welcome-note p {
    font-size: 0.85rem;
    color: #fbbf24;
    margin: 0;
}

.start-button {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 2.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, #a855f7 0%, #ec4899 100%);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 20px rgba(168, 85, 247, 0.4);
}

.start-button:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 30px rgba(168, 85, 247, 0.5);
}

.start-button:active {
    transform: translateY(0) scale(0.98);
}

.start-button svg {
    transition: transform 0.2s ease;
}

.start-button:hover svg {
    transform: translateX(4px);
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    inset: 0;
    background: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.loader {
    text-align: center;
}

.loader h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.loader p {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.loader-spinner {
    width: 40px;
    height: 40px;
    border: 2px solid var(--border-color);
    border-top-color: var(--text-primary);
    border-radius: 50%;
    margin: 0 auto 1rem;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* App Container */
.app-container {
    display: grid;
    grid-template-rows: var(--header-height) 1fr;
    grid-template-columns: 1fr auto;
    height: 100vh;
    width: 100vw;
}

.app-container.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Color Palette Header */
.palette-header {
    grid-column: 1 / -1;
    display: flex;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
}

.color-box {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: opacity 0.15s;
    border-right: 1px solid rgba(0, 0, 0, 0.3);
}

.color-box:last-child {
    border-right: none;
}

.color-box span {
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.9;
}

.color-box:hover {
    opacity: 0.85;
}

.color-box.active {
    box-shadow: inset 0 0 0 3px #fff;
}

.eraser-box span {
    color: #aaa;
}

/* Canvas Area */
.canvas-area {
    position: relative;
    background: #000;
    overflow: hidden;
}

#video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

#drawing-canvas,
#ui-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#ui-canvas {
    z-index: 10;
}

/* Controls Panel */
.controls-panel {
    width: 160px;
    background: var(--bg-panel);
    border-left: 1px solid var(--border-color);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.control-group label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.mode-badge {
    padding: 0.4rem 0.75rem;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    text-align: center;
    font-weight: 500;
    font-size: 0.75rem;
}

.mode-badge.drawing {
    border-color: #4a4;
    color: #6c6;
}

.mode-badge.selection {
    border-color: #aa4;
    color: #cc6;
}

.mode-badge.eraser {
    border-color: #666;
    color: #999;
}

.mode-badge.clear {
    border-color: #a44;
    color: #c66;
}

/* Brush Size Controls */
.brush-size-control {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.brush-size-control span {
    font-weight: 600;
    font-size: 1rem;
    min-width: 2rem;
    text-align: center;
}

.btn-icon {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: transparent;
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-icon:hover {
    background: var(--border-color);
}

.brush-preview {
    width: 40px;
    height: 40px;
    margin: 0.5rem auto;
    border-radius: 50%;
    background: #fff;
}

/* Action Buttons */
.btn-action {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.15s;
    margin-bottom: 0.4rem;
}

.btn-action:hover {
    background: var(--border-color);
}

/* Instructions */
.instructions-toggle {
    position: fixed;
    bottom: 1rem;
    left: 1rem;
    z-index: 100;
}

.btn-help {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--bg-panel);
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    transition: border-color 0.15s;
}

.btn-help:hover {
    border-color: var(--text-muted);
}

.instructions {
    position: fixed;
    bottom: 3.5rem;
    left: 1rem;
    width: 220px;
    padding: 1rem;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    z-index: 99;
    transition: opacity 0.2s, transform 0.2s;
}

.instructions.hidden {
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
}

.instructions h3 {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

.instructions ul {
    list-style: none;
    margin-bottom: 0.75rem;
}

.instructions li {
    font-size: 0.8rem;
    padding: 0.15rem 0;
    color: var(--text-muted);
}

.instructions li strong {
    color: var(--text-primary);
}

/* Responsive */
@media (max-width: 768px) {
    .controls-panel {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: auto;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        padding: 0.75rem;
        gap: 0.75rem;
        border-left: none;
        border-top: 1px solid var(--border-color);
    }

    .control-group {
        flex: 0 0 auto;
    }

    .app-container {
        grid-template-columns: 1fr;
        grid-template-rows: var(--header-height) 1fr auto;
    }

    .instructions {
        left: 50%;
        transform: translateX(-50%);
        bottom: 5rem;
    }

    .instructions.hidden {
        transform: translateX(-50%) translateY(10px);
    }

    .instructions-toggle {
        bottom: 4rem;
        left: 50%;
        transform: translateX(-50%);
    }
}