/* ============================================================
   main.css — Base styles, variables, layout, typography
   Pasig City Civic Intelligence Dashboard
   ============================================================ */

/* ─── CSS Custom Properties ─────────────────────────────────── */
:root {
  --primary:        #6366F1;
  --primary-dark:   #4F46E5;
  --primary-light:  #818CF8;
  --primary-xlight: #EEF2FF;
  --accent:         #06B6D4;
  --accent-dark:    #0891B2;
  --success:        #10B981;
  --warning:        #F59E0B;
  --danger:         #EF4444;
  --purple:         #8B5CF6;
  --pink:           #EC4899;

  --bg:             #F1F5F9;
  --bg-card:        #FFFFFF;
  --bg-sidebar:     #0F172A;
  --bg-sidebar-hl:  #1E293B;
  --bg-topbar:      #FFFFFF;

  --text-primary:   #0F172A;
  --text-secondary: #475569;
  --text-muted:     #94A3B8;
  --text-white:     #F8FAFC;

  --border:         #E2E8F0;
  --border-light:   #F1F5F9;

  --shadow-sm:      0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:         0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
  --shadow-md:      0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
  --shadow-lg:      0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
  --shadow-indigo:  0 4px 14px rgba(99,102,241,0.25);

  --radius-sm:      6px;
  --radius:         10px;
  --radius-lg:      16px;
  --radius-xl:      20px;

  --sidebar-w:      240px;
  --topbar-h:       64px;
  --transition:     0.22s ease;
}

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

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ─── Layout ─────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ─── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  position: relative;
  z-index: 100;
}

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

.logo-mark {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow: var(--shadow-indigo);
}

.logo-text {
  display: flex;
  flex-direction: column;
}

.logo-brand {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-white);
  letter-spacing: 0.5px;
  line-height: 1.2;
}

.logo-sub {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.3px;
}

/* City badge */
.city-badge {
  margin: 16px 14px;
  background: rgba(99,102,241,0.12);
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.city-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary-light);
  letter-spacing: 0.4px;
}

.city-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--success);
  border-radius: 50%;
  margin-right: 5px;
  animation: blink 2s ease infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Nav */
.nav-section {
  padding: 12px 14px 6px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  padding: 0 6px;
  margin-bottom: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 2px;
  position: relative;
}

.nav-item:hover {
  background: var(--bg-sidebar-hl);
}

.nav-item.active {
  background: rgba(99,102,241,0.15);
  border: 1px solid rgba(99,102,241,0.2);
}

.nav-item.active .nav-icon { color: var(--primary-light); }
.nav-item.active .nav-label { color: var(--text-white); }

.nav-icon {
  width: 18px;
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
  transition: color var(--transition);
  flex-shrink: 0;
}

.nav-label {
  font-size: 13px;
  font-weight: 500;
  color: #94A3B8;
  transition: color var(--transition);
}

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 20px;
  min-width: 18px;
  height: 18px;
  display: none;
  align-items: center;
  justify-content: center;
}

.nav-badge.pulse {
  animation: navPulse 1s ease 3;
}

@keyframes navPulse {
  0%,100% { transform: scale(1); }
  50% { transform: scale(1.3); }
}

/* Sidebar footer */
.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid rgba(255,255,255,0.06);
  padding: 16px 14px;
}

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

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

.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text-white); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-muted); }

/* ─── Main content area ───────────────────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ─── Top bar ────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 20px;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  z-index: 50;
  position: relative;
}

.topbar-left { flex: 1; }

.topbar-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.topbar-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

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

.live-indicator {
  display: flex;
  align-items: center;
  gap: 7px;
  background: #ECFDF5;
  border: 1px solid #A7F3D0;
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #059669;
}

.live-dot {
  width: 7px;
  height: 7px;
  background: var(--success);
  border-radius: 50%;
  animation: blink 1.5s ease infinite;
}

.clock-display {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  background: var(--bg);
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

.topbar-avatar {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 14px;
  cursor: pointer;
}

/* ─── View container ─────────────────────────────────────────── */
.view-wrapper {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.view {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: 24px 28px;
  opacity: 0;
  pointer-events: none;
  display: none;
}

.view.active {
  display: block;
  opacity: 1;
  pointer-events: all;
}

.view.animate-in {
  animation: fadeSlideIn 0.35s ease forwards;
}

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

/* ─── Card ───────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}

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

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title i {
  color: var(--primary);
  font-size: 13px;
}

/* ─── Badges & Pills ─────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.severity-low  { background: #DCFCE7; color: #15803D; }
.severity-med  { background: #FEF9C3; color: #A16207; }
.severity-high { background: #FEE2E2; color: #DC2626; }

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

.status-new          { background: #EFF6FF; color: #2563EB; border: 1px solid #BFDBFE; }
.status-monitoring   { background: #FFFBEB; color: #D97706; border: 1px solid #FDE68A; }
.status-acknowledged { background: #ECFDF5; color: #059669; border: 1px solid #A7F3D0; }

/* ─── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow-indigo);
}

.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }

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

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

/* ─── Divider ────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 16px 0; }

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

/* ─── Trend indicators ───────────────────────────────────────── */
.trend-up   { color: var(--danger);  font-size: 11px; font-weight: 600; }
.trend-down { color: var(--success); font-size: 11px; font-weight: 600; }
.trend-stable { color: var(--text-muted); font-size: 11px; }

/* ─── Section label ──────────────────────────────────────────── */
.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ─── Notifications ──────────────────────────────────────────── */
#notification-container {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.notif-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--danger);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  box-shadow: var(--shadow-lg);
  min-width: 340px;
  max-width: 400px;
  pointer-events: all;
  transform: translateX(420px);
  opacity: 0;
  transition: all 0.35s cubic-bezier(0.34,1.56,0.64,1);
}

.notif-card.show { transform: translateX(0); opacity: 1; }

.notif-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}

.notif-body { flex: 1; min-width: 0; }

.notif-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--danger);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 3px;
}

.notif-text { font-size: 13px; font-weight: 500; color: var(--text-primary); line-height: 1.3; }
.notif-meta { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.notif-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  padding: 2px;
  flex-shrink: 0;
  margin-top: -2px;
  transition: color var(--transition);
}

.notif-close:hover { color: var(--text-primary); }

/* ─── Toast ──────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 10px 20px;
  border-radius: 40px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s ease;
  pointer-events: all;
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: #ECFDF5; color: #059669; border: 1px solid #A7F3D0; }
.toast-info    { background: #EFF6FF; color: #2563EB; border: 1px solid #BFDBFE; }
.toast-warning { background: #FFFBEB; color: #D97706; border: 1px solid #FDE68A; }
.toast-error   { background: #FEF2F2; color: #DC2626; border: 1px solid #FECACA; }

/* ─── Modal overlay ──────────────────────────────────────────── */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.5);
  z-index: 500;
  display: none;
  backdrop-filter: blur(3px);
}

#modal-overlay.active { display: block; }
