/* ==========================================================================
   SendMe — administration (complète app.css)
   ========================================================================== */

:root { --sidebar-w: 244px; }

body.admin { background: var(--bg-2); }
body.admin::before { opacity: .25; height: 40vh; }

/* ---------------------------------------------------------------- */
/* Structure                                                         */
/* ---------------------------------------------------------------- */

.admin-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

/* --- Barre latérale --- */
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 20px 14px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
}

.sidebar .brand { margin: 4px 6px 22px; }

.nav-group { display: grid; gap: 2px; }
.nav-label {
    padding: 14px 12px 6px;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--text-3);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--text-2);
    font-size: .9rem;
    font-weight: 520;
    transition: background var(--speed) var(--ease), color var(--speed) var(--ease);
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.is-active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}
.nav-item .count {
    margin-left: auto;
    padding: 2px 7px;
    border-radius: 99px;
    background: var(--surface-3);
    font-size: .72rem;
    font-weight: 600;
    color: var(--text-3);
}

.sidebar-foot {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
}
.avatar {
    display: grid; place-items: center;
    width: 34px; height: 34px; flex: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    font-size: .82rem;
    font-weight: 700;
}
.sidebar-user .who { min-width: 0; }
.sidebar-user .who strong { display: block; font-size: .86rem; }
.sidebar-user .who span { font-size: .74rem; color: var(--text-3); }

/* --- Zone de contenu --- */
.admin-main { min-width: 0; padding: 26px clamp(16px, 3vw, 34px) 60px; }

.admin-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 26px;
}
.admin-topbar h1 { font-size: 1.5rem; }
.admin-topbar .sub { font-size: .88rem; color: var(--text-3); margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.mobile-nav-toggle { display: none; }

/* ---------------------------------------------------------------- */
/* Cartes de statistiques                                            */
/* ---------------------------------------------------------------- */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.stat-card {
    position: relative;
    padding: 18px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color var(--speed) var(--ease), transform var(--speed) var(--ease);
}
.stat-card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.stat-card .stat-icon {
    display: grid; place-items: center;
    width: 36px; height: 36px;
    margin-bottom: 12px;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent);
}
.stat-card .stat-value {
    font-size: 1.7rem;
    font-weight: 700;
    letter-spacing: -.03em;
    line-height: 1.1;
}
.stat-card .stat-label {
    margin-top: 3px;
    font-size: .82rem;
    color: var(--text-3);
}
.stat-card .stat-delta { margin-top: 8px; font-size: .78rem; }

.stat-card.accent-success .stat-icon { background: color-mix(in srgb, var(--success) 15%, transparent); color: var(--success); }
.stat-card.accent-warning .stat-icon { background: color-mix(in srgb, var(--warning) 15%, transparent); color: var(--warning); }
.stat-card.accent-info    .stat-icon { background: color-mix(in srgb, var(--info) 15%, transparent);    color: var(--info); }

/* --- Jauge de stockage --- */
.gauge { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin-top: 12px; }
.gauge .fill {
    height: 100%;
    border-radius: 99px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    transition: width .4s var(--ease);
}
.gauge.warn .fill { background: linear-gradient(90deg, var(--warning), var(--danger)); }

/* ---------------------------------------------------------------- */
/* Graphique d'activité                                              */
/* ---------------------------------------------------------------- */

.chart {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 168px;
    padding: 16px 4px 0;
}
.chart-col {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    min-width: 0;
}
/* Piste de hauteur définie : sans elle, la hauteur en % des barres
   n'aurait aucune référence et resterait plate. */
.chart-track {
    flex: 1;
    width: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    min-height: 0;
}
.chart-bar {
    width: 100%;
    max-width: 34px;
    min-height: 3px;
    border-radius: 6px 6px 3px 3px;
    background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent-2) 70%, transparent));
    transition: filter var(--speed) var(--ease), transform var(--speed) var(--ease);
    cursor: default;
}
.chart-col:hover .chart-bar { filter: brightness(1.2); transform: scaleY(1.02); }
.chart-label {
    font-size: .68rem;
    color: var(--text-3);
    white-space: nowrap;
}

/* ---------------------------------------------------------------- */
/* Filtres & barre d'actions groupées                                */
/* ---------------------------------------------------------------- */

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 18px;
}
.filter-bar .input,
.filter-bar .select { width: auto; min-width: 170px; padding-block: 9px; }
.filter-bar .search-field { position: relative; flex: 1 1 240px; min-width: 0; }
.filter-bar .search-field .input { width: 100%; padding-left: 38px; }
.filter-bar .search-field svg {
    position: absolute;
    left: 12px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-3);
    pointer-events: none;
}

.bulk-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 12px 16px;
    margin-bottom: 14px;
    border-radius: var(--radius);
    background: var(--accent-soft);
    border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
    font-size: .88rem;
}
.bulk-bar strong { color: var(--accent); }
.bulk-bar .spacer { flex: 1; }

