/* ═══════════════════════════════════════════════════════════════
   CrowdPredict Design System
   Dark urban theme — Glassmorphism — Neon accents
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ─── Tokens ──────────────────────────────────────────────────── */
:root {
  --bg-0:         #060b14;
  --bg-1:         #0a1628;
  --bg-2:         #0f1f3d;
  --bg-card:      rgba(15, 31, 61, 0.7);
  --bg-glass:     rgba(255, 255, 255, 0.04);

  --cyan:         #00d4ff;
  --cyan-dim:     rgba(0, 212, 255, 0.15);
  --cyan-glow:    0 0 20px rgba(0, 212, 255, 0.4);
  --amber:        #ff9f1c;
  --amber-dim:    rgba(255, 159, 28, 0.15);
  --green:        #00ff88;
  --green-dim:    rgba(0, 255, 136, 0.15);
  --red:          #ff4757;
  --red-dim:      rgba(255, 71, 87, 0.15);
  --purple:       #a855f7;
  --purple-dim:   rgba(168, 85, 247, 0.15);

  --text-primary:   #e8f4ff;
  --text-secondary: #7a9ec0;
  --text-muted:     #3d5a7a;

  --border:       rgba(0, 212, 255, 0.15);
  --border-hover: rgba(0, 212, 255, 0.4);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(0, 212, 255, 0.08);
  --shadow-glow: 0 0 40px rgba(0, 212, 255, 0.2);

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

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-0);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

/* Animated mesh background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% 20%, rgba(0, 212, 255, 0.06) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 80%, rgba(168, 85, 247, 0.06) 0%, transparent 60%),
    radial-gradient(ellipse 50% 60% at 50% 50%, rgba(255, 159, 28, 0.03) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ─── Typography ──────────────────────────────────────────────── */
h1 { font-size: 2rem;   font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: 1.5rem; font-weight: 700; }
h3 { font-size: 1.1rem; font-weight: 600; }
h4 { font-size: 0.9rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-secondary); }

a { color: var(--cyan); text-decoration: none; transition: color var(--transition); }
a:hover { color: white; }

.mono { font-family: 'JetBrains Mono', monospace; }

/* ─── Layout ──────────────────────────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.main-content {
  padding: 24px;
  overflow-y: auto;
  max-height: 100vh;
}

/* ─── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

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

.sidebar-logo .logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  margin-bottom: 8px;
  box-shadow: var(--cyan-glow);
}

.sidebar-logo h2 {
  font-size: 1.1rem;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-logo p {
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.nav-section-label {
  padding: 12px 20px 6px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  color: var(--text-secondary);
  transition: all var(--transition);
  border-left: 3px solid transparent;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 500;
  text-decoration: none;
}

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

.nav-item.active {
  color: var(--cyan);
  background: var(--cyan-dim);
  border-left-color: var(--cyan);
}

.nav-item .nav-icon { font-size: 1rem; width: 20px; text-align: center; }
.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}

.user-info .user-name { font-size: 0.82rem; font-weight: 600; }
.user-info .user-role {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ─── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-card);
  padding: 20px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

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

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

/* ─── KPI Cards ───────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  backdrop-filter: blur(20px);
  position: relative;
  overflow: hidden;
  transition: all var(--transition);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent-color, var(--cyan));
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card), 0 0 30px rgba(0, 212, 255, 0.15);
}

.kpi-card.cyan  { --accent-color: var(--cyan);   }
.kpi-card.amber { --accent-color: var(--amber);  }
.kpi-card.green { --accent-color: var(--green);  }
.kpi-card.red   { --accent-color: var(--red);    }
.kpi-card.purple{ --accent-color: var(--purple); }

.kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  margin-bottom: 12px;
  background: var(--accent-bg, var(--cyan-dim));
}
.kpi-card.cyan   .kpi-icon { background: var(--cyan-dim); }
.kpi-card.amber  .kpi-icon { background: var(--amber-dim); }
.kpi-card.green  .kpi-icon { background: var(--green-dim); }
.kpi-card.red    .kpi-icon { background: var(--red-dim); }
.kpi-card.purple .kpi-icon { background: var(--purple-dim); }

.kpi-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  color: var(--accent-color, var(--cyan));
}

.kpi-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 4px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.kpi-delta {
  position: absolute;
  top: 20px;
  right: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
}
.kpi-delta.up   { background: var(--green-dim); color: var(--green); }
.kpi-delta.down { background: var(--red-dim);   color: var(--red); }

/* ─── Severity badges ─────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.badge-low      { background: var(--green-dim);  color: var(--green); }
.badge-medium   { background: var(--amber-dim);  color: var(--amber); }
.badge-high     { background: var(--red-dim);    color: var(--red); }
.badge-critical { background: rgba(255,0,80,0.2);color: #ff0050; animation: pulse-badge 1s infinite; }

/* ─── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  font-family: 'Inter', sans-serif;
}

.btn-primary {
  background: linear-gradient(135deg, var(--cyan), #0088cc);
  color: #0a0a0a;
  box-shadow: 0 4px 15px rgba(0, 212, 255, 0.3);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 25px rgba(0, 212, 255, 0.5);
}

.btn-outline {
  background: transparent;
  color: var(--cyan);
  border: 1px solid var(--border-hover);
}
.btn-outline:hover {
  background: var(--cyan-dim);
}

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

.btn-danger {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(255, 71, 87, 0.3);
}
.btn-danger:hover { background: rgba(255, 71, 87, 0.25); }

.btn-sm { padding: 5px 12px; font-size: 0.78rem; }
.btn-lg { padding: 12px 28px; font-size: 0.95rem; }

/* ─── Inputs ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 10px 14px;
  font-size: 0.88rem;
  font-family: 'Inter', sans-serif;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px var(--cyan-dim);
}
.form-select option { background: var(--bg-2); }
.form-textarea { resize: vertical; min-height: 80px; }

/* ─── Table ───────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-md); }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
}
tbody tr {
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background var(--transition);
}
tbody tr:hover { background: var(--bg-glass); }
tbody td { padding: 13px 16px; font-size: 0.86rem; }
tbody tr:last-child { border-bottom: none; }

/* ─── Progress bar ────────────────────────────────────────────── */
.progress-wrap {
  background: rgba(255,255,255,0.05);
  border-radius: 20px;
  height: 6px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  border-radius: 20px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}
