/* ==========================================================================
   QR Studio — feuille de style
   Palette : graphite / or / sauge. Toutes les couleurs passent par :root.
   ========================================================================== */

:root {
    --bg:           #141414;
    --surface:      #1F1F1F;   /* panneaux */
    --surface-2:    #292929;   /* survol, onglet actif */
    --field:        #181818;   /* champs de saisie */
    --line:         #333333;
    --line-strong:  #474747;
    --text:         #F2F2EF;
    --muted:        #A3A39C;
    --faint:        #85857F;

    --accent:       #C9A35E;
    --accent-hover: #D9B777;
    --accent-ink:   #1C1609;   /* texte posé sur l'or */
    --accent-rgb:   201, 163, 94;
    --mint:         #8FB399;
    --mint-rgb:     143, 179, 153;

    --radius:       16px;
    --radius-sm:    10px;
    --shadow:       0 1px 0 rgba(255,255,255,.03) inset, 0 18px 40px -24px rgba(0,0,0,.7);
    --ring:         0 0 0 3px rgba(var(--accent-rgb), .22);
    --ease:         cubic-bezier(.2, .7, .2, 1);

    --font-display: "Space Grotesk", "Segoe UI", sans-serif;
    --font-body:    "Inter", "Segoe UI", sans-serif;
    --font-mono:    "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    padding: 48px 0 80px;
    min-height: 100vh;
    background-color: var(--bg);
    /* trame de modules : rappel de la grille d'un QR code */
    background-image:
            linear-gradient(rgba(255,255,255,.02) 1px, transparent 1px),
            linear-gradient(90deg, rgba(255,255,255,.02) 1px, transparent 1px),
            radial-gradient(900px 520px at 85% -10%, rgba(var(--accent-rgb), .09), transparent 60%);
    background-size: 22px 22px, 22px 22px, 100% 100%;
    color: var(--text);
    font-family: var(--font-body);
    -webkit-font-smoothing: antialiased;
}

.main-container { max-width: 1200px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- En-tête ------------------------------------------------------------ */
.hero {
    margin-bottom: 36px;
    animation: rise .6s var(--ease) both;
}

.hero .eyebrow {
    font-family: var(--font-mono);
    font-size: .74rem;
    letter-spacing: .22em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 10px;
}

.hero h1 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2.2rem, 4.5vw, 3.2rem);
    letter-spacing: -.025em;
    margin: 0 0 10px;
}

.hero h1 .dot { color: var(--accent); }

.hero p {
    color: var(--muted);
    max-width: 58ch;
    margin: 0;
    font-size: 1.02rem;
    line-height: 1.6;
}

.badges { margin-top: 18px; display: flex; gap: 8px; flex-wrap: wrap; }

.badge-chip {
    font-family: var(--font-mono);
    font-size: .72rem;
    letter-spacing: .03em;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 13px;
}
.badge-chip i { color: var(--mint); margin-right: 6px; }

/* --- Mise en page ------------------------------------------------------- */
/* Desktop : configuration et conseils à gauche, aperçu fixe à droite.
   Mobile : configuration, puis aperçu, puis conseils. */
.layout {
    display: grid;
    gap: 20px;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
    grid-template-areas:
        "config  preview"
        "tips    preview";
    align-items: start;
}

.area-config  { grid-area: config; }
.area-tips    { grid-area: tips; }
.area-preview { grid-area: preview; position: sticky; top: 24px; }

/* --- Panneaux ----------------------------------------------------------- */
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    animation: rise .6s var(--ease) both;
}
.area-preview { animation-delay: .08s; }
.area-tips    { animation-delay: .14s; }

.panel-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 22px;
    border-bottom: 1px solid var(--line);
}

.panel-head h2 {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: .01em;
    margin: 0;
}
.panel-head > i { color: var(--accent); }

.panel-body { padding: 22px; }

.panel-foot {
    border-top: 1px solid var(--line);
    padding: 14px 22px;
}

.section-title {
    font-family: var(--font-mono);
    font-size: .72rem;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 18px;
}

