:root {
    --bg-color: #021b21;
    --bg-color: #8e0000;
    /* Christmas Red */
    --text-color: #FFFFFF;
    --accent-color: #FFD700;
    /* Gold */
    --font-main: 'Montserrat', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body,
html {
    width: 100%;
    height: 100%;
    /* Gradient Background for Christmas vibe */
    background: linear-gradient(180deg, #8e0000 0%, #0F3B1E 100%);
    /* Red to Pine Green */
    color: var(--text-color);
    font-family: var(--font-main);
    overflow: hidden;
    /* Prevent scrolling on kiosk */
    display: flex;
    flex-direction: column;
}

#app {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.screen {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease-in-out;
    background: transparent;
    /* Allow body gradient to show */
    z-index: 1;
}

.screen.active {
    opacity: 1;
    pointer-events: all;
    z-index: 10;
}

/* --- IDLE SCREEN --- */
.main-logo-text {
    font-size: 5rem;
    font-weight: 900;
    color: var(--accent-color);
    /* Strong Gold Glow */
    text-shadow:
        0 0 10px rgba(255, 215, 0, 0.8),
        0 0 20px rgba(255, 215, 0, 0.6),
        0 0 40px rgba(255, 215, 0, 0.4);
    margin: 0;
    line-height: 1;
    font-family: 'Montserrat', sans-serif;
    letter-spacing: 5px;
    text-align: center;
}

.logo-container {
    text-align: center;
    margin-bottom: 50px;
}

.cta-container {
    margin-top: 100px;
    animation: pulse 2s infinite;
}

.cta-text {
    font-size: 1.5rem;
    margin-bottom: 20px;
    text-transform: uppercase;
    font-weight: 700;
    text-shadow: 0 0 10px rgba(0, 229, 255, 0.5);
}

/* --- CAMERA SCREEN --- */
#screen-camera {
    background-color: black;
    /* Cinematic black bars */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.camera-viewport {
    position: relative;
    /* Drive size by height first to avoid wide-screen stretch */
    height: 65vh;
    width: auto;
    aspect-ratio: 3 / 4;
    max-width: 100%;
    /* Safety for mobile */
    overflow: hidden;
    border: 4px solid white;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.5);
    border-radius: 4px;
    margin: 0 auto;
    /* Center it */
}

/* On very narrow screens, width becomes the limiter */
@media (max-aspect-ratio: 3/4) {
    .camera-viewport {
        width: 90%;
        height: auto;
    }
}

/* Ensure viewport doesn't overflow width on mobile */
@media (max-width: 600px) {
    .camera-viewport {
        margin-bottom: 10px;
    }
}

#webcam-feed {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Crucial: Fills the 3:4 box */
    transform: scaleX(-1);
    display: block;
}

#camera-overlay-preview {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* Overlay fits perfectly */
    pointer-events: none;
    z-index: 10;
}

#countdown-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 15rem;
    font-weight: 900;
    color: white;
    text-shadow: 0 0 30px var(--accent-color);
    z-index: 20;
}

.hidden {
    display: none !important;
}

/* Controls Wrapper */
#camera-controls-ui {
    margin-top: 20px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    position: relative;
    height: 120px;
    /* Reserved space */
}

#btn-snap {
    /* Reset absolute positioning */
    position: relative;
    bottom: auto;
    left: auto;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.1);
    border: 4px solid white;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.2s;
    outline: none;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
}

#btn-snap:active {
    transform: scale(0.95);
}

.btn-inner {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--accent-color);
}

/* Overlay Selector (Now in controls) */
#overlay-selector {
    /* Reset absolute */
    position: relative;
    top: auto;
    left: auto;
    transform: none;
    display: flex;
    align-items: center;
    gap: 20px;
    z-index: 20;
    background: transparent;
    padding: 0;
    border-radius: 0;
    backdrop-filter: none;
}


/* --- REVIEW SCREEN --- */
.preview-container {
    height: 80%;
    display: flex;
    justify-content: center;
    align-items: center;
}

#photo-preview {
    max-height: 100%;
    max-width: 90%;
    border: 10px solid white;
    box-shadow: 0 0 40px rgba(255, 215, 0, 0.3);
}

.controls {
    height: 20%;
    display: flex;
    gap: 40px;
    align-items: center;
}

.btn {
    padding: 15px 40px;
    font-size: 1.5rem;
    border: none;
    cursor: pointer;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 2px;
    transition: all 0.3s;
    font-family: var(--font-main);
}

.btn-outline {
    background: transparent;
    border: 2px solid white;
    color: white;
}

.btn-outline:hover {
    background: white;
    color: var(--bg-color);
    box-shadow: 0 0 20px white;
}

.btn-solid {
    background: var(--accent-color);
    color: #000;
}

.btn-solid:hover {
    background: #ffffff;
    box-shadow: 0 0 30px var(--accent-color);
}

