/* GHCNh Explorer Custom Styles */

/* Make modal title take full width so flexbox alignment works */
.modal-header .modal-title {
  flex: 1 !important;
  width: 100% !important;
}

/* Frozen overlay - blocks all interactions during data loading */
.frozen-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.3);
  z-index: 9999;
  display: none;
  cursor: wait;
}

.frozen-overlay.active {
  display: flex !important;
  align-items: flex-start !important;
  justify-content: flex-end !important;
  padding: 80px 30px 30px 30px !important;
}

.frozen-overlay-content {
  position: relative;
  background: white;
  width: 400px;
  min-height: 200px;
  padding: 30px;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.frozen-overlay-content .spinner-border {
  width: 3rem;
  height: 3rem;
  margin-bottom: 15px;
}

.frozen-overlay-content p {
  margin: 0;
  font-size: 1.1rem;
  color: #333;
}

.frozen-overlay-close {
  position: absolute;
  top: 10px;
  right: 15px;
  border: none;
  background: none;
  font-size: 1.5rem;
  color: #666;
  cursor: pointer;
  line-height: 1;
}

.frozen-overlay-close:hover {
  color: #000;
}

/* Disable pointer events on sidebar when frozen */
body.ui-frozen .bslib-sidebar-layout>.sidebar {
  pointer-events: none;
  opacity: 0.6;
}

body.ui-frozen .navbar {
  pointer-events: none;
  opacity: 0.6;
}

div.outer {
  position: relative;
  height: calc(100vh - 100px);
}

#zoom_home_panel {
  z-index: 999 !important;
}

.btn-home {
  background: white;
  border: 2px solid rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  color: #444;
  width: 34px;
  height: 34px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-home:hover {
  background: #f4f4f4;
  color: #000;
}

/* Move plotly modebar to bottom */
.plotly .modebar-container {
  top: auto !important;
  bottom: 10px !important;
}

.plotly .modebar {
  background: rgba(255, 255, 255, 0.9) !important;
  border-radius: 4px;
  padding: 2px 5px;
}

/* Collapsible Map Control Styling */
.map-layer-control {
  background-color: white;
  border-radius: 4px;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
  padding: 5px;
  width: 36px;
  height: 36px;
  overflow: hidden;
  transition: width 0.3s ease, height 0.3s ease;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.map-layer-control.expanded {
  width: 200px;
  height: auto;
  padding: 10px;
}

.control-icon {
  width: 26px;
  height: 26px;
  text-align: center;
  margin-bottom: 5px;
  font-size: 18px;
  color: #333;
  flex-shrink: 0;
}

.control-content {
  opacity: 0;
  transition: opacity 0.3s ease;
  margin-top: 5px;
  white-space: nowrap;
}

.map-layer-control.expanded .control-content {
  opacity: 1;
  white-space: normal;
}

.map-layer-control.expanded .control-icon {
  display: none !important;
}

.map-layer-control .control-content label {
  font-size: 85%;
}

@media (max-width: 768px) {

  /* Hide MapLibre navigation control (zoom +/-) on mobile */
  .maplibregl-ctrl-top-left .maplibregl-ctrl-group,
  .mapboxgl-ctrl-top-left .mapboxgl-ctrl-group {
    display: none !important;
  }

  /* Hide layer control panel on mobile */
  .map-layer-control {
    display: none !important;
  }

  /* Hide plotly modebar (zoom/pan/download toolbar) on mobile */
  .plotly .modebar-container {
    display: none !important;
  }

  /* Hide info icon annotations on mobile (hover doesn't work on touch) */
  .js-plotly-plot .annotation {
    display: none !important;
  }

  /* Edge-to-edge layout on mobile */
  .container,
  .container-fluid,
  .tab-content,
  .card,
  .card-body,
  .bslib-gap-spacing,
  .bslib-sidebar-layout>.main {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  /* Ensure tab content and tables use full height instead of collapsing */
  .tab-pane,
  .bslib-page-fill {
    min-height: auto !important;
    height: auto !important;
    flex: none !important;
  }

  /* Make DataTables horizontally scrollable on narrow screens */
  .dataTables_wrapper {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }
}

/* Plot fade-in animation */
@keyframes plotFadeIn {
  from {
    opacity: 0.3;
  }

  to {
    opacity: 1;
  }
}

.js-plotly-plot {
  animation: plotFadeIn 0.4s ease-out forwards;
  opacity: 1;
  /* Ensure visible even if animation fails */
}

/* Map loading spinner overlay */
.map-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
  transition: opacity 0.4s ease-out;
}

.map-loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.map-loading-content {
  text-align: center;
  color: #555;
}

.map-loading-content p {
  margin-top: 12px;
  font-size: 0.9rem;
  font-weight: 500;
}

.map-spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto;
  border: 4px solid #e0e0e0;
  border-top: 4px solid #1976d2;
  border-radius: 50%;
  animation: mapSpin 0.8s linear infinite;
}

@keyframes mapSpin {
  to {
    transform: rotate(360deg);
  }
}

/* --- Summary Cards (Glassmorphism) --- */
.summary-cards-container {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 10px;
  margin-bottom: 5px;
}

.summary-cards-header {
  width: 100%;
  font-size: 0.75rem;
  font-weight: bold;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-left: 0.25rem;
  margin-bottom: -0.5rem;
}

.glass-card {
  flex: 1 1 calc(20% - 1rem); /* 5 cols by default */
  min-width: 180px;
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 1rem;
  padding: 1rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.glass-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.glass-card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  font-size: 1.1rem;
}

.glass-card-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.glass-card-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: #475569;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.glass-card-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: #0f172a;
  margin-top: 0.1rem;
}

