@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&family=DM+Serif+Display:ital@0;1&display=swap');

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

:root {
  --gray-50:  #FAFAFA;
  --gray-100: #F4F4F5;
  --gray-200: #E4E4E7;
  --gray-300: #D1D1D6;
  --gray-400: #A1A1AA;
  --gray-500: #71717A;
  --gray-600: #52525B;
  --gray-700: #3F3F46;
  --gray-800: #27272A;
  --gray-900: #18181B;
  --blue-50:  #EFF6FF;
  --blue-100: #DBEAFE;
  --blue-400: #60A5FA;
  --blue-500: #3B82F6;
  --blue-600: #2563EB;
  --blue-700: #1D4ED8;
  --green-50:  #F0FDF4;
  --green-100: #DCFCE7;
  --green-500: #22C55E;
  --green-600: #16A34A;
  --orange-50:  #FFF7ED;
  --orange-500: #F97316;
  --red-50:  #FEF2F2;
  --red-400: #F87171;
  --red-500: #EF4444;
  --font-sans:  'DM Sans', sans-serif;
  --font-serif: 'DM Serif Display', serif;
  --radius: 10px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.10), 0 4px 12px rgba(0,0,0,0.06);
}

body {
  font-family: var(--font-sans);
  background: var(--gray-100);
  min-height: 100vh;
  color: var(--gray-900);
  background-image:
    radial-gradient(circle at 15% 15%, rgba(59,130,246,.05) 0%, transparent 50%),
    radial-gradient(circle at 85% 85%, rgba(59,130,246,.03) 0%, transparent 50%);
}

/* ── App Shell ──────────────────────────────────────────────────────────────── */

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────────────────────── */

.sidebar {
  width: 200px;
  flex-shrink: 0;
  background: var(--gray-900);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
}

.sidebar-brand {
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-brand-icon {
  width: 32px; height: 32px;
  background: var(--blue-600);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.sidebar-brand-name {
  font-family: var(--font-serif);
  font-size: 14px;
  color: white;
  line-height: 1.2;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--gray-600);
  padding: 10px 20px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  font-size: 13px;
  color: var(--gray-400);
  cursor: pointer;
  border-left: 2px solid transparent;
  text-decoration: none;
  transition: all .15s;
}

.nav-item:hover { color: var(--gray-200); background: rgba(255,255,255,.04); }

.nav-item.active {
  color: white;
  background: rgba(59,130,246,.12);
  border-left-color: var(--blue-500);
}

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

.nav-badge {
  margin-left: auto;
  background: var(--blue-600);
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 20px;
}

.sidebar-user {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.06);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 32px; height: 32px;
  background: var(--gray-700);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 12px; font-weight: 500; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 10px; color: var(--gray-500); }

/* ── Main content ───────────────────────────────────────────────────────────── */

.main {
  flex: 1;
  margin-left: 200px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: white;
  padding: 14px 24px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-family: var(--font-serif);
  font-size: 18px;
  color: var(--gray-900);
}

.topbar-right { display: flex; align-items: center; gap: 12px; }

.topbar-notif {
  position: relative;
  width: 34px; height: 34px;
  background: var(--gray-100);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s;
}

.topbar-notif:hover { background: var(--gray-200); }

.notif-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--red-500);
  border-radius: 50%;
  border: 1.5px solid white;
}

.content { flex: 1; padding: 20px 24px; }

/* ── Buttons ────────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all .15s;
}

.btn-dark { background: var(--gray-900); color: white; }
.btn-dark:hover { background: var(--gray-700); }

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

.btn-outline { background: white; color: var(--gray-700); border: 1.5px solid var(--gray-200); }
.btn-outline:hover { border-color: var(--gray-300); background: var(--gray-50); }

.btn-green { background: var(--green-600); color: white; }
.btn-green:hover { background: #15803d; }

.btn-red { background: var(--red-500); color: white; }
.btn-red:hover { background: #dc2626; }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 11px 22px; font-size: 14px; }
.btn-full { width: 100%; justify-content: center; }

/* ── Cards ──────────────────────────────────────────────────────────────────── */

.card {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
}

/* ── Badges ─────────────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
}

.badge-active   { background: var(--green-50);   color: var(--green-600); }
.badge-closed   { background: var(--gray-100);   color: var(--gray-500); }
.badge-event    { background: var(--orange-50);  color: var(--orange-500); }
.badge-pending  { background: var(--blue-50);    color: var(--blue-600); }

/* ── Forms ──────────────────────────────────────────────────────────────────── */

.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-600);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--gray-900);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  background: white;
}

.form-input:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.form-input::placeholder { color: var(--gray-300); }

.form-error {
  font-size: 12px;
  color: var(--red-500);
  margin-top: 5px;
}

/* ── Progress bar ───────────────────────────────────────────────────────────── */

.progress-bar {
  height: 4px;
  background: var(--gray-200);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--green-500);
  border-radius: 4px;
  transition: width .3s;
}

/* ── Section headers ────────────────────────────────────────────────────────── */

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  letter-spacing: .05em;
  text-transform: uppercase;
}

.section-link {
  font-size: 11px;
  color: var(--blue-600);
  cursor: pointer;
  text-decoration: none;
}

.section-link:hover { text-decoration: underline; }

/* ── Alerts / Flash messages ────────────────────────────────────────────────── */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-error   { background: var(--red-50);   color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: var(--green-50); color: #166534; border: 1px solid #bbf7d0; }
.alert-info    { background: var(--blue-50);  color: #1e40af; border: 1px solid #bfdbfe; }

/* ── HTMX loading states ────────────────────────────────────────────────────── */

.htmx-indicator { opacity: 0; transition: opacity .2s; }
.htmx-request .htmx-indicator { opacity: 1; }
.htmx-request.htmx-indicator { opacity: 1; }

/* ── Mobile responsive ──────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s;
  }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .content { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .mobile-menu-btn { display: flex; }
}

@media (min-width: 769px) {
  .mobile-menu-btn { display: none; }
  .mobile-nav { display: none; }
}

.mobile-menu-btn {
  width: 34px; height: 34px;
  background: var(--gray-100);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  cursor: pointer;
  border: none;
}

/* ── Overlay (mobile sidebar) ───────────────────────────────────────────────── */

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

.sidebar-overlay.open { display: block; }

/* ── Empty states ───────────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--gray-400);
}

.empty-state-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state-title { font-size: 15px; font-weight: 500; color: var(--gray-600); margin-bottom: 6px; }
.empty-state-text { font-size: 13px; }

/* ── Spinner ────────────────────────────────────────────────────────────────── */

.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--blue-500);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

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