/* doc-project | stats/assets/css/stats.css | Définit le thème premium responsive du module statistiques avec hero, cartes KPI, tableaux comparatifs, filtres, boutons et états visuels de sauvegarde AJAX. | Expose: aucun | Dépend de: stats/stats.php, Bootstrap 4, classes DOM du module stats | Impacte: UI statistiques, lisibilité des tableaux, responsive desktop/tablette/mobile | Tables: aucune */

:root {
    --stats-bg: #0d1117;
    --stats-bg-soft: #111827;
    --stats-panel: rgba(18, 25, 38, 0.92);
    --stats-panel-strong: rgba(24, 34, 51, 0.98);
    --stats-border: rgba(148, 163, 184, 0.22);
    --stats-border-strong: rgba(148, 163, 184, 0.34);
    --stats-text: #f8fafc;
    --stats-muted: #94a3b8;
    --stats-muted-strong: #cbd5e1;
    --stats-primary: #38bdf8;
    --stats-primary-strong: #0ea5e9;
    --stats-success: #22c55e;
    --stats-danger: #fb7185;
    --stats-warning: #f59e0b;
    --stats-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
    --stats-radius-xl: 28px;
    --stats-radius-lg: 20px;
    --stats-radius-md: 14px;
}

* {
    box-sizing: border-box;
}

body.stats-page {
    min-height: 100vh;
    margin: 0;
    color: var(--stats-text);
    background:
        radial-gradient(circle at top left, rgba(56, 189, 248, 0.18), transparent 34rem),
        radial-gradient(circle at top right, rgba(245, 158, 11, 0.12), transparent 30rem),
        linear-gradient(135deg, #0a0f1d 0%, #111827 42%, #070a12 100%);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.stats-page .container {
    width: min(100%, 1480px);
    max-width: none;
    padding: 28px;
}

.stats-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin: 8px 0 22px;
    padding: 30px;
    border: 1px solid var(--stats-border);
    border-radius: var(--stats-radius-xl);
    background:
        linear-gradient(135deg, rgba(15, 23, 42, 0.96), rgba(30, 41, 59, 0.78)),
        linear-gradient(90deg, rgba(56, 189, 248, 0.12), rgba(245, 158, 11, 0.10));
    box-shadow: var(--stats-shadow);
    text-align: left;
}

.stats-hero h1 {
    margin: 0;
    font-size: clamp(2rem, 4vw, 4.2rem);
    line-height: 0.95;
    font-weight: 900;
    letter-spacing: -0.07em;
}

.stats-hero p {
    max-width: 760px;
    margin: 14px 0 0;
    color: var(--stats-muted-strong);
    font-size: 1.05rem;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    color: var(--stats-primary);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.eyebrow::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: var(--stats-success);
    box-shadow: 0 0 18px rgba(34, 197, 94, 0.78);
}

.stats-refresh-button {
    flex: 0 0 auto;
    min-height: 52px;
    padding-inline: 22px;
    border: 0;
    border-radius: 999px;
    color: #111827;
    font-weight: 900;
    box-shadow: 0 16px 34px rgba(245, 158, 11, 0.22);
}

.stats-kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stats-kpi-card {
    position: relative;
    overflow: hidden;
    min-height: 142px;
    padding: 22px;
    border: 1px solid var(--stats-border);
    border-radius: var(--stats-radius-lg);
    background: linear-gradient(160deg, rgba(15, 23, 42, 0.96), rgba(30, 41, 59, 0.78));
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.24);
    text-align: left;
}

.stats-kpi-card::after {
    content: "";
    position: absolute;
    inset: auto -40px -70px auto;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: rgba(56, 189, 248, 0.10);
}

