/* ════════════════════════════════════════════════════════════════════════════
   style.css — ODT → Markdown Convertisseur
   Design épuré, moderne, responsive. Zéro dépendance externe.
   Optimisé pour Firefox (moteur Gecko) ; propriétés CSS standardisées uniquement.
   ════════════════════════════════════════════════════════════════════════════ */

/* ── Réinitialisation minimale ─────────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ── Variables CSS (thème) ─────────────────────────────────────────────────── */
:root {
    /* Couleurs de surface */
    --c-bg:           #f1f5f9;
    --c-surface:      #ffffff;
    --c-surface-alt:  #f8fafc;

    /* Bordures */
    --c-border:       #e2e8f0;
    --c-border-focus: #818cf8;

    /* Typographie */
    --c-text:         #1e293b;
    --c-text-muted:   #64748b;

    /* Accent (indigo) */
    --c-accent:       #6366f1;
    --c-accent-dark:  #4f46e5;
    --c-accent-light: #eef2ff;
    --c-accent-ring:  rgba(99, 102, 241, 0.22);

    /* États drag-and-drop */
    --c-drop-bg:      #ede9fe;
    --c-drop-border:  #a5b4fc;

    /* Succès */
    --c-success:      #16a34a;
    --c-success-bg:   #f0fdf4;
    --c-success-border: #86efac;

    /* Erreur */
    --c-error:        #dc2626;
    --c-error-bg:     #fef2f2;
    --c-error-border: #fca5a5;

    /* Géométrie */
    --r-sm:  6px;
    --r-md:  12px;
    --r-lg:  18px;

    /* Ombres */
    --shadow-xs: 0 1px 2px rgba(0,0,0,.05);
    --shadow-sm: 0 1px 4px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 18px rgba(0,0,0,.09), 0 2px 6px rgba(0,0,0,.05);

    /* Polices */
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
            'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'Cascadia Code', 'Fira Code', 'Consolas',
                 'Courier New', monospace;

    /* Transitions */
    --tr: 160ms ease;
}

/* ── Base ──────────────────────────────────────────────────────────────────── */
body {
    font-family: var(--font);
    background-color: var(--c-bg);
    color: var(--c-text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── Conteneur principal ───────────────────────────────────────────────────── */
.page {
    max-width: 880px;
    margin: 0 auto;
    padding: 2.75rem 1.5rem 5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* ── En-tête ───────────────────────────────────────────────────────────────── */
.header {
    display: flex;
    align-items: center;
    gap: 1.125rem;
    padding-bottom: 1.625rem;
    border-bottom: 1px solid var(--c-border);
}

.header__badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: var(--c-accent-light);
    color: var(--c-accent);
    border-radius: var(--r-md);
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 700;
    flex-shrink: 0;
    user-select: none;
    border: 1px solid var(--c-drop-border);
}

.header__title {
    font-size: 1.625rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--c-text);
}

.header__arrow {
    color: var(--c-accent);
}

.header__subtitle {
    font-size: 0.875rem;
    color: var(--c-text-muted);
    margin-top: 0.15rem;
}

/* ── Zone principale ───────────────────────────────────────────────────────── */
.main {
    display: flex;
    flex-direction: column;
    gap: 1.375rem;
}

/* ── Zone de dépôt ─────────────────────────────────────────────────────────── */
.drop-zone {
    background: var(--c-surface);
    border: 2px dashed var(--c-border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    outline: none;
    transition:
        border-color var(--tr),
        background-color var(--tr),
        box-shadow var(--tr);
}

/* Survol souris ou focus clavier */
.drop-zone:hover,
.drop-zone:focus-visible {
    border-color: var(--c-drop-border);
    background: var(--c-accent-light);
    box-shadow: var(--shadow-md);
}

/* Objet glissé au-dessus de la zone */
.drop-zone--dragging {
    border-color: var(--c-accent);
    border-style: solid;
    background: var(--c-drop-bg);
    box-shadow: 0 0 0 4px var(--c-accent-ring), var(--shadow-md);
}

/* Fichier sélectionné avec succès */
.drop-zone--has-file {
    border-style: solid;
    border-color: var(--c-success-border);
    background: var(--c-success-bg);
}

.drop-zone__body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3.75rem 2rem 2.5rem;
    text-align: center;
    gap: 0.625rem;
    /* Empêche les clics sur les enfants de remonter au handler du drop-zone inutilement */
    pointer-events: none;
}

.drop-zone__icon {
    color: var(--c-accent);
    opacity: 0.75;
    margin-bottom: 0.5rem;
    transition: transform var(--tr), opacity var(--tr);
}

.drop-zone--dragging .drop-zone__icon {
    opacity: 1;
    transform: translateY(-4px) scale(1.06);
}

.drop-zone__primary {
    font-size: 1.0625rem;
    font-weight: 500;
    color: var(--c-text);
}

.drop-zone__primary strong {
    color: var(--c-accent);
}

.drop-zone__sep {
    font-size: 0.8125rem;
    color: var(--c-text-muted);
}

.drop-zone__filename {
    min-height: 1.75rem;
    padding: 0 1.25rem 1.125rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--c-success);
    text-align: center;
}

/* ── Boutons ───────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1.125rem;
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.4;
    border-radius: var(--r-sm);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition:
        background-color var(--tr),
        border-color var(--tr),
        color var(--tr),
        box-shadow var(--tr);
    /* pointer-events réactivés pour les boutons même dans un container pointer-events:none */
    pointer-events: all;
}

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