/* --- Onglets ------------------------------------------------------------ */
.tabs { display: flex; flex-direction: column; gap: 4px; }

.tabs .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    color: var(--muted);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 11px 14px;
    font-size: .92rem;
    font-weight: 500;
    transition: background .18s var(--ease), color .18s var(--ease), border-color .18s var(--ease);
}

.tabs .nav-link:hover { background: var(--surface-2); color: var(--text); }

.tabs .nav-link.active {
    background: var(--surface-2);
    border-color: var(--line-strong);
    color: var(--text);
    box-shadow: inset 3px 0 0 var(--accent);
}
.tabs .nav-link.active i { color: var(--accent); }

.tabs .nav-link i { font-size: 1rem; }

/* --- Formulaire --------------------------------------------------------- */
.form-label {
    font-size: .82rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
}

.form-text { color: var(--muted); font-size: .78rem; margin-top: 6px; }

.form-control,
.form-select {
    background-color: var(--field);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 11px 13px;
    font-size: .93rem;
    transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}

.form-control::placeholder { color: var(--faint); }

.form-control:hover,
.form-select:hover { border-color: #5A5A5A; }

.form-control:focus,
.form-select:focus {
    background-color: var(--field);
    color: var(--text);
    border-color: var(--accent);
    box-shadow: var(--ring);
    outline: none;
}

/* Flèche du select aux couleurs du thème (le fill vaut --muted). */
.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23A3A39C' d='M8 11 3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px;
}

.form-select option { background: var(--field); color: var(--text); }

/* Champ fichier : bouton « Parcourir » assorti */
.form-control::file-selector-button {
    background: var(--surface-2);
    color: var(--text);
    border: 0;
    border-right: 1px solid var(--line-strong);
    margin: -11px 13px -11px -13px;
    padding: 11px 14px;
}
.form-control:hover:not(:disabled):not([readonly])::file-selector-button { background: #333333; }

/* Curseurs */
.form-range { height: 22px; }
.form-range:focus { box-shadow: none; }
.form-range::-webkit-slider-runnable-track {
    height: 4px; background: var(--line-strong); border-radius: 2px;
}
.form-range::-webkit-slider-thumb {
    margin-top: -6px;
    width: 16px; height: 16px;
    background: var(--accent);
    border: none; border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(var(--accent-rgb), .18);
}
.form-range:focus-visible::-webkit-slider-thumb { box-shadow: var(--ring); }
.form-range::-moz-range-track { height: 4px; background: var(--line-strong); border-radius: 2px; }
.form-range::-moz-range-thumb {
    width: 16px; height: 16px; background: var(--accent);
    border: none; border-radius: 50%;
}

.range-value {
    font-family: var(--font-mono);
    font-size: .8rem;
    color: var(--mint);
    text-align: right;
}

/* Interrupteur */
.form-check-input {
    background-color: var(--field);
    border-color: var(--line-strong);
}
.form-check-input:checked {
    background-color: var(--accent);
    border-color: var(--accent);
}
.form-check-input:focus { border-color: var(--accent); box-shadow: var(--ring); }
.form-check-input:disabled ~ .form-check-label { color: var(--faint); }
.form-check-label { font-size: .9rem; color: var(--text); }

/* --- Couleurs ----------------------------------------------------------- */
.color-row { display: flex; gap: 12px; align-items: center; }

.color-swatch {
    width: 46px; height: 46px;
    flex: 0 0 46px;
    padding: 0;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: transparent;
    cursor: pointer;
    transition: transform .18s var(--ease), border-color .18s var(--ease);
}
.color-swatch:hover { transform: scale(1.05); border-color: var(--accent); }
.color-swatch::-webkit-color-swatch-wrapper { padding: 4px; }
.color-swatch::-webkit-color-swatch { border: none; border-radius: 6px; }
.color-swatch::-moz-color-swatch { border: none; border-radius: 6px; }

.color-row .form-control { font-family: var(--font-mono); text-transform: uppercase; }

.presets { display: flex; flex-wrap: wrap; gap: 8px; }

.preset {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--field);
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    color: var(--muted);
    font-size: .8rem;
    padding: 6px 13px 6px 7px;
    transition: border-color .18s var(--ease), color .18s var(--ease);
}
.preset:hover { border-color: var(--accent); color: var(--text); }