.glass-card-subtext {
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 0.25rem;
  line-height: 1.2;
}

/* Color variations for glass cards */
.glass-card.card-red { background: rgba(254, 242, 242, 0.5); border-color: rgba(254, 226, 226, 0.5); }
.glass-card.card-red .glass-card-icon { color: #ef4444; background: rgba(254, 226, 226, 0.5); }

.glass-card.card-blue { background: rgba(239, 246, 255, 0.5); border-color: rgba(219, 234, 254, 0.5); }
.glass-card.card-blue .glass-card-icon { color: #3b82f6; background: rgba(219, 234, 254, 0.5); }

.glass-card.card-emerald { background: rgba(236, 253, 245, 0.5); border-color: rgba(209, 250, 229, 0.5); }
.glass-card.card-emerald .glass-card-icon { color: #10b981; background: rgba(209, 250, 229, 0.5); }

.glass-card.card-cyan { background: rgba(236, 254, 255, 0.5); border-color: rgba(207, 250, 254, 0.5); }
.glass-card.card-cyan .glass-card-icon { color: #06b6d4; background: rgba(207, 250, 254, 0.5); }

.glass-card.card-purple { background: rgba(250, 245, 255, 0.5); border-color: rgba(243, 232, 255, 0.5); }
.glass-card.card-purple .glass-card-icon { color: #a855f7; background: rgba(243, 232, 255, 0.5); }

.glass-card.card-sky { background: rgba(240, 249, 255, 0.5); border-color: rgba(224, 242, 254, 0.5); }
.glass-card.card-sky .glass-card-icon { color: #38bdf8; background: rgba(224, 242, 254, 0.5); }

.glass-card.card-amber { background: rgba(255, 251, 235, 0.5); border-color: rgba(254, 243, 199, 0.5); }
.glass-card.card-amber .glass-card-icon { color: #f59e0b; background: rgba(254, 243, 199, 0.5); }

.glass-card.card-pink { background: rgba(253, 242, 248, 0.5); border-color: rgba(252, 231, 243, 0.5); }
.glass-card.card-pink .glass-card-icon { color: #ec4899; background: rgba(252, 231, 243, 0.5); }

.glass-card.card-slate { background: rgba(248, 250, 252, 0.5); border-color: rgba(241, 245, 249, 0.5); }
.glass-card.card-slate .glass-card-icon { color: #64748b; background: rgba(241, 245, 249, 0.5); }

@media (max-width: 991px) {
  .glass-card {
    flex: 1 1 calc(33.333% - 1rem);
  }
}
@media (max-width: 767px) {
  .glass-card {
    flex: 1 1 calc(50% - 1rem);
  }
}
@media (max-width: 480px) {
  .glass-card {
    flex: 1 1 100%;
  }
}