.stats-kpi-label {
    display: block;
    margin-bottom: 10px;
    color: var(--stats-muted);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.stats-kpi-card strong {
    display: block;
    font-size: clamp(1.8rem, 3vw, 3.2rem);
    line-height: 1;
    letter-spacing: -0.05em;
}

.stats-kpi-card small {
    display: inline-flex;
    margin-top: 12px;
    padding: 6px 10px;
    border-radius: 999px;
    color: var(--stats-muted-strong);
    background: rgba(148, 163, 184, 0.12);
    font-weight: 800;
}

.stats-kpi-card small.is-positive {
    color: #bbf7d0;
    background: rgba(34, 197, 94, 0.14);
}

.stats-kpi-card small.is-negative {
    color: #fecdd3;
    background: rgba(251, 113, 133, 0.14);
}

.stats-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin: 0 0 22px;
    padding: 18px;
    border: 1px solid var(--stats-border);
    border-radius: var(--stats-radius-lg);
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(16px);
}

.stats-toolbar .btn,
.stats-section .btn,
.action-button {
    border-radius: 999px;
    font-weight: 800;
}

.stats-toolbar .btn-group .btn,
.stats-section .btn {
    border-color: rgba(255, 255, 255, 0.08);
}

.stats-toolbar .btn.active {
    outline: 3px solid rgba(56, 189, 248, 0.20);
    box-shadow: 0 0 0 1px rgba(248, 250, 252, 0.18) inset;
}

.datepicker-container {
    margin: 0;
}

.datepicker-container form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 0;
}

.stats-page label {
    margin: 0;
    color: var(--stats-muted-strong);
    font-weight: 800;
}

.stats-page input[type="date"] {
    min-height: 40px;
    padding: 8px 12px;
    border: 1px solid var(--stats-border-strong);
    border-radius: 12px;
    color: var(--stats-text);
    background: rgba(15, 23, 42, 0.9);
}

.stats-section-title {
    margin: 20px 0 14px;
    color: var(--stats-text);
    font-size: 1.55rem;
    font-weight: 900;
    letter-spacing: -0.04em;
}

.table-wrapper {
    max-width: 100%;
    margin-bottom: 22px;
    overflow-x: auto;
    border: 1px solid var(--stats-border);
    border-radius: var(--stats-radius-lg);
    background: rgba(15, 23, 42, 0.76);
    box-shadow: var(--stats-shadow);
}

.table-wrapper::-webkit-scrollbar {
    height: 12px;
}

.table-wrapper::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.9);
}

.table-wrapper::-webkit-scrollbar-thumb {
    border: 3px solid rgba(15, 23, 42, 0.9);
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.75);
}

.custom-table {
    min-width: 980px;
    margin: 0;
    border-collapse: separate;
    border-spacing: 0;
    color: var(--stats-text);
    background: transparent;
}

.custom-table th,
.custom-table td {
    min-width: 150px;
    padding: 16px;
    border: 0;
    border-right: 1px solid rgba(148, 163, 184, 0.14);
    border-bottom: 1px solid rgba(148, 163, 184, 0.14);
    text-align: center;
    vertical-align: top;
    white-space: nowrap;
}

.custom-table thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    color: #dbeafe;
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.98), rgba(15, 23, 42, 0.98));
    font-weight: 900;
}

.custom-table th.sticky-col,
.custom-table td.sticky-col,
.custom-table tbody th.sticky-col {
    position: sticky;
    left: 0;
    z-index: 6;
    min-width: 220px;
    color: var(--stats-text);
    background: linear-gradient(90deg, rgba(15, 23, 42, 0.98), rgba(30, 41, 59, 0.98));
    text-align: left;
    font-weight: 900;
}

.custom-table tbody tr:hover td,
.custom-table tbody tr:hover th {
    background-color: rgba(56, 189, 248, 0.08);
}

.custom-table .current-week {
    color: #f8fafc;
}

.cell-content {
    display: grid;
    gap: 8px;
    max-height: 158px;
    overflow-y: auto;
    padding-right: 4px;
    text-align: left;
}

.year-value {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 34px;
    margin: 0;
    padding: 7px 10px;
    border: 1px solid rgba(148, 163, 184, 0.13);
    border-radius: 12px;
    color: var(--stats-muted-strong);
    background: rgba(15, 23, 42, 0.58);
    cursor: pointer;
    transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.year-value::before {
    content: attr(data-year);
    color: var(--stats-muted);
    font-size: 0.73rem;
    font-weight: 900;
}

.year-value:hover {
    transform: translateY(-1px);
    border-color: rgba(56, 189, 248, 0.48);
    background: rgba(56, 189, 248, 0.10);
}

.year-value.current-year-value {
    color: #ffffff;
    border-color: rgba(56, 189, 248, 0.48);
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.24), rgba(15, 23, 42, 0.72));
    font-weight: 900;
}

