/* ── Variables ──────────────────────────────────────────────── */
:root {
  --sidebar-w: 240px;
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --accent: #6366f1;
  --accent-light: #818cf8;
  --bg: #f1f5f9;
  --card-bg: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --topbar-h: 56px;
  --bottom-nav-h: 60px;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
}

/* ── Reset ──────────────────────────────────────────────────── */
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
       background: var(--bg); color: var(--text); }

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0; height: 100vh; width: var(--sidebar-w);
  background: var(--sidebar-bg); z-index: 1040;
  transition: transform .25s ease; overflow-y: auto;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-icon { font-size: 22px; color: var(--accent-light); }
.brand-text { font-size: 17px; font-weight: 700; color: #f8fafc; letter-spacing: -.3px; }

.sidebar-nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border-radius: 8px; color: #94a3b8; text-decoration: none;
  font-size: 14px; font-weight: 500; transition: all .15s; position: relative;
}
.nav-item:hover { background: var(--sidebar-hover); color: #f1f5f9; }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-item i { font-size: 17px; flex-shrink: 0; }
.nav-divider { height: 1px; background: rgba(255,255,255,.08); margin: 8px 12px; }
.badge-nav {
  margin-left: auto; background: #ef4444; color: #fff;
  font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 99px; min-width: 20px; text-align: center;
}
.text-danger-nav { color: #f87171 !important; }
.text-danger-nav:hover { background: rgba(239,68,68,.15) !important; color: #fca5a5 !important; }

.sidebar-footer {
  padding: 10px; border-top: 1px solid rgba(255,255,255,.08);
  display: flex; flex-direction: column; gap: 2px;
}

/* ── Topbar (mobile) ────────────────────────────────────────── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h);
  background: var(--sidebar-bg); z-index: 1030;
  display: flex; align-items: center; padding: 0 16px; gap: 14px;
}
.btn-hamburger {
  background: none; border: none; color: #f1f5f9; font-size: 24px;
  cursor: pointer; padding: 4px; line-height: 1;
}
.topbar-title { color: #f8fafc; font-weight: 600; font-size: 16px; flex: 1; }
.topbar-badge {
  background: #ef4444; color: #fff; font-size: 12px; font-weight: 700;
  padding: 2px 9px; border-radius: 99px; text-decoration: none;
}

/* ── Main content ───────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh; padding: 28px 28px 80px;
}
.main-content-full { padding: 0; }

/* ── Bottom nav (mobile) ────────────────────────────────────── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; height: var(--bottom-nav-h);
  background: var(--sidebar-bg); border-top: 1px solid rgba(255,255,255,.1);
  display: flex; justify-content: space-around; align-items: center; z-index: 1030;
}
.bottom-nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: #94a3b8; text-decoration: none; font-size: 10px; font-weight: 500;
  padding: 6px 8px; border-radius: 8px; min-width: 56px; text-align: center;
}
.bottom-nav-item i { font-size: 20px; }
.bottom-nav-item.active { color: var(--accent-light); }
.bottom-badge { background: #ef4444; color: #fff; font-size: 9px; border-radius: 99px; padding: 1px 4px; }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-header {
  background: transparent; border-bottom: 1px solid var(--border);
  padding: 16px 20px; font-weight: 600; font-size: 15px;
  display: flex; align-items: center; gap: 8px;
}
.card-body { padding: 20px; }

/* ── KPI cards ──────────────────────────────────────────────── */
.kpi-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 16px;
}
.kpi-icon {
  width: 52px; height: 52px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.kpi-icon.indigo  { background: #eef2ff; color: var(--accent); }
.kpi-icon.orange  { background: #fff7ed; color: #f97316; }
.kpi-icon.green   { background: #f0fdf4; color: #22c55e; }
.kpi-icon.blue    { background: #eff6ff; color: #3b82f6; }
.kpi-value { font-size: 28px; font-weight: 700; line-height: 1; color: var(--text); }
.kpi-label { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ── Page header ────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; gap: 12px; flex-wrap: wrap;
}
.page-title { font-size: 22px; font-weight: 700; margin: 0; }
.page-subtitle { font-size: 14px; color: var(--text-muted); margin: 0; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn { border-radius: 8px; font-weight: 500; font-size: 14px; }
.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { background: #4f46e5; border-color: #4f46e5; }
.btn-sm { padding: 5px 12px; font-size: 13px; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-label { font-size: 13px; font-weight: 500; color: var(--text-muted); margin-bottom: 4px; }
.form-control, .form-select {
  border-radius: 8px; border: 1.5px solid var(--border);
  font-size: 14px; padding: 8px 12px;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
textarea.form-control { min-height: 120px; resize: vertical; }

/* ── Tables ─────────────────────────────────────────────────── */
.table { font-size: 14px; }
.table th { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.table-hover tbody tr:hover { background: #f8fafc; cursor: pointer; }
.table-wrapper { overflow-x: auto; border-radius: var(--radius); }

/* ── Status badges ──────────────────────────────────────────── */
.badge-status { padding: 4px 10px; border-radius: 99px; font-size: 12px; font-weight: 500; }
.badge-attente  { background: #fff7ed; color: #c2410c; }
.badge-valide   { background: #f0fdf4; color: #166534; }
.badge-rejete   { background: #fef2f2; color: #991b1b; }
.badge-publie   { background: #eff6ff; color: #1d4ed8; }
.badge-active   { background: #f0fdf4; color: #166534; }
.badge-entrainement { background: #faf5ff; color: #6b21a8; }
.badge-starter   { background: #f1f5f9; color: #475569; }
.badge-standard  { background: #eff6ff; color: #1d4ed8; }
.badge-premium   { background: #fdf4ff; color: #7e22ce; }

/* ── Post card ──────────────────────────────────────────────── */
.post-card {
  border: 2px solid var(--border); border-radius: var(--radius);
  transition: border-color .15s, box-shadow .15s; cursor: pointer;
  margin-bottom: 12px;
}
.post-card:hover, .post-card.selected {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,.1);
}
.post-card.selected { background: #fafbff; }
.post-card-header { padding: 12px 16px 8px; display: flex; align-items: center; gap: 8px; }
.post-card-body { padding: 0 16px 12px; font-size: 14px; color: var(--text); }
.post-card-footer { padding: 8px 16px; border-top: 1px solid var(--border); background: #f8fafc; border-radius: 0 0 10px 10px; }

/* ── Media grid ─────────────────────────────────────────────── */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px,1fr)); gap: 12px; }
.media-item {
  background: var(--card-bg); border: 1.5px solid var(--border); border-radius: var(--radius);
  overflow: hidden; transition: border-color .15s;
}
.media-item:hover { border-color: var(--accent); }
.media-thumb { width: 100%; height: 110px; object-fit: cover; background: var(--bg); display: block; }
.media-thumb-placeholder {
  width: 100%; height: 110px; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; color: var(--text-muted);
}
.media-info { padding: 8px 10px; }
.media-name { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-type { font-size: 11px; color: var(--text-muted); }

/* ── Upload zone ────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 28px; text-align: center; color: var(--text-muted);
  cursor: pointer; transition: all .15s; background: var(--bg);
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent); color: var(--accent); background: #f5f3ff;
}
.upload-zone i { font-size: 32px; margin-bottom: 8px; }

/* ── Alert toast ────────────────────────────────────────────── */
.alert-toast {
  position: fixed; top: 16px; right: 16px; z-index: 9999;
  max-width: 360px; border-radius: var(--radius); box-shadow: var(--shadow-md);
  animation: slideIn .25s ease;
}
@keyframes slideIn { from { transform: translateX(100px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Login page ─────────────────────────────────────────────── */
.login-wrapper {
  min-height: 100vh; background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.login-card {
  background: #fff; border-radius: 20px; padding: 40px;
  width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .icon { font-size: 40px; color: var(--accent); }
.login-logo h1 { font-size: 22px; font-weight: 700; margin: 8px 0 4px; }
.login-logo p { font-size: 14px; color: var(--text-muted); margin: 0; }

/* ── Sidebar overlay (mobile) ───────────────────────────────── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 1039;
}
.sidebar-overlay.show { display: block; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 991px) {
  .sidebar { transform: translateX(calc(-1 * var(--sidebar-w))); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: calc(var(--topbar-h) + 16px) 16px calc(var(--bottom-nav-h) + 16px); }
  .page-header { margin-bottom: 16px; }
  .kpi-card { padding: 14px; gap: 12px; }
  .kpi-value { font-size: 22px; }
  .kpi-icon { width: 44px; height: 44px; font-size: 18px; }
  .media-grid { grid-template-columns: repeat(auto-fill, minmax(130px,1fr)); }
}
@media (max-width: 575px) {
  .login-card { padding: 28px 20px; }
  .media-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Égéries status ─────────────────────────────────────────── */
.egerie-card {
  background: var(--card-bg); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 16px; transition: border-color .15s;
}
.egerie-card:hover { border-color: var(--accent); }
.egerie-avatar {
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: #fff; flex-shrink: 0;
}

/* ── Progress bar budget ────────────────────────────────────── */
.budget-bar { height: 6px; border-radius: 99px; background: var(--border); overflow: hidden; }
.budget-fill { height: 100%; border-radius: 99px; transition: width .3s; }

/* ── Split layout ────────────────────────────────────────────── */
.split-layout { display: grid; grid-template-columns: 1fr 420px; gap: 20px; align-items: start; }
@media (max-width: 1199px) { .split-layout { grid-template-columns: 1fr; } }
