/* ============================================================================
   iWITNESS CIVIC INFRASTRUCTURE - MASTER DESIGN SYSTEM & GLASSMORPHIC ENGINE
   Supports: Dark Mode (Default), Light Mode, Glassmorphism, High Readability,
             Responsive Grid, Dynamic Image Slots, PDF Analytics Styling.
   ============================================================================ */

/* ----------------------------------------------------------------------------
   1. CSS VARIABLES & DYNAMIC THEMES
   ---------------------------------------------------------------------------- */
:root {
  /* Dark Theme Default Palette */
  --bg-primary: #080c14;
  --bg-secondary: #0f172a;
  --bg-tertiary: #1e293b;

  --glass-bg: rgba(15, 23, 42, 0.75);
  --glass-bg-hover: rgba(30, 41, 59, 0.85);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-border-focus: rgba(56, 189, 248, 0.5);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.45);

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-inverse: #0f172a;

  /* Accent & Civic Status Colors */
  --accent-primary: #0284c7; /* Vibrant Civic Blue */
  --accent-primary-hover: #0369a1;
  --accent-green: #10b981; /* Verified / Success */
  --accent-yellow: #f59e0b; /* Under Review / Warning */
  --accent-red: #ef4444; /* Critical Alert / Danger */
  --accent-purple: #8b5cf6; /* Election Watch */
  --accent-cyan: #06b6d4; /* Community / Good News */

  --font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme Overrides */
[data-theme="light"] {
  --bg-primary: #f1f5f9;
  --bg-secondary: #ffffff;
  --bg-tertiary: #e2e8f0;

  --glass-bg: rgba(255, 255, 255, 0.82);
  --glass-bg-hover: rgba(241, 245, 249, 0.95);
  --glass-border: rgba(15, 23, 42, 0.12);
  --glass-border-focus: rgba(2, 132, 199, 0.6);
  --glass-shadow: 0 8px 30px 0 rgba(15, 23, 42, 0.08);

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-inverse: #f8fafc;
}

/* ----------------------------------------------------------------------------
   2. GLOBAL RESET & BASE STYLES
   ---------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  transition: background-color var(--transition-smooth), color var(--transition-smooth);
}

a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--accent-primary-hover);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ----------------------------------------------------------------------------
   3. GLASSMORPHISM UTILITY CONTAINERS
   ---------------------------------------------------------------------------- */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.glass-panel:hover {
  border-color: rgba(255, 255, 255, 0.25);
}

.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Grid Utilities */
.grid { display: grid; gap: 1.5rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* ----------------------------------------------------------------------------
   4. NAVIGATION & HEADER SYSTEM
   ---------------------------------------------------------------------------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--glass-border);
  padding: 0.85rem 0;
}

.nav-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.brand-badge {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-purple));
  color: #ffffff;
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  font-weight: 700;
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  list-style: none;
}

.nav-link {
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 500;
  transition: color var(--transition-fast);
}

.nav-link:hover, .nav-link.active {
  color: var(--text-main);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Theme Toggle Switch */
.theme-toggle-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  transition: background var(--transition-fast);
}

.theme-toggle-btn:hover {
  background: var(--glass-bg-hover);
}