/* --- PRINTING SCREEN --- */
.printing-content {
    text-align: center;
}

.loader {
    width: 60px;
    height: 60px;
    border: 8px solid rgba(255, 255, 255, 0.1);
    border-top: 8px solid var(--accent-color);
    border-radius: 50%;
    margin: 0 auto 30px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes pulse {
    0% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.5;
    }
}

#scanner-input {
    opacity: 0;
    position: absolute;
    top: -1000px;
}

/* --- SUCCESS SCREEN --- */
.success-content {
    text-align: center;
    animation: fadeIn 0.5s ease-out;
}

.checkmark-circle {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--accent-color);
    margin: 0 auto 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 30px var(--accent-color);
}

.checkmark {
    width: 30px;
    height: 60px;
    border-bottom: 8px solid #000;
    /* Contrast with cyan */
    border-right: 8px solid #000;
    transform: rotate(45deg);
    margin-top: -10px;
}

.small {
    font-size: 1rem;
    opacity: 0.7;
    margin-top: 20px;
    font-style: italic;
    color: var(--accent-color);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- ERROR FEEDBACK --- */
.error-msg {
    color: #ff0033;
    /* Bright Red */
    font-weight: 900;
    font-size: 2rem;
    margin-top: 20px;
    text-shadow: 0 0 10px rgba(255, 0, 51, 0.5);
    animation: shake 0.5s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes shake {

    10%,
    90% {
        transform: translate3d(-1px, 0, 0);
    }

    20%,
    80% {
        transform: translate3d(2px, 0, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-4px, 0, 0);
    }

    40%,
    60% {
        transform: translate3d(4px, 0, 0);
    }
}

/* --- FORM SCREEN --- */
.form-container {
    width: 90%;
    max-width: 600px;
    background: rgba(50, 0, 0, 0.9);
    padding: 30px;
    border-radius: 20px;
    border: 2px solid var(--accent-color);
    box-shadow: 0 0 40px rgba(255, 215, 0, 0.3);
    text-align: center;
}

.form-container h2 {
    color: var(--accent-color);
    margin-bottom: 10px;
    font-size: 1.8rem;
}

.form-container p {
    margin-bottom: 20px;
    opacity: 0.8;
}

#user-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.form-row {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

/* On mobile, stack the row inputs (nom/prenom) */
@media (max-width: 480px) {
    .form-row {
        flex-direction: column;
        gap: 15px;
    }
}

input {
    width: 100%;
    padding: 15px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.3);
    color: white;
    font-size: 1rem;
    font-family: var(--font-main);
    border-radius: 10px;
    outline: none;
    transition: all 0.3s;
}

input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
}

.btn-large {
    width: 100%;
    margin-top: 10px;
    padding: 20px;
}

.btn-small {
    padding: 10px;
    font-size: 1rem;
    border: none;
    opacity: 0.7;
}

.btn-small:hover {
    opacity: 1;
    background: transparent;
    box-shadow: none;
    text-decoration: underline;
}

/* --- OVERLAY SELECTOR --- */
#overlay-selector {
    position: absolute;
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 20px;
    z-index: 20;
    background: rgba(0, 0, 0, 0.5);
    padding: 10px 20px;
    border-radius: 30px;
    backdrop-filter: blur(5px);
}

#overlay-name {
    font-weight: 700;
    text-transform: uppercase;
    min-width: 150px;
    text-align: center;
}

.nav-btn {
    background: transparent;
    border: 2px solid white;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.nav-btn:hover {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: black;
}

/* --- MOBILE RESPONSIVENESS (iPhone SE eq) --- */
@media (max-width: 480px) {

    /* IDLE SCREEN */
    .main-logo-text {
        font-size: 3rem;
    }

    .cta-text {
        font-size: 1.2rem;
    }

    /* REVIEW SCREEN */
    .controls {
        flex-direction: column;
        gap: 15px;
        height: auto;
        padding-bottom: 20px;
    }

    .btn {
        width: 100%;
        padding: 15px;
        font-size: 1.1rem;
    }

    .preview-container {
        height: 65%;
    }
}

/* --- TOAST NOTIFICATIONS --- */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast-message {
    background: rgba(50, 0, 0, 0.95);
    border: 1px solid var(--accent-color);
    border-left: 5px solid var(--accent-color);
    color: white;
    padding: 15px 25px;
    border-radius: 4px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    font-family: var(--font-main);
    font-size: 1rem;
    pointer-events: all;
    animation: slideIn 0.3s ease-out forwards;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 300px;
    backdrop-filter: blur(10px);
}

.toast-message.error {
    border-left-color: #ff0033;
    box-shadow: 0 5px 15px rgba(255, 0, 51, 0.2);
}

.toast-message.success {
    border-left-color: #00ff66;
    box-shadow: 0 5px 15px rgba(0, 255, 102, 0.2);
}

.toast-message.info {
    border-left-color: var(--accent-color);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateX(20px);
    }
}