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

html {
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
}

body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  letter-spacing: -0.01em;
  transition: background-color 0.15s ease, color 0.15s ease;
  padding-bottom: env(safe-area-inset-bottom);
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
}

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

/* Prevent automatic viewport zoom on iOS Safari when tapping inputs */
@media (max-width: 768px) {
  input, select, textarea {
    font-size: 16px !important;
  }
}

/* Smooth scrolling and native momentum on iOS Safari */
.overflow-x-auto, .overflow-y-auto, .touch-pan-x, .touch-pan-y {
  -webkit-overflow-scrolling: touch;
}

.scrollbar-none::-webkit-scrollbar,
.no-scrollbar::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}
.scrollbar-none,
.no-scrollbar {
  -ms-overflow-style: none !important;
  scrollbar-width: none !important;
}

[v-cloak] {
  display: none !important;
}

/* Custom Scrollbars - Dark Theme (Default) */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: #0b0f17;
}

::-webkit-scrollbar-thumb {
  background: #1e293b;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #334155;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.animate-fade {
  animation: fadeIn 0.15s ease-out forwards;
}

/* ==============================================================================
   LIGHT MODE COMPLETE THEME OVERRIDES (Triggered whenever html is not dark)
   ============================================================================== */
html:not(.dark) {
  color-scheme: light;
}

html.dark {
  color-scheme: dark;
}

html:not(.dark) body {
  background-color: #f8fafc !important;
  color: #0f172a !important;
}

/* Segmented Theme Switcher */
.theme-switch {
  display: inline-flex !important;
  align-items: center;
  padding: 3px !important;
  border-radius: 12px !important;
  gap: 3px;
}

html.dark .theme-switch {
  background-color: #0f172a !important;
  border: 1px solid #334155 !important;
}

html:not(.dark) .theme-switch {
  background-color: #e2e8f0 !important;
  border: 1px solid #cbd5e1 !important;
}

.theme-switch button {
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  padding: 4px 10px !important;
  border-radius: 8px !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  border: 1px solid transparent !important;
  transition: all 0.15s ease-in-out !important;
  outline: none !important;
  box-shadow: none !important;
}

html.dark .theme-switch button.active {
  background-color: #1e293b !important;
  color: #ffffff !important;
  border-color: #475569 !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4) !important;
}

html.dark .theme-switch button:not(.active) {
  background-color: transparent !important;
  color: #94a3b8 !important;
  border-color: transparent !important;
}

html.dark .theme-switch button:not(.active):hover {
  color: #ffffff !important;
}

html:not(.dark) .theme-switch button.active {
  background-color: #ffffff !important;
  color: #0f172a !important;
  border-color: #cbd5e1 !important;
  box-shadow: 0 2px 4px rgba(0,0,0,0.08) !important;
}

html:not(.dark) .theme-switch button:not(.active) {
  background-color: transparent !important;
  color: #64748b !important;
  border-color: transparent !important;
}

html:not(.dark) .theme-switch button:not(.active):hover {
  color: #0f172a !important;
}

/* Header & Navigation Bar */
html:not(.dark) header {
  background-color: rgba(255, 255, 255, 0.96) !important;
  border-color: #e2e8f0 !important;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
}

html:not(.dark) header .border-t {
  border-color: #e2e8f0 !important;
}

html:not(.dark) header button {
  color: #475569;
}

html:not(.dark) header button:hover {
  color: #0f172a !important;
  background-color: #f1f5f9 !important;
}

html:not(.dark) header button.text-red-400 {
  color: #dc2626 !important;
  background-color: #fef2f2 !important;
}

/* All Surface Panels & Cards */
html:not(.dark) [class*="bg-slate-900"],
html:not(.dark) .bg-slate-900 {
  background-color: #ffffff !important;
  border-color: #e2e8f0 !important;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.04), 0 1px 2px -1px rgba(0, 0, 0, 0.03) !important;
}

