/* DHS.ma — Design System */
/* Aesthetic: Refined dark tech with Moroccan red accent */

:root {
  --bg-base:       #0a0a0f;
  --bg-surface:    #12121a;
  --bg-elevated:   #1a1a26;
  --bg-card:       #1e1e2e;
  --bg-hover:      #252538;
  --border:        rgba(255,255,255,0.07);
  --border-light:  rgba(255,255,255,0.12);

  --accent:        #e63946;
  --accent-dark:   #c1121f;
  --accent-glow:   rgba(230,57,70,0.25);
  --green-ma:      #006233;
  --green-light:   #00a854;

  --text-primary:  #f0f0f5;
  --text-secondary:#9999b8;
  --text-muted:    #5a5a7a;

  --font-main:     'Sora', sans-serif;
  --font-mono:     'Space Mono', monospace;

  --sidebar-w:     260px;
  --radius:        12px;
  --radius-lg:     18px;
  --shadow:        0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg:     0 8px 48px rgba(0,0,0,0.6);

  --transition:    0.2s cubic-bezier(0.4,0,0.2,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-main);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  display: block;
  overflow-x: hidden;
}

/* ── Scrollbar ──────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ── Sidebar ───────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.logo-icon svg { width: 36px; height: 36px; }

.logo-text {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.logo-dot { color: var(--accent); }

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.92rem;
  font-weight: 500;
  transition: all var(--transition);
  position: relative;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 60%;
  background: var(--accent);
  border-radius: 0 4px 4px 0;
}

.nav-icon { width: 18px; text-align: center; font-size: 1rem; }

.sidebar-bottom {
  padding: 16px 12px;
  border-top: 1px solid var(--border);
}

.user-menu { display: flex; flex-direction: column; gap: 8px; }

.user-avatar-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius);
}

.user-avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; }

.user-avatar-placeholder {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem; color: white;
  flex-shrink: 0;
}

.user-info { display: flex; flex-direction: column; }
.user-name { font-size: 0.85rem; font-weight: 600; }
.user-badge {
  font-size: 0.65rem;
  background: var(--accent);
  color: white;
  padding: 1px 6px;
  border-radius: 4px;
  width: fit-content;
  margin-top: 2px;
}

.nav-item-small {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.82rem;
  transition: all var(--transition);
}

.nav-item-small:hover { background: var(--bg-hover); color: var(--text-secondary); }
.nav-item-small.logout:hover { color: var(--accent); }

.auth-buttons { display: flex; flex-direction: column; gap: 8px; }

.btn-login, .btn-register {
  display: block;
  text-align: center;
  padding: 10px;
  border-radius: var(--radius);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.88rem;
  transition: all var(--transition);
}

.btn-login {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
}

.btn-login:hover { background: var(--bg-hover); }

.btn-register {
  background: var(--accent);
  color: white;
}

.btn-register:hover { background: var(--accent-dark); }

/* ── Mobile header ─────────────────────── */
.mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 58px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 200;
}

.menu-toggle {
  background: none; border: none;
  color: var(--text-primary);
  font-size: 1.2rem;
  cursor: pointer; padding: 8px;
}

.mobile-logo {
  font-family: var(--font-mono);
  font-weight: 700; font-size: 1.2rem;
  text-decoration: none;
  color: var(--text-primary);
}

.mobile-logo span { color: var(--accent); }

.mobile-avatar, .mobile-avatar-placeholder {
  width: 32px; height: 32px; border-radius: 50%;
}

.mobile-avatar-placeholder {
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.8rem; color: white;
}

.btn-login-mobile {
  font-size: 0.85rem; font-weight: 600;
  color: var(--accent); text-decoration: none;
}

.overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 90;
}