.progress-bar.low      { background: linear-gradient(90deg, var(--green), #00cc66); }
.progress-bar.medium   { background: linear-gradient(90deg, var(--amber), #ff6b00); }
.progress-bar.high     { background: linear-gradient(90deg, var(--red), #cc0000); }
.progress-bar.critical {
  background: linear-gradient(90deg, #ff0050, #ff0000);
  animation: shimmer 1s infinite;
}

@keyframes shimmer {
  0%   { opacity: 1; }
  50%  { opacity: 0.7; }
  100% { opacity: 1; }
}

/* ─── Map ─────────────────────────────────────────────────────── */
#map-container {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  height: 480px;
}

.leaflet-container {
  background: #0a1628 !important;
  font-family: 'Inter', sans-serif !important;
}

.map-popup {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
}

/* ─── Alert Feed ──────────────────────────────────────────────── */
.alert-feed { display: flex; flex-direction: column; gap: 10px; }

.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-glass);
  animation: slideInAlert 0.3s ease;
  transition: all var(--transition);
}

.alert-item:hover { border-color: var(--border-hover); }

.alert-item.critical { border-left: 3px solid #ff0050; background: rgba(255, 0, 80, 0.05); }
.alert-item.high     { border-left: 3px solid var(--red);    background: var(--red-dim); }
.alert-item.medium   { border-left: 3px solid var(--amber);  background: var(--amber-dim); }
.alert-item.low      { border-left: 3px solid var(--green);  background: var(--green-dim); }

@keyframes slideInAlert {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: translateX(0); }
}

.alert-icon { font-size: 1.3rem; flex-shrink: 0; margin-top: 2px; }
.alert-content { flex: 1; min-width: 0; }
.alert-title { font-weight: 600; font-size: 0.88rem; }
.alert-message { color: var(--text-secondary); font-size: 0.8rem; margin-top: 2px; }
.alert-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ─── Live Indicator ──────────────────────────────────────────── */
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  display: inline-block;
  animation: live-pulse 1.5s infinite;
}
@keyframes live-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 255, 136, 0.6); }
  50%       { box-shadow: 0 0 0 6px rgba(0, 255, 136, 0); }
}

/* ─── Login Page ──────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  z-index: 1;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px;
  backdrop-filter: blur(30px);
  box-shadow: var(--shadow-card), var(--shadow-glow);
}

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

.login-logo .logo-circle {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin: 0 auto 16px;
  box-shadow: var(--cyan-glow);
}

.login-logo h1 {
  font-size: 1.6rem;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 6px;
}

.login-logo p { color: var(--text-secondary); font-size: 0.85rem; }

.login-error {
  background: var(--red-dim);
  border: 1px solid rgba(255, 71, 87, 0.3);
  color: var(--red);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.83rem;
  margin-bottom: 16px;
  display: none;
}

.credentials-hint {
  margin-top: 16px;
  padding: 12px;
  background: var(--cyan-dim);
  border: 1px solid rgba(0, 212, 255, 0.2);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.credentials-hint strong { color: var(--cyan); }
.credentials-hint code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  background: rgba(0, 0, 0, 0.3);
  padding: 1px 5px;
  border-radius: 3px;
}

/* ─── Page Header ─────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-header h1 { font-size: 1.5rem; }
.page-header p { color: var(--text-secondary); font-size: 0.85rem; margin-top: 2px; }

/* ─── Grid utilities ──────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr;     gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }

/* ─── Modal ───────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px;
  width: 100%;
  max-width: 500px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  transform: scale(0.95);
  transition: transform var(--transition);
}
.modal-overlay.open .modal { transform: scale(1); }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 4px;
  line-height: 1;
}
.modal-close:hover { color: var(--text-primary); }

/* ─── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

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

.toast {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  font-size: 0.84rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  animation: toastIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 320px;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--cyan); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ─── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .app-layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: relative;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
  }
  .main-content { max-height: none; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ─── Animations ──────────────────────────────────────────────── */
.fade-in {
  animation: fadeIn 0.4s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Misc ────────────────────────────────────────────────────── */
.text-cyan   { color: var(--cyan); }
.text-amber  { color: var(--amber); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-muted  { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }

.flex        { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-8       { gap: 8px; }
.gap-12      { gap: 12px; }
.gap-16      { gap: 16px; }
.mt-8        { margin-top: 8px; }
.mt-16       { margin-top: 16px; }
.mt-24       { margin-top: 24px; }
.mb-16       { margin-bottom: 16px; }
.mb-24       { margin-bottom: 24px; }
.w-full      { width: 100%; }

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { font-size: 0.88rem; }

/* Loading skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--bg-2) 25%, var(--bg-glass) 50%, var(--bg-2) 75%);
  background-size: 200% 100%;
  animation: skeleton-wave 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-wave {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
