/* shadcn/ui Design Tokens & Themes based on shadcn-dashboard-landing-template */

:root {
  --font-inter: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --radius: 0.625rem;

  /* Light Theme (shadcn zinc default) */
  --background: #ffffff;
  --foreground: #09090b;
  --card: #ffffff;
  --card-foreground: #09090b;
  --popover: #ffffff;
  --popover-foreground: #09090b;
  --primary: #18181b;
  --primary-foreground: #fafafa;
  --secondary: #f4f4f5;
  --secondary-foreground: #18181b;
  --muted: #f4f4f5;
  --muted-foreground: #71717a;
  --accent: #f4f4f5;
  --accent-foreground: #18181b;
  --destructive: #ef4444;
  --destructive-foreground: #fafafa;
  --border: #e4e4e7;
  --input: #e4e4e7;
  --ring: #18181b;
  
  /* Status & Brand */
  --brand: #2563eb;
  --brand-foreground: #ffffff;
  --success: #10b981;
  --success-foreground: #ffffff;
  --warning: #f59e0b;
  --info: #0284c7;

  /* Chart colors */
  --chart-1: #2563eb;
  --chart-2: #0284c7;
  --chart-3: #10b981;
  --chart-4: #f59e0b;
  --chart-5: #ef4444;
}

.dark {
  /* Dark Theme (shadcn zinc dark) */
  --background: #09090b;
  --foreground: #fafafa;
  --card: #09090b;
  --card-foreground: #fafafa;
  --popover: #09090b;
  --popover-foreground: #fafafa;
  --primary: #fafafa;
  --primary-foreground: #18181b;
  --secondary: #27272a;
  --secondary-foreground: #fafafa;
  --muted: #18181b;
  --muted-foreground: #a1a1aa;
  --accent: #27272a;
  --accent-foreground: #fafafa;
  --destructive: #7f1d1d;
  --destructive-foreground: #fafafa;
  --border: #27272a;
  --input: #27272a;
  --ring: #d4d4d8;

  /* Chart colors */
  --chart-1: #3b82f6;
  --chart-2: #38bdf8;
  --chart-3: #34d399;
  --chart-4: #fbbf24;
  --chart-5: #f87171;
}

body {
  font-family: var(--font-inter);
  background-color: var(--background);
  color: var(--foreground);
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Reusable Dot Pattern from shadcn landing template */
.dot-pattern {
  background-image: radial-gradient(rgba(0, 0, 0, 0.08) 1px, transparent 1px);
  background-size: 24px 24px;
}

.dark .dot-pattern {
  background-image: radial-gradient(rgba(255, 255, 255, 0.12) 1px, transparent 1px);
}

/* Radial Mask for clean edge fading */
.dot-pattern-fade {
  mask-image: radial-gradient(ellipse at center, black 40%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse at center, black 40%, transparent 80%);
}

/* Card gradients & glass styling */
.shadcn-card {
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
  transition: all 0.2s ease;
}

.dark .shadcn-card {
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.3);
}

.shadcn-card:hover {
  border-color: rgba(37, 99, 235, 0.3);
}

/* Section Card Header & Action layout */
.section-card {
  background: linear-gradient(to top, rgba(37, 99, 235, 0.03), var(--card));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: transform 0.15s ease, border-color 0.2s ease;
}

.section-card:hover {
  transform: translateY(-2px);
  border-color: rgba(37, 99, 235, 0.4);
}

/* Leaflet map inside dark/light theme */
#map {
  height: 340px;
  min-height: 340px;
  width: 100%;
  border-radius: calc(var(--radius) - 2px);
  z-index: 10;
  background-color: #f1f5f9;
}

.dark #map {
  background-color: #0f172a;
}

.dark #map .leaflet-tile {
  filter: brightness(0.65) invert(1) contrast(3) hue-rotate(200deg) saturate(0.3) brightness(0.7);
}

.dark #map .leaflet-control-zoom a {
  background-color: #1e293b;
  color: #f8fafc;
  border-color: #334155;
}

.dark #map .leaflet-control-zoom a:hover {
  background-color: #334155;
}

.dark #map .leaflet-control-attribution {
  background-color: rgba(15, 23, 42, 0.85);
  color: #94a3b8;
}

.dark #map .leaflet-control-attribution a {
  color: #60a5fa;
}

/* Status badges */
.badge-rain-yes {
  background-color: rgba(37, 99, 235, 0.1);
  color: #2563eb;
  border: 1px solid rgba(37, 99, 235, 0.3);
}

.dark .badge-rain-yes {
  background-color: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-rain-no {
  background-color: var(--muted);
  color: var(--muted-foreground);
  border: 1px solid var(--border);
}

/* Print styling */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  .no-print {
    display: none !important;
  }
  .print-only {
    display: block !important;
  }
  .shadcn-card {
    border: 1px solid #ccc !important;
    box-shadow: none !important;
  }
}

/* ========================================================================= */
/* RESPONSIVE & MOBILE ENGINE (Device & Viewport Adaptation)                */
/* ========================================================================= */

html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: manipulation;
}

/* Dynamic Viewport Height Variables */
:root {
  --vh: 1vh;
  --app-height: 100dvh;
}

/* Touch Friendly Tap Targets */
@media (pointer: coarse) {
  button, 
  a.cursor-pointer, 
  input[type="button"], 
  input[type="submit"] {
    min-height: 40px;
  }

  /* Prevent iOS Safari 16px auto-zoom on input focus */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="date"],
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* Smooth Horizontal Touch Scrolling for Tab Bars and Tables */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.touch-scroll {
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

/* Responsive Table Container Hint */
.table-responsive-wrapper {
  position: relative;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Leaflet Map Responsive Overrides */
@media (max-width: 640px) {
  #map {
    height: 240px !important;
    min-height: 240px !important;
  }
  
  .leaflet-control-zoom {
    margin-right: 8px !important;
    margin-bottom: 8px !important;
  }
}

/* Mobile Drawer Animation & Styling */
#mobileNavDrawer {
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
}

#mobileNavDrawer.drawer-open {
  display: block !important;
  animation: drawerSlideDown 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes drawerSlideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Device Detection Specific Classes */
.device-mobile .shadcn-card {
  border-radius: calc(var(--radius) - 2px);
}

.device-mobile .section-card {
  padding: 1rem;
}

/* Responsive Action Button Stacking */
@media (max-width: 480px) {
  .mobile-stack-buttons {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 0.5rem;
  }
  .mobile-stack-buttons > button,
  .mobile-stack-buttons > a {
    width: 100%;
    justify-content: center;
  }
}