/* ---------------------------------------------------------------- */
/* Tableaux                                                          */
/* ---------------------------------------------------------------- */

.admin-main table.data th:first-child,
.admin-main table.data td:first-child { padding-left: 18px; }
.admin-main table.data th:last-child,
.admin-main table.data td:last-child { padding-right: 18px; }

.cell-file { display: flex; align-items: center; gap: 11px; min-width: 0; }
.cell-file .file-thumb { width: 36px; height: 36px; border-radius: 9px; }
.cell-file .file-thumb svg { width: 17px; height: 17px; }
.cell-file .meta { min-width: 0; }
.cell-file .name {
    font-weight: 550;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cell-file .sub { font-size: .76rem; color: var(--text-3); }

.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.row-actions form { display: inline; }

.check-cell { width: 44px; }
.check-cell input[type="checkbox"] {
    appearance: none;
    width: 17px; height: 17px;
    border: 1.5px solid var(--border-strong);
    border-radius: 4px;
    background: var(--bg-2);
    cursor: pointer;
    vertical-align: middle;
}
.check-cell input[type="checkbox"]:checked {
    background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center/11px no-repeat;
    border-color: var(--accent);
}
.check-cell input[type="checkbox"]:indeterminate {
    background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='white' stroke-width='3.5' stroke-linecap='round'%3E%3Cpath d='M6 12h12'/%3E%3C/svg%3E") center/11px no-repeat;
    border-color: var(--accent);
}

/* ---------------------------------------------------------------- */
/* Page de connexion                                                 */
/* ---------------------------------------------------------------- */

.login-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px;
    position: relative;
    z-index: 1;
}
.login-box { width: 100%; max-width: 400px; }
.login-box .brand { justify-content: center; margin-bottom: 24px; }
.login-head { text-align: center; margin-bottom: 24px; }
.login-head h1 { font-size: 1.45rem; margin-bottom: 6px; }
.login-head p { color: var(--text-3); font-size: .88rem; }

/* ---------------------------------------------------------------- */
/* Réglages                                                          */
/* ---------------------------------------------------------------- */

.settings-section {
    padding: 22px;
    margin-bottom: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}
.settings-section > h2 {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 1rem;
    padding-bottom: 14px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--border);
}

.setting-row {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 18px;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px dashed var(--border);
}
.setting-row:last-child { border-bottom: 0; padding-bottom: 0; }
.setting-row .desc strong { display: block; font-size: .92rem; font-weight: 560; }
.setting-row .desc p { font-size: .8rem; color: var(--text-3); margin-top: 3px; }
.setting-row .control .input,
.setting-row .control .select { width: 100%; }

.settings-actions {
    position: sticky;
    bottom: 16px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 18px;
    margin-top: 20px;
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-lg);
}

/* --- Diagnostic --- */
.diag-list { display: grid; gap: 1px; background: var(--border); border-radius: var(--radius); overflow: hidden; }
.diag-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 11px 16px;
    background: var(--surface);
    font-size: .86rem;
}
.diag-row .k { color: var(--text-2); }
.diag-row .v { font-family: var(--mono); font-size: .82rem; text-align: right; word-break: break-all; }
.diag-ok   { color: var(--success); }
.diag-warn { color: var(--warning); }
.diag-bad  { color: var(--danger); }

/* ---------------------------------------------------------------- */
/* Responsive                                                        */
/* ---------------------------------------------------------------- */

@media (max-width: 1000px) {
    .admin-shell { grid-template-columns: 1fr; }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: 280px;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform .28s var(--ease-out);
        box-shadow: var(--shadow-lg);
    }
    .sidebar.is-open { transform: none; }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 99;
        background: rgba(0,0,0,.5);
        backdrop-filter: blur(2px);
        opacity: 0;
        pointer-events: none;
        transition: opacity .28s var(--ease);
    }
    .sidebar-backdrop.is-open { opacity: 1; pointer-events: auto; }

    .mobile-nav-toggle {
        display: grid;
        place-items: center;
        width: 40px; height: 40px;
        border-radius: 10px;
        border: 1px solid var(--border);
        background: var(--surface);
        color: var(--text);
        cursor: pointer;
    }

    .setting-row { grid-template-columns: 1fr; gap: 10px; }
    .settings-actions { position: static; }
}

@media (max-width: 620px) {
    .admin-main { padding: 18px 14px 48px; }
    .admin-topbar h1 { font-size: 1.25rem; }
    .stat-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
    .stat-card { padding: 14px 16px; }
    .stat-card .stat-value { font-size: 1.35rem; }
    .cell-file .name { max-width: 160px; }
    .filter-bar .input, .filter-bar .select { width: 100%; min-width: 0; }
    .chart { height: 130px; }
    .chart-label { display: none; }
}
