/* ══════════════════════════════════════════════════════
   VARIABLES — Light & Dark
══════════════════════════════════════════════════════ */
:root {
    --navy:          #123865;
    --navy-dark:     #0D2847;
    --navy-light:    #1E4F8C;
    --green:         #69CA45;
    --green-dark:    #4FA832;
    --bg:            #F0F3F8;
    --bg-card:       #FFFFFF;
    --bg-input:      #FFFFFF;
    --text:          #1A2B3C;
    --text-muted:    #5A7090;
    --border:        #D0DAE8;
    --border-light:  #E8EBF0;
    --shadow:        0 2px 8px rgba(18,56,101,.12);
    --shadow-lg:     0 4px 20px rgba(18,56,101,.16);
    --row-hover:     #F4F7FC;
    --table-border:  #F0F0F0;
    --radius:        8px;
    --nav-h:         56px;
    --bottom-h:      0px;
    --danger:        #e74c3c;
    --danger-dark:   #c0392b;
    /* ── Alias de compatibilité (variables historiques dans les templates) ── */
    --gray-light:    #e8edf5;
    --gold:          #f0c040;
    --gold-dark:     #c9952a;
    --muted:         var(--text-muted);
    --row-sep:       var(--table-border);
}
[data-theme="dark"] {
    --bg:            #0F172A;
    --bg-card:       #1E293B;
    --bg-input:      #273548;
    --text:          #E2E8F0;
    --text-muted:    #94A3B8;
    --border:        #334155;
    --border-light:  #2D3F55;
    --shadow:        0 2px 8px rgba(0,0,0,.35);
    --shadow-lg:     0 4px 20px rgba(0,0,0,.5);
    --row-hover:     #243552;
    --table-border:  #2D3F55;
    --gray-light:    #243552;
    --gold:          #d4a82a;
    --gold-dark:     #b8891e;
}

