/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   T-Code  —  Custom Stylesheet
   Extends Tailwind CDN; handles map, markers, panels, and animations.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

/* ── Footer theme ── */
.site-footer {
  background: #f1f5f9 !important;
  color: #64748b !important;
}
.site-footer h3 {
  color: #1e293b !important;
}
.site-footer a {
  color: #64748b !important;
}
.site-footer a:hover {
  color: #1e293b !important;
}
.site-footer .bg-slate-800 {
  background: #e2e8f0 !important;
}
.site-footer .bg-slate-800 svg {
  color: #475569 !important;
}
.site-footer .border-slate-800 {
  border-color: #e2e8f0 !important;
}
.site-footer .text-slate-500 {
  color: #94a3b8 !important;
}
.site-footer .text-slate-300 {
  color: #64748b !important;
}
html[data-theme="dark"] .site-footer {
  background: #0f172a !important;
  color: #94a3b8 !important;
}
html[data-theme="dark"] .site-footer h3 {
  color: #f1f5f9 !important;
}
html[data-theme="dark"] .site-footer a {
  color: #94a3b8 !important;
}
html[data-theme="dark"] .site-footer a:hover {
  color: #f1f5f9 !important;
}
html[data-theme="dark"] .site-footer .bg-slate-800 {
  background: #1e293b !important;
}
html[data-theme="dark"] .site-footer .bg-slate-800 svg {
  color: #94a3b8 !important;
}
html[data-theme="dark"] .site-footer .border-slate-800 {
  border-color: #1e293b !important;
}
html[data-theme="dark"] .site-footer .text-slate-500 {
  color: #64748b !important;
}

/* ── Base ── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  font-family: "Inter", ui-sans-serif, system-ui, sans-serif;
  background-color: #f1f5f9; /* light grey in light mode */
}
html[data-theme="dark"] body {
  background-color: #0f172a;
}

/* Search input uppercase */
#search-input {
  text-transform: uppercase;
}

/* ── Tailwind-compatible utility aliases ── */
.shadow-card {
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.08),
    0 4px 16px rgba(0, 0, 0, 0.05);
}
.shadow-elevated {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
.shadow-deep {
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ HERO BACKGROUND GRID ── */
.hero-grid-bg {
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 40px 40px;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ LEAFLET MAP ── */
#map,
#hero-map,
#tcode-map {
  width: 100%;
  height: 100%;
  background: #f1f5f9; /* slate-100 while tiles load */
}

/* Override default Leaflet font */
.leaflet-container {
  font-family: "Inter", ui-sans-serif, system-ui, sans-serif;
  font-size: 12px;
  -webkit-font-smoothing: antialiased;
}

/* Zoom controls */
.leaflet-control-zoom {
  border: none !important;
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.1),
    0 4px 16px rgba(0, 0, 0, 0.08) !important;
  border-radius: 12px !important;
  overflow: hidden;
}
.leaflet-control-zoom-in,
.leaflet-control-zoom-out {
  width: 36px !important;
  height: 36px !important;
  line-height: 36px !important;
  font-size: 18px !important;
  font-weight: 300 !important;
  color: #334155 !important;
  background: rgba(255, 255, 255, 0.95) !important;
  border: none !important;
  transition:
    background 0.15s,
    color 0.15s !important;
}
.leaflet-control-zoom-in:hover,
.leaflet-control-zoom-out:hover {
  background: #fff !important;
  color: #2563eb !important;
}

/* Attribution */
.leaflet-control-attribution {
  background: rgba(255, 255, 255, 0.75) !important;
  backdrop-filter: blur(4px);
  border-radius: 6px 0 0 0 !important;
  font-size: 10px !important;
  color: #94a3b8 !important;
}
.leaflet-control-attribution a {
  color: #64748b !important;
}

/* Popup */
.leaflet-popup-content-wrapper {
  border-radius: 12px !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12) !important;
  padding: 0 !important;
  overflow: hidden;
  border: 1px solid #e2e8f0;
}
.leaflet-popup-content {
  margin: 0 !important;
  padding: 12px 14px !important;
  font-family: "Inter", sans-serif;
  font-size: 13px;
  line-height: 1.5;
}
.leaflet-popup-tip-container {
  margin-top: -1px;
}
.leaflet-popup-tip {
  box-shadow: none !important;
  background: white !important;
}
.leaflet-popup-close-button {
  color: #94a3b8 !important;
  font-size: 16px !important;
  top: 8px !important;
  right: 8px !important;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ CUSTOM MARKERS ── */
.tcode-marker {
  position: relative;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: bottom center;
  will-change: transform;
}
.tcode-marker:hover,
.tcode-marker.active {
  transform: scale(1.25);
  z-index: 1000 !important;
}

/* Pin shape */
.marker-pin {
  width: 26px;
  height: 26px;
  background: #2563eb;
  border: 3px solid #fff;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow:
    0 3px 12px rgba(37, 99, 235, 0.45),
    0 1px 4px rgba(0, 0, 0, 0.2);
  transition: background 0.2s;
}
.tcode-marker.active .marker-pin,
.tcode-marker:hover .marker-pin {
  background: #dc2626;
}

/* Pulse ring on active marker */
.tcode-marker.active::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 36px;
  height: 36px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 2px solid rgba(37, 99, 235, 0.5);
  animation: pulseRing 1.5s ease-out infinite;
  pointer-events: none;
}
@keyframes pulseRing {
  0% {
    transform: translate(-50%, -50%) scale(0.8);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(2);
    opacity: 0;
  }
}