.preset .chip {
    width: 18px; height: 18px;
    border-radius: 50%;
    border: 1px solid var(--line-strong);
}

/* --- Note --------------------------------------------------------------- */
.note {
    border: 1px solid var(--line);
    border-left: 3px solid var(--mint);
    background: var(--field);
    border-radius: var(--radius-sm);
    color: var(--muted);
    font-size: .86rem;
    line-height: 1.55;
    padding: 12px 14px;
}
.note strong { color: var(--text); }

/* --- Aperçu du logo ----------------------------------------------------- */
.dropzone {
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-sm);
    background:
            repeating-conic-gradient(rgba(255,255,255,.025) 0% 25%, transparent 0% 50%) 0 0 / 18px 18px,
            var(--field);
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    text-align: center;
    color: var(--muted);
    padding: 20px;
}
.dropzone i { font-size: 2rem; opacity: .5; }
.dropzone p { margin: 10px 0 0; font-size: .84rem; }

.logo-preview {
    max-width: 100%;
    max-height: 150px;
    border-radius: 8px;
    animation: pop .35s var(--ease) both;
}

/* --- Boutons ------------------------------------------------------------ */
.btn-generate {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--accent-ink);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1rem;
    letter-spacing: .01em;
    padding: 14px 24px;
    box-shadow: 0 10px 24px -14px rgba(var(--accent-rgb), .8);
    transition: background .18s var(--ease), transform .18s var(--ease);
}
.btn-generate:hover,
.btn-generate:focus-visible {
    background: var(--accent-hover);
    color: var(--accent-ink);
    transform: translateY(-1px);
}
.btn-generate:active { transform: translateY(0); }

.btn-ghost,
.btn-download {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: var(--radius-sm);
    font-size: .88rem;
    padding: 10px 14px;
    transition: border-color .18s var(--ease), background .18s var(--ease), color .18s var(--ease);
}

.btn-ghost {
    background: var(--field);
    border: 1px solid var(--line-strong);
    color: var(--text);
}
.btn-ghost:hover { border-color: var(--accent); background: var(--surface-2); color: var(--text); }

.btn-download {
    background: rgba(var(--mint-rgb), .12);
    border: 1px solid rgba(var(--mint-rgb), .55);
    color: var(--mint);
    font-weight: 500;
}
.btn-download:hover { background: rgba(var(--mint-rgb), .2); border-color: var(--mint); color: var(--mint); }

/* --- Aperçu ------------------------------------------------------------- */
.status-pill {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: var(--font-mono);
    font-size: .7rem;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--mint);
    background: rgba(var(--mint-rgb), .1);
    border: 1px solid rgba(var(--mint-rgb), .35);
    border-radius: 999px;
    padding: 3px 10px;
}
.status-pill.d-none { display: none; }

.preview-empty { text-align: center; color: var(--muted); }
.preview-empty p { margin: 18px 0 0; font-size: .86rem; line-height: 1.55; }

/* Silhouette de QR : trois repères d'angle sur une trame pointillée */
.preview-placeholder {
    position: relative;
    aspect-ratio: 1;
    max-width: 240px;
    margin: 0 auto;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-sm);
    background:
            radial-gradient(circle, rgba(255,255,255,.07) 1.5px, transparent 2px) 0 0 / 14px 14px,
            var(--field);
}
.preview-placeholder span {
    position: absolute;
    width: 26%; aspect-ratio: 1;
    border: 6px solid var(--line-strong);
    border-radius: 8px;
}
.preview-placeholder span::after {
    content: "";
    position: absolute;
    inset: 22%;
    background: var(--line-strong);
    border-radius: 3px;
}
.preview-placeholder span:nth-child(1) { top: 10%; left: 10%; }
.preview-placeholder span:nth-child(2) { top: 10%; right: 10%; }
.preview-placeholder span:nth-child(3) { bottom: 10%; left: 10%; }

