/* ==========================================================================
   REP-BAC — Thème de l'interface (surcouche AdminLTE 3 / Bootstrap 4)
   ========================================================================== */

:root {
    --rb-primary: #2563eb;
    --rb-primary-dark: #1d4ed8;
    --rb-primary-soft: #eff4ff;
    --rb-success: #059669;
    --rb-success-soft: #ecfdf5;
    --rb-warning: #d97706;
    --rb-warning-soft: #fffbeb;
    --rb-danger: #dc2626;
    --rb-danger-soft: #fef2f2;
    --rb-violet: #7c3aed;
    --rb-violet-soft: #f5f3ff;

    --rb-ink: #0f172a;
    --rb-text: #334155;
    --rb-muted: #64748b;
    --rb-line: #e2e8f0;
    --rb-surface: #ffffff;
    --rb-canvas: #f4f6fb;

    --rb-sidebar: #0b1430;
    --rb-sidebar-2: #13204a;

    --rb-radius: 14px;
    --rb-radius-sm: 10px;
    --rb-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .06);
    --rb-shadow-lg: 0 10px 30px rgba(15, 23, 42, .12);
    --rb-font: "Inter", "Source Sans Pro", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

/* ---------- Base ---------- */
body,
.main-header .navbar-nav .nav-link,
.btn, .form-control, .table, .modal {
    font-family: var(--rb-font);
}

body { color: var(--rb-text); font-size: .925rem; }

.content-wrapper { background: var(--rb-canvas); }

h1, h2, h3, h4, h5, .h1, .h2, .h3, .h4, .h5 { color: var(--rb-ink); font-weight: 700; letter-spacing: -.01em; }

a { color: var(--rb-primary); }
a:hover { color: var(--rb-primary-dark); }

.text-muted { color: var(--rb-muted) !important; }
.fw-600 { font-weight: 600; }
.tabular { font-variant-numeric: tabular-nums; }

/* ---------- Sidebar ---------- */
.main-sidebar {
    background: linear-gradient(180deg, var(--rb-sidebar) 0%, var(--rb-sidebar-2) 100%) !important;
    box-shadow: none !important;
}

.main-sidebar .brand-link {
    display: flex;
    align-items: center;
    gap: .65rem;
    height: 64px;
    padding: 0 1.1rem;
    border-bottom: 1px solid rgba(255, 255, 255, .06) !important;
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    color: #fff;
    font-size: 1rem;
    box-shadow: 0 6px 16px rgba(59, 130, 246, .35);
}

.brand-text { color: #fff; font-weight: 800 !important; letter-spacing: .02em; }
.brand-text small { display: block; font-size: .68rem; font-weight: 500; color: rgba(255, 255, 255, .5); letter-spacing: .04em; margin-top: -2px; }

.sidebar { padding: 0 .65rem; }

.nav-sidebar .nav-header {
    color: rgba(255, 255, 255, .38) !important;
    font-size: .68rem !important;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    padding: 1.1rem .9rem .4rem !important;
}

.nav-sidebar > .nav-item > .nav-link {
    color: rgba(255, 255, 255, .72) !important;
    border-radius: 10px !important;
    margin-bottom: 2px;
    padding: .6rem .9rem;
    transition: background .15s ease, color .15s ease;
}

.nav-sidebar > .nav-item > .nav-link:hover {
    background: rgba(255, 255, 255, .07) !important;
    color: #fff !important;
}

.sidebar-dark-primary .nav-sidebar > .nav-item > .nav-link.active {
    background: var(--rb-primary) !important;
    color: #fff !important;
    box-shadow: 0 6px 18px rgba(37, 99, 235, .4) !important;
}

.nav-sidebar .nav-link .nav-icon { font-size: .95rem !important; }

.sidebar-cta {
    margin: 1.25rem .25rem 0;
    padding: 1rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, .06);
    border: 1px dashed rgba(255, 255, 255, .16);
    color: rgba(255, 255, 255, .78);
    font-size: .8rem;
}

.sidebar-collapse .sidebar-cta { display: none; }

/* ---------- Topbar ---------- */
.main-header.navbar {
    background: rgba(255, 255, 255, .85);
    backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--rb-line) !important;
    min-height: 64px;
}

.topbar-title { font-weight: 600; color: var(--rb-ink); }

/* ---------- Page header ---------- */
.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.6rem .5rem 1.2rem;
}

.page-header__icon {
    display: inline-grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: var(--rb-primary-soft);
    color: var(--rb-primary);
    font-size: 1.2rem;
    flex: 0 0 48px;
}

.page-header h1 { font-size: 1.5rem; margin: 0; }
.page-header p { margin: .15rem 0 0; color: var(--rb-muted); }

