/* ============================================================
   MUNICIPIO CONECTADO - CSS Principal
   Design System: Municipal / Civic Tech
   ============================================================ */

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

/* ============================================================
   CSS VARIABLES - Design Tokens
   ============================================================ */
:root {
  --primary:        #1e40af;
  --primary-dark:   #1e3a8a;
  --primary-light:  #eff6ff;
  --secondary:      #0ea5e9;
  --success:        #10b981;
  --warning:        #f59e0b;
  --danger:         #ef4444;
  --info:           #6366f1;

  --text-primary:   #111827;
  --text-secondary: #6b7280;
  --text-tertiary:  #9ca3af;

  --bg:             #f9fafb;
  --bg-subtle:      #f3f4f6;
  --card-bg:        #ffffff;
  --input-bg:       #ffffff;
  --border:         #e5e7eb;
  --border-dark:    #d1d5db;

  --shadow-sm:  0 1px 2px rgba(0,0,0,0.05);
  --shadow:     0 4px 6px -1px rgba(0,0,0,0.1);
  --shadow-lg:  0 10px 15px -3px rgba(0,0,0,0.1);
  --shadow-xl:  0 20px 25px -5px rgba(0,0,0,0.1);

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

  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body:    'Inter', system-ui, sans-serif;

  --navbar-h: 64px;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  padding-top: var(--navbar-h);
}

img { max-width: 100%; display: block; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ============================================================
   NAVBAR
   ============================================================ */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--navbar-h);
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 1000;
  transition: box-shadow 0.2s;
}

.navbar.scrolled { box-shadow: var(--shadow); }

.nav-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  text-decoration: none;
  flex-shrink: 0;
}

.brand-icon {
  font-size: 1.75rem;
  line-height: 1;
}

.brand-name {
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.0625rem;
  color: var(--text-primary);
  line-height: 1.1;
}

.brand-tagline {
  display: block;
  font-size: 0.6875rem;
  color: var(--text-secondary);
  font-weight: 400;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav-link {
  padding: 0.4375rem 0.875rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
}

.nav-link:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
  text-decoration: none;
}

.nav-cta {
  background: var(--primary) !important;
  color: white !important;
  font-weight: 600;
}

.nav-cta:hover {
  background: var(--primary-dark) !important;
  color: white !important;
}

.btn-nav-registro {
  padding: 0.4375rem 1rem;
  border: 1.5px solid var(--primary);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  transition: all 0.15s;
}

.btn-nav-registro:hover {
  background: var(--primary);
  color: white;
  text-decoration: none;
}

/* User dropdown */
.nav-user { position: relative; }

.nav-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-weight: 700;
  font-size: 0.875rem;
  border: none;
  cursor: pointer;
  transition: transform 0.15s;
}

.nav-avatar:hover { transform: scale(1.05); }

.user-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  padding: 0.5rem;
  display: none;
}

.user-dropdown.open { display: block; }

.dropdown-header {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.375rem;
  font-size: 0.875rem;
}

.badge-puntos {
  display: block;
  font-size: 0.75rem;
  color: var(--warning);
  font-weight: 600;
  margin-top: 0.125rem;
}

.dropdown-item {
  display: block;
  padding: 0.4375rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: var(--text-primary);
  text-decoration: none;
  transition: background 0.15s;
}

.dropdown-item:hover {
  background: var(--bg-subtle);
  text-decoration: none;
}

.dropdown-divider { border: none; border-top: 1px solid var(--border); margin: 0.375rem 0; }
.dropdown-admin { color: var(--primary) !important; font-weight: 600; }
.dropdown-logout { color: var(--danger) !important; }

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}

.nav-toggle span {
  width: 22px; height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: all 0.2s;
}

/* ============================================================
   ALERTAS FLASH
   ============================================================ */
.alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.875rem 1.25rem;
  font-size: 0.9375rem;
  border-left: 4px solid transparent;
  position: relative;
  z-index: 100;
}

