/* Celestory Uploader v2 -- feuille de style unique, sans dependance externe. */

:root {
    color-scheme: light dark;
    --bg: #f6f7fb;
    --surface: #ffffff;
    --surface-2: #f1f2f7;
    --border: #e2e4ed;
    --text: #1a1c25;
    --text-muted: #666c80;
    --accent: #4f5ce8;
    --accent-hover: #3f4bd4;
    --accent-soft: #eceefe;
    --danger: #c8324a;
    --danger-soft: #fdecef;
    --success: #1c7a4f;
    --success-soft: #e7f6ee;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(20, 22, 40, .05), 0 8px 24px rgba(20, 22, 40, .05);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #12141c;
        --surface: #1a1d27;
        --surface-2: #22262f;
        --border: #2e3340;
        --text: #e9ebf2;
        --text-muted: #9aa1b4;
        --accent: #7b86ff;
        --accent-hover: #8f98ff;
        --accent-soft: #23283f;
        --danger: #ff7089;
        --danger-soft: #33202a;
        --success: #62d69c;
        --success-soft: #172a22;
        --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
    }
}

/* Le bouton de bascule doit gagner dans les deux sens. */
:root[data-theme="light"] {
    --bg: #f6f7fb; --surface: #fff; --surface-2: #f1f2f7; --border: #e2e4ed;
    --text: #1a1c25; --text-muted: #666c80; --accent: #4f5ce8;
    --accent-hover: #3f4bd4; --accent-soft: #eceefe; --danger: #c8324a;
    --danger-soft: #fdecef; --success: #1c7a4f; --success-soft: #e7f6ee;
    --shadow: 0 1px 2px rgba(20, 22, 40, .05), 0 8px 24px rgba(20, 22, 40, .05);
}
:root[data-theme="dark"] {
    --bg: #12141c; --surface: #1a1d27; --surface-2: #22262f; --border: #2e3340;
    --text: #e9ebf2; --text-muted: #9aa1b4; --accent: #7b86ff;
    --accent-hover: #8f98ff; --accent-soft: #23283f; --danger: #ff7089;
    --danger-soft: #33202a; --success: #62d69c; --success-soft: #172a22;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

/* --- Barre du haut --- */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; padding: .85rem clamp(1rem, 4vw, 2.5rem);
    background: var(--surface); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 20;
}
.brand {
    display: flex; align-items: center; gap: .6rem;
    font-weight: 650; text-decoration: none; color: var(--text);
}
.brand-mark { color: var(--accent); display: flex; }
.topbar-actions { display: flex; align-items: center; gap: .6rem; }
.topbar-actions form { margin: 0; }
.who {
    font-size: .85rem; color: var(--text-muted);
    padding: .2rem .55rem; background: var(--surface-2);
    border-radius: 99px; border: 1px solid var(--border);
}

.page {
    max-width: 1100px; margin: 0 auto;
    padding: clamp(1rem, 3vw, 2rem) clamp(1rem, 4vw, 2.5rem) 3rem;
    display: flex; flex-direction: column; gap: 1.25rem;
}

/* --- Cartes --- */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: clamp(1rem, 2.5vw, 1.6rem);
}
.card-narrow { max-width: 460px; margin: 3rem auto 0; }
.card-centered { text-align: center; }
.card-success { border-color: color-mix(in srgb, var(--success) 45%, var(--border)); }
.card-title { margin: 0 0 .35rem; font-size: 1.15rem; font-weight: 650; }
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; flex-wrap: wrap; margin-bottom: .9rem;
}
.muted { color: var(--text-muted); }
.empty { color: var(--text-muted); padding: 1.5rem 0; text-align: center; }

/* --- Statistiques --- */
.stats {
    display: grid; gap: .9rem;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}
