:root {
  --primary: #4F46E5;
  --primary-light: #EEF2FF;
  --primary-dark: #3730A3;
  --success: #10B981;
  --success-light: #ECFDF5;
  --warning: #F59E0B;
  --warning-light: #FFFBEB;
  --danger: #EF4444;
  --danger-light: #FEF2F2;
  --maybe: #8B5CF6;
  --maybe-light: #F5F3FF;
  --bg: #F1F5F9;
  --card: #FFFFFF;
  --text: #0F172A;
  --text2: #64748B;
  --text3: #94A3B8;
  --border: #E2E8F0;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: var(--card); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; z-index: 100; }
.main { margin-left: 240px; flex: 1; display: flex; flex-direction: column; }
.topbar { background: var(--card); border-bottom: 1px solid var(--border); padding: 0 1.5rem; height: 56px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 50; }
.content { padding: 1.5rem; flex: 1; }

/* Sidebar */
.sidebar-logo { padding: 1.25rem 1.25rem .75rem; border-bottom: 1px solid var(--border); }
.sidebar-logo h1 { font-size: 16px; font-weight: 700; color: var(--primary); display: flex; align-items: center; gap: 8px; }
.sidebar-logo span { font-size: 11px; color: var(--text2); }
.sidebar-nav { flex: 1; padding: .75rem 0; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 1.25rem; color: var(--text2); text-decoration: none; font-size: 13.5px; font-weight: 500; transition: all .15s; border-radius: 0; }
.nav-item:hover { background: var(--primary-light); color: var(--primary); }
.nav-item.active { background: var(--primary-light); color: var(--primary); border-right: 3px solid var(--primary); }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-section { font-size: 10px; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: .08em; padding: .75rem 1.25rem .25rem; }
.sidebar-footer { padding: .75rem 1.25rem; border-top: 1px solid var(--border); }
.user-card { display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text2); }

/* Cards */
.card { background: var(--card); border-radius: var(--radius-lg); border: 1px solid var(--border); box-shadow: var(--shadow); }
.card-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-title { font-size: 15px; font-weight: 600; }
.card-body { padding: 1.25rem; }

/* KPIs */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.kpi { background: var(--card); border-radius: var(--radius-lg); border: 1px solid var(--border); padding: 1.25rem; box-shadow: var(--shadow); }
.kpi-icon { width: 42px; height: 42px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; margin-bottom: .75rem; }
.kpi-icon svg { width: 22px; height: 22px; }
.kpi-val { font-size: 28px; font-weight: 700; line-height: 1; margin-bottom: 3px; }
.kpi-label { font-size: 12px; color: var(--text2); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius); font-size: 13.5px; font-weight: 600; border: none; cursor: pointer; transition: all .15s; text-decoration: none; white-space: nowrap; font-family: inherit; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #DC2626; }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-icon { padding: 7px; border-radius: 8px; background: transparent; border: 1px solid var(--border); color: var(--text2); cursor: pointer; display: inline-flex; }
.btn-icon:hover { background: var(--bg); color: var(--text); }
.btn svg { width: 16px; height: 16px; }