/* User location dot */
.user-location-marker .marker-dot {
  width: 14px;
  height: 14px;
  background: #2563eb;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.5);
  position: relative;
}
.user-location-marker .marker-dot::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.15);
  animation: pulseRing 2s ease-out infinite;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ CLUSTER ICONS ── */
.tcode-cluster {
  background: transparent !important;
  border: none !important;
}

.cluster-icon {
  background: rgba(37, 99, 235, 0.9);
  border: 3px solid #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 12px rgba(37, 99, 235, 0.4);
  transition:
    transform 0.15s,
    box-shadow 0.15s;
  cursor: pointer;
  font-family: "Inter", sans-serif;
}
.cluster-icon:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
}
.cluster-icon span {
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
}

/* Override default cluster plugin styles */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background: transparent !important;
}
.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  display: none;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ DETAIL PANEL ── */
.detail-panel {
  position: absolute;
  top: 78px; /* sits below the floating nav bar */
  right: 8px;
  width: 340px;
  height: calc(100% - 86px); /* top offset + 8px bottom gap */
  background: #fff;
  box-shadow:
    0 8px 40px rgba(0, 0, 0, 0.14),
    0 2px 8px rgba(0, 0, 0, 0.08);
  border-radius: 20px;
  z-index: 1002;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.detail-panel.translate-x-full {
  transform: translateX(calc(100% + 16px));
}
.detail-panel.translate-x-0 {
  transform: translateX(0);
}

@media (max-width: 767px) {
  .detail-panel {
    position: fixed !important;
    top: auto !important;
    right: 0 !important;
    bottom: 0;
    left: 0;
    width: 100% !important;
    height: auto;
    max-height: 75vh;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.14);
  }
  .detail-panel.translate-x-full {
    transform: translateY(100%);
  }
  .detail-panel.translate-x-0 {
    transform: translateY(0);
  }
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ SEARCH DROPDOWN ── */
#search-results {
  scrollbar-width: thin;
  scrollbar-color: #e2e8f0 transparent;
}
#search-results::-webkit-scrollbar {
  width: 4px;
}
#search-results::-webkit-scrollbar-track {
  background: transparent;
}
#search-results::-webkit-scrollbar-thumb {
  background: #e2e8f0;
  border-radius: 4px;
}

.custom-scroll {
  scrollbar-width: thin;
  scrollbar-color: #e2e8f0 transparent;
}
.custom-scroll::-webkit-scrollbar {
  width: 4px;
}
.custom-scroll::-webkit-scrollbar-track {
  background: transparent;
}
.custom-scroll::-webkit-scrollbar-thumb {
  background: #e2e8f0;
  border-radius: 4px;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ANIMATIONS ── */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.animate-scale-in {
  animation: scaleIn 0.25s ease-out both;
}

/* Scroll reveal (JS adds class) */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition:
    opacity 0.6s ease,
    transform 0.6s ease;
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ MAP LOADER ── */
#map-loader {
  pointer-events: none;
}
#map-loader.show {
  opacity: 1 !important;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ MODAL LOGO ── */
