/* Design System Shadcn UI Blanc & Monochrome Bleu - ÉcolePro Bénin */
:root {
  --bg-main: #F8FAFC;
  --bg-surface: #FFFFFF;
  --bg-subtle: #F1F5F9;
  --border-color: #E2E8F0;
  --border-focus: #3B82F6;

  /* Monochrome Bleu (Palette Shadcn Slate / Blue) */
  --blue-950: #0F172A;
  --blue-900: #1E3A8A;
  --blue-800: #1E40AF;
  --blue-700: #1D4ED8; /* Action primaire */
  --blue-600: #2563EB;
  --blue-500: #3B82F6;
  --blue-200: #BFDBFE;
  --blue-100: #DBEAFE;
  --blue-50:  #EFF6FF;

  /* Accents sémantiques discrets */
  --emerald-700: #047857;
  --emerald-600: #059669;
  --emerald-100: #D1FAE5;
  --red-700: #B91C1C;
  --red-600: #DC2626;
  --red-100: #FEE2E2;
  --amber-700: #B45309;
  --amber-600: #D97706;
  --amber-100: #FEF3C7;

  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-muted: #64748B;
  --text-light: #94A3B8;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.05);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Lucide Vector Icons (Shadcn style) */
.lucide-icon {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

.lucide-icon-sm {
  width: 15px;
  height: 15px;
  stroke-width: 2;
}

.lucide-icon-lg {
  width: 24px;
  height: 24px;
  stroke-width: 2;
}

/* ==========================================================================
   AUTH WALL (SAS DE CONNEXION EXCLUSIF)
   ========================================================================== */
#auth-wall {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: linear-gradient(135deg, #F8FAFC 0%, #EFF6FF 100%);
}

.auth-container {
  width: 100%;
  max-width: 480px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow-lg);
}

.auth-header {
  text-align: center;
  margin-bottom: 24px;
}

.auth-logo-badge {
  width: 48px;
  height: 48px;
  background: var(--blue-700);
  color: white;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  box-shadow: 0 4px 8px rgba(29, 78, 216, 0.25);
}

.auth-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--blue-950);
  letter-spacing: -0.02em;
}

.auth-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.quick-roles-card {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px dashed var(--border-color);
}

.quick-roles-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.quick-role-buttons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.quick-role-btn {
  border: 1px solid var(--border-color);
  background: var(--bg-main);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-primary);
  transition: all 0.15s;
}

.quick-role-btn:hover {
  background: var(--blue-50);
  border-color: var(--blue-200);
  color: var(--blue-700);
}

/* ==========================================================================
   APP HEADER TOPBAR
   ========================================================================== */
.app-header {
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 60;
  box-shadow: var(--shadow-sm);
}

.topbar-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 38px;
  height: 38px;
  background: var(--blue-700);
  color: white;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-name {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--blue-950);
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Cycle Switcher Component */
.cycle-switcher {
  display: flex;
  align-items: center;
  background: var(--blue-50);
  border: 1px solid var(--blue-200);
  border-radius: var(--radius-md);
  padding: 2px;
  gap: 2px;
}

.cycle-btn {
  border: none;
  background: transparent;
  padding: 5px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.cycle-btn.active {
  background: var(--bg-surface);
  color: var(--blue-700);
  box-shadow: var(--shadow-sm);
}

/* Badges & Profile Header */
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
}

.badge-online {
  background: var(--emerald-100);
  color: var(--emerald-700);
  border: 1px solid #A7F3D0;
}

.badge-offline {
  background: var(--red-100);
  color: var(--red-700);
  border: 1px solid #FECACA;
}

.badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.role-badge {
  background: var(--blue-50);
  color: var(--blue-700);
  border: 1px solid var(--blue-200);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* Update Banner */
.update-banner {
  background: var(--amber-100);
  border-bottom: 1px solid #FDE68A;
  color: var(--amber-700);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 500;
}
.update-banner.hidden { display: none; }

/* ==========================================================================
   APP LAYOUT (SIDEBAR + CONTENT)
   ========================================================================== */
.app-layout {
  display: flex;
  flex: 1;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

.sidebar {
  position: fixed;
  top: 60px;
  bottom: 0;
  left: 0;
  z-index: 55;
  width: 260px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex-shrink: 0;
  overflow-y: auto;
  transform: translateX(-105%);
  transition: transform 180ms ease-out;
  box-shadow: var(--shadow-lg);
}
.sidebar.open { transform: translateX(0); }
.main-viewport { padding: 24px 32px; }

.nav-group-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-light);
  font-weight: 700;
  padding: 0 10px 6px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 500;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.nav-link:hover {
  background: var(--blue-50);
  color: var(--blue-700);
}

.nav-link.active {
  background: var(--blue-50);
  color: var(--blue-700);
  font-weight: 600;
  border-color: var(--blue-200);
}

.issue-tag {
  margin-left: auto;
  font-size: 0.65rem;
  color: var(--text-light);
  font-weight: 600;
}

/* Navigation latérale */
.sidebar-section-title,
.clean-nav-list,
.clean-nav-link { font-family: inherit; }
.sidebar-section-title {
  padding: 0 10px 6px;
  color: var(--text-light);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.clean-nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.clean-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
}
.clean-nav-link:hover,
.clean-nav-link.active {
  background: var(--blue-50);
  border-color: var(--blue-200);
  color: var(--blue-700);
}

/* Journal et filtres */
.filter-pills-row { display:flex;gap:6px;flex-wrap:wrap; }
.filter-pill {
  min-height:32px;
  padding:6px 10px;
  border:1px solid var(--border-color);
  border-radius:999px;
  background:var(--bg-surface);
  color:var(--text-secondary);
  font-size:.75rem;
  font-weight:700;
  cursor:pointer;
}
.filter-pill.active { background:var(--blue-700);border-color:var(--blue-700);color:white; }
.flux-badge-in,.flux-badge-out,.cat-badge {
  display:inline-flex;
  align-items:center;
  border-radius:999px;
  padding:4px 8px;
  font-size:.72rem;
  font-weight:700;
}
.flux-badge-in { background:var(--emerald-100);color:var(--emerald-700); }
.flux-badge-out { background:var(--red-100);color:var(--red-700); }
.cat-badge { background:var(--bg-subtle);color:var(--text-secondary); }

/* Tiroir contextuel */
.drawer-backdrop {
  position:fixed;
  inset:0;
  z-index:1100;
  display:flex;
  justify-content:flex-end;
  background:rgba(15,23,42,.48);
  backdrop-filter:blur(2px);
}
.drawer-panel {
  width:min(440px,92vw);
  height:100%;
  display:flex;
  flex-direction:column;
  background:var(--bg-surface);
  border-left:1px solid var(--border-color);
  box-shadow:var(--shadow-lg);
}
.drawer-header {
  min-height:76px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:16px 20px;
  border-bottom:1px solid var(--border-color);
}
.drawer-header-title-wrap { display:flex;align-items:center;gap:10px; }
.drawer-icon { width:38px;height:38px;display:flex;align-items:center;justify-content:center;border-radius:var(--radius-md);background:var(--blue-700);color:white; }
.drawer-title { margin:0;font-size:1.05rem;color:var(--blue-950); }
.drawer-subtitle { margin-top:3px;color:var(--text-muted);font-size:.78rem; }
.drawer-close-btn { width:36px;height:36px;border:1px solid var(--border-color);border-radius:var(--radius-md);background:var(--bg-surface);color:var(--text-secondary);font-size:1.4rem;cursor:pointer; }
.drawer-body { flex:1;overflow-y:auto;padding:20px; }
.drawer-footer { display:flex;justify-content:flex-end;gap:8px;padding:12px 20px;border-top:1px solid var(--border-color);background:var(--bg-surface); }

@media (max-width:600px) {
  .drawer-panel { width:100%; }
  .drawer-header { padding:12px 14px; }
  .drawer-body { padding:14px; }
  .drawer-footer { padding:10px 14px; }
  .filter-pills-row { width:100%; }
  .filter-pill { flex:1; }
}

/* Main Viewport */
.main-viewport {
  flex: 1;
  padding: 14px 18px;
  overflow-y: auto;
}

.view-section {
  display: none;
  animation: fadeIn 0.15s ease;
}

.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   CARDS, TABLES, FORMS & BUTTONS
   ========================================================================== */
.view-header {
  margin-bottom: 12px;
}

.view-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--blue-950);
  letter-spacing: -0.01em;
}

