/* CSS minimal, mobile d'abord, mode sombre par défaut (décision confirmée).
   Points de repère de largeur : ~390px (iPhone, cible première), puis
   48rem (tablette/bureau) pour les mises en page qui en profitent. */

:root {
    color-scheme: dark;
    --bg: #11151a;
    --bg-raised: #171c23;
    --fg: #e8ecef;
    --muted: #9aa5b1;
    --accent: #5aa9e6;
    --border: #262d37;
    --danger: #e67a7a;
    --max-width: 40rem;
}

/* Mode sombre par défaut (décision confirmée) : pas de bascule claire/sombre
   en v1, seulement un respect de la préférence système si elle est claire. */
@media (prefers-color-scheme: light) {
    :root {
        color-scheme: light;
        --bg: #fafafa;
        --bg-raised: #ffffff;
        --fg: #1a1f24;
        --muted: #5a6572;
        --border: #dde2e8;
    }
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    line-height: 1.5;
}

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

.page {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 1.25rem;
}

h1 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

h2 {
    font-size: 1.1rem;
    margin-top: 2rem;
}

.subtitle {
    color: var(--muted);
    margin-top: 0;
}

.status strong {
    color: var(--accent);
}

.hint {
    color: var(--muted);
    font-size: 0.85rem;
}

.empty {
    color: var(--muted);
    font-style: italic;
}

/* Barre supérieure : marque + bascule de langue. */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.topbar .brand {
    font-weight: 600;
    text-decoration: none;
    color: var(--fg);
}

.topbar .lang-switch {
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    padding: 0.15rem 0.5rem;
    font-size: 0.8rem;
    text-decoration: none;
    color: var(--muted);
}

/* Navigation : rangée d'onglets horizontale défilante en mobile (évite le
   menu hamburger, plus simple à atteindre au pouce sur iPhone). */
.tabbar {
    display: flex;
    gap: 0.25rem;
    overflow-x: auto;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-raised);
}

.tabbar a {
    flex: 0 0 auto;
    padding: 0.4rem 0.75rem;
    border-radius: 0.4rem;
    text-decoration: none;
    color: var(--muted);
    white-space: nowrap;
    font-size: 0.9rem;
}

.tabbar a.active {
    background: var(--accent);
    color: #0b1016;
    font-weight: 600;
}

.logout-form {
    margin-left: auto;
    flex: 0 0 auto;
}

.link-button {
    background: none;
    border: none;
    color: var(--muted);
    font: inherit;
    padding: 0.4rem 0.75rem;
    cursor: pointer;
}

/* Boutons. */
.button,
button[type="submit"] {
    display: inline-block;
    background: var(--accent);
    color: #0b1016;
    border: none;
    border-radius: 0.4rem;
    padding: 0.6rem 1rem;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Formulaires : un champ par ligne, cible tactile confortable en mobile. */
form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin: 1rem 0;
}

form.catalog-filters {
    flex-direction: column;
}

label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.9rem;
    color: var(--muted);
}

input,
select {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    color: var(--fg);
    border-radius: 0.3rem;
    padding: 0.5rem;
    font-size: 1rem;
}

.add-allowlist {
    flex-direction: row;
    align-items: flex-end;
    flex-wrap: wrap;
}

/* Badges de statut. */
.badge {
    display: inline-block;
    font-size: 0.75rem;
    padding: 0.1rem 0.4rem;
    border-radius: 0.3rem;
    background: var(--border);
    color: var(--muted);
    margin-left: 0.3rem;
}

.badge-accent {
    background: var(--accent);
    color: #0b1016;
}

.badge-muted {
    background: var(--border);
    color: var(--muted);
}

/* Cartes de chaînes suivies : liste empilée, lisible au pouce. */
.channel-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.channel-card {
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.75rem;
    background: var(--bg-raised);
}

.channel-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.channel-card-meta {
    color: var(--muted);
    font-size: 0.9rem;
}

.channel-card-actions {
    margin: 0.5rem 0 0;
}

/* Tableaux de données : en dessous de 640px, chaque ligne devient une
   carte empilée (motif « responsive table » classique), avec l'étiquette
   de colonne injectée via `data-label` devant chaque valeur. */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.5rem 0 1.5rem;
}

.data-table th,
.data-table td {
    text-align: left;
    padding: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    color: var(--muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

@media (max-width: 640px) {
    .data-table thead {
        display: none;
    }

    .data-table,
    .data-table tbody,
    .data-table tr,
    .data-table td {
        display: block;
        width: 100%;
    }

    .data-table tr {
        border: 1px solid var(--border);
        border-radius: 0.5rem;
        margin-bottom: 0.75rem;
        padding: 0.25rem 0.5rem;
    }

    .data-table td {
        border-bottom: none;
        padding: 0.35rem 0;
        display: flex;
        justify-content: space-between;
        gap: 0.5rem;
    }

    .data-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 0.75rem;
        text-transform: uppercase;
        flex: 0 0 auto;
    }
}

.export-links {
    display: flex;
    gap: 1rem;
    font-size: 0.9rem;
}

/* Quota (profil). */
.quota-bar {
    background: var(--border);
    border-radius: 0.5rem;
    height: 0.75rem;
    overflow: hidden;
    margin: 0.5rem 0;
}

.quota-bar-fill {
    background: var(--accent);
    height: 100%;
}

.quota-figures {
    font-size: 0.9rem;
    color: var(--muted);
}

@media (min-width: 48rem) {
    .page {
        padding: 2.5rem 1.25rem;
    }

    form.catalog-filters,
    .add-allowlist {
        flex-direction: row;
        align-items: flex-end;
        flex-wrap: wrap;
    }

    form.catalog-filters label,
    form.catalog-filters select,
    form.catalog-filters input {
        flex: 1 1 auto;
    }
}

/* Écrans larges (ordinateur de bureau) : la même interface, pas une
   seconde — la rangée d'onglets devient une sidebar fixe au défilement,
   et le contenu profite de la largeur disponible au lieu de rester
   coincé à 40rem. */
@media (min-width: 64rem) {
    .layout {
        display: flex;
        align-items: flex-start;
        gap: 2rem;
        max-width: 72rem;
        margin: 0 auto;
    }

    .tabbar {
        flex: 0 0 13rem;
        flex-direction: column;
        align-items: stretch;
        gap: 0.15rem;
        overflow-x: visible;
        border-bottom: none;
        border-right: 1px solid var(--border);
        background: transparent;
        padding: 2rem 0.75rem;
        position: sticky;
        top: 0;
        align-self: flex-start;
    }

    .tabbar a,
    .tabbar .link-button {
        text-align: left;
        padding: 0.55rem 0.75rem;
    }

    .logout-form {
        margin-left: 0;
        margin-top: 1rem;
    }

    .page {
        flex: 1 1 auto;
        max-width: none;
        margin: 0;
        padding: 2.5rem 0 2.5rem 0.5rem;
    }

    .channel-list {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1rem;
    }
}