.alert-exito  { background: #ecfdf5; border-color: var(--success); color: #065f46; }
.alert-error  { background: #fef2f2; border-color: var(--danger); color: #991b1b; }
.alert-warning { background: #fffbeb; border-color: var(--warning); color: #92400e; }

.alert-close {
  background: none; border: none; cursor: pointer;
  font-size: 1.25rem; color: currentColor; opacity: 0.7;
  flex-shrink: 0;
}

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
  background: var(--text-primary);
  color: rgba(255,255,255,0.8);
  padding: 3rem 0 0;
  margin-top: 4rem;
}

.footer-inner {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 3rem;
  padding-bottom: 2.5rem;
}

.footer-logo {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 700;
  color: white;
  display: block;
  margin-bottom: 0.5rem;
}

.footer-brand p {
  font-size: 0.875rem;
  line-height: 1.6;
  max-width: 280px;
}

.footer-links {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.footer-links strong {
  display: block;
  color: white;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  font-family: var(--font-display);
}

.footer-links a {
  display: block;
  color: rgba(255,255,255,0.6);
  font-size: 0.875rem;
  padding: 0.1875rem 0;
  transition: color 0.15s;
}

.footer-links a:hover { color: white; text-decoration: none; }

.footer-bottom {
  border-top: 1px solid rgba(255,255,255,0.1);
  padding: 1.125rem 0;
  text-align: center;
  font-size: 0.8125rem;
  color: rgba(255,255,255,0.5);
}

/* ============================================================
   COMPONENTS - Badges de estado
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1875rem 0.625rem;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-pendiente  { background: #fef3c7; color: #92400e; }
.badge-validando  { background: #ede9fe; color: #5b21b6; }
.badge-asignado   { background: #dbeafe; color: #1e40af; }
.badge-en_proceso { background: #fef9c3; color: #713f12; }
.badge-resuelto   { background: #dcfce7; color: #14532d; }
.badge-rechazado  { background: #fee2e2; color: #7f1d1d; }
.badge-duplicado  { background: #f3f4f6; color: #374151; }

.badge-baja    { background: #f3f4f6; color: #374151; }
.badge-media   { background: #fef9c3; color: #713f12; }
.badge-alta    { background: #fed7aa; color: #7c2d12; }
.badge-urgente { background: #fee2e2; color: #7f1d1d; }

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

.card-body { padding: 1.25rem; }
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ============================================================
   COMPONENTS - Botones
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5625rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); color: white; text-decoration: none; }

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

.btn-success { background: var(--success); color: white; }
.btn-danger  { background: var(--danger); color: white; }

.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
#toastContainer {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.875rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.25s ease;
  max-width: 320px;
}

.toast-success { background: var(--success); color: white; }
.toast-error   { background: var(--danger); color: white; }
.toast-warning { background: var(--warning); color: white; }
.toast-info    { background: var(--primary); color: white; }

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

/* ============================================================
   TABLA ADMIN
   ============================================================ */
.tabla-admin {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.tabla-admin th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border);
  background: var(--bg-subtle);
  white-space: nowrap;
}

.tabla-admin td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.tabla-admin tr:hover td { background: var(--primary-light); }
.tabla-admin tr:last-child td { border-bottom: none; }

/* ============================================================
   STATS CARDS
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text-primary);
}

.stat-label {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.stat-change {
  font-size: 0.75rem;
  margin-top: 0.5rem;
  font-weight: 600;
}

.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ============================================================
   GAMIFICACIÓN
   ============================================================ */
.nivel-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.nivel-1 { background: #f3f4f6; color: #374151; }
.nivel-2 { background: #fef3c7; color: #92400e; }
.nivel-3 { background: #dcfce7; color: #14532d; }
.nivel-4 { background: #ede9fe; color: #4c1d95; }

.puntos-bar {
  background: var(--border);
  border-radius: 100px;
  height: 8px;
  overflow: hidden;
}

.puntos-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 100px;
  transition: width 0.6s ease;
}

/* ============================================================
   MAPA
   ============================================================ */
#mapa-publico, #mapa-admin {
  height: 600px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.leaflet-container { font-family: var(--font-body) !important; }

.reporte-popup { max-width: 220px; }
.reporte-popup h4 { font-size: 0.875rem; font-weight: 600; margin-bottom: 0.25rem; }
.reporte-popup p  { font-size: 0.8125rem; color: var(--text-secondary); }

/* ============================================================
   PANEL ADMIN - Sidebar
   ============================================================ */
.admin-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: calc(100vh - var(--navbar-h));
}

.admin-sidebar {
  background: var(--text-primary);
  padding: 1.5rem 0;
  position: sticky;
  top: var(--navbar-h);
  height: calc(100vh - var(--navbar-h));
  overflow-y: auto;
}

.sidebar-section { margin-bottom: 0.25rem; }

.sidebar-title {
  padding: 0.25rem 1.25rem;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.4);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5625rem 1.25rem;
  font-size: 0.875rem;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.sidebar-link:hover {
  background: rgba(255,255,255,0.07);
  color: white;
  text-decoration: none;
}

.sidebar-link.active {
  background: rgba(255,255,255,0.1);
  color: white;
  border-left-color: var(--secondary);
}

.sidebar-badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 0 0.375rem;
  border-radius: 100px;
  min-width: 18px;
  text-align: center;
}

.admin-content {
  padding: 1.75rem;
  overflow-x: hidden;
}

.admin-page-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .nav-links {
    display: none;
    position: absolute;
    top: var(--navbar-h);
    left: 0; right: 0;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 1rem;
    gap: 0.25rem;
    box-shadow: var(--shadow-lg);
  }

  .nav-links.open { display: flex; }
  .nav-toggle { display: flex; }

  .footer-inner { grid-template-columns: 1fr; gap: 2rem; }
  .footer-links { grid-template-columns: repeat(2, 1fr); }

  .admin-layout { grid-template-columns: 1fr; }
  .admin-sidebar { display: none; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .footer-links { grid-template-columns: 1fr; }
}
