/* =====================================================================
   Green Gain Hub - Modern UI/UX Stylesheet
   Design Language: Fastwork Minimalist, White Canvas, Noto Sans Thai + Inter
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@300;400;500;600;700;800&family=IBM+Plex+Sans+Thai:wght@300;400;500;600;700&family=Inter:wght@400;500;600;700;800;900&display=swap');

:root {
  --primary: #059669;
  --primary-dark: #047857;
  --secondary: #0284c7;
  --accent: #d97706;
  --font-sans: 'Noto Sans Thai', 'IBM Plex Sans Thai', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Inter', sans-serif;
  --font-mono: 'Inter', monospace;
}

body {
  font-family: var(--font-sans);
  background-color: #f8fafc;
  color: #0f172a;
  letter-spacing: -0.012em;
  -webkit-tap-highlight-color: transparent;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}

.num-tnum, .font-mono {
  font-family: 'Inter', monospace;
  font-variant-numeric: tabular-nums;
}

/* Fastwork-style Stacked Cards Micro-Interaction */
@keyframes subtle-wobble {
  0% { transform: translateY(-4px) rotate(0deg) scale(1.02); }
  25% { transform: translateY(-6px) rotate(-1.5deg) scale(1.03); }
  50% { transform: translateY(-4px) rotate(1.2deg) scale(1.03); }
  75% { transform: translateY(-5px) rotate(-0.6deg) scale(1.02); }
  100% { transform: translateY(-4px) rotate(0deg) scale(1.02); }
}

.animate-wobble {
  animation: subtle-wobble 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.fastwork-card-active {
  transform: translateY(-6px) scale(1.02) !important;
  z-index: 30 !important;
  box-shadow: 0 20px 35px -10px rgba(15, 23, 42, 0.12), 0 10px 15px -5px rgba(15, 23, 42, 0.06) !important;
}

/* Glassmorphism Card Effect */
.glass-panel {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(226, 232, 240, 0.8);
}

.glass-dark {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

/* Tao Bin Style Impact Counter Cards */
.ticker-card {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.05);
}

.ticker-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 28px -4px rgba(16, 185, 129, 0.15);
}

/* Pulse Radar for User Location */
.gps-pulse {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #3b82f6;
  box-shadow: 0 0 0 rgba(59, 130, 246, 0.6);
  animation: pulse-ring 1.8s infinite;
}

@keyframes pulse-ring {
  0% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7);
  }
  70% {
    box-shadow: 0 0 0 12px rgba(59, 130, 246, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
  }
}

/* Leaflet Map Customization */
#map {
  width: 100%;
  min-height: 480px;
  height: 520px;
  z-index: 10;
  border-radius: 1.25rem;
}

@media (max-width: 768px) {
  #map {
    min-height: 400px;
    height: 420px;
  }
}

/* Modal Backdrop & Animation */
.modal-backdrop {
  background-color: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fadeIn 0.2s ease-out;
  cursor: pointer;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content-anim {
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: default;
}

@keyframes slideUp {
  from { transform: translateY(20px) scale(0.97); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

/* Flash Demand Glow */
.flash-border {
  border: 2px solid #ef4444;
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.2);
}

.flash-pulse {
  animation: flashPulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes flashPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Calculator Highlight Badges */
.calc-card-winner {
  border: 2px solid #10b981;
  background: linear-gradient(180deg, #ecfdf5 0%, #ffffff 100%);
  box-shadow: 0 10px 25px -5px rgba(16, 185, 129, 0.2);
}

.leaflet-popup-content-wrapper {
  border-radius: 1rem !important;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04) !important;
  padding: 0 !important;
  overflow: hidden !important;
  border: 1px solid #e2e8f0 !important;
}

.leaflet-popup-content {
  margin: 0 !important;
  line-height: 1.5 !important;
  font-family: var(--font-sans) !important;
}

.leaflet-popup-tip-container {
  margin-top: -1px;
}

/* Smooth Horizontal Scroll for Category Chips */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Shimmer Loading Animation */
.shimmer {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

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

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* High-Contrast Accessible Buttons (WCAG AA/AAA Pass) */
.btn-primary-action {
  background-color: #047857;
  color: #ffffff !important;
  font-weight: 700;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}
.btn-primary-action:hover {
  background-color: #065f46;
}

.btn-blue-action {
  background-color: #1d4ed8;
  color: #ffffff !important;
  font-weight: 700;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}
.btn-blue-action:hover {
  background-color: #1e40af;
}

.btn-danger-action {
  background-color: #b91c1c;
  color: #ffffff !important;
  font-weight: 700;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}
.btn-danger-action:hover {
  background-color: #991b1b;
}

/* Role Selector Radio Styling */
.role-card:has(input[type="radio"]:checked) {
  border-color: #059669 !important;
  background-color: #ecfdf5 !important;
  box-shadow: 0 0 0 1px #059669 !important;
}

/* Leaflet Popup Content Buttons & Links Contrast Override (WCAG AA/AAA) */
.leaflet-popup-content button,
.leaflet-popup-content a {
  color: #ffffff !important;
  font-weight: 700 !important;
}

.leaflet-popup-content button span,
.leaflet-popup-content a span {
  color: #ffffff !important;
  font-weight: 700 !important;
}

/* Horizontal Carousel for Flash Demand Board (Prevents Page Spill) */
.demand-carousel {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 1rem;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.75rem;
  padding-top: 0.25rem;
}

.demand-card-item {
  flex: 0 0 320px;
  max-width: 360px;
  scroll-snap-align: start;
}

@media (min-width: 640px) {
  .demand-card-item {
    flex: 0 0 340px;
  }
}

.scrollbar-thin::-webkit-scrollbar {
  height: 6px;
}
.scrollbar-thin::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 9999px;
}
.scrollbar-thin::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 9999px;
}
.scrollbar-thin::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Strict Stock Guard Input & Button Validation */
.input-stock-error {
  border-color: #ef4444 !important;
  background-color: #fef2f2 !important;
  color: #991b1b !important;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.35) !important;
}

.btn-submit-disabled {
  opacity: 0.5 !important;
  cursor: not-allowed !important;
  background-color: #94a3b8 !important;
  pointer-events: none !important;
  box-shadow: none !important;
}

/* Flash Demand Card Header & Non-overlapping Distance Badge */
.demand-header-flex {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  width: 100%;
}

.demand-dist-badge {
  position: static !important;
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  white-space: normal;
  word-break: break-word;
  line-height: 1.35;
}