/* ══════════════════════════════════════════════════════
   RESET & BASE
══════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    padding-top: var(--nav-h);
    transition: background .25s, color .25s;
}

/* ══════════════════════════════════════════════════════
   NAVBAR
══════════════════════════════════════════════════════ */
.navbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--nav-h);
    background: var(--navy-dark);
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    padding: 0 12px;
    z-index: 1000;
    box-shadow: 0 2px 12px rgba(0,0,0,.3);
    gap: 8px;
}
.nav-logo {
    display: flex; align-items: center; gap: 8px;
    text-decoration: none; flex-shrink: 0;
}
.nav-logo img { height: 34px; width: auto; filter: brightness(0) invert(1); }
.nav-logo-text { color: #fff; font-size: 13px; font-weight: 700; line-height: 1.2; white-space: nowrap; }
.nav-logo-text span { display: block; color: var(--green); font-size: 10px; font-weight: 400; letter-spacing: .4px; }
.nav-center {
    display: flex; align-items: center; justify-content: center;
    gap: 2px; overflow: hidden; min-width: 0;
}
.nav-link {
    display: flex; align-items: center; gap: 5px;
    padding: 6px 10px; border-radius: 6px; font-size: 12.5px;
    color: rgba(255,255,255,.72); text-decoration: none;
    transition: background .15s, color .15s; white-space: nowrap; flex-shrink: 0;
}
.nav-link:hover  { background: rgba(255,255,255,.1);  color: #fff; }
.nav-link.active { background: rgba(105,202,69,.18); color: var(--green); }
.nav-sep { width: 1px; height: 18px; background: rgba(255,255,255,.15); margin: 0 2px; flex-shrink: 0; }
.nav-right { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }

.btn-theme {
    background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18);
    color: rgba(255,255,255,.85); border-radius: 20px; padding: 5px 9px;
    font-size: 14px; cursor: pointer; display: flex; align-items: center; gap: 4px;
    transition: background .15s; line-height: 1; flex-shrink: 0;
}
.btn-theme:hover { background: rgba(255,255,255,.2); }
.theme-icon-sun  { display: none; }
.theme-icon-moon { display: inline; }
[data-theme="dark"] .theme-icon-sun  { display: inline; }
[data-theme="dark"] .theme-icon-moon { display: none; }

.nav-profile-btn {
    display: flex; align-items: center; gap: 6px;
    text-decoration: none; color: rgba(255,255,255,.85);
    padding: 4px 8px; border-radius: 6px; transition: background .15s;
}
.nav-profile-btn:hover { background: rgba(255,255,255,.1); }
.nav-avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--navy-light); border: 2px solid rgba(105,202,69,.5);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 12px; color: #fff; flex-shrink: 0;
}
.nav-username { color: rgba(255,255,255,.85); font-size: 12.5px; white-space: nowrap; }
.nav-btn-logout {
    padding: 5px 10px; background: transparent;
    border: 1px solid rgba(255,255,255,.22); border-radius: 5px;
    color: rgba(255,255,255,.65); font-size: 12px; cursor: pointer;
    text-decoration: none; transition: background-color .15s, color .15s, border-color .15s; white-space: nowrap; font-family: inherit;
}
.nav-btn-logout:hover { background: rgba(255,255,255,.1); color: #fff; border-color: rgba(255,255,255,.45); }

/* Hamburger */
.nav-hamburger {
    display: none; flex-direction: column; justify-content: center;
    align-items: center; gap: 5px; width: 36px; height: 36px;
    border: none; background: rgba(255,255,255,.1); border-radius: 8px;
    cursor: pointer; flex-shrink: 0; padding: 0; -webkit-tap-highlight-color: transparent;
}
.nav-hamburger span {
    display: block; width: 18px; height: 2px;
    background: rgba(255,255,255,.85); border-radius: 2px;
    transition: transform .22s, opacity .22s;
}
.nav-hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-hamburger.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav-hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Drawer mobile */
.nav-drawer {
    display: none; position: fixed;
    top: var(--nav-h); left: 0; right: 0;
    background: #0D2847; z-index: 999;
    padding: 8px 10px 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,.45);
    border-top: 1px solid rgba(255,255,255,.07);
    max-height: calc(100dvh - var(--nav-h));
    overflow-y: auto; -webkit-overflow-scrolling: touch;
    animation: drawerIn .2s ease;
}
@keyframes drawerIn { from { opacity: 0; transform: translateY(-8px); } }
.nav-drawer.open { display: block; }
.nav-drawer .nav-link {
    display: flex; padding: 11px 12px; border-radius: 8px;
    font-size: 14px; color: rgba(255,255,255,.78); margin-bottom: 1px;
    text-decoration: none; transition: background .15s;
}
.nav-drawer .nav-link:hover  { background: rgba(255,255,255,.07); color: #fff; }
.nav-drawer .nav-link.active { background: rgba(105,202,69,.15); color: var(--green); }
.nav-drawer .nav-sep { width: 100%; height: 1px; margin: 6px 0; background: rgba(255,255,255,.09); }
.nav-drawer-section {
    font-size: 10px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .8px; color: rgba(255,255,255,.35); padding: 10px 12px 4px;
}
.nav-drawer-user {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px 12px; border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 4px;
}
.nav-drawer-user .nav-avatar  { width: 36px; height: 36px; font-size: 13px; }
.nav-drawer-user-info { flex: 1; }
.nav-drawer-user-name { color: #fff; font-size: 14px; font-weight: 600; }
.nav-drawer-user-role { color: var(--green); font-size: 11px; margin-top: 2px; }
.nav-drawer-logout {
    width: 100%; text-align: left; border: none; background: transparent;
    cursor: pointer; color: rgba(255,255,255,.65); font-size: 14px;
    padding: 11px 12px; border-radius: 8px; font-family: inherit;
    transition: background .15s, color .15s;
    display: flex; align-items: center; gap: 8px;
}
.nav-drawer-logout:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.5); z-index: 998;
    backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}
.nav-overlay.open { display: block; }

/* ══════════════════════════════════════════════════════
   PAGE WRAPPER
══════════════════════════════════════════════════════ */
.page-wrap {
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
    padding: 20px 20px 0;
    min-height: calc(100vh - var(--nav-h));
}
.page-content { }