.page-header .breadcrumb {
    background: none;
    padding: 0;
    margin: 0 0 .25rem;
    font-size: .78rem;
}

.page-header__actions { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ---------- Cards ---------- */
.card {
    border: 1px solid var(--rb-line);
    border-radius: var(--rb-radius);
    box-shadow: var(--rb-shadow);
    margin-bottom: 1.5rem;
}

.card > .card-header {
    background: transparent;
    border-bottom: 1px solid var(--rb-line);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem;
}

.card > .card-header::after { display: none; }
.card-title { font-weight: 700; color: var(--rb-ink); font-size: 1rem; float: none; }
.card-subtitle { color: var(--rb-muted); font-size: .8rem; margin: .15rem 0 0; }
.card-body { padding: 1.25rem; }

/* ---------- Stat cards ---------- */
.stat-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.15rem 1.25rem;
    background: var(--rb-surface);
    border: 1px solid var(--rb-line);
    border-radius: var(--rb-radius);
    box-shadow: var(--rb-shadow);
    margin-bottom: 1.5rem;
    overflow: hidden;
    transition: transform .15s ease, box-shadow .15s ease;
}

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--rb-shadow-lg); }

.stat-card__icon {
    display: inline-grid;
    place-items: center;
    width: 52px;
    height: 52px;
    border-radius: 14px;
    font-size: 1.25rem;
    flex: 0 0 52px;
}