/* Sub-panels, Table Wrappers & Nested Containers */
html:not(.dark) [class*="bg-slate-950"],
html:not(.dark) .bg-slate-950 {
  background-color: #f8fafc !important;
  border-color: #e2e8f0 !important;
}

/* Border Colors */
html:not(.dark) [class*="border-slate-800"],
html:not(.dark) .border-slate-800,
html:not(.dark) [class*="border-slate-700"],
html:not(.dark) .border-slate-700 {
  border-color: #e2e8f0 !important;
}

html:not(.dark) [class*="divide-slate-800"] > *,
html:not(.dark) .divide-slate-800 > * {
  border-color: #f1f5f9 !important;
}

/* Typography Hierarchy */
html:not(.dark) .text-white,
html:not(.dark) .text-slate-100,
html:not(.dark) .text-slate-200 {
  color: #0f172a !important;
}

html:not(.dark) .text-slate-300,
html:not(.dark) .text-slate-400 {
  color: #475569 !important;
}

html:not(.dark) .text-slate-500 {
  color: #64748b !important;
}

/* Safeguard white text on colored backgrounds, badges, and buttons */
html:not(.dark) .bg-red-600,
html:not(.dark) [class*="bg-red-600"],
html:not(.dark) .bg-red-500,
html:not(.dark) [class*="from-red-600"],
html:not(.dark) button[class*="bg-red-600"] *,
html:not(.dark) button[class*="bg-red-600"],
html:not(.dark) .bg-red-600 .text-white,
html:not(.dark) .bg-red-600 span,
html:not(.dark) .bg-red-600 i,
html:not(.dark) .bg-gradient-to-tr i,
html:not(.dark) .shadow-red-600\/30 i {
  color: #ffffff !important;
}

/* Form Controls (Inputs, Selects, Textareas) */
html:not(.dark) input,
html:not(.dark) select,
html:not(.dark) textarea {
  background-color: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02) !important;
}

html:not(.dark) input::placeholder {
  color: #94a3b8 !important;
}

html:not(.dark) input:focus,
html:not(.dark) select:focus,
html:not(.dark) textarea:focus {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.15) !important;
}

/* Buttons */
html:not(.dark) .bg-slate-800 {
  background-color: #f1f5f9 !important;
  color: #334155 !important;
  border-color: #cbd5e1 !important;
}

html:not(.dark) .bg-slate-800:hover,
html:not(.dark) .hover\:bg-slate-700:hover,
html:not(.dark) .hover\:bg-slate-800:hover {
  background-color: #e2e8f0 !important;
  color: #0f172a !important;
}

html:not(.dark) button.bg-slate-800:disabled {
  background-color: #f1f5f9 !important;
  opacity: 0.5;
}

/* Tables */
html:not(.dark) thead,
html:not(.dark) thead.bg-slate-950\/60 {
  background-color: #f1f5f9 !important;
  border-color: #e2e8f0 !important;
}

html:not(.dark) thead th {
  color: #475569 !important;
}

html:not(.dark) tbody tr {
  border-color: #f1f5f9 !important;
}

html:not(.dark) tbody tr:hover,
html:not(.dark) [class*="hover:bg-slate-800"]:hover {
  background-color: #f1f5f9 !important;
}

/* Modal */
html:not(.dark) .fixed.inset-0.bg-black\/85 {
  background-color: rgba(15, 23, 42, 0.5) !important;
}

html:not(.dark) .fixed.inset-0 [class*="bg-slate-900"] {
  background-color: #ffffff !important;
  border-color: #e2e8f0 !important;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1) !important;
}

html:not(.dark) .fixed.inset-0 [class*="bg-slate-950"] {
  background-color: #f8fafc !important;
  border-color: #e2e8f0 !important;
}

/* Light Scrollbars */
html:not(.dark) ::-webkit-scrollbar-track {
  background: #f1f5f9;
}

html:not(.dark) ::-webkit-scrollbar-thumb {
  background: #cbd5e1;
}