.qr-frame {
    background: var(--field);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 14px;
    animation: pop .4s var(--ease) both;
}
.qr-frame img {
    display: block;
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
    border-radius: 4px;
    image-rendering: pixelated;
}

.qr-meta {
    margin-top: 12px;
    text-align: center;
    font-family: var(--font-mono);
    font-size: .74rem;
    color: var(--muted);
}

.result-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 16px;
}
.result-actions .btn-download { grid-column: 1 / -1; }
.result-actions .btn-reset { grid-column: 1 / -1; }

/* --- Compteur ----------------------------------------------------------- */
.counter { display: flex; align-items: baseline; gap: 10px; }

.counter .value {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1;
    color: var(--accent);
    letter-spacing: -.02em;
}

.counter .label {
    font-family: var(--font-mono);
    font-size: .7rem;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--muted);
}

/* --- Conseils ----------------------------------------------------------- */
.tips {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px 28px;
}
.tip h3 {
    font-family: var(--font-display);
    font-size: .92rem;
    font-weight: 600;
    margin: 0 0 6px;
    display: flex;
    align-items: baseline;
    gap: 8px;
}
.tip h3 span { color: var(--accent); font-family: var(--font-mono); font-size: .78rem; }
.tip p { margin: 0; font-size: .84rem; color: var(--muted); line-height: 1.55; }

/* --- Chargement --------------------------------------------------------- */
.overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(20, 20, 20, .82);
    backdrop-filter: blur(6px);
}
.overlay.is-open { display: flex; }

.overlay-box { text-align: center; }

.scanner {
    width: 66px; height: 66px;
    margin: 0 auto;
    border: 2px solid var(--line-strong);
    border-radius: 10px;
    position: relative;
    overflow: hidden;
}
.scanner::after {
    content: "";
    position: absolute;
    left: 0; right: 0; top: 0;
    height: 2px;
    background: var(--accent);
    box-shadow: 0 0 12px var(--accent);
    animation: scan 1.1s var(--ease) infinite;
}

.overlay-box p {
    margin: 16px 0 0;
    font-family: var(--font-mono);
    font-size: .78rem;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--muted);
}

/* --- Animations --------------------------------------------------------- */
@keyframes rise  { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes pop   { from { opacity: 0; transform: scale(.94); }      to { opacity: 1; transform: none; } }
@keyframes scan  { 0% { top: 0; } 50% { top: calc(100% - 2px); } 100% { top: 0; } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* --- Responsive --------------------------------------------------------- */
@media (max-width: 991px) {
    body { padding: 32px 0 56px; }

    .layout {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: "config" "preview" "tips";
    }
    .area-preview { position: static; }

    /* Onglets en barre horizontale défilable */
    .tabs {
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 6px;
        padding-bottom: 4px;
        margin-bottom: 4px;
        scrollbar-width: none;
    }
    .tabs::-webkit-scrollbar { display: none; }
    .tabs .nav-link {
        width: auto;
        flex: 1 0 auto;
        justify-content: center;
        white-space: nowrap;
        padding: 9px 14px;
        border-color: var(--line);
    }
    .tabs .nav-link.active { box-shadow: inset 0 -2px 0 var(--accent); }
}

@media (max-width: 575px) {
    .panel-head, .panel-body { padding-left: 16px; padding-right: 16px; }
    .panel-foot { padding-left: 16px; padding-right: 16px; }
    .tips { grid-template-columns: 1fr; }
    /* Quatre onglets toujours visibles : icône au-dessus du libellé */
    .tabs { display: grid; grid-template-columns: repeat(4, 1fr); overflow: visible; }
    .tabs .nav-link {
        flex-direction: column;
        gap: 4px;
        padding: 9px 4px;
        font-size: .76rem;
    }
    .tabs .nav-link i { font-size: 1.05rem; }
}