/* ══════════════════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════════════════ */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border: none; border-radius: var(--radius);
    font-size: 13px; cursor: pointer; text-decoration: none;
    transition: filter .15s; font-family: inherit; line-height: 1;
}
.btn:hover  { filter: brightness(.9); }
.btn:active { filter: brightness(.8); transform: scale(.98); }
.btn-navy    { background: var(--navy);  color: #fff; }
.btn-green   { background: var(--green); color: var(--navy-dark); font-weight: 700; }
.btn-outline {
    background: transparent; border: 1.5px solid var(--border); color: var(--text);
}
.btn-outline:hover { border-color: var(--navy); color: var(--navy); filter: none; }
[data-theme="dark"] .btn-outline:hover { border-color: var(--green); color: var(--green); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm     { padding: 5px 10px; font-size: 12px; }
.btn-icon   { padding: 6px; border-radius: 6px; }
/* Bouton fantôme — pour boutons posés sur fond navy (headers, barres colorées) */
.btn-ghost  { background: rgba(255,255,255,.15); color: rgba(255,255,255,.9); border: 1px solid rgba(255,255,255,.3); }
.btn-ghost:hover { filter: none; background: rgba(255,255,255,.25); }

/* ══════════════════════════════════════════════════════
   CARDS
══════════════════════════════════════════════════════ */
.card {
    background: var(--bg-card); border-radius: var(--radius);
    box-shadow: var(--shadow); border: 1px solid var(--border-light);
    transition: background .25s, border-color .25s;
}

/* ══════════════════════════════════════════════════════
   INPUTS
══════════════════════════════════════════════════════ */
.controls { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
input[type="text"], input[type="search"], input[type="email"],
input[type="number"], input[type="password"], input[type="date"],
select, textarea {
    padding: 7px 10px; border: 1.5px solid var(--border);
    border-radius: var(--radius); font-size: 13px;
    background: var(--bg-input); color: var(--text);
    font-family: inherit; transition: border-color .15s, background .25s, color .25s;
    width: 100%;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--navy);
    box-shadow: 0 0 0 3px rgba(18,56,101,.1);
}
[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus {
    border-color: var(--green); box-shadow: 0 0 0 3px rgba(105,202,69,.12);
}
input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: .7; }
select option { background: var(--bg-card); color: var(--text); }
label {
    display: block; font-size: 12px; font-weight: 600;
    color: var(--text-muted); margin-bottom: 5px;
}

/* ══════════════════════════════════════════════════════
   CHAMP DE RECHERCHE AVEC ICÔNE
══════════════════════════════════════════════════════ */
.search-input-wrap,
.search-input-row {
    position: relative;
}
.search-icon,
.search-icon-s {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 15px;
    pointer-events: none;
    color: var(--text-muted);
    line-height: 1;
    z-index: 1;
}
/* Spécificité input.class (0,1,1) > input[type] (0,1,1) par ordre → place après */
input.search-inp,
input.search-inp-s {
    width: 100%;
    padding: 9px 36px 9px 36px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    background: var(--bg-input);
    color: var(--text);
    font-family: inherit;
    transition: border-color .15s, background .25s;
    box-sizing: border-box;
}
input.search-inp:focus,
input.search-inp-s:focus {
    outline: none;
    border-color: var(--navy);
    box-shadow: 0 0 0 3px rgba(18,56,101,.1);
}
[data-theme="dark"] input.search-inp:focus,
[data-theme="dark"] input.search-inp-s:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(105,202,69,.12);
}

/* ══════════════════════════════════════════════════════
   BADGES
══════════════════════════════════════════════════════ */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 700; color: #fff; }
.badge-ok        { background: #27ae60; }
.badge-auto      { background: #f39c12; color: #333; }
.badge-manual    { background: var(--navy-light); }
.badge-corrected { background: #e67e22; }
.badge-none      { background: #9ca3af; }

/* ══════════════════════════════════════════════════════
   TABLES
══════════════════════════════════════════════════════ */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; background: var(--bg-card); border-radius: var(--radius); overflow: hidden; transition: background .25s; }
.tbl-wrap table { border-radius: 0; box-shadow: none; }
thead th {
    background: var(--navy); color: #fff; padding: 10px 12px;
    font-size: 12.5px; text-align: left; white-space: nowrap;
}
td {
    padding: 8px 12px; font-size: 13px;
    border-bottom: 1px solid var(--table-border);
    vertical-align: middle; color: var(--text); transition: background .15s;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td     { background: var(--row-hover); }

/* ══════════════════════════════════════════════════════
   TOAST
══════════════════════════════════════════════════════ */
.toast {
    position: fixed; bottom: 20px; right: 16px;
    background: var(--navy-dark); color: #fff;
    padding: 10px 18px; border-radius: 8px; font-size: 13px;
    opacity: 0; transition: opacity .3s; z-index: 2000; pointer-events: none;
    max-width: calc(100vw - 32px); box-shadow: 0 4px 16px rgba(0,0,0,.3);
}
.toast.show    { opacity: 1; }
.toast.error,
.toast.err     { background: var(--danger-dark); }
.toast.ok,
.toast.success { background: var(--green-dark); }

/* ══════════════════════════════════════════════════════
   SPINNER
══════════════════════════════════════════════════════ */
.spinner {
    display: inline-block; width: 13px; height: 13px;
    border: 2px solid rgba(0,0,0,.1); border-top-color: var(--navy);
    border-radius: 50%; animation: spin .55s linear infinite; vertical-align: middle;
}
[data-theme="dark"] .spinner { border-color: rgba(255,255,255,.12); border-top-color: var(--green); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════════════════
   ROLE PILLS
══════════════════════════════════════════════════════ */
.role-pill { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 11px; font-weight: 700; }
.role-superadmin   { background: #2c3e50; color: #ecf0f1; }
.role-admin_compet { background: var(--navy); color: #fff; }
.role-pdj          { background: #8e44ad; color: #fff; }
.role-arbitre      { background: #27ae60; color: #fff; }

/* ══════════════════════════════════════════════════════
   TWEMOJI — rendu emoji cohérent cross-OS
══════════════════════════════════════════════════════ */
img.emoji {
    height: 1.1em; width: 1.1em;
    margin: 0 .05em 0 .1em;
    vertical-align: -0.15em;
    display: inline-block;
}

/* ══════════════════════════════════════════════════════
   UTILITAIRES
══════════════════════════════════════════════════════ */
.text-muted { color: var(--text-muted) !important; }
.text-navy  { color: var(--navy); }
.text-green { color: var(--green); }
.extra-badge { display: inline-block; background: var(--border-light); color: var(--text); font-size: 11px; padding: 2px 6px; border-radius: 8px; margin: 1px; }
.cat-badge { display: inline-block; background: var(--border-light); color: var(--navy); font-size: 11px; padding: 2px 7px; border-radius: 8px; }
[data-theme="dark"] .cat-badge { background: rgba(30,79,140,.3); color: #93c5fd; }

/* ══════════════════════════════════════════════════════
   BARRES CATÉGORIES / CHIPS — scrollables sur mobile
   Règle : .cat-bar (wrapper) > .cat-scroll/.cat-filters/.cat-chips-row (inline-flex)
   Le wrapper scrolle ; l'enfant inline-flex se dimensionne sur son contenu.
══════════════════════════════════════════════════════ */
.cat-bar {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin-bottom: 14px;
}
.cat-bar::-webkit-scrollbar { display: none; }

/* inline-flex = se dimensionne sur le contenu → peut déborder → .cat-bar scrolle */
.cat-scroll,
.cat-filters,
.cat-chips-row {
    display: inline-flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    min-width: 100%;
    vertical-align: top;
}

.cat-btn,
.cat-chip,
.cat-chip-s {
    flex-shrink: 0;
    white-space: nowrap;
}

/* ══════════════════════════════════════════════════════
   BOTTOM NAV — Mobile
══════════════════════════════════════════════════════ */
.bottom-nav {
    display: none;
    position: fixed; bottom: 0; left: 0; right: 0;
    height: 60px;
    background: var(--navy-dark);
    border-top: 1px solid rgba(255,255,255,.08);
    z-index: 990; padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 12px rgba(0,0,0,.25);
}
.bottom-nav-inner { display: flex; align-items: stretch; height: 60px; }
.bn-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; text-decoration: none; color: rgba(255,255,255,.5);
    font-size: 10px; font-weight: 600; letter-spacing: .2px;
    transition: color .15s, background .15s; -webkit-tap-highlight-color: transparent;
    border: none; background: transparent; cursor: pointer; font-family: inherit;
    padding: 0 2px; position: relative;
}
.bn-item:active { background: rgba(255,255,255,.06); }
.bn-item.active  { color: var(--green); }
.bn-item.active .bn-icon { transform: scale(1.1); }
.bn-icon { font-size: 20px; line-height: 1; display: block; transition: transform .15s; }
.bn-label { line-height: 1; }
.bn-item.active::after {
    content: ''; position: absolute; top: 0; left: 15%; right: 15%;
    height: 2px; background: var(--green); border-radius: 0 0 3px 3px;
}
.bn-item.bn-more { color: rgba(255,255,255,.4); }
.bn-item.bn-more.open { color: rgba(255,255,255,.85); }

/* ══════════════════════════════════════════════════════
   RESPONSIVE — Mobile
══════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    :root {
        --nav-h:    52px;
        --bottom-h: 60px;
    }
    body { padding-bottom: var(--bottom-h); }

    .navbar            { justify-content: space-between; }
    .nav-center        { display: none !important; }
    .nav-hamburger     { display: flex; }
    .nav-username      { display: none; }
    .nav-btn-logout    { display: none; }
    .nav-logo-text span { display: none; }
    .nav-profile-btn   { display: none; }

    .page-wrap { padding: 12px 10px calc(var(--bottom-h) + 12px); }

    table { min-width: 480px; }
    .tbl-wrap, .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

    .controls { gap: 6px; }
    .controls input, .controls select { font-size: 14px; }

    .save-bar { bottom: var(--bottom-h) !important; }
    .bottom-nav { display: block; }
    .site-footer { display: none; }
}
@media (max-width: 420px) {
    .nav-logo-text { display: none; }
}

/* ══════════════════════════════════════════════════════
   SITE FOOTER — Admin
══════════════════════════════════════════════════════ */
.site-footer {
    background: var(--navy-dark);
    border-top: 1px solid rgba(255,255,255,.07);
    padding: 24px 20px 16px;
    margin-top: 48px;
}
.site-footer-inner {
    max-width: 1400px; margin: 0 auto;
    display: flex; align-items: flex-start;
    justify-content: space-between; flex-wrap: wrap; gap: 20px;
}
.footer-brand {
    display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.footer-brand img {
    height: 26px; filter: brightness(0) invert(1); opacity: .7;
}
.footer-brand-text { line-height: 1.3; }
.footer-brand-name {
    color: rgba(255,255,255,.85); font-size: 13px; font-weight: 700;
    display: block;
}
.footer-brand-sub {
    color: var(--green); font-size: 10px; font-weight: 400;
    display: block; letter-spacing: .3px;
}
.footer-nav-cols {
    display: flex; gap: 32px; flex-wrap: wrap;
}
.footer-nav-col { display: flex; flex-direction: column; gap: 6px; }
.footer-nav-label {
    font-size: 10px; font-weight: 700; color: rgba(255,255,255,.35);
    text-transform: uppercase; letter-spacing: .6px; margin-bottom: 2px;
}
.footer-nav-link {
    color: rgba(255,255,255,.5); font-size: 12px; text-decoration: none;
    transition: color .15s; white-space: nowrap;
}
.footer-nav-link:hover { color: rgba(255,255,255,.9); }
.footer-divider {
    max-width: 1400px; margin: 14px auto 0;
    border: none; border-top: 1px solid rgba(255,255,255,.07);
}
.footer-bottom {
    max-width: 1400px; margin: 10px auto 0;
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 8px;
}
.footer-copy {
    font-size: 11px; color: rgba(255,255,255,.25);
}
.footer-rgpd {
    font-size: 10px; color: rgba(255,255,255,.2);
    line-height: 1.5; text-align: right; max-width: 480px;
}
.footer-rgpd a {
    color: rgba(255,255,255,.35); text-decoration: underline;
    text-decoration-color: rgba(255,255,255,.15); transition: color .15s;
}
.footer-rgpd a:hover { color: rgba(255,255,255,.6); }

@media (max-width: 768px) {
    .site-footer { padding-bottom: calc(var(--bottom-h) + 16px); }
    .site-footer-inner { flex-direction: column; gap: 16px; }
    .footer-nav-cols { gap: 20px; }
    .footer-rgpd { text-align: left; }
    .footer-bottom { flex-direction: column; align-items: flex-start; }
}
