@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700&display=swap');

:root {
    --primary-color: #f5c518;
    /* Gold/Yellow */
    --secondary-color: #f4f4f4;
    /* Light gray */
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --text-color: #1a1a1a;
    --text-muted: #666666;
    --accent: #ff4d4d;
    --input-bg: #ffffff;
    --input-border: #e0e0e0;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.container {
    width: 100%;
    max-width: 500px;
    background: var(--card-bg);
    padding: 40px;
    border-radius: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 10px;
}

header p {
    color: var(--text-muted);
}

.step-indicator {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 30px;
}

.step {
    width: 40px;
    height: 4px;
    background: #eee;
    border-radius: 2px;
}

.step.active {
    background: var(--primary-color);
}

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 400;
    color: var(--text-muted);
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="file"] {
    width: 100%;
    padding: 14px 18px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 12px;
    color: var(--text-color);
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.3s ease;
}

input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(245, 197, 24, 0.1);
}

.upload-area {
    border: 2px dashed #ddd;
    padding: 30px;
    border-radius: 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fafafa;
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: rgba(245, 197, 24, 0.05);
}

.upload-area i {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 10px;
    display: block;
}

.btn {
    width: 100%;
    padding: 16px;
    background: var(--primary-color);
    border: none;
    border-radius: 12px;
    color: #000;
    font-weight: 700;
    font-size: 1.1rem;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    margin-top: 10px;
}

.btn:hover {
    background: #e5b815;
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    background: #444;
    color: #888;
    cursor: not-allowed;
}

.checkbox-group {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 15px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.checkbox-group input {
    -webkit-appearance: none;
    appearance: none;
    background-color: #fff;
    margin: 4px 0 0 0;
    width: 22px !important;
    height: 22px !important;
    min-width: 22px !important;
    min-height: 22px !important;
    border: 2px solid #ddd;
    border-radius: 6px;
    display: grid;
    place-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.checkbox-group input::before {
    content: "";
    width: 12px;
    height: 12px;
    transform: scale(0);
    transition: 120ms transform ease-in-out;
    background-color: var(--primary-color);
    clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}

.checkbox-group input:checked::before {
    transform: scale(1);
}

.checkbox-group input:checked {
    border-color: var(--primary-color);
    background-color: #fff;
}


#result-ocr {
    margin-top: 20px;
    padding: 15px;
    background: rgba(0, 255, 0, 0.05);
    border: 1px solid rgba(0, 255, 0, 0.1);
    border-radius: 12px;
    display: none;
}

.loading {
    display: none;
    text-align: center;
    margin: 20px 0;
}

.spinner {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(245, 197, 24, 0.3);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: inline-block;
}

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

#form-p2 {
    display: none;
}

/* Caméra et Overlay */
#camera-container {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 1000;
}

#camera-stream {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.crop-guide {
    width: 80%;
    height: 60%;
    border: 2px solid var(--primary-color);
    border-radius: 12px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
    position: relative;
}

.crop-guide::after {
    content: "CADREZ VOTRE TICKET ICI";
    position: absolute;
    top: -30px;
    left: 0;
    width: 100%;
    text-align: center;
    color: var(--primary-color);
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 1px;
}

.camera-controls {
    position: absolute;
    bottom: 40px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-around;
    align-items: center;
    pointer-events: auto;
}

.shutter-btn {
    width: 70px;
    height: 70px;
    background: white;
    border-radius: 50%;
    border: 5px solid rgba(245, 197, 24, 0.5);
    cursor: pointer;
}

.close-camera {
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}

.instruction-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    background: #f0f0f0;
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 20px;
    border-left: 4px solid var(--primary-color);
}

/* Popup de résultat (Modale) */
#result-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.popup-card {
    background: white;
    padding: 40px;
    border-radius: 32px;
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: popupSlide 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popupSlide {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

#lottie-container {
    width: 180px;
    height: 180px;
    margin-bottom: 20px;
}

.result-title {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.result-message {
    color: var(--text-muted);
    margin-bottom: 30px;
    max-width: 300px;
}

/* --- RESPONSIVE OPTIMIZATIONS --- */

@media (max-width: 600px) {
    body {
        padding: 10px;
        align-items: flex-start;
        /* Permet le scroll si nécessaire */
    }

    .container {
        padding: 25px 20px;
        border-radius: 20px;
        margin-top: 10px;
    }

    header h1 {
        font-size: 2rem;
    }

    .instruction-text {
        font-size: 0.8rem;
        padding: 10px;
    }

    .upload-area {
        padding: 20px;
    }

    .popup-card {
        padding: 30px 20px;
        border-radius: 24px;
        width: 90%;
    }

    .result-title {
        font-size: 1.5rem;
    }

    .result-message {
        font-size: 0.9rem;
    }

    /* Ajustement caméra sur mobile */
    .crop-guide {
        width: 85%;
        height: 50%;
    }

    .camera-controls {
        bottom: 30px;
    }

    .shutter-btn {
        width: 60px;
        height: 60px;
    }
}

/* Gestion des très petits écrans (iPhone SE, etc.) */
@media (max-height: 700px) {
    .container {
        margin-bottom: 20px;
    }

    #lottie-container {
        width: 120px;
        height: 120px;
    }

    .popup-card {
        padding: 20px;
    }
}