/* ----------------------------------------------------------------------------
   5. BUTTONS & INTERACTIVE CONTROLS
   ---------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.35rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent-primary);
  color: #ffffff;
}
.btn-primary:hover {
  background: var(--accent-primary-hover);
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--accent-red);
  color: #ffffff;
}
.btn-danger:hover {
  opacity: 0.9;
}

.btn-success {
  background: var(--accent-green);
  color: #ffffff;
}

.btn-outline {
  background: transparent;
  border-color: var(--glass-border);
  color: var(--text-main);
}
.btn-outline:hover {
  background: var(--glass-bg-hover);
  border-color: var(--text-muted);
}

/* ----------------------------------------------------------------------------
   6. CIVIC BADGES & PRIORITY INDICATORS
   ---------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  text-transform: uppercase;
}

.badge-critical { background: rgba(239, 68, 68, 0.2); color: #fca5a5; border: 1px solid var(--accent-red); }
.badge-high { background: rgba(245, 158, 11, 0.2); color: #fcd34d; border: 1px solid var(--accent-yellow); }
.badge-verified { background: rgba(16, 185, 129, 0.2); color: #6ee7b7; border: 1px solid var(--accent-green); }
.badge-standard { background: rgba(2, 132, 199, 0.2); color: #7dd3fc; border: 1px solid var(--accent-primary); }
.badge-election { background: rgba(139, 92, 246, 0.2); color: #c4b5fd; border: 1px solid var(--accent-purple); }

/* ----------------------------------------------------------------------------
   7. DYNAMIC LANDING HERO & IMAGE SLOTS
   ---------------------------------------------------------------------------- */
.hero-section {
  position: relative;
  padding: 5rem 0 3rem;
  overflow: hidden;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 2.5rem;
  align-items: center;
}

.hero-title {
  font-size: 3rem;
  font-weight: 900;
  line-height: 1.15;
  margin-bottom: 1.25rem;
  background: linear-gradient(135deg, var(--text-main) 30%, var(--accent-primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-description {
  font-size: 1.15rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

/* Admin Dynamic Image Slot Container */
.image-slot-container {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  max-height: 420px;
}

.image-slot-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-smooth);
}

.image-slot-container:hover img {
  transform: scale(1.03);
}

/* ----------------------------------------------------------------------------
   8. METRIC & HIT COUNTER WIDGETS
   ---------------------------------------------------------------------------- */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
  margin: 2rem 0;
}

.metric-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  text-align: center;
}

.metric-number {
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--accent-primary);
  line-height: 1;
  margin-bottom: 0.35rem;
}

.metric-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.05em;
}

/* ----------------------------------------------------------------------------
   9. FORM CONTROLS & REPORTING INPUTS
   ---------------------------------------------------------------------------- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
}

.form-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
}

.form-control, .form-select, .form-textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.2);
}

.form-textarea {
  resize: vertical;
  min-height: 120px;
}

/* ----------------------------------------------------------------------------
   10. USER MANUAL & DOCUMENTATION TYPOGRAPHY
   ---------------------------------------------------------------------------- */
.manual-wrapper {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 2rem;
  margin-top: 2rem;
}

.manual-sidebar {
  position: sticky;
  top: 5rem;
  height: fit-content;
}

.manual-toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.manual-toc-link {
  display: block;
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.9rem;
  transition: all var(--transition-fast);
}

.manual-toc-link:hover, .manual-toc-link.active {
  background: var(--glass-bg-hover);
  color: var(--accent-primary);
  font-weight: 600;
}

.manual-content h2 {
  font-size: 1.75rem;
  margin: 1.5rem 0 0.85rem;
  color: var(--text-main);
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 0.5rem;
}

.manual-content p {
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* ----------------------------------------------------------------------------
   11. FOOTER & EXPORT STYLES
   ---------------------------------------------------------------------------- */
.footer {
  margin-top: auto;
  border-top: 1px solid var(--glass-border);
  padding: 2.5rem 0;
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-size: 0.9rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}

/* Printable PDF Export Support */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  .navbar, .footer, .btn, .theme-toggle-btn {
    display: none !important;
  }
  .glass-panel, .glass-card {
    border: 1px solid #cccccc !important;
    box-shadow: none !important;
    background: #ffffff !important;
  }
}

/* ----------------------------------------------------------------------------
   12. RESPONSIVE MOBILE BREAKPOINTS
   ---------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; }
  .manual-wrapper { grid-template-columns: 1fr; }
  .manual-sidebar { position: static; }
  .nav-menu { display: none; } /* Expanded in mobile menu implementation */
  .hero-title { font-size: 2.25rem; }
}