.stat {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: .9rem 1.1rem;
}
.stat-label {
    display: block; font-size: .78rem; text-transform: uppercase;
    letter-spacing: .04em; color: var(--text-muted);
}
.stat-value { display: block; font-size: 1.6rem; font-weight: 650; margin-top: .15rem; }
.stat-hint { font-size: .75rem; color: var(--text-muted); }
.meter {
    height: 5px; background: var(--surface-2); border-radius: 99px;
    overflow: hidden; margin: .45rem 0 .3rem;
}
.meter span { display: block; height: 100%; background: var(--accent); }

/* --- Zone de depot --- */
.dropzone {
    border: 2px dashed var(--border); border-radius: var(--radius);
    background: var(--surface-2); padding: 2rem 1rem; text-align: center;
    cursor: pointer; transition: border-color .15s, background .15s, transform .1s;
    color: var(--text-muted);
}
.dropzone:hover, .dropzone:focus-visible {
    border-color: var(--accent); background: var(--accent-soft); outline: none;
}
.dropzone.is-dragging {
    border-color: var(--accent); background: var(--accent-soft);
    transform: scale(1.005);
}
.dropzone svg { color: var(--accent); }
.dropzone-title { margin: .5rem 0 .15rem; font-weight: 600; color: var(--text); }
.dropzone-hint { margin: 0; font-size: .88rem; }
.dropzone-file {
    margin: .7rem 0 0; font-family: var(--mono); font-size: .85rem;
    color: var(--text); background: var(--surface); display: inline-block;
    padding: .3rem .6rem; border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

/* --- Formulaires --- */
.options { margin-top: 1rem; }
.options summary {
    cursor: pointer; font-weight: 600; font-size: .92rem;
    color: var(--text-muted); padding: .3rem 0;
}
.grid {
    display: grid; gap: .9rem; margin-top: .8rem;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .8rem; }
.field > span { font-size: .85rem; font-weight: 600; }
.field small { color: var(--text-muted); font-size: .78rem; }
input[type=text], input[type=password], input[type=search], select {
    font: inherit; font-size: .93rem; padding: .5rem .65rem;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text); width: 100%;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
    outline: 2px solid var(--accent); outline-offset: 2px;
}
.form-actions { margin-top: 1rem; display: flex; gap: .6rem; justify-content: flex-end; }
.search { display: flex; gap: .5rem; align-items: center; }
.search input { min-width: 200px; }
.visually-hidden {
    position: absolute !important; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0;
}

/* --- Boutons --- */
.button {
    display: inline-flex; align-items: center; gap: .35rem;
    font: inherit; font-size: .9rem; font-weight: 550;
    padding: .45rem .85rem; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--surface);
    color: var(--text); cursor: pointer; text-decoration: none;
    transition: background .12s, border-color .12s, opacity .12s;
    white-space: nowrap;
}
.button:hover { background: var(--surface-2); }
.button-primary {
    background: var(--accent); border-color: var(--accent); color: #fff;
}
.button-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.button-primary:disabled { opacity: .5; cursor: not-allowed; }
.button-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.button-ghost:hover { background: var(--surface-2); }
.button-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, var(--border)); }
.button-danger:hover { background: var(--danger-soft); }
.button-small { font-size: .82rem; padding: .3rem .6rem; }
.icon-button {
    font: inherit; cursor: pointer; background: transparent;
    border: 1px solid transparent; border-radius: var(--radius-sm);
    padding: .25rem .45rem; color: var(--text-muted); line-height: 1;
}
.icon-button:hover { background: var(--surface-2); color: var(--text); }