.stat-card__label { font-size: .78rem; color: var(--rb-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.stat-card__value { font-size: 1.65rem; font-weight: 800; color: var(--rb-ink); line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat-card__hint { font-size: .78rem; color: var(--rb-muted); }

.tone-primary { background: var(--rb-primary-soft); color: var(--rb-primary); }
.tone-success { background: var(--rb-success-soft); color: var(--rb-success); }
.tone-warning { background: var(--rb-warning-soft); color: var(--rb-warning); }
.tone-danger  { background: var(--rb-danger-soft);  color: var(--rb-danger); }
.tone-violet  { background: var(--rb-violet-soft);  color: var(--rb-violet); }

/* ---------- Buttons ---------- */
.btn { border-radius: var(--rb-radius-sm); font-weight: 600; padding: .5rem 1rem; }
.btn-sm { border-radius: 8px; padding: .3rem .65rem; }
.btn-primary { background: var(--rb-primary); border-color: var(--rb-primary); box-shadow: 0 4px 12px rgba(37, 99, 235, .25); }
.btn-primary:hover, .btn-primary:focus { background: var(--rb-primary-dark); border-color: var(--rb-primary-dark); }
.btn-light { background: #fff; border-color: var(--rb-line); color: var(--rb-text); }
.btn-light:hover { background: #f8fafc; border-color: #cbd5e1; }
.btn-soft-primary { background: var(--rb-primary-soft); color: var(--rb-primary); border: 0; }
.btn-soft-primary:hover { background: var(--rb-primary); color: #fff; }
.btn-soft-danger { background: var(--rb-danger-soft); color: var(--rb-danger); border: 0; }
.btn-soft-danger:hover { background: var(--rb-danger); color: #fff; }
.btn-icon { width: 34px; height: 34px; padding: 0; display: inline-grid; place-items: center; }

/* ---------- Badges / chips ---------- */
.chip {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .2rem .6rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 700;
    line-height: 1.4;
    white-space: nowrap;
}

.chip-serie { background: var(--rb-primary-soft); color: var(--rb-primary); min-width: 2.2rem; justify-content: center; }
.chip-muted { background: #f1f5f9; color: var(--rb-muted); }
.chip-success { background: var(--rb-success-soft); color: var(--rb-success); }
.chip-warning { background: var(--rb-warning-soft); color: var(--rb-warning); }

/* ---------- Tables ---------- */
.table { color: var(--rb-text); margin-bottom: 0; }
.table thead th {
    border-top: 0;
    border-bottom: 1px solid var(--rb-line) !important;
    background: #f8fafc;
    color: var(--rb-muted);
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    white-space: nowrap;
}
.table td, .table th { padding: .7rem .9rem; vertical-align: middle !important; border-color: #eef2f7; }
.table-hover tbody tr:hover { background: #f8faff; }
.table tfoot td { background: #f8fafc; font-weight: 800; color: var(--rb-ink); border-top: 2px solid var(--rb-line); }
.table-bordered, .table-bordered td, .table-bordered th { border-color: #eef2f7; }

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    border-radius: 8px;
    border: 1px solid var(--rb-line);
}
.dataTables_wrapper .dataTables_filter input { min-width: 220px; padding-left: .75rem; }
.dataTables_wrapper .dataTables_info { color: var(--rb-muted); font-size: .82rem; }
.page-item.active .page-link { background: var(--rb-primary); border-color: var(--rb-primary); }
.page-link { border-radius: 8px !important; margin: 0 2px; border-color: var(--rb-line); color: var(--rb-text); }
.dt-buttons .btn { border-radius: 8px !important; }

/* ---------- Tabs ---------- */
.nav-segmented {
    display: inline-flex;
    flex-wrap: wrap;
    gap: .25rem;
    padding: .3rem;
    background: #eef2f7;
    border-radius: 12px;
    border: 0;
}

.nav-segmented .nav-link {
    border: 0 !important;
    border-radius: 9px !important;
    color: var(--rb-muted);
    font-weight: 600;
    padding: .45rem .9rem;
}

.nav-segmented .nav-link.active { background: #fff !important; color: var(--rb-ink) !important; box-shadow: var(--rb-shadow); }

/* ---------- Progress bars (séries) ---------- */
.bar-row { display: grid; grid-template-columns: 3rem 1fr 4.5rem; align-items: center; gap: .75rem; margin-bottom: .7rem; }
.bar-track { height: 10px; border-radius: 999px; background: #eef2f7; overflow: hidden; }
.bar-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, #3b82f6, #6366f1); }
.bar-value { text-align: right; font-weight: 700; color: var(--rb-ink); font-variant-numeric: tabular-nums; }

/* ---------- Upload zone ---------- */
.dropzone-area {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    min-height: 240px;
    padding: 2rem;
    text-align: center;
    border: 2px dashed #c7d2fe;
    border-radius: var(--rb-radius);
    background: linear-gradient(180deg, #fafbff, #f3f6ff);
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease, transform .15s ease;
}

.dropzone-area:hover, .dropzone-area.is-dragover { border-color: var(--rb-primary); background: var(--rb-primary-soft); }
.dropzone-area.is-dragover { transform: scale(1.01); }
.dropzone-area input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.dropzone-area__icon {
    display: inline-grid;
    place-items: center;
    width: 64px;
    height: 64px;
    border-radius: 18px;
    background: #fff;
    color: var(--rb-primary);
    font-size: 1.6rem;
    box-shadow: var(--rb-shadow);
    margin-bottom: .25rem;
}

.dropzone-area__title { font-weight: 700; color: var(--rb-ink); font-size: 1.05rem; }
.dropzone-area__file { display: none; margin-top: .5rem; }
.dropzone-area.has-file .dropzone-area__file { display: inline-flex; }

.format-list { list-style: none; padding: 0; margin: 0; }
.format-list li { display: flex; gap: .75rem; padding: .75rem 0; border-bottom: 1px solid var(--rb-line); }
.format-list li:last-child { border-bottom: 0; }
.format-list i { margin-top: .2rem; }

/* ---------- Preview (aperçu d'import) ---------- */
.preview-centre { border: 1px solid var(--rb-line); border-radius: 12px; margin-bottom: .75rem; overflow: hidden; background: #fff; }
.preview-centre__head { display: flex; align-items: center; gap: .9rem; padding: .85rem 1rem; cursor: pointer; }
.preview-centre__head:hover { background: #fafbff; }
.preview-centre__name { font-weight: 700; color: var(--rb-ink); }
.preview-centre__meta { color: var(--rb-muted); font-size: .8rem; }
.preview-centre__body { border-top: 1px solid var(--rb-line); max-height: 340px; overflow: auto; }
.preview-centre .chevron { transition: transform .2s ease; color: var(--rb-muted); }
.preview-centre .collapsed .chevron { transform: rotate(-90deg); }

.custom-checkbox-lg .custom-control-label::before,
.custom-checkbox-lg .custom-control-label::after { width: 1.2rem; height: 1.2rem; top: .1rem; }

/* ---------- Info list / centre header ---------- */
.hero-card {
    position: relative;
    padding: 1.5rem;
    border-radius: var(--rb-radius);
    color: #fff;
    background: radial-gradient(circle at 85% 20%, rgba(255, 255, 255, .18), transparent 40%), linear-gradient(135deg, #1e3a8a, #2563eb 55%, #6366f1);
    box-shadow: var(--rb-shadow-lg);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.hero-card h2 { color: #fff; font-size: 1.5rem; margin: 0; }
.hero-card .hero-meta { opacity: .8; }
.hero-stats { display: flex; flex-wrap: wrap; gap: 2rem; margin-top: 1.25rem; }
.hero-stats .value { font-size: 1.6rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.hero-stats .label { font-size: .75rem; opacity: .75; text-transform: uppercase; letter-spacing: .06em; }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--rb-muted); }
.empty-state i { font-size: 2.5rem; color: #cbd5e1; margin-bottom: 1rem; }
.empty-state h5 { color: var(--rb-ink); }

/* ---------- Footer / toasts ---------- */
.main-footer { background: transparent; border-top: 1px solid var(--rb-line); color: var(--rb-muted); font-size: .8rem; }
#toast-container > div { border-radius: 12px; box-shadow: var(--rb-shadow-lg); opacity: 1; font-family: var(--rb-font); }

/* ---------- Print ---------- */
@media print {
    .main-sidebar, .main-header, .main-footer, .page-header__actions, .nav-segmented, .dataTables_filter, .dataTables_length, .dataTables_paginate, .dataTables_info, .dt-buttons { display: none !important; }
    .content-wrapper { margin: 0 !important; background: #fff; }
    .card { box-shadow: none; }
}

/* ---------- Correctifs de mise en page ---------- */
.row > [class*="col"] > .stat-card { height: calc(100% - 1.5rem); }
.card-footer.d-flex::after, .card-header::after { display: none; }
.card > .table-responsive:last-child .table tfoot td,
.card > .table-responsive:last-child .table tbody tr:last-child td { border-bottom: 0; }
.card > .table-responsive:last-child { border-radius: 0 0 var(--rb-radius) var(--rb-radius); }
div.dataTables_wrapper div.dataTables_length { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
div.dataTables_wrapper div.dataTables_length label { margin: 0; }
div.dataTables_wrapper .dt-buttons { display: inline-flex; gap: .35rem; margin-left: 0 !important; }
div.dataTables_wrapper > .row:first-child { margin-bottom: .75rem; align-items: center; }

/* ---------- Modales ---------- */
.modal-modern { border: 0; border-radius: 18px; box-shadow: 0 24px 60px rgba(15, 23, 42, .25); overflow: hidden; }
.modal-modern .modal-header { border-bottom: 1px solid var(--rb-line); padding: 1rem 1.25rem; align-items: center; }
.modal-modern .modal-body { padding: 1.25rem; }
.modal-modern .modal-footer { border-top: 1px solid var(--rb-line); padding: .9rem 1.25rem; }
.modal-backdrop.show { opacity: .45; backdrop-filter: blur(2px); }
.modal.fade .modal-dialog { transform: translateY(12px) scale(.98); transition: transform .2s ease; }
.modal.show .modal-dialog { transform: none; }

.confirm-icon {
    display: inline-grid;
    place-items: center;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--rb-danger-soft);
    color: var(--rb-danger);
    font-size: 1.5rem;
    box-shadow: 0 0 0 8px #fff5f5;
}

.impact-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.impact-grid > div { background: var(--rb-danger-soft); border-radius: 12px; padding: .7rem .5rem; text-align: center; }
.impact-grid .value { display: block; font-size: 1.3rem; font-weight: 800; color: var(--rb-danger); font-variant-numeric: tabular-nums; }
.impact-grid .label { font-size: .72rem; color: #b91c1c; text-transform: uppercase; letter-spacing: .05em; }
.confirm-word { background: var(--rb-danger-soft); color: var(--rb-danger); padding: .1rem .4rem; border-radius: 6px; font-weight: 700; }
#sm-confirmation { font-weight: 700; letter-spacing: .08em; text-align: center; }

/* ---------- Sélecteur de séries ---------- */
.serie-picker { display: flex; flex-wrap: wrap; gap: .45rem; }
.serie-toggle { margin: 0; cursor: pointer; }
.serie-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.serie-toggle span {
    display: inline-grid;
    place-items: center;
    min-width: 3.2rem;
    padding: .45rem .7rem;
    border-radius: 10px;
    border: 1.5px solid var(--rb-line);
    background: #fff;
    font-weight: 700;
    color: var(--rb-text);
    transition: all .12s ease;
    user-select: none;
}
.serie-toggle:hover span { border-color: #93c5fd; }
.serie-toggle input:checked + span { background: var(--rb-primary); border-color: var(--rb-primary); color: #fff; box-shadow: 0 4px 10px rgba(37, 99, 235, .3); }
.serie-toggle input:focus-visible + span { outline: 2px solid var(--rb-primary); outline-offset: 2px; }
.serie-toggle.is-taken { cursor: not-allowed; }
.serie-toggle.is-taken span { background: #f1f5f9; color: #cbd5e1; border-style: dashed; }

/* ---------- Rapport ---------- */
.rapport-table { font-size: .85rem; font-variant-numeric: tabular-nums; }
.rapport-table tbody tr:hover td { filter: brightness(.98); }
.filter-bar .card-body { padding: 1rem 1.25rem; }
.confirm-icon i { font-size: 1.5rem !important; line-height: 1; margin: 0 !important; color: inherit !important; }
