/* ==========================================================================
   Extranet Cercle Saint Nicolas — thème applicatif (Bootstrap 5.3)
   Surcouche unique : ne pas modifier bootstrap5.min.css.
   ========================================================================== */

:root {
    /* Identité — le rouge historique de l'extranet, décliné proprement */
    --csn-red: #d92b26;
    --csn-red-dark: #a81f1b;
    --csn-red-soft: rgba(217, 43, 38, .1);

    /* Neutres */
    --csn-ink: #14181f;
    --csn-body: #f4f6f9;
    --csn-surface: #ffffff;
    --csn-border: #e3e8ef;
    --csn-muted: #6b7280;

    /* Sidebar */
    --csn-sidebar-bg: #161b24;
    --csn-sidebar-fg: #a8b0bd;
    --csn-sidebar-fg-active: #ffffff;
    --csn-sidebar-w: 264px;

    --csn-topbar-h: 62px;
    --csn-radius: 10px;
    --csn-shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 12px rgba(16, 24, 40, .06);

    /* Bootstrap overrides */
    --bs-primary: var(--csn-red);
    --bs-body-bg: var(--csn-body);
    --bs-body-color: var(--csn-ink);
    --bs-body-font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --bs-border-color: var(--csn-border);
}

body {
    background: var(--csn-body);
    color: var(--csn-ink);
    font-family: var(--bs-body-font-family);
    font-size: .9375rem;
    -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   Structure
   ========================================================================== */

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--csn-sidebar-w);
    background: var(--csn-sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.app-main {
    margin-left: var(--csn-sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-content {
    flex: 1;
    padding: 1.75rem;
}

@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
        transition: transform .22s ease;
        box-shadow: 0 0 40px rgba(0, 0, 0, .35);
    }

    .app-sidebar.is-open {
        transform: none;
    }

    .app-main {
        margin-left: 0;
    }

    .app-content {
        padding: 1.125rem;
    }
}

/* Voile derrière la sidebar mobile */
.app-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(9, 12, 17, .5);
    z-index: 1035;
    opacity: 0;
    visibility: hidden;
    transition: opacity .22s ease, visibility .22s ease;
}

.app-backdrop.is-open {
    opacity: 1;
    visibility: visible;
}

/* ==========================================================================
   Topbar
   ========================================================================== */

.app-topbar {
    height: var(--csn-topbar-h);
    background: var(--csn-surface);
    border-bottom: 1px solid var(--csn-border);
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 0 1.25rem;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.app-topbar .brand {
    font-weight: 650;
    letter-spacing: -.01em;
    color: var(--csn-ink);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: .625rem;
}

.app-topbar .brand img {
    height: 30px;
    width: auto;
}

.sidebar-toggle {
    border: 0;
    background: transparent;
    color: var(--csn-ink);
    font-size: 1.15rem;
    padding: .4rem .55rem;
    border-radius: 8px;
    line-height: 1;
}

.sidebar-toggle:hover {
    background: var(--csn-body);
}

@media (min-width: 992px) {
    .sidebar-toggle {
        display: none;
    }
}

/* ==========================================================================
   Sidebar — identité utilisateur + navigation
   ========================================================================== */

.sidebar-user {
    padding: 1.5rem 1.25rem 1.25rem;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
}

.sidebar-user img {
    width: 62px;
    height: 62px;
    border-radius: 50%;
    object-fit: cover;
    background: #fff;
    padding: 4px;
}

.sidebar-user .name {
    color: #fff;
    font-weight: 600;
    margin-top: .625rem;
    font-size: .9375rem;
    line-height: 1.3;
}

.sidebar-user .meta {
    color: var(--csn-sidebar-fg);
    font-size: .78rem;
    margin-top: .2rem;
}

.sidebar-nav {
    list-style: none;
    margin: 0;
    padding: .875rem .625rem 1.5rem;
}

.sidebar-nav .nav-section {
    color: #5f6875;
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .09em;
    padding: 1.125rem .75rem .4rem;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .625rem .75rem;
    margin-bottom: 2px;
    color: var(--csn-sidebar-fg);
    text-decoration: none;
    border-radius: 8px;
    font-size: .9rem;
    font-weight: 500;
    transition: background .15s ease, color .15s ease;
}

.sidebar-nav a i {
    width: 18px;
    text-align: center;
    font-size: .95rem;
    flex: none;
}

.sidebar-nav a:hover {
    background: rgba(255, 255, 255, .06);
    color: #fff;
}

.sidebar-nav a.active {
    background: var(--csn-red);
    color: var(--csn-sidebar-fg-active);
    box-shadow: 0 2px 8px rgba(217, 43, 38, .35);
}

/* ==========================================================================
   En-tête de page
   ========================================================================== */

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .75rem;
    margin-bottom: 1.25rem;
}

.page-head h1 {
    font-size: 1.3rem;
    font-weight: 650;
    letter-spacing: -.015em;
    margin: 0;
    display: flex;
    align-items: center;
    gap: .625rem;
}

.page-head h1 i {
    color: var(--csn-red);
    font-size: 1.05rem;
}

/* ==========================================================================
   Cartes
   ========================================================================== */