/* --- Tableau --- */
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th {
    text-align: left; font-size: .76rem; text-transform: uppercase;
    letter-spacing: .04em; color: var(--text-muted); font-weight: 600;
    padding: .5rem .6rem; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: .7rem .6rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover { background: var(--surface-2); }
.table .right { text-align: right; }
.row-expired { opacity: .55; }
.project-name { font-weight: 600; }
.project-meta { font-size: .78rem; color: var(--text-muted); margin-top: .1rem; }
.slug-cell { display: flex; align-items: center; gap: .3rem; }
.slug-cell code { font-family: var(--mono); font-size: .82rem; }
.actions { display: flex; gap: .35rem; justify-content: flex-end; flex-wrap: wrap; }
.inline { display: inline; margin: 0; }
.select-small { font-size: .82rem; padding: .3rem .45rem; width: auto; }

/* --- Badges --- */
.badge {
    display: inline-block; font-size: .72rem; font-weight: 600;
    padding: .1rem .45rem; border-radius: 99px;
    background: var(--accent-soft); color: var(--accent);
    border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
}
.badge-quiet { background: var(--surface-2); color: var(--text-muted); border-color: var(--border); }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }

/* --- Partage / QR --- */
.share { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: .6rem 0; }
.share input { font-family: var(--mono); font-size: .85rem; flex: 1 1 260px; }
.qr { background: #fff; padding: .5rem; border-radius: var(--radius-sm); border: 1px solid var(--border); }

/* --- Progression --- */
.progress { margin-top: 1rem; display: flex; align-items: center; gap: .7rem; }
.progress-bar {
    flex: 1; height: 7px; background: var(--surface-2);
    border-radius: 99px; overflow: hidden;
}
.progress-bar span {
    display: block; height: 100%; width: 0; background: var(--accent);
    transition: width .15s linear;
}
.progress-label { font-size: .84rem; color: var(--text-muted); min-width: 5.5rem; }

/* --- Messages --- */
.flashes { display: flex; flex-direction: column; gap: .5rem; }
.flash {
    padding: .6rem .85rem; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--surface-2);
    font-size: .92rem; word-break: break-word;
}
.flash-success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 30%, transparent); color: var(--success); }
.flash-error { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); color: var(--danger); }

.toasts {
    position: fixed; right: 1rem; bottom: 1rem; z-index: 60;
    display: flex; flex-direction: column; gap: .5rem; max-width: min(90vw, 380px);
}
.toast {
    background: var(--surface); border: 1px solid var(--border);
    border-left: 3px solid var(--accent); border-radius: var(--radius-sm);
    padding: .6rem .8rem; box-shadow: var(--shadow); font-size: .9rem;
    animation: toast-in .18s ease-out;
}
.toast.is-error { border-left-color: var(--danger); }
.toast.is-success { border-left-color: var(--success); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

/* --- Boite de dialogue --- */
.dialog {
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--surface); color: var(--text); padding: 1.2rem;
    box-shadow: var(--shadow); text-align: center;
}
.dialog::backdrop { background: rgba(10, 12, 20, .55); }
.dialog h2 { margin: 0 0 .8rem; font-size: 1rem; }
.dialog img { background: #fff; border-radius: var(--radius-sm); padding: .5rem; }
.dialog form { margin: .9rem 0 0; }

.checklist { padding-left: 1.1rem; }
.checklist li { margin-bottom: .35rem; }
code {
    font-family: var(--mono); font-size: .88em;
    background: var(--surface-2); padding: .1rem .3rem; border-radius: 4px;
}

.footer {
    display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
    max-width: 1100px; margin: 0 auto; padding: 1rem clamp(1rem, 4vw, 2.5rem) 2rem;
    font-size: .8rem; color: var(--text-muted);
}

[data-theme-icon] { display: none; }
:root[data-theme="light"] [data-theme-icon="light"],
:root[data-theme="dark"] [data-theme-icon="dark"] { display: inline; }
:root[data-theme="auto"] [data-theme-icon="dark"] { display: inline; }

@media (max-width: 640px) {
    .table thead { display: none; }
    .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
    .table tr {
        border: 1px solid var(--border); border-radius: var(--radius);
        margin-bottom: .7rem; padding: .5rem;
    }
    .table td { border: none; padding: .3rem .4rem; }
    .table .right { text-align: left; }
    .actions { justify-content: flex-start; }
}

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