/**
 * CivicLink CT — Nano Banana Pro Design System
 * Design tokens, components și utilitare
 */

/* ─── Reset & Base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { 
  -webkit-font-smoothing: antialiased; 
  -moz-osx-font-smoothing: grayscale;
  background: #F2F4F7;
}
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font: inherit; }

/* ─── Nano Banana Design Tokens ────────────────────────────────────────────── */
:root {
  /* Primary Colors */
  --nb-navy: #1B3A5C;
  --nb-navy-dark: #0D2E4A;
  --nb-teal: #2A9D8F;
  --nb-teal-dark: #1E8080;
  --nb-teal-light: #E8F7F5;

  /* Semantic Colors */
  --nb-amber: #E9A23B;
  --nb-amber-dark: #C4841A;
  --nb-green: #27AE60;
  --nb-green-light: #E8F5E9;
  --nb-blue: #2F80ED;
  --nb-blue-light: #EBF4FF;
  --nb-red: #EB5757;
  --nb-red-light: #FDEAEA;
  --nb-orange: #F4A261;
  --nb-orange-light: #FFF3E0;

  /* Text Colors */
  --nb-text-primary: #1B3A5C;
  --nb-text-secondary: #6B7280;
  --nb-text-placeholder: #9CA3AF;
  --nb-text-white: #FFFFFF;
  --nb-text-white-dim: rgba(255,255,255,0.65);

  /* Background Colors */
  --nb-bg-page: #F2F4F7;
  --nb-bg-card: #FFFFFF;
  --nb-bg-header: #1B3A5C;
  --nb-bg-input: #FFFFFF;

  /* Borders */
  --nb-border: #D1D5DB;
  --nb-border-light: #E5E7EB;
  --nb-border-focus: #2A9D8F;

  /* Spacing */
  --nb-page-pad: 16px;
  --nb-section-gap: 16px;
  --nb-card-pad: 16px;

  /* Radius */
  --nb-radius-sm: 8px;
  --nb-radius-md: 10px;
  --nb-radius-lg: 12px;
  --nb-radius-xl: 16px;
  --nb-radius-2xl: 20px;
  --nb-radius-full: 9999px;

  /* Shadows */
  --nb-shadow-card: 0 2px 8px rgba(0,0,0,0.06);
  --nb-shadow-card-hover: 0 4px 16px rgba(0,0,0,0.10);
  --nb-shadow-fab: 0 4px 12px rgba(42,157,143,0.4);
  --nb-shadow-header: 0 2px 8px rgba(0,0,0,0.12);
  --nb-shadow-modal: 0 20px 60px rgba(0,0,0,0.2);

  /* Typography */
  --nb-font: 'Inter', system-ui, sans-serif;
  --nb-font-title: 24px;
  --nb-font-h1: 22px;
  --nb-font-h2: 18px;
  --nb-font-h3: 16px;
  --nb-font-body: 15px;
  --nb-font-sm: 14px;
  --nb-font-xs: 13px;
  --nb-font-xxs: 12px;
}

/* ─── Layout Shell ────────────────────────────────────────────────────────── */
#app {
  min-height: 100vh;
  font-family: var(--nb-font);
  color: var(--nb-text-primary);
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  background: var(--nb-bg-page);
}

/* ─── Header ──────────────────────────────────────────────────────────────── */
.nb-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--nb-bg-header);
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 var(--nb-page-pad);
  box-shadow: var(--nb-shadow-header);
  max-width: 480px;
  margin: 0 auto;
}

/* ─── Bottom Nav ──────────────────────────────────────────────────────────── */
.nb-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  background: #FFFFFF;
  border-top: 1px solid var(--nb-border-light);
  height: 62px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  max-width: 480px;
  margin: 0 auto;
}

.nb-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 4px;
  color: var(--nb-text-placeholder);
  transition: color 0.15s;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
}

.nb-nav-item span {
  font-size: 10px;
  font-weight: 500;
  line-height: 1;
}

.nb-nav-item.nav-active,
.nb-nav-item:focus,
.nb-nav-item[class*="nav-active"] {
  color: var(--nb-navy);
}

.nb-nav-item svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

/* ─── Page Container ──────────────────────────────────────────────────────── */
.nb-page {
  padding-top: 56px;
  padding-bottom: 70px;
  min-height: 100vh;
  background: var(--nb-bg-page);
}