.btn--primary {
    background: var(--c-accent);
    color: #fff;
    border-color: var(--c-accent);
}

.btn--primary:hover {
    background: var(--c-accent-dark);
    border-color: var(--c-accent-dark);
    box-shadow: 0 0 0 3px var(--c-accent-ring);
}

.btn--outline {
    background: transparent;
    color: var(--c-accent);
    border-color: var(--c-drop-border);
}

.btn--outline:hover {
    background: var(--c-accent-light);
    border-color: var(--c-accent);
}

.btn--ghost {
    background: transparent;
    color: var(--c-text-muted);
    border-color: var(--c-border);
}

.btn--ghost:hover {
    background: var(--c-surface-alt);
    color: var(--c-text);
    border-color: #cbd5e1;
}

/* ── Indicateur de traitement ──────────────────────────────────────────────── */
.processing {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.875rem;
    padding: 1.375rem;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-sm);
    color: var(--c-text-muted);
    font-size: 0.9375rem;
}

/* Spinner CSS pur (animation border-top) */
.spinner {
    width: 22px;
    height: 22px;
    border: 3px solid var(--c-border);
    border-top-color: var(--c-accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
}

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

/* ── Boîte d'erreur ────────────────────────────────────────────────────────── */
.error-box {
    padding: 1rem 1.25rem;
    background: var(--c-error-bg);
    border: 1px solid var(--c-error-border);
    border-left: 4px solid var(--c-error);
    border-radius: var(--r-md);
    color: #991b1b;
    font-size: 0.9rem;
    line-height: 1.55;
}

/* ── Section résultat ──────────────────────────────────────────────────────── */
.result {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

/* Barre d'outils du résultat */
.result__toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    background: var(--c-surface-alt);
    border-bottom: 1px solid var(--c-border);
    flex-wrap: wrap;
}

.result__title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--c-text);
}

.result__actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

/* Ligne de métadonnées (nb lignes, images, nom fichier) */
.result__meta {
    padding: 0.5rem 1.25rem;
    font-size: 0.8rem;
    color: var(--c-text-muted);
    background: var(--c-surface-alt);
    border-bottom: 1px solid var(--c-border);
    font-variant-numeric: tabular-nums;
}

/* Zone d'aperçu Markdown brut */
.md-preview {
    display: block;
    width: 100%;
    min-height: 300px;
    max-height: 560px;
    resize: vertical;
    padding: 1.25rem 1.375rem;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    line-height: 1.75;
    color: var(--c-text);
    background: var(--c-surface);
    border: none;
    outline: none;
    overflow-y: auto;
    white-space: pre;
    overflow-wrap: normal;
    tab-size: 4;
}

.md-preview:focus {
    outline: none;
}

/* ── Configuration URL tatouage RAG ───────────────────────────────────────── */
.url-config {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-left: 3px solid var(--c-accent);
    border-radius: var(--r-md);
    padding: 0.875rem 1.125rem 0.75rem;
    box-shadow: var(--shadow-xs);
}

.url-config__label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--c-text);
    letter-spacing: 0.01em;
}

.url-config__input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--c-text);
    background: var(--c-surface-alt);
    border: 1px solid var(--c-border);
    border-radius: var(--r-sm);
    outline: none;
    transition: border-color var(--tr), box-shadow var(--tr);
}

.url-config__input:focus {
    border-color: var(--c-border-focus);
    box-shadow: 0 0 0 3px var(--c-accent-ring);
    background: var(--c-surface);
}

.url-config__hint {
    font-size: 0.75rem;
    color: var(--c-text-muted);
    line-height: 1.45;
}

.url-config__hint code {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    background: var(--c-accent-light);
    color: var(--c-accent-dark);
    padding: 0 0.25em;
    border-radius: 3px;
}

/* ── Liste des fichiers convertis (mode batch) ─────────────────────────────── */
.batch-list {
    list-style: none;
    padding: 0.875rem 1.375rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    border-bottom: 1px solid var(--c-border);
}

.batch-list__item {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-family: var(--font-mono);
    line-height: 1.5;
}

.batch-list__item--ok {
    color: var(--c-success);
}

.batch-list__item--err {
    color: var(--c-error);
}

/* ── Pied de page ──────────────────────────────────────────────────────────── */
.footer {
    text-align: center;
    font-size: 0.8rem;
    color: var(--c-text-muted);
    padding-top: 0.25rem;
}

/* ── Utilitaires ───────────────────────────────────────────────────────────── */

/* Masquage complet (display:none) — classe utilitaire principale */
.hidden {
    display: none !important;
}

/* Masquage visuel accessible (conserve la présence pour les lecteurs d'écran) */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .page {
        padding: 1.75rem 1rem 3.5rem;
        gap: 1.25rem;
    }

    .header {
        gap: 0.75rem;
    }

    .header__title {
        font-size: 1.3rem;
    }

    .drop-zone__body {
        padding: 2.75rem 1.25rem 2rem;
    }

    .result__toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .result__actions {
        width: 100%;
        justify-content: flex-end;
    }
}

@media (max-width: 400px) {
    .header__badge {
        display: none;
    }

    .result__actions {
        flex-direction: column;
        align-items: stretch;
    }

    .result__actions .btn {
        justify-content: center;
    }
}