html:not(.dark) ::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Leaflet Map Customizations (Dark & Light Theme) */
.leaflet-popup-content-wrapper {
  background: #0f172a !important;
  color: #f8fafc !important;
  border: 1px solid #334155 !important;
  border-radius: 12px !important;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5) !important;
  padding: 4px !important;
}
.leaflet-popup-tip {
  background: #0f172a !important;
}
.leaflet-container {
  background: #0b0f17 !important;
  font-family: inherit !important;
  border-radius: 1rem !important;
}
html:not(.dark) .leaflet-popup-content-wrapper {
  background: #ffffff !important;
  color: #0f172a !important;
  border: 1px solid #cbd5e1 !important;
}
html:not(.dark) .leaflet-popup-tip {
  background: #ffffff !important;
}
.custom-qv-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: bold;
  box-shadow: 0 0 10px rgba(0,0,0,0.5);
  border: 2px solid white;
}

/* Mobile Bottom Navigation & Safe Area Adjustments */
.safe-area-bottom {
  padding-bottom: env(safe-area-inset-bottom, 16px);
}

@media (max-width: 768px) {
  .touch-target-large {
    min-height: 44px;
  }
}

/* Bottom Navigation Bar Light Mode Overrides */
html:not(.dark) nav.mobile-bottom-nav {
  background-color: rgba(255, 255, 255, 0.98) !important;
  border-color: #e2e8f0 !important;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.06) !important;
}

html:not(.dark) nav.mobile-bottom-nav button {
  color: #64748b;
}

html:not(.dark) nav.mobile-bottom-nav button.text-red-500 {
  color: #dc2626 !important;
}

html:not(.dark) nav.mobile-bottom-nav button.text-amber-500 {
  color: #d97706 !important;
}

html:not(.dark) nav.mobile-bottom-nav button.text-emerald-500 {
  color: #059669 !important;
}

html:not(.dark) .mobile-drawer-sheet {
  background-color: #ffffff !important;
  border-color: #e2e8f0 !important;
  box-shadow: 0 -10px 25px -5px rgba(0, 0, 0, 0.1) !important;
}

/* Floating Map Controls */
.map-floating-controls {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Fullscreen Map Styles */
.leaflet-map-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  z-index: 40 !important;
  width: 100vw !important;
  height: 100vh !important;
  border-radius: 0 !important;
  border: none !important;
  margin: 0 !important;
}

/* User GPS Pulse Animation */
@keyframes userPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    box-shadow: 0 0 0 16px rgba(16, 185, 129, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

.user-gps-pulse > div {
  animation: userPulse 2s infinite;
}

/* Citizen Marker Pulse Animation */
@keyframes citizenPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7);
  }
  70% {
    box-shadow: 0 0 0 16px rgba(59, 130, 246, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
  }
}

.citizen-marker-pulse > div {
  animation: citizenPulse 2s infinite;
}

/* Copy Toast Notification */
.toast-slide-enter-active,
.toast-slide-leave-active {
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.toast-slide-enter-from,
.toast-slide-leave-to {
  opacity: 0;
  transform: translateY(12px) scale(0.95);
}

/* Print Stylesheet for Formal Intelligence Dossiers */
@media print {
  header,
  nav,
  .mobile-bottom-nav,
  .mobile-drawer-sheet,
  button,
  .theme-switch,
  .no-print {
    display: none !important;
  }

  body, html, #app {
    background: #ffffff !important;
    color: #000000 !important;
    padding: 0 !important;
    margin: 0 !important;
    font-size: 11pt !important;
  }

  .fixed.inset-0 {
    position: static !important;
    background: #ffffff !important;
    padding: 0 !important;
  }

  .fixed.inset-0 > div {
    max-width: 100% !important;
    max-height: none !important;
    box-shadow: none !important;
    border: 1px solid #ccc !important;
    color: #000 !important;
  }

  * {
    color-adjust: exact !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}