/* ─── Cards ───────────────────────────────────────────────────────────────── */
.nb-card {
  background: var(--nb-bg-card);
  border-radius: var(--nb-radius-xl);
  box-shadow: var(--nb-shadow-card);
  padding: var(--nb-card-pad);
}

.nb-card:hover {
  box-shadow: var(--nb-shadow-card-hover);
}

/* ─── Inputs ──────────────────────────────────────────────────────────────── */
.nb-input {
  width: 100%;
  background: var(--nb-bg-input);
  border: 1.5px solid var(--nb-border);
  border-radius: var(--nb-radius-md);
  padding: 13px 16px;
  font-size: var(--nb-font-sm);
  color: var(--nb-text-primary);
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
  appearance: none;
  font-family: var(--nb-font);
  height: 52px;
}

.nb-input::placeholder {
  color: var(--nb-text-placeholder);
}

.nb-input:focus {
  border-color: var(--nb-border-focus);
  box-shadow: 0 0 0 3px rgba(42,157,143,0.12);
}

.nb-input-label {
  display: block;
  font-size: var(--nb-font-xs);
  font-weight: 600;
  color: var(--nb-text-secondary);
  margin-bottom: 6px;
}

.nb-textarea {
  width: 100%;
  background: var(--nb-bg-input);
  border: 1.5px solid var(--nb-border);
  border-radius: var(--nb-radius-md);
  padding: 13px 16px;
  font-size: var(--nb-font-sm);
  color: var(--nb-text-primary);
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
  appearance: none;
  font-family: var(--nb-font);
  resize: none;
  min-height: 100px;
}

.nb-textarea::placeholder {
  color: var(--nb-text-placeholder);
}

.nb-textarea:focus {
  border-color: var(--nb-border-focus);
  box-shadow: 0 0 0 3px rgba(42,157,143,0.12);
}

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
.nb-btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 52px;
  background: var(--nb-teal);
  color: var(--nb-text-white);
  font-size: 16px;
  font-weight: 700;
  border-radius: var(--nb-radius-md);
  transition: background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  font-family: var(--nb-font);
}

.nb-btn-primary:active {
  transform: scale(0.98);
  background: var(--nb-teal-dark);
}

.nb-btn-primary:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.nb-btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 52px;
  background: transparent;
  color: var(--nb-teal);
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--nb-radius-md);
  border: 1.5px solid var(--nb-teal);
  transition: all 0.15s;
  font-family: var(--nb-font);
}

.nb-btn-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--nb-teal);
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  transition: background 0.15s;
  font-family: var(--nb-font);
  height: 36px;
}

.nb-btn-sm:active {
  background: var(--nb-teal-dark);
}