.view-subtitle { display: none; }

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}

.card-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--blue-950);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }

.form-group { margin-bottom: 10px; }
.form-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.form-input, .form-select {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  color: var(--text-primary);
  background: var(--bg-surface);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus, .form-select:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 2px var(--blue-100);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
}

.btn-primary { background: var(--blue-700); color: white; }
.btn-primary:hover { background: var(--blue-800); }

.btn-secondary {
  background: var(--blue-50);
  color: var(--blue-700);
  border: 1px solid var(--blue-200);
}
.btn-secondary:hover { background: #E0E7FF; }

.btn-danger { background: var(--red-600); color: white; }
.btn-danger:hover { background: var(--red-700); }

.btn-success { background: var(--emerald-600); color: white; }
.btn-success:hover { background: var(--emerald-700); }

.btn-sm {
  height: 32px;
  padding: 0 10px;
  font-size: 0.75rem;
}

.table-container { overflow-x: auto; }
.app-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  text-align: left;
}

.app-table th {
  background: var(--bg-main);
  padding: 10px 12px;
  color: var(--text-secondary);
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
}

.app-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.app-table tr:hover { background: var(--blue-50); }

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
}
.stat-label { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; }
.stat-value { font-size: 1.4rem; font-weight: 800; color: var(--blue-950); margin-top: 4px; }

/* Mobile Bottom Nav */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 62px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  justify-content: space-around;
  align-items: center;
  z-index: 50;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 500;
}

.bottom-nav-item.active { color: var(--blue-700); font-weight: 700; }

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    top: 60px;
    bottom: 0;
    left: 0;
    width: min(280px, 86vw);
    z-index: 55;
    overflow-y: auto;
    transform: translateX(-105%);
    transition: transform 180ms ease-out;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .main-viewport { width: 100%; max-width: 100%; overflow-x: hidden; padding: 16px 12px 84px; }
  .school-type-pill, .brand-sub, #network-badge { display: none; }
  .topbar-inner { padding: 8px 12px; }
  .header-actions { gap: 6px; }
  #logout-btn span { display: none; }
  .brand-logo { display: none; }
}

@media (max-width: 600px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .view-header { margin-bottom: 12px; }
  .view-title { font-size: 1.12rem; }
  .card { padding: 14px; }
  .main-viewport { padding: 12px 8px 84px; }
  .header-actions .role-badge { display: none; }
  .topbar-inner { gap: 6px; }
}

@media print {
  body { background: white !important; }
  .sidebar, .topbar, .bottom-nav, #auth-wall, .view-header, .btn, .nav-group-title, .hub-subnav-bar { display: none !important; }
  .view-section { display: none !important; }
  .view-section.active, .printable-area { display: block !important; }
  .card { box-shadow: none !important; border: 1px solid #ccc !important; }
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-primary);
  cursor: pointer;
}
.icon-btn:hover,.icon-btn:focus-visible {
  background: var(--blue-50);
  border-color: var(--blue-200);
  color: var(--blue-700);
  outline: none;
}
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 60px 0 0 0;
  background: rgba(15,23,42,.38);
  z-index: 54;
}
.sidebar-backdrop.open { display: block; }
.sidebar-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}
.finance-chart { width: 100%; height: 220px; display: block; }
.finance-chart-lg { height: 280px; }
.analytics-bars { display: flex; flex-direction: column; gap: 12px; padding-top: 4px; }
.analytics-bar-row { display: flex; flex-direction: column; gap: 4px; }
.analytics-bar-meta { display: flex; justify-content: space-between; font-size: 0.82rem; font-weight: 600; color: var(--text-primary); }
.analytics-bar-track { width: 100%; height: 10px; background: #E2E8F0; border-radius: 999px; overflow: hidden; }
.analytics-bar-fill { height: 100%; border-radius: 999px; background: var(--blue-600); transition: width 200ms ease; }
.quick-actions-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  padding: 8px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}
.flux-totals-row td {
  background: #F8FAFC;
  border-top: 2px solid var(--border-color);
  font-weight: 700;
  font-size: 0.82rem;
}
.recurring-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  background: #FEF3C7;
  color: #92400E;
}