.card {
    background: var(--csn-surface);
    border: 1px solid var(--csn-border);
    border-radius: var(--csn-radius);
    box-shadow: var(--csn-shadow);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--csn-border);
    padding: .875rem 1.125rem;
    font-weight: 600;
    font-size: .95rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
}

.card-header i {
    color: var(--csn-red);
    margin-right: .4rem;
}

.card-body {
    padding: 1.125rem;
}

/* Tuile de statistique */
.stat-tile {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.125rem;
}

.stat-tile .icon {
    width: 46px;
    height: 46px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: var(--csn-red-soft);
    color: var(--csn-red);
    font-size: 1.15rem;
    flex: none;
}

.stat-tile .value {
    font-size: 1.5rem;
    font-weight: 680;
    line-height: 1.1;
    letter-spacing: -.02em;
}

.stat-tile .label {
    color: var(--csn-muted);
    font-size: .8rem;
    margin-top: .15rem;
}

/* ==========================================================================
   Tableaux
   ========================================================================== */

.table {
    --bs-table-bg: transparent;
    margin-bottom: 0;
    font-size: .885rem;
}

.table > thead th {
    background: #fafbfc;
    color: var(--csn-muted);
    font-weight: 600;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    border-bottom: 1px solid var(--csn-border);
    padding: .7rem .875rem;
    white-space: nowrap;
}

.table > tbody td {
    padding: .7rem .875rem;
    vertical-align: middle;
    border-bottom: 1px solid #eef1f5;
}

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

.table-hover > tbody > tr:hover > * {
    background: #f8fafc;
}

/* Le tableau prend toute la largeur de la carte, sans double bordure */
.card > .table-responsive {
    border-radius: 0 0 var(--csn-radius) var(--csn-radius);
}

/* Ligne "aucun résultat" */
.table-empty td {
    text-align: center;
    color: var(--csn-muted);
    padding: 2.25rem 1rem !important;
}

/* ==========================================================================
   Boutons, badges, formulaires
   ========================================================================== */

.btn {
    border-radius: 8px;
    font-weight: 550;
    font-size: .875rem;
    padding: .45rem .9rem;
}

.btn-primary {
    --bs-btn-bg: var(--csn-red);
    --bs-btn-border-color: var(--csn-red);
    --bs-btn-hover-bg: var(--csn-red-dark);
    --bs-btn-hover-border-color: var(--csn-red-dark);
    --bs-btn-active-bg: var(--csn-red-dark);
    --bs-btn-active-border-color: var(--csn-red-dark);
    --bs-btn-disabled-bg: var(--csn-red);
    --bs-btn-disabled-border-color: var(--csn-red);
}

.btn-sm {
    padding: .28rem .6rem;
    font-size: .8rem;
}

.badge {
    font-weight: 600;
    font-size: .72rem;
    padding: .35em .6em;
    border-radius: 6px;
}

/* Badges de poste (marqueur, chrono, arbitre…) */
.badge-poste {
    background: #eef2f7;
    color: #445063;
}

.form-label {
    font-weight: 550;
    font-size: .85rem;
    margin-bottom: .3rem;
}

.form-control,
.form-select {
    border-radius: 8px;
    border-color: var(--csn-border);
    font-size: .9rem;
    padding: .5rem .75rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--csn-red);
    box-shadow: 0 0 0 3px var(--csn-red-soft);
}

.form-text {
    font-size: .8rem;
    color: var(--csn-muted);
}

/* ==========================================================================
   Page de connexion
   ========================================================================== */

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    background: linear-gradient(160deg, #1b2029 0%, #0f1218 100%);
}

.login-card {
    width: 100%;
    max-width: 388px;
    background: var(--csn-surface);
    border-radius: 14px;
    padding: 2.25rem 2rem;
    box-shadow: 0 18px 48px rgba(0, 0, 0, .35);
}

.login-brand {
    text-align: center;
    margin-bottom: 1.75rem;
}

.login-brand img {
    width: 66px;
    height: 66px;
    object-fit: contain;
    margin-bottom: .75rem;
}

.login-brand h1 {
    font-size: 1.3rem;
    font-weight: 680;
    letter-spacing: -.02em;
    margin: 0;
}

.login-brand p {
    color: var(--csn-muted);
    font-size: .85rem;
    margin: .15rem 0 0;
}

.login-footer {
    margin-top: 1.5rem;
    text-align: center;
    font-size: .78rem;
    color: var(--csn-muted);
}

.login-footer a {
    color: var(--csn-red);
    text-decoration: none;
}

.login-footer a:hover {
    text-decoration: underline;
}

.login-footer p {
    margin: .75rem 0 0;
    line-height: 1.5;
}

/* ==========================================================================
   Divers
   ========================================================================== */

.alert {
    border-radius: var(--csn-radius);
    border: 1px solid transparent;
    font-size: .885rem;
}

.text-muted-sm {
    color: var(--csn-muted);
    font-size: .82rem;
}

@media print {

    .app-sidebar,
    .app-topbar,
    .app-backdrop,
    .no-print {
        display: none !important;
    }

    .app-main {
        margin-left: 0;
    }

    .card {
        box-shadow: none;
        border-color: #ccc;
    }
}