/* Badges présence */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.badge-present { background: var(--success-light); color: var(--success); }
.badge-absent { background: var(--danger-light); color: var(--danger); }
.badge-maybe { background: var(--maybe-light); color: var(--maybe); }
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-admin { background: #FEF3C7; color: #92400E; }
.badge-coach { background: var(--primary-light); color: var(--primary); }
.badge-athlete { background: #F0FDF4; color: #166534; }

/* Tableau */
.tbl-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--card); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { background: var(--bg); padding: 10px 14px; text-align: left; font-size: 11px; font-weight: 700; color: var(--text2); text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #FAFBFD; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text2); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .04em; }
.form-control { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; color: var(--text); background: var(--card); font-family: inherit; transition: border-color .15s; }
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-full { grid-column: 1 / -1; }

/* Modal */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 200; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal { background: var(--card); border-radius: var(--radius-lg); width: 540px; max-width: 96vw; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 16px; font-weight: 700; }
.modal-body { padding: 1.5rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* Présence buttons */
.presence-btn { display: inline-flex; align-items: center; gap: 5px; padding: 6px 14px; border-radius: 99px; font-size: 12px; font-weight: 600; border: 2px solid transparent; cursor: pointer; transition: all .15s; background: transparent; }
.presence-btn.present { border-color: var(--success); color: var(--success); }
.presence-btn.present.active, .presence-btn.present:hover { background: var(--success); color: #fff; }
.presence-btn.absent { border-color: var(--danger); color: var(--danger); }
.presence-btn.absent.active, .presence-btn.absent:hover { background: var(--danger); color: #fff; }
.presence-btn.maybe { border-color: var(--maybe); color: var(--maybe); }
.presence-btn.maybe.active, .presence-btn.maybe:hover { background: var(--maybe); color: #fff; }

/* Stats bar */
.stat-bar { height: 8px; border-radius: 99px; background: var(--border); overflow: hidden; }
.stat-bar-fill { height: 100%; border-radius: 99px; background: var(--success); transition: width .3s; }

/* Page header */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.page-title { font-size: 22px; font-weight: 700; }
.page-subtitle { font-size: 13px; color: var(--text2); margin-top: 2px; }

/* Auth */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%); padding: 1rem; }
.auth-card { background: var(--card); border-radius: 20px; padding: 2.5rem; width: 420px; max-width: 100%; box-shadow: 0 25px 60px rgba(0,0,0,.2); }
.auth-logo { text-align: center; margin-bottom: 2rem; }
.auth-logo h1 { font-size: 22px; font-weight: 800; color: var(--primary); }
.auth-logo p { font-size: 13px; color: var(--text2); margin-top: 4px; }
.auth-title { font-size: 20px; font-weight: 700; margin-bottom: 1.5rem; }
.auth-link { color: var(--primary); text-decoration: none; font-weight: 600; }
.auth-link:hover { text-decoration: underline; }

/* Alert */
.alert { padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 1rem; }
.alert-error { background: var(--danger-light); color: var(--danger); border: 1px solid #FCA5A5; }
.alert-success { background: var(--success-light); color: var(--success); border: 1px solid #6EE7B7; }

/* Calendrier */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-day-hdr { text-align: center; font-size: 11px; font-weight: 700; color: var(--text2); padding: 6px 0; }
.cal-day { min-height: 80px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px; font-size: 11px; }
.cal-day.other-month { background: var(--bg); opacity: .5; }
.cal-day.today { border-color: var(--primary); border-width: 2px; }
.cal-day-num { font-weight: 600; font-size: 12px; margin-bottom: 4px; }
.cal-event { padding: 2px 6px; border-radius: 4px; font-size: 10px; font-weight: 600; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }

/* Topbar user */
.topbar-left { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.topbar-title { font-size: 15px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

/* Hamburger button — masqué par défaut sur desktop */
.menu-btn { display: none; align-items: center; justify-content: center; width: 36px; height: 36px; border: none; background: transparent; cursor: pointer; color: var(--text); border-radius: var(--radius); flex-shrink: 0; }
.menu-btn:hover { background: var(--bg); }
.menu-btn svg { width: 20px; height: 20px; }

/* Sidebar overlay (mobile) */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 250; }
.sidebar-overlay.open { display: block; }

/* Transition sidebar */
.sidebar { transition: transform .25s ease; }

/* Séances */
.seances-filtre-groupe { width: 180px; }
.vue-toggle { display: flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; flex-shrink: 0; }
.vue-toggle a { padding: 7px 14px; font-size: 13px; font-weight: 600; text-decoration: none; display: flex; align-items: center; gap: 5px; }
.cal-jour-mini { display: none; }

/* Bottom navigation (masquée sur desktop) */
.bottom-nav { display: none; }

/* Bilan stats : cartes masquées sur desktop, table visible */
.bilan-cards { display: none; }
.bilan-table-wrap { display: block; }

/* Bilan card */
.bilan-card { display: flex; align-items: center; gap: .75rem; padding: .875rem 1.25rem; border-bottom: 1px solid var(--border); }
.bilan-card:last-child { border-bottom: none; }
.bilan-card-rank { width: 22px; text-align: center; font-size: 11px; font-weight: 700; color: var(--text3); flex-shrink: 0; }
.bilan-card-body { flex: 1; min-width: 0; }
.bilan-card-name { font-weight: 600; font-size: 13px; }
.bilan-card-sub { display: flex; gap: .75rem; margin-top: .2rem; font-size: 12px; flex-wrap: wrap; }
.bilan-card-taux { text-align: center; flex-shrink: 0; min-width: 52px; }

/* Stats grilles */
.stats-kpi-grid    { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.stats-filter-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; align-items: end; }

/* Grid utilitaires */
.grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.grid-1-2  { display: grid; grid-template-columns: 1fr 2fr; gap: 1.25rem; }
.grid-3col { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.membres-grid  { display: grid; gap: 1.25rem; align-items: start; }
.saisons-outer { display: grid; gap: 1.25rem; align-items: start; }
.groupes-outer  { display: grid; gap: 1.25rem; }
.groupes-detail { grid-column: 2; }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--border); margin-bottom: 1.5rem; }
.tab { padding: 9px 18px; font-size: 13.5px; font-weight: 600; color: var(--text2); border: none; background: none; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: color .15s; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab:hover { color: var(--text); }

/* Responsive */
@media (max-width: 768px) {
  /* Sidebar drawer */
  .sidebar { transform: translateX(-100%); z-index: 300; }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,.15); }
  .main { margin-left: 0; }

  /* Topbar */
  .topbar { padding: 0 .875rem; }
  .menu-btn { display: flex; }

  /* Content padding — espace pour la bottom nav */
  .content { padding: 1rem 1rem 74px; }

  /* Correction zoom iOS sur les inputs */
  .form-control { font-size: 16px; }

  /* Touch targets minimum 44px */
  .btn-sm { min-height: 36px; }
  .presence-btn { min-height: 38px; min-width: 38px; }
  .btn-icon { min-height: 36px; min-width: 36px; }

  /* Bottom navigation */
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 58px;
    background: var(--card);
    border-top: 1px solid var(--border);
    z-index: 200;
    box-shadow: 0 -1px 8px rgba(0,0,0,.07);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--text2);
    text-decoration: none;
    font-size: 10px;
    font-weight: 600;
    border: none;
    background: none;
    cursor: pointer;
    padding: 8px 0;
    font-family: inherit;
    transition: color .15s;
  }
  .bottom-nav-item svg { width: 22px; height: 22px; }
  .bottom-nav-item.active { color: var(--primary); }
  .bottom-nav-item:active { opacity: .7; }

  /* Toolbar séances : colonne unique, chaque item pleine largeur */
  .seances-toolbar { flex-direction: column; align-items: stretch; gap: .5rem; }
  .vue-toggle a { flex: 1; justify-content: center; }
  .seances-filtre-groupe { width: 100% !important; }

  /* Table séances → cartes sur mobile */
  .seances-table { min-width: auto !important; }
  .seances-table thead { display: none; }
  .seances-table tr {
    display: flex; flex-wrap: wrap;
    padding: .875rem 1rem; gap: .3rem .75rem;
    align-items: flex-start;
    border-bottom: 1px solid var(--border);
  }
  .seances-table tr:last-child { border-bottom: none; }
  .seances-table td { display: block; padding: 0; border: none; }
  .seance-td-date   { flex: 0 0 auto; }
  .seance-td-titre  { flex: 1; min-width: 0; }
  .seance-td-groupe { margin-left: auto; align-self: center; }
  .seance-td-presences  { flex: 0 0 100%; border-top: 1px solid var(--border); padding-top: .5rem; margin-top: .2rem; }
  .seance-td-mypresence { flex: 0 0 100%; padding-top: .35rem; }
  .seance-td-actions    { flex: 0 0 100%; padding-top: .35rem; display: flex; gap: .35rem; }

  /* Calendrier : jours abrégés en 1 lettre sur mobile */
  .cal-jour-abbr { display: none; }
  .cal-jour-mini { display: inline; }

  /* Stats : grilles responsives */
  .stats-kpi-grid    { grid-template-columns: repeat(3, 1fr); gap: .75rem; margin-bottom: 1rem; }
  .stats-filter-grid { grid-template-columns: 1fr 1fr; }

  /* Sort bar : colonne + boutons en scroll horizontal */
  .stats-sort-bar { flex-direction: column !important; align-items: stretch !important; gap: .5rem !important; }
  .stats-sort-bar .form-control { max-width: 100% !important; }
  .stats-sort-bar .flex.gap-2 { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }

  /* Bilan : table masquée, cartes affichées */
  .bilan-table-wrap { display: none; }
  .bilan-cards { display: block; }

  /* Par séance → masquer colonnes secondaires */
  #tbl-seances th:nth-child(4), #tbl-seances td:nth-child(4),
  #tbl-seances th:nth-child(5), #tbl-seances td:nth-child(5),
  #tbl-seances th:nth-child(7), #tbl-seances td:nth-child(7),
  #tbl-seances th:nth-child(8), #tbl-seances td:nth-child(8),
  #tbl-seances th:nth-child(9), #tbl-seances td:nth-child(9),
  #tbl-seances th:nth-child(10), #tbl-seances td:nth-child(10) { display: none; }

  /* KPI 2 colonnes */
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: .75rem; margin-bottom: 1rem; }
  .kpi { padding: 1rem; }
  .kpi-val { font-size: 22px; }

  /* Forms */
  .form-grid { grid-template-columns: 1fr; }

  /* Page header empilé */
  .page-header { flex-direction: column; align-items: flex-start; gap: .75rem; }

  /* Tabs défilables */
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 1px; }
  .tab { white-space: nowrap; padding: 9px 14px; }

  /* Tables — scroll horizontal déjà géré par .tbl-wrap */
  .tbl-wrap { -webkit-overflow-scrolling: touch; }
  table { min-width: 500px; }

  /* Calendrier */
  .cal-day { min-height: 52px; padding: 4px; }
  .cal-event { font-size: 9px; }

  /* Modal plein écran bas */
  .modal { width: 100%; max-width: 100%; border-radius: var(--radius-lg) var(--radius-lg) 0 0; position: fixed; bottom: 0; left: 0; right: 0; margin: 0; max-height: 90vh; }
  .modal-overlay { align-items: flex-end; }

  /* Boutons groupés */
  .flex.gap-2, .flex.gap-3 { flex-wrap: wrap; }

  /* Filtre séances pleine largeur */
  .seances-filtre-groupe { width: 100%; }

  /* Grilles → 1 colonne */
  .grid-2col, .grid-1-2, .grid-3col { grid-template-columns: 1fr; }
  .membres-grid, .saisons-outer { grid-template-columns: 1fr !important; }
  .saisons-inner { grid-template-columns: 1fr !important; }
  .groupes-outer  { grid-template-columns: 1fr !important; }
  .groupes-inner  { grid-template-columns: 1fr !important; }
  .groupes-detail { grid-column: 1; }

  /* Cellules calendrier compactes */
  .cal-cell { min-height: 52px !important; }

  /* Table membres : masquer colonnes secondaires (Rôle, Email, Saison, Groupes, Taux) */
  .membres-table th:nth-child(2), .membres-table td:nth-child(2),
  .membres-table th:nth-child(3), .membres-table td:nth-child(3),
  .membres-table th:nth-child(4), .membres-table td:nth-child(4),
  .membres-table th:nth-child(5), .membres-table td:nth-child(5),
  .membres-table th:nth-child(6), .membres-table td:nth-child(6) { display: none; }

  /* Filtres membres : champs pleine largeur quand ils wrappent */
  .membres-filters .form-control { width: 100% !important; max-width: 100% !important; }

  /* Panneau détail membre remonté avant le tableau sur mobile */
  .membres-detail { order: -1; }
}

/* Tablette : grille 3 col → 2 col */
@media (min-width: 480px) and (max-width: 768px) {
  .grid-3col { grid-template-columns: repeat(2, 1fr); }
}

/* Misc */
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-2 { gap: .5rem; } .gap-3 { gap: .75rem; } .gap-4 { gap: 1rem; }
.mt-1 { margin-top: .25rem; } .mt-2 { margin-top: .5rem; } .mt-4 { margin-top: 1rem; }
.text-sm { font-size: 12px; } .text-muted { color: var(--text2); } .font-bold { font-weight: 700; }
.empty-state { text-align: center; padding: 3rem; color: var(--text2); }
.empty-state svg { width: 48px; height: 48px; margin: 0 auto 1rem; opacity: .3; }