.year-value.is-saving {
    opacity: 0.72;
    pointer-events: none;
}

.year-value.is-saved {
    border-color: rgba(34, 197, 94, 0.62);
}

.year-value.is-error {
    border-color: rgba(251, 113, 133, 0.75);
}

.action-button {
    width: 100%;
    min-height: 34px;
    padding: 6px 12px;
    border: 0;
    background: linear-gradient(135deg, var(--stats-primary), var(--stats-primary-strong));
    box-shadow: 0 10px 20px rgba(14, 165, 233, 0.20);
}

.stats-section {
    margin-top: 32px;
    padding: 28px;
    border: 1px solid var(--stats-border);
    border-radius: var(--stats-radius-xl);
    background: var(--stats-panel);
    box-shadow: var(--stats-shadow);
    text-align: left;
}

.stats-section h3,
.stats-section h4 {
    color: var(--stats-text);
    font-weight: 900;
    letter-spacing: -0.03em;
}

.stats-section h3 {
    margin-bottom: 20px;
    font-size: 1.6rem;
}

.stats-section h4 {
    margin: 24px 0 16px;
    color: var(--stats-muted-strong);
    font-size: 1.05rem;
    line-height: 1.55;
}

.form-section {
    margin-bottom: 16px;
    padding: 18px;
    border: 1px solid var(--stats-border);
    border-radius: var(--stats-radius-lg);
    background: rgba(15, 23, 42, 0.72);
}

.form-section h4 {
    margin: 0 0 14px;
    color: var(--stats-text);
    font-size: 1.05rem;
    text-decoration: none;
}

.radio-group {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-bottom: 0;
}

.radio-group div {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border: 1px solid var(--stats-border);
    border-radius: 999px;
    background: rgba(30, 41, 59, 0.78);
}

.radio-group input {
    accent-color: var(--stats-primary);
}

#customPeriodInputs {
    display: none;
    margin-top: 16px;
}

#customPeriodInputs[style*="display: none"] {
    display: none !important;
}

#customPeriodInputs label {
    display: inline-block;
    min-width: 120px;
    margin: 8px 0;
}

.stats-table {
    width: 100%;
    max-width: 940px;
    margin: 0 auto;
    overflow: hidden;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid var(--stats-border);
    border-radius: var(--stats-radius-lg);
    background: rgba(15, 23, 42, 0.82);
}

.stats-table th,
.stats-table td {
    padding: 15px;
    border: 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.14);
    text-align: center;
}

.stats-table th {
    color: #dbeafe;
    background: rgba(30, 41, 59, 0.92);
    font-weight: 900;
}

.stats-table tr:last-child td {
    border-bottom: 0;
}

.stats-table td.current-year {
    color: #ffffff;
    background: rgba(56, 189, 248, 0.10);
    font-weight: 900;
}

.stats-table td.other-year {
    color: var(--stats-muted-strong);
}

@media (max-width: 900px) {
    .stats-page .container {
        padding: 18px;
    }

    .stats-hero {
        align-items: stretch;
        flex-direction: column;
        padding: 22px;
    }

    .stats-kpi-grid {
        grid-template-columns: 1fr;
    }

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

    .datepicker-container form {
        align-items: stretch;
        flex-direction: column;
    }
}

@media (max-width: 576px) {
    .stats-page .container {
        padding: 14px;
    }

    .stats-hero h1 {
        font-size: 2.2rem;
    }

    .custom-table {
        min-width: 840px;
        font-size: 14px;
    }

    .custom-table th,
    .custom-table td {
        min-width: 126px;
        padding: 12px;
    }

    .custom-table th.sticky-col,
    .custom-table td.sticky-col,
    .custom-table tbody th.sticky-col {
        min-width: 180px;
    }

    .stats-section {
        padding: 18px;
    }
}