/* ─── Status Badges ───────────────────────────────────────────────────────── */
.nb-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--nb-radius-full);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.nb-badge-green { background: var(--nb-green-light); color: var(--nb-green); }
.nb-badge-orange { background: var(--nb-orange-light); color: #C4680A; }
.nb-badge-blue { background: var(--nb-blue-light); color: var(--nb-blue); }
.nb-badge-red { background: var(--nb-red-light); color: var(--nb-red); }
.nb-badge-gray { background: #F3F4F6; color: #6B7280; }
.nb-badge-teal { background: var(--nb-teal-light); color: var(--nb-teal-dark); }

/* ─── Header Banner ───────────────────────────────────────────────────────── */
.nb-hero {
  background: linear-gradient(135deg, var(--nb-navy) 0%, var(--nb-navy-dark) 100%);
  padding: 24px var(--nb-page-pad) 28px;
  position: relative;
  overflow: hidden;
}

.nb-hero::before {
  content: '';
  position: absolute;
  top: -40px;
  right: -40px;
  width: 140px;
  height: 140px;
  background: var(--nb-teal);
  border-radius: 50%;
  opacity: 0.15;
}

.nb-hero::after {
  content: '';
  position: absolute;
  top: 12px;
  right: 16px;
  width: 64px;
  height: 64px;
  background: var(--nb-teal);
  border-radius: 50%;
  opacity: 0.08;
}

/* ─── Stat Card ───────────────────────────────────────────────────────────── */
.nb-stat-card {
  background: var(--nb-bg-card);
  border-radius: var(--nb-radius-lg);
  padding: 12px 8px;
  text-align: center;
  box-shadow: var(--nb-shadow-card);
}

.nb-stat-number {
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}

.nb-stat-label {
  font-size: 11px;
  color: var(--nb-text-placeholder);
  font-weight: 400;
}

/* ─── Quick Action Card ───────────────────────────────────────────────────── */
.nb-action-card {
  display: flex;
  flex-direction: column;
  padding: 16px;
  border-radius: var(--nb-radius-xl);
  min-height: 90px;
  text-decoration: none;
  transition: transform 0.15s, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.nb-action-card:active {
  transform: scale(0.97);
  opacity: 0.9;
}

.nb-action-card svg {
  margin-bottom: 10px;
}

.nb-action-card-label {
  font-size: 13px;
  font-weight: 600;
  color: #FFFFFF;
  line-height: 1.3;
}

/* ─── Issue List Item ─────────────────────────────────────────────────────── */
.nb-issue-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px var(--nb-page-pad);
  background: var(--nb-bg-card);
  border-bottom: 1px solid var(--nb-border-light);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s;
  text-decoration: none;
  color: inherit;
}

.nb-issue-row:last-child { border-bottom: none; }

.nb-issue-row:active { background: #F9FAFB; }

.nb-issue-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

/* ─── Section Header ──────────────────────────────────────────────────────── */
.nb-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--nb-page-pad);
  margin-bottom: 8px;
}

.nb-section-title {
  font-size: var(--nb-font-h3);
  font-weight: 700;
  color: var(--nb-text-primary);
}

.nb-section-link {
  font-size: var(--nb-font-xs);
  font-weight: 600;
  color: var(--nb-teal);
}

/* ─── FAB Button ──────────────────────────────────────────────────────────── */
.nb-fab {
  position: fixed;
  bottom: 80px;
  right: 16px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--nb-teal);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--nb-shadow-fab);
  z-index: 30;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s;
  text-decoration: none;
}

.nb-fab:active { transform: scale(0.95); }

/* ─── Modal ───────────────────────────────────────────────────────────────── */
.nb-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.nb-modal {
  background: #FFFFFF;
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s cubic-bezier(0.16,1,0.3,1);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.nb-modal-handle {
  width: 36px;
  height: 4px;
  background: #E5E7EB;
  border-radius: 2px;
  margin: 12px auto 0;
}

.nb-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--nb-border-light);
}

.nb-modal-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--nb-text-primary);
}

.nb-modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #F3F4F6;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6B7280;
  font-size: 16px;
  transition: background 0.15s;
}

.nb-modal-close:hover { background: #E5E7EB; }

.nb-modal-body {
  padding: 16px 20px;
}

/* ─── Toast ───────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: 64px;
  right: 12px;
  left: 12px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.nb-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  color: #FFFFFF;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  animation: slideInRight 0.3s cubic-bezier(0.16,1,0.3,1);
  pointer-events: auto;
}

.nb-toast-success { background: var(--nb-green); }
.nb-toast-error { background: var(--nb-red); }
.nb-toast-warning { background: var(--nb-amber); }
.nb-toast-info { background: var(--nb-navy); }

/* ─── Page Back Header ────────────────────────────────────────────────────── */
.nb-page-header {
  background: var(--nb-teal);
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 var(--nb-page-pad);
  gap: 12px;
}

.nb-page-header-title {
  font-size: 17px;
  font-weight: 700;
  color: #FFFFFF;
  flex: 1;
  text-align: center;
}

.nb-back-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

/* ─── Skeleton ────────────────────────────────────────────────────────────── */
.nb-skeleton {
  background: linear-gradient(90deg, #F3F4F6 25%, #E9EAEB 50%, #F3F4F6 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 8px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ─── Filter Tabs ─────────────────────────────────────────────────────────── */
.nb-filter-tabs {
  display: flex;
  gap: 8px;
  padding: 12px var(--nb-page-pad);
  overflow-x: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.nb-filter-tabs::-webkit-scrollbar { display: none; }

.nb-filter-tab {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: var(--nb-radius-full);
  font-size: 13px;
  font-weight: 500;
  border: 1.5px solid var(--nb-border);
  background: #FFFFFF;
  color: var(--nb-text-secondary);
  transition: all 0.15s;
  white-space: nowrap;
}

.nb-filter-tab.active {
  background: var(--nb-navy);
  border-color: var(--nb-navy);
  color: #FFFFFF;
}

/* ─── Info Row ────────────────────────────────────────────────────────────── */
.nb-info-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--nb-border-light);
}

.nb-info-row:last-child { border-bottom: none; }

.nb-info-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--nb-teal-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--nb-teal);
}