/* Light mode: show dark logos; hide white logos */
.modal-logo-dark {
  display: none;
}
/* Dark mode: hide dark logos; show white logos */
html[data-theme="dark"] .modal-logo-light {
  display: none !important;
}
html[data-theme="dark"] .modal-logo-dark {
  display: inline !important;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ OVERLAY MODALS ── */
.overlay-modal {
  position: fixed;
  inset: 0;
  z-index: 3000;
  pointer-events: none;
}
.overlay-modal.open {
  pointer-events: all;
}
.overlay-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.overlay-modal.open .overlay-modal-backdrop {
  opacity: 1;
}
.overlay-modal-card {
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  height: 100%;
  background: #fff;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.38s cubic-bezier(0.4, 0, 0.2, 1);
  color: #0f172a;
}
.overlay-modal.open .overlay-modal-card {
  transform: translateX(0);
}

.modal-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #fff;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  transition:
    background 0.2s,
    border-color 0.2s;
}
.modal-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
}
.modal-nav-strip {
  display: flex;
  gap: 2px;
  padding: 4px 16px 10px;
  overflow-x: auto;
  scrollbar-width: none;
  border-top: 1px solid #f1f5f9;
}
.modal-nav-strip::-webkit-scrollbar { display: none; }
.modal-nav-strip button {
  white-space: nowrap;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 8px;
  color: #64748b;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.modal-nav-strip button:hover {
  background: #f8fafc;
  color: #1e293b;
}
.modal-nav-strip button.modal-nav-active {
  background: #FFD000;
  color: #1a1a1a;
}

.page-content {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Dark-mode modal overrides */
html[data-theme="dark"] .overlay-modal-card {
  background: #1e293b;
  color: #f1f5f9;
}
html[data-theme="dark"] .modal-header {
  background: #1e293b;
  border-color: #334155;
}
html[data-theme="dark"] .modal-nav-strip {
  border-color: #334155;
}
html[data-theme="dark"] .modal-nav-strip button {
  color: #94a3b8;
}
html[data-theme="dark"] .modal-nav-strip button:hover {
  background: rgba(255,255,255,0.06);
  color: #f1f5f9;
}
html[data-theme="dark"] .modal-nav-strip button.modal-nav-active {
  background: #FFD000;
  color: #1a1a1a;
}
html[data-theme="dark"] .overlay-modal-card h1,
html[data-theme="dark"] .overlay-modal-card h2,
html[data-theme="dark"] .overlay-modal-card h3,
html[data-theme="dark"] .overlay-modal-card h4 {
  color: #f1f5f9;
}
html[data-theme="dark"] .overlay-modal-card p,
html[data-theme="dark"] .overlay-modal-card .text-slate-500,
html[data-theme="dark"] .overlay-modal-card .text-slate-600 {
  color: #94a3b8 !important;
}
html[data-theme="dark"] .overlay-modal-card .text-slate-400 {
  color: #64748b !important;
}
html[data-theme="dark"] .overlay-modal-card .text-slate-900 {
  color: #f1f5f9 !important;
}
html[data-theme="dark"] .overlay-modal-card .bg-slate-50 {
  background: #263347 !important;
}
html[data-theme="dark"] .overlay-modal-card .bg-white {
  background: #263347 !important;
}
html[data-theme="dark"] .overlay-modal-card .border-slate-100 {
  border-color: #334155 !important;
}
html[data-theme="dark"] .overlay-modal-card .border-slate-200 {
  border-color: #334155 !important;
}
html[data-theme="dark"] .overlay-modal-card input,
html[data-theme="dark"] .overlay-modal-card textarea {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #f1f5f9 !important;
}
html[data-theme="dark"] .overlay-modal-card input::placeholder,
html[data-theme="dark"] .overlay-modal-card textarea::placeholder {
  color: #64748b !important;
}
html[data-theme="dark"] .overlay-modal-card .modal-close-btn {
  background: rgba(51, 65, 85, 0.6) !important;
  color: #f1f5f9 !important;
}
html[data-theme="dark"] .overlay-modal-card .modal-close-btn:hover {
  background: rgba(71, 85, 105, 0.8) !important;
}

/* ── Mobile responsive overrides (< 640 px) ── */
@media (max-width: 639px) {
  /* Tighter modal header on small screens */
  .modal-header-top {
    padding: 10px 14px;
  }
  .modal-header img {
    height: 24px !important;
  }
  .modal-nav-strip {
    padding: 4px 10px 8px;
  }

  /* More breathing room for modal body text */
  .page-content {
    padding: 0 14px;
  }

  /* Reduce detail panel bottom-sheet height so content is still usable */
  .detail-panel {
    max-height: 80vh;
  }
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ DARK MODE ── */

/* Body */
html[data-theme="dark"] body {
  background-color: #0f172a;
  color: #e2e8f0;
}

/* ── Floating nav pill ── */
html[data-theme="dark"] #nav-pill {
  background: rgba(15, 23, 42, 0.95) !important;
  border-color: rgba(51, 65, 85, 0.8) !important;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.5),
    0 1px 3px rgba(0, 0, 0, 0.3) !important;
}
html[data-theme="dark"] #nav-pill nav a,
html[data-theme="dark"] #nav-pill nav button {
  color: #fff;
}
html[data-theme="dark"] #nav-pill nav a:hover,
html[data-theme="dark"] #nav-pill nav button:hover {
  color: #f1f5f9 !important;
  background: rgba(30, 41, 59, 1) !important;
}
html[data-theme="dark"] #dark-toggle {
  color: #94a3b8 !important;
}
html[data-theme="dark"] #dark-toggle:hover {
  background: rgba(30, 41, 59, 1) !important;
  color: #f1f5f9 !important;
}
html[data-theme="dark"] #nav-lang-btn {
  color: #94a3b8 !important;
  border-color: #334155 !important;
  background: transparent !important;
}
html[data-theme="dark"] #nav-lang-dropdown {
  background: #0f172a !important;
  border-color: #334155 !important;
}
html[data-theme="dark"] #nav-lang-dropdown button {
  color: #e2e8f0 !important;
}
html[data-theme="dark"] #nav-lang-dropdown button:hover {
  background: #1e293b !important;
}
html[data-theme="dark"] #mobile-menu-btn {
  color: #94a3b8 !important;
}
html[data-theme="dark"] #mobile-menu {
  background: rgba(15, 23, 42, 0.97) !important;
  border-color: #334155 !important;
}
html[data-theme="dark"] #mobile-menu a,
html[data-theme="dark"] #mobile-menu button {
  color: #94a3b8 !important;
}
html[data-theme="dark"] #mobile-menu a:hover,
html[data-theme="dark"] #mobile-menu button:hover {
  background: rgba(30, 41, 59, 1) !important;
  color: #f1f5f9 !important;
}

