:root {
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --primary-light: #eef2ff;
  --navy: #0f172a;
  --navy-2: #1e2749;
  --bg: #f6f7fb;
  --card-bg: #ffffff;
  --text: #1e2233;
  --muted: #64748b;
  --border: #e5e7eb;
  --danger: #dc2626;
  --success: #16a34a;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 6px 20px rgba(15, 23, 42, 0.04);
  --shadow-hover: 0 4px 12px rgba(15, 23, 42, 0.08), 0 12px 28px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { letter-spacing: -0.01em; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Topbar --- */
.topbar {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 100%);
  color: white;
  box-shadow: 0 2px 12px rgba(0,0,0,0.12);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-admin { background: linear-gradient(135deg, #111827 0%, #312e81 100%); }
.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.brand {
  color: white;
  font-weight: 700;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--primary);
  font-weight: 800;
  font-size: 0.95rem;
}
.nav-toggle {
  display: none;
  background: none;
  border: 1px solid rgba(255,255,255,0.25);
  color: white;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 1rem;
}
.main-nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.main-nav a {
  color: rgba(255,255,255,0.82);
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.main-nav a:hover { color: white; background: rgba(255,255,255,0.1); text-decoration: none; }
.main-nav .logout { color: #fca5a5; }
.main-nav .logout:hover { background: rgba(220,38,38,0.15); color: #fecaca; }
.section-tag {
  background: rgba(255,255,255,0.14);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-right: 4px;
}

@media (max-width: 900px) {
  .nav-toggle { display: inline-block; }
  .main-nav { display: none; width: 100%; flex-direction: column; align-items: stretch; gap: 2px; }
  .main-nav.open { display: flex; }
  .main-nav a { padding: 10px 12px; }
}

/* --- Layout --- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 28px;
}
.container h1 { font-size: 1.7rem; margin-bottom: 6px; }
.muted { color: var(--muted); }
.breadcrumb { color: var(--muted); margin-bottom: 6px; font-size: 0.85rem; }

/* --- Login page --- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at 20% 20%, #eef2ff 0%, var(--bg) 55%);
}
.login-card {
  background: var(--card-bg);
  padding: 44px 40px;
  border-radius: 20px;
  box-shadow: var(--shadow-hover);
  width: 100%;
  max-width: 400px;
  border-top: 4px solid var(--primary);
}
.login-card h1 { margin-top: 0; font-size: 1.5rem; }
.subtitle { color: var(--muted); margin-bottom: 28px; font-size: 0.92rem; line-height: 1.5; }

/* --- Forms --- */
.form { display: flex; flex-direction: column; gap: 6px; }
.form label { font-size: 0.85rem; font-weight: 600; margin-top: 10px; color: #334155; }
.form input, .form select, .form textarea {
  padding: 11px 13px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  background-color: white;
  caret-color: #000000;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form input:-webkit-autofill,
.form input:-webkit-autofill:hover,
.form input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text) !important;
  caret-color: #000000 !important;
  transition: background-color 9999s ease-in-out 0s;
  box-shadow: 0 0 0 1000px white inset !important;
}
.form input:focus, .form select:focus, .form textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.form button, main button[type="submit"], .btn, button {
  font-family: inherit;
}
.form button {
  margin-top: 22px;
  background: var(--primary);
  color: white;
  border: none;
  padding: 13px;
  border-radius: 10px;
  font-size: 0.98rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}
.form button:hover { background: var(--primary-dark); }
.form button:active { transform: translateY(1px); }
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row > div { flex: 1; min-width: 180px; }
.form-row .full-width { flex: 1 1 100%; }

.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; font-size: 0.9rem; font-weight: 500; }
.alert-error { background: #fee2e2; color: var(--danger); }
.alert-success { background: #dcfce7; color: var(--success); }

/* --- Cards (student dashboard) --- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 18px;
  margin-top: 28px;
}
.menu-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.18s, transform 0.18s, border-color 0.18s;
}
.menu-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-3px);
  border-color: var(--primary);
  text-decoration: none;
}
.menu-card h2 { margin-top: 0; font-size: 1.05rem; }
.menu-card p { color: var(--muted); margin-bottom: 0; font-size: 0.88rem; line-height: 1.5; }

/* --- Document list --- */
.doc-list { list-style: none; padding: 0; margin-top: 22px; }
.doc-item {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 22px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
}
.doc-info h3 { margin: 0 0 4px 0; font-size: 1rem; }
.doc-info p { margin: 0 0 6px 0; color: var(--muted); font-size: 0.88rem; }
.doc-date { font-size: 0.78rem; color: var(--muted); }
.btn-download {
  background: var(--primary);
  color: white;
  padding: 9px 18px;
  border-radius: 9px;
  white-space: nowrap;
  font-weight: 600;
  font-size: 0.88rem;
  transition: background 0.15s;
}
.btn-download:hover { background: var(--primary-dark); text-decoration: none; }
.empty-state { color: var(--muted); margin-top: 28px; background: white; padding: 24px; border-radius: 12px; border: 1px dashed var(--border); text-align: center; }

/* --- Admin tables/panels --- */
.panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 28px;
  margin-top: 24px;
  box-shadow: var(--shadow);
}
.panel h2 { margin-top: 0; font-size: 1.15rem; }
.admin-table { width: 100%; border-collapse: collapse; margin-top: 14px; }
.admin-table th, .admin-table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.admin-table th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
.admin-table tbody tr:hover { background: #fafbff; }
.btn-danger {
  background: none;
  border: 1.5px solid var(--danger);
  color: var(--danger);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
}
.btn-danger:hover { background: var(--danger); color: white; }
.admin-actions { margin-top: 26px; display: flex; gap: 10px; flex-wrap: wrap; }
.btn {
  background: var(--primary);
  color: white;
  padding: 10px 18px;
  border-radius: 9px;
  font-weight: 600;
  font-size: 0.88rem;
  display: inline-block;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn-secondary {
  background: white;
  border: 1.5px solid var(--border);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 9px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
}
.btn-secondary:hover { background: #f8fafc; }
.badge {
  display: inline-block;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.question-block {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 16px;
  background: #fafbff;
}
.reset-password-form { display: flex; gap: 6px; align-items: center; }
.reset-password-form input {
  padding: 6px 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
  width: 140px;
}
.btn-reset {
  background: none;
  border: 1.5px solid var(--primary);
  color: var(--primary);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}
.btn-reset:hover { background: var(--primary); color: white; }
.btn-reset-auto {
  border-color: var(--muted);
  color: var(--muted);
}
.btn-reset-auto:hover { background: var(--muted); color: white; }

/* --- Forum --- */
.forum-post {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

/* --- Glisser-déposer de fichiers --- */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  background: #fafbff;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover { border-color: var(--primary); background: var(--primary-light); }
.dropzone.dropzone-active { border-color: var(--primary); background: var(--primary-light); }
.dropzone-icon { font-size: 1.8rem; display: block; margin-bottom: 6px; }
.dropzone-text { margin: 0; color: var(--muted); font-size: 0.88rem; }
.dropzone-browse { color: var(--primary); font-weight: 600; text-decoration: underline; }
.dropzone-filename { margin: 0; color: var(--text); font-weight: 600; font-size: 0.9rem; }
.dropzone input[type="file"] { display: none; }