/* ── Main content ──────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  width: calc(100% - var(--sidebar-w));
}

/* ── Footer ────────────────────────────── */
.app-footer {
  padding: 20px 32px;
  border-top: 1px solid var(--border);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.footer-links { display: flex; gap: 16px; }
.footer-links a { color: var(--text-muted); text-decoration: none; }
.footer-links a:hover { color: var(--text-secondary); }

/* ── Page header ───────────────────────── */
.page-header {
  padding: 32px 36px 24px;
  border-bottom: 1px solid var(--border);
}

.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-title i { color: var(--accent); font-size: 1.3rem; }
.page-subtitle { color: var(--text-secondary); font-size: 0.9rem; margin-top: 4px; }

/* ── Buttons ───────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-family: var(--font-main);
  font-weight: 600;
  font-size: 0.88rem;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
}

.btn-secondary:hover { background: var(--bg-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ── Cards ─────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--transition);
}

.card:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow);
}

/* ── Forms ─────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-input, .form-textarea, .form-select {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 0.9rem;
  transition: all var(--transition);
  outline: none;
  width: 100%;
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input::placeholder { color: var(--text-muted); }
.form-textarea { resize: vertical; min-height: 100px; }

/* ── Badges ────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
}

.badge-red    { background: rgba(230,57,70,0.15); color: var(--accent); }
.badge-green  { background: rgba(0,98,51,0.2); color: var(--green-light); }
.badge-blue   { background: rgba(96,165,250,0.15); color: #60a5fa; }
.badge-yellow { background: rgba(251,191,36,0.15); color: #fbbf24; }
.badge-gray   { background: var(--bg-elevated); color: var(--text-secondary); }

/* ── Toast ─────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.87rem;
  min-width: 240px;
  animation: slideIn 0.3s ease;
  box-shadow: var(--shadow);
}

.toast.success { border-left-color: var(--green-light); }
.toast.error   { border-left-color: var(--accent); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ── Loader ────────────────────────────── */
.loader {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.page-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px;
  color: var(--text-muted);
  font-size: 0.9rem;
  gap: 12px;
}

/* ── Empty state ───────────────────────── */
.empty-state {
  text-align: center;
  padding: 80px 40px;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 3rem;
  margin-bottom: 16px;
  display: block;
  opacity: 0.4;
}

.empty-state h3 {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

/* ── Grid layouts ──────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }

/* ── Modal ─────────────────────────────── */
.modal-bg {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-bg.open { display: flex; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn 0.25s ease;
}

@keyframes modalIn {
  from { transform: scale(0.95) translateY(10px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-title { font-size: 1.1rem; font-weight: 700; }

.modal-close {
  background: none; border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
  transition: color var(--transition);
}

.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 24px; }

/* ── Auth pages ────────────────────────── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo .logo-icon svg { width: 48px; height: 48px; }
.auth-logo .logo-text { font-size: 1.8rem; font-family: var(--font-mono); font-weight: 700; }
.auth-title { font-size: 1.4rem; font-weight: 700; margin-bottom: 8px; text-align: center; }
.auth-subtitle { color: var(--text-secondary); font-size: 0.88rem; text-align: center; margin-bottom: 28px; }

.auth-divider {
  text-align: center;
  margin: 20px 0;
  color: var(--text-muted);
  font-size: 0.82rem;
  position: relative;
}

.auth-divider::before {
  content: '';
  position: absolute;
  top: 50%; left: 0;
  width: 45%; height: 1px;
  background: var(--border);
}

.auth-divider::after {
  content: '';
  position: absolute;
  top: 50%; right: 0;
  width: 45%; height: 1px;
  background: var(--border);
}

.auth-link {
  display: block;
  text-align: center;
  margin-top: 20px;
  font-size: 0.87rem;
  color: var(--text-secondary);
}

.auth-link a { color: var(--accent); text-decoration: none; font-weight: 600; }

.alert {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.87rem;
  margin-bottom: 16px;
}

.alert-error { background: rgba(230,57,70,0.1); border: 1px solid rgba(230,57,70,0.3); color: #ff6b7a; }
.alert-success { background: rgba(0,168,84,0.1); border: 1px solid rgba(0,168,84,0.3); color: var(--green-light); }

/* ── Responsive ────────────────────────── */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: 300;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .mobile-header { display: flex; }

  .main-content {
    margin-left: 0;
    width: 100%;
    padding-top: 58px;
  }

  .overlay.active { display: block; }
  .page-header { padding: 20px 16px 16px; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .app-footer { padding: 16px 20px; }
}

@media (max-width: 600px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .footer-inner { flex-direction: column; gap: 8px; text-align: center; }
  .auth-card { padding: 28px 20px; }
  .page-header { padding: 16px 14px 12px; }
  .page-title { font-size: 1.3rem; }
}

/* ── Utility ───────────────────────────── */
.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.p-4 { padding: 16px; }
.p-6 { padding: 24px; }
.mb-4 { margin-bottom: 16px; }
.mt-4 { margin-top: 16px; }
.text-sm { font-size: 0.85rem; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-accent { color: var(--accent); }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