/* ── Page sections (index, tcode, etc.) ── */
html[data-theme="dark"] section {
  background-color: #0f172a !important;
}
html[data-theme="dark"] main {
  background-color: #0f172a !important;
}
html[data-theme="dark"] footer {
  background-color: #020617 !important;
}

/* Cards & surfaces */
html[data-theme="dark"] .bg-white {
  background-color: #1e293b !important;  /* white cards appear as light surface on dark bg */
}
html[data-theme="dark"] .bg-slate-50 {
  background-color: #162032 !important;
}
/* Grid/card items in dark mode — lighter so they read as "white" against dark bg */
html[data-theme="dark"] .border-slate-100 {
  border-color: #334155 !important;
}
html[data-theme="dark"] .bg-white\/80,
html[data-theme="dark"] .bg-white\/90,
html[data-theme="dark"] .bg-white\/95 {
  background-color: rgba(15, 23, 42, 0.95) !important;
}

/* Text */
html[data-theme="dark"] .text-slate-900 {
  color: #f1f5f9 !important;
}
html[data-theme="dark"] .text-slate-800 {
  color: #e2e8f0 !important;
}
html[data-theme="dark"] .text-slate-700 {
  color: #cbd5e1 !important;
}
html[data-theme="dark"] .text-slate-600 {
  color: #94a3b8 !important;
}
html[data-theme="dark"] .text-slate-500 {
  color: #64748b !important;
}
html[data-theme="dark"] .text-slate-400 {
  color: #475569 !important;
}

/* Borders */
html[data-theme="dark"] .border-slate-200 {
  border-color: #334155 !important;
}
html[data-theme="dark"] .border-slate-100 {
  border-color: #1e293b !important;
}

/* Hover states */
html[data-theme="dark"] .hover\:bg-slate-50:hover {
  background-color: #1e293b !important;
}
html[data-theme="dark"] .hover\:bg-slate-100:hover {
  background-color: #263347 !important;
}

/* Inputs */
html[data-theme="dark"]
  input:not([type="submit"]):not([type="button"]):not([type="reset"]),
html[data-theme="dark"] textarea,
html[data-theme="dark"] select {
  background-color: #1e293b !important;
  border-color: #334155 !important;
  color: #f1f5f9 !important;
}
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
  color: #475569 !important;
}

/* Accordion / bordered containers */
html[data-theme="dark"] .border.border-slate-200 {
  border-color: #334155 !important;
}

/* tcode page bg-slate-50 main */
html[data-theme="dark"] main.bg-slate-50,
html[data-theme="dark"] main.min-h-screen {
  background-color: #0f172a !important;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