/* ─── Segment Control ─────────────────────────────────────────────────────── */
.nb-segment {
  display: flex;
  background: #F3F4F6;
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}

.nb-segment-btn {
  flex: 1;
  padding: 8px 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--nb-text-secondary);
  border-radius: 8px;
  transition: all 0.2s;
  text-align: center;
}

.nb-segment-btn.active {
  background: #FFFFFF;
  color: var(--nb-navy);
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

/* ─── Leaflet Overrides ────────────────────────────────────────────────────── */
.leaflet-container { font-family: var(--nb-font); }
.leaflet-popup-content-wrapper {
  border-radius: 12px !important;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15) !important;
  padding: 0 !important;
  overflow: hidden;
}
.leaflet-popup-content { margin: 12px 14px !important; }
.leaflet-popup-tip-container { display: none; }
.leaflet-control-attribution { font-size: 9px !important; }
.leaflet-control-zoom a {
  border-radius: 8px !important;
  font-size: 18px !important;
  line-height: 30px !important;
}

/* ─── Animations ──────────────────────────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: translateX(0); } }
@keyframes fadeInPage { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

#main-content > * { animation: fadeInPage 0.25s ease-out; }

/* ─── Scrollbar ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 3px; height: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(42,157,143,0.25); border-radius: 3px; }

/* ─── Utility ──────────────────────────────────────────────────────────────── */
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }
.no-scrollbar::-webkit-scrollbar { display: none; }
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Legacy compatibility */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; background: var(--nb-teal); color: #FFFFFF;
  font-size: 14px; font-weight: 700; border-radius: 10px;
  transition: background 0.15s; border: none; cursor: pointer;
  font-family: var(--nb-font);
}
.btn-primary:hover { background: var(--nb-teal-dark); }

.btn-outline {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; background: transparent; color: var(--nb-teal);
  font-size: 14px; font-weight: 600; border-radius: 10px;
  border: 1.5px solid var(--nb-teal); transition: all 0.15s;
  font-family: var(--nb-font);
}
.btn-outline-light {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.85);
  font-size: 13px; font-weight: 600; border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.2); transition: all 0.15s;
  font-family: var(--nb-font);
}

.shadow-card { box-shadow: var(--nb-shadow-card); }
.shadow-card-hover { box-shadow: var(--nb-shadow-card-hover); }

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (min-width: 480px) {
  #app { box-shadow: 0 0 40px rgba(0,0,0,0.08); }
  .nb-header, .nb-bottom-nav { left: 50%; transform: translateX(-50%); width: 480px; right: auto; }
}

@media (max-width: 480px) {
  .leaflet-control-zoom { display: none; }
  a, button { -webkit-tap-highlight-color: transparent; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

@media print {
  .nb-header, .nb-bottom-nav, #pwa-install-banner { display: none !important; }
  #main-content { padding-top: 0 !important; }
}

/* ─── Timeline ─────────────────────────────────────────────────────────────── */
.timeline-item { position: relative; padding-left: 28px; }
.timeline-item::before {
  content: ''; position: absolute; left: 8px; top: 28px; bottom: -16px;
  width: 1px; background: #E2E8F0;
}
.timeline-item:last-child::before { display: none; }

/* ─── Table Row ────────────────────────────────────────────────────────────── */
.table-row { 
  display: flex; align-items: center; padding: 12px 16px;
  border-bottom: 1px solid #F1F5F9; transition: background 0.1s;
  cursor: pointer;
}
.table-row:hover { background: #F8FAFC; }
.table-row:last-child { border-bottom: none; }

/* ─── Priority Dots ────────────────────────────────────────────────────────── */
.priority-dot-low { color: #27AE60; }
.priority-dot-medium { color: #E9A23B; }
.priority-dot-high { color: #F97316; }
.priority-dot-critical { color: #EB5757; }

/* ─── Spinner ─────────────────────────────────────────────────────────────── */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
