/* ==========================================================================
   Billiard Pro Zone — Dashboard · Thème « Azur »
   Une seule feuille de style pour toutes les pages.
   Sommaire : 1. Jetons  2. Base  3. Structure (sidebar / topbar / contenu)
              4. Composants (cartes, boutons, formulaires, tableaux, badges, alertes)
              5. Accueil (cartes de modules)  6. Connexion  7. Responsive / impression
   ========================================================================== */

/* 1. Jetons ---------------------------------------------------------------- */
:root {
    --bg: #F4F7FB;
    --surface: #FFFFFF;
    --surface-2: #F7F9FC;
    --border: #E1E7F0;
    --border-soft: #EDF1F6;
    --border-strong: #CBD5E3;

    --text: #0B1A33;
    --text-2: #2A3953;
    --muted: #526079;
    --faint: #94A3B8;

    --primary: #1F5FD6;
    --primary-hover: #174AA8;
    --primary-soft: #E8F0FD;
    --primary-ring: rgba(31, 95, 214, .25);

    --navy: #0B2A5B;
    --navy-2: #16407F;
    --navy-line: #1D4686;
    --navy-text: #D2DFF5;
    --navy-muted: #9DB5E0;

    --success: #067647;  --success-soft: #ECFDF3; --success-line: #ABEFC6;
    --warning: #B54708;  --warning-soft: #FFFAEB; --warning-line: #FEDF89;
    --danger: #B42318;   --danger-soft: #FEF2F2;  --danger-line: #FECACA;

    --radius-sm: 6px;
    --radius: 9px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(11, 26, 51, .05);
    --shadow: 0 4px 16px rgba(11, 26, 51, .08);
    --shadow-lg: 0 12px 32px rgba(11, 26, 51, .16);

    --sidebar-w: 264px;
    --topbar-h: 64px;

    --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* 2. Base ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
h1, h2, h3, h4 { margin: 0; color: var(--text); letter-spacing: -.01em; }
h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
p { margin: 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: 0; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.text-muted { color: var(--muted); }
.text-sm { font-size: 13px; }
.text-right { text-align: right; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* 3. Structure ------------------------------------------------------------- */
.app { display: flex; min-height: 100vh; }

/* Barre latérale */
.sidebar {
    position: sticky; top: 0;
    width: var(--sidebar-w); height: 100vh; flex: none;
    display: flex; flex-direction: column; gap: 24px;
    padding: 20px 14px;
    background: var(--navy); color: var(--navy-text);
    overflow-y: auto;
}
.sidebar-brand { display: flex; flex-direction: column; gap: 6px; padding: 4px 8px; }
.sidebar-brand img { height: 38px; width: auto; max-width: 200px; object-fit: contain; object-position: left; }
.sidebar-brand span { font-size: 12px; color: var(--navy-muted); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
    margin: 16px 10px 6px;
    font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
    color: var(--navy-muted);
}
.nav-link {
    display: flex; align-items: center; gap: 10px;
    min-height: 40px; padding: 0 10px; border-radius: 8px;
    color: var(--navy-text); font-weight: 500;
    cursor: pointer; list-style: none; user-select: none;
}
.nav-link:hover { background: rgba(255, 255, 255, .07); color: #FFFFFF; }
.nav-link.is-active { background: var(--navy-2); color: #FFFFFF; font-weight: 700; }
.nav-link svg { flex: none; }
.nav-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-count { font-size: 12px; color: var(--navy-muted); font-variant-numeric: tabular-nums; }
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary .chev { opacity: .7; transition: transform .15s ease; }
.nav-group[open] > summary .chev { transform: rotate(90deg); }
.nav-sub {
    display: flex; flex-direction: column; gap: 1px;
    margin: 2px 0 6px 19px; padding-left: 10px;
    border-left: 1px solid var(--navy-line);
}
.nav-sub a { display: block; padding: 7px 10px; border-radius: 6px; font-size: 13px; color: var(--navy-muted); }
.nav-sub a:hover { color: #FFFFFF; background: rgba(255, 255, 255, .07); }
.nav-sub a.is-current { color: #FFFFFF; background: var(--navy-2); font-weight: 600; }

.sidebar-user {
    margin-top: auto;
    display: flex; align-items: center; gap: 10px;
    padding: 14px 8px 4px; border-top: 1px solid var(--navy-line);
}
.avatar {
    width: 32px; height: 32px; flex: none; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--navy-line); color: #FFFFFF; font-size: 12px; font-weight: 700;
}
.sidebar-user .who { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.sidebar-user .who strong { font-size: 13px; font-weight: 600; color: #FFFFFF; }
.sidebar-user .who span { font-size: 12px; color: var(--navy-muted); }
.sidebar .icon-btn { background: transparent; color: var(--navy-text); border-color: var(--navy-line); }
.sidebar .icon-btn:hover { background: rgba(255, 255, 255, .08); color: #FFFFFF; }
.sidebar-backdrop { display: none; }

/* Zone principale */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 20;
    min-height: var(--topbar-h);
    display: flex; align-items: center; gap: 16px;
    padding: 12px 32px;
    background: rgba(255, 255, 255, .94);
    backdrop-filter: saturate(1.4) blur(8px);
    border-bottom: 1px solid var(--border);
}
.topbar .topbar-menu { display: none; }
.topbar-date { font-size: 13px; color: var(--muted); white-space: nowrap; }

.breadcrumb { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13px; color: var(--muted); }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb [aria-current] { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.breadcrumb .sep { color: var(--faint); }

/* Recherche Ctrl K */
.search {
    position: relative; margin-left: auto;
    display: flex; align-items: center; gap: 8px;
    width: 380px; max-width: 100%; height: 40px; padding: 0 12px;
    border: 1px solid var(--border-strong); border-radius: var(--radius);
    background: var(--surface-2); color: var(--muted);
}
.search:focus-within { background: #FFFFFF; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font: inherit; color: var(--text); }
.search input::-webkit-search-cancel-button { display: none; }
.search kbd {
    font-family: inherit; font-size: 11px; color: var(--muted);
    background: #FFFFFF; border: 1px solid var(--border); border-radius: 5px; padding: 2px 6px;
}
.search-results {
    position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 30;
    max-height: 380px; overflow-y: auto; padding: 6px;
    background: #FFFFFF; border: 1px solid var(--border); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}
.search-results a { display: flex; flex-direction: column; padding: 8px 10px; border-radius: 7px; color: var(--text); }
.search-results a small { font-size: 12px; color: var(--muted); }
.search-results a.is-selected, .search-results a:hover { background: var(--primary-soft); color: var(--primary-hover); }
.search-empty { padding: 10px; font-size: 13px; color: var(--muted); }

.content {
    flex: 1; width: 100%; max-width: 1240px;
    padding: 32px;
    display: flex; flex-direction: column; gap: 24px;
}
.content.is-wide { max-width: none; }

/* 4. Composants ------------------------------------------------------------ */

/* En-tête de page */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-header > div:first-child { display: flex; flex-direction: column; gap: 6px; }
.page-header p { color: var(--muted); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Cartes */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.card-head h2 { font-size: 15px; }
.card-body { padding: 20px; }
.card-foot {
    padding: 14px 20px; border-top: 1px solid var(--border);
    background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Indicateurs */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.stat { padding: 18px 20px; }
.stat-label { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.stat-value { margin-top: 6px; font-size: 26px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-note { margin-top: 2px; font-size: 13px; color: var(--muted); }

/* Boutons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 40px; padding: 0 16px;
    border: 1px solid transparent; border-radius: var(--radius);
    font: inherit; font-size: 14px; font-weight: 700; line-height: 1;
    white-space: nowrap; cursor: pointer; text-decoration: none;
    transition: background-color .15s, border-color .15s, box-shadow .15s;
}
.btn:disabled, .btn.is-disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: var(--primary); color: #FFFFFF; }
.btn-primary:hover { background: var(--primary-hover); color: #FFFFFF; }
.btn-secondary { background: #FFFFFF; color: var(--text-2); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); color: var(--text); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-success { background: var(--success); color: #FFFFFF; }
.btn-success:hover { background: #05603A; color: #FFFFFF; }
.btn-danger { background: var(--danger); color: #FFFFFF; }
.btn-danger:hover { background: #912018; color: #FFFFFF; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 7px; }
.btn-lg { height: 46px; padding: 0 20px; font-size: 15px; }
.btn-block { width: 100%; }
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center; flex: none;
    width: 40px; height: 40px; border-radius: 8px;
    border: 1px solid var(--border); background: #FFFFFF; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* Formulaires */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px 20px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.span-2 { grid-column: span 2; }
.field.span-full { grid-column: 1 / -1; }
.field > label, .label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.hint { font-size: 12px; color: var(--muted); }
.error-text { font-size: 12px; color: var(--danger); }

.input, .select, .textarea,
.field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.field select, .field textarea {
    width: 100%; height: 42px; padding: 0 12px;
    border: 1px solid var(--border-strong); border-radius: var(--radius);
    background: #FFFFFF; color: var(--text);
    font: inherit; font-size: 14px;
    transition: border-color .15s, box-shadow .15s;
}
.textarea, .field textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; }
.select, .field select {
    appearance: none; -webkit-appearance: none; padding-right: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23526079' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center;
}
.input:focus, .select:focus, .textarea:focus,
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring);
}
.input::placeholder, .field input::placeholder, .field textarea::placeholder { color: var(--faint); }
.input:disabled, .field input:disabled, .field select:disabled { background: var(--surface-2); color: var(--muted); }
.is-invalid, .field .is-invalid { border-color: var(--danger) !important; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; padding-top: 4px; }
.input-group { position: relative; display: flex; }
.input-group .input, .input-group input { padding-right: 84px; }
.input-group .input-addon {
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    height: 30px; padding: 0 10px; border: 0; border-radius: 6px;
    background: transparent; color: var(--muted); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.input-group .input-addon:hover { background: var(--surface-2); color: var(--text); }

/* Barre d'outils (filtres au-dessus d'un tableau) */
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.toolbar .input, .toolbar .select { width: auto; min-width: 200px; }

/* Tableaux */
.table-wrap { overflow-x: auto; background: #FFFFFF; border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card .table-wrap { border: 0; border-radius: 0; box-shadow: none; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
    position: sticky; top: 0;
    padding: 10px 14px; text-align: left; white-space: nowrap;
    font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
    color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #FAFBFD; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .actions { text-align: right; white-space: nowrap; }
.table-compact td { padding: 8px 12px; }

/* Badges */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    height: 22px; padding: 0 8px; border-radius: 999px; white-space: nowrap;
    font-size: 12px; font-weight: 700;
    background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.badge-primary { background: var(--primary-soft); color: var(--primary-hover); border-color: transparent; }
.badge-success { background: var(--success-soft); color: var(--success); border-color: var(--success-line); }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: var(--warning-line); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger);  border-color: var(--danger-line); }

/* Alertes */
.alert { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border: 1px solid; border-radius: 10px; font-size: 14px; }
.alert svg { flex: none; margin-top: 2px; }
.alert-info    { background: var(--primary-soft); border-color: #C6D8F8; color: var(--primary-hover); }
.alert-success { background: var(--success-soft); border-color: var(--success-line); color: var(--success); }
.alert-warning { background: var(--warning-soft); border-color: var(--warning-line); color: var(--warning); }
.alert-danger  { background: var(--danger-soft);  border-color: var(--danger-line);  color: var(--danger); }
.alert a { color: inherit; text-decoration: underline; font-weight: 600; }

.empty-state { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty-state h3 { margin-bottom: 4px; }

/* 5. Accueil : cartes de modules ------------------------------------------ */
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.module-card { overflow: hidden; }
.module-card-head { display: flex; align-items: center; gap: 10px; padding: 16px 16px 10px; }
.module-card-head h2 { flex: 1; font-size: 14px; font-weight: 700; }
.icon-tile {
    width: 30px; height: 30px; flex: none; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    background: var(--primary-soft); color: var(--primary);
}
.count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.module-links { display: flex; flex-direction: column; padding: 0 8px 8px; }
.module-link {
    display: flex; align-items: center; gap: 8px;
    min-height: 40px; padding: 0 10px; border-radius: 8px;
    color: #1A2A44;
}
.module-link:hover { background: var(--surface-2); color: var(--primary); }
.module-link .label-text { flex: 1; }
.module-link .chev { color: var(--faint); display: flex; }
.module-empty { margin: 2px 10px 8px; font-size: 13px; color: var(--muted); }
.module-foot { border-top: 1px solid var(--border-soft); background: var(--surface-2); }
.module-foot summary {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 18px; font-size: 12px; color: var(--muted);
    cursor: pointer; list-style: none;
}
.module-foot summary::-webkit-details-marker { display: none; }
.module-foot summary::after { content: 'Voir'; margin-left: auto; font-weight: 700; color: var(--primary); }
.module-foot[open] summary::after { content: 'Masquer'; }
.dot { width: 6px; height: 6px; flex: none; border-radius: 50%; background: var(--faint); }
.module-foot ul { list-style: none; margin: 0; padding: 0 18px 12px; display: flex; flex-direction: column; gap: 6px; }
.module-foot li { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--muted); }
.module-foot li code { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }

/* 6. Connexion ------------------------------------------------------------- */
.login { min-height: 100vh; display: flex; flex-wrap: wrap; background: #FFFFFF; }
.login-aside {
    flex: 1 1 420px; padding: 48px;
    display: flex; flex-direction: column; justify-content: space-between; gap: 48px;
    background: var(--navy); color: #EAF1FC;
}
.login-aside img { height: 44px; width: auto; max-width: 240px; object-fit: contain; object-position: left; }
.login-pitch { max-width: 440px; display: flex; flex-direction: column; gap: 14px; }
.login-pitch h2 { font-size: 34px; line-height: 1.15; font-weight: 700; letter-spacing: -.02em; color: #FFFFFF; }
.login-pitch p { font-size: 15px; line-height: 1.55; color: #BFD2F2; }
.login-legal { font-size: 12px; color: #A9C0E8; }
.login-main { flex: 1 1 420px; padding: 48px; display: flex; align-items: center; justify-content: center; }
.login-form { width: 380px; max-width: 100%; display: flex; flex-direction: column; gap: 20px; }
.login-form h1 { font-size: 26px; }
.login-form .field input { height: 44px; font-size: 15px; }
.login-form .btn { height: 44px; font-size: 15px; }

/* 7. Responsive / impression ---------------------------------------------- */
@media (max-width: 960px) {
    .sidebar {
        position: fixed; left: 0; top: 0; z-index: 50;
        transform: translateX(-100%); transition: transform .2s ease;
    }
    body.sidebar-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
    .sidebar-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(11, 26, 51, .45); }
    body.sidebar-open .sidebar-backdrop { display: block; }
    .topbar { flex-wrap: wrap; padding: 10px 16px; }
    .topbar .topbar-menu { display: inline-flex; }
    .topbar-date { display: none; }
    .search { order: 3; width: 100%; margin-left: 0; }
    .content { padding: 20px 16px; }
}
@media (max-width: 640px) {
    h1, .page-header h1 { font-size: 22px; }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .stat { padding: 14px 16px; }
    .stat-value { font-size: 22px; }
    .field.span-2 { grid-column: auto; }
    .search kbd { display: none; }
    .toolbar .input, .toolbar .select { width: 100%; }
    .login-aside { padding: 32px 24px; gap: 28px; }
    .login-pitch h2 { font-size: 26px; }
    .login-legal { display: none; }
    .login-main { padding: 32px 24px; }
}
@media print {
    .sidebar, .sidebar-backdrop, .topbar { display: none !important; }
    body { background: #FFFFFF; }
    .content { padding: 0; max-width: none; }
    .card, .table-wrap { box-shadow: none; }
}
