:root {
    --booth-bg: #f4f5f7;
    --card-bg: #ffffff;
    --border: #e2e4e9;
    --accent: #6c5ce7;
    --text: #232530;
    --text-muted: #6b7280;
    --slot-bg: #e9eaee;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--booth-bg);
    color: var(--text);
    overflow: hidden;
    height: 100vh;
}

/* =========================================
   MOVIE SELECT SCREEN
========================================= */
.kiosk-select {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    padding: 2rem;
    text-align: center;
}
.branch-logo { max-height: 80px; margin-bottom: 1rem; }
.select-header h1 { margin: 0.25rem 0; font-size: 1.8rem; color: var(--text); }
.select-header p { color: var(--text-muted); margin-bottom: 2rem; }

.movie-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.5rem;
    max-width: 900px;
    width: 100%;
}
.movie-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text);
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.15s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.movie-tile:active { transform: scale(0.96); }
.movie-tile img { width: 100%; height: 220px; object-fit: cover; }
.movie-tile-placeholder {
    width: 100%;
    height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: white;
    font-size: 1.2rem;
    padding: 1rem;
    text-align: center;
}
.movie-tile-title { padding: 0.75rem; font-size: 1rem; font-weight: 600; }
.no-movies { color: var(--text-muted); grid-column: 1 / -1; }

.pending-print-banner {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #16a34a;
    color: white;
    border-radius: 14px;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 8px 30px rgba(0,0,0,0.25);
    z-index: 100;
    max-width: 90vw;
}
.pending-strip-thumb { width: 40px; height: 113px; object-fit: cover; border-radius: 4px; }
.pending-print-text { display: flex; flex-direction: column; font-size: 0.9rem; }
.pending-print-banner .control-btn { padding: 0.6rem 1.2rem; font-size: 0.9rem; }

/* =========================================
   CAPTURE SCREEN
========================================= */
.kiosk-capture { height: 100vh; display: flex; align-items: center; justify-content: center; }

.booth-frame {
    display: flex;
    width: 95vw;
    max-width: 1200px;
    height: 90vh;
    max-height: 720px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 24px rgba(0,0,0,0.06);
}

/* Left: numbered slots — sized to match the ACTUAL photo aspect ratio (829:669)
   so the customer can judge before printing whether the shot looks right,
   instead of a thin distorted sliver. */
.slot-panel {
    width: 190px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px 12px;
    background: #fafafa;
    justify-content: center;
    flex-shrink: 0;
}
.slot {
    aspect-ratio: 829 / 669;
    width: 100%;
    background: var(--slot-bg);
    border: 1px dashed #c9cbd4;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}
.slot span { font-size: 2rem; font-weight: 700; color: #9ca3af; }
.slot.filled { border-style: solid; border-color: var(--accent); }
.slot.filled span { display: none; }
.slot-thumb { width: 100%; height: 100%; object-fit: cover; }

/* Center: camera preview */
.preview-panel {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px;
    min-width: 0;
}
.camera-select-row { width: 100%; text-align: right; margin-bottom: 6px; display: flex; justify-content: flex-end; gap: 8px; }
.flip-camera-btn {
    background: #f0f0f3;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 0.4rem 0.9rem;
    font-size: 0.8rem;
    color: var(--text);
    cursor: pointer;
}
#cameraSelect {
    background: #f0f0f3;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    color: var(--text);
    max-width: 220px;
}

#cameraFeed, #reviewImage {
    width: 100%;
    height: 100%;
    max-height: calc(100% - 70px);
    object-fit: cover;
    border-radius: 10px;
    background: #e5e7eb;
    transform: scaleX(1); /* mirroring is toggled via .mirrored class in JS, based on front/back camera */
}
#reviewImage { transform: none; } /* already mirrored at capture time */
#cameraFeed.mirrored { transform: scaleX(-1); }

.countdown-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.55);
    border-radius: 10px;
}
#countdownNumber { font-size: 8rem; font-weight: 800; color: var(--accent); }

.filter-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 12px;
}
.filter-btn, .x-btn {
    background: #f0f0f3;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0.6rem 1.4rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
}
.filter-btn.active { background: var(--accent); color: white; border-color: var(--accent); }
.x-btn { padding: 0.6rem 1rem; }

.brand-mark { margin-top: 8px; font-style: italic; font-size: 0.9rem; color: var(--text-muted); }

/* Right: controls */
.control-panel {
    width: 170px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px 12px;
    justify-content: center;
    background: #fafafa;
    flex-shrink: 0;
}
.control-btn {
    background: white;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 1rem 0.5rem;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
}
#startBtn, #startCountBtn {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
.control-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.control-btn:active:not(:disabled) { transform: scale(0.97); }
.change-movie-link { text-align: center; color: var(--text-muted); font-size: 0.85rem; text-decoration: underline; margin-top: 8px; }

/* =========================================
   RESULT / PRINT SCREEN
========================================= */
.result-screen {
    height: 100vh;
    width: 100vw;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    text-align: center;
    background: var(--booth-bg);
    color: var(--text);
}
.strip-preview {
    max-height: 55vh;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.12);
}
.print-status { font-size: 1.1rem; color: var(--accent); }
/* =========================================
   MOBILE RESPONSIVE FIX
   Stacks the booth-frame vertically on small
   screens so the camera preview gets real space.
========================================= */
@media (max-width: 768px) {

    body {
        overflow-y: auto; /* allow scrolling on short screens if needed */
    }

    .kiosk-capture {
        height: auto;
        min-height: 100vh;
        padding: 10px 0;
    }

    .booth-frame {
        flex-direction: column;
        width: 95vw;
        height: auto;
        max-height: none;
        border-radius: 12px;
    }

    /* Camera preview comes FIRST and gets the biggest chunk */
    .preview-panel {
        order: 1;
        width: 100%;
        padding: 10px;
        min-height: 60vh;
    }

    #cameraFeed, #reviewImage {
        max-height: 50vh;
    }

    /* Slot thumbnails become a horizontal scroll strip below camera */
    .slot-panel {
        order: 2;
        width: 100%;
        flex-direction: row;
        overflow-x: auto;
        padding: 10px;
        gap: 8px;
    }

    .slot {
        width: 70px;
        flex-shrink: 0;
    }

    .slot span {
        font-size: 1.2rem;
    }

    /* Controls become a horizontal row below the slots */
    .control-panel {
        order: 3;
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        padding: 12px;
        gap: 8px;
    }

    .control-btn {
        flex: 1 1 auto;
        min-width: 100px;
        padding: 0.8rem 0.5rem;
        font-size: 0.95rem;
    }

    .change-movie-link {
        width: 100%;
        margin-top: 4px;
    }

    #countdownNumber {
        font-size: 5rem;
    }
}

/* Extra-narrow phones */
@media (max-width: 380px) {
    .slot {
        width: 56px;
    }
    .control-btn {
        font-size: 0.85rem;
        padding: 0.7rem 0.4rem;
    }
}
