:root {
  --leaflet-tooltip-bg: rgba(17, 24, 39, 0.95);
}

/* Leaflet tooltip styling */
.leaflet-tooltip.hydro-tooltip {
  background: var(--leaflet-tooltip-bg);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  padding: 12px 16px;
  box-shadow: 0 20px 30px -10px rgba(0, 0, 0, 0.3);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  line-height: 1.5;
  backdrop-filter: blur(4px);
}

.leaflet-tooltip.hydro-tooltip:before {
  border-top-color: var(--leaflet-tooltip-bg);
  filter: drop-shadow(0 -2px 2px rgba(0, 0, 0, 0.1));
}

.hydro-tooltip .title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 4px;
}

.hydro-tooltip .value {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.9);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.hydro-tooltip .value span {
  color: #a5b4fc;
}

/* Leaflet controls styling */
.leaflet-control-zoom a {
  border-radius: 12px !important;
  color: #4f46e5 !important;
  background: white !important;
  border: 1px solid #e5e7eb !important;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05) !important;
  transition: all 0.2s ease !important;
}

.leaflet-control-zoom a:hover {
  background-color: #eef2ff !important;
  border-color: #4f46e5 !important;
  transform: scale(1.05);
}

.leaflet-control-attribution {
  background: rgba(255, 255, 255, 0.9) !important;
  backdrop-filter: blur(4px);
  border-radius: 20px 0 0 0 !important;
  padding: 4px 8px !important;
  font-size: 10px !important;
}

/* Gauge status pill styling */
#gaugeStatusPill {
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

#gaugeStatusPill[data-status="normal"] {
  background-color: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}

#gaugeStatusPill[data-status="warning"] {
  background-color: #fef9c3;
  color: #854d0e;
  border: 1px solid #fde047;
}

#gaugeStatusPill[data-status="danger"] {
  background-color: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

/* Table row styling */
#stationsTbody tr {
  cursor: pointer;
  transition: all 0.15s ease;
}

#stationsTbody tr:hover {
  background-color: rgba(99, 102, 241, 0.04);
}

#stationsTbody tr.selected {
  background: rgba(99, 102, 241, 0.08);
  border-left: 3px solid #4f46e5;
}

#stationsTbody tr.selected td:first-child {
  padding-left: calc(1.5rem - 3px);
}

/* Status badges in table */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-badge.normal {
  background-color: #dcfce7;
  color: #166534;
}

.status-badge.warning {
  background-color: #fef9c3;
  color: #854d0e;
}

.status-badge.danger {
  background-color: #fee2e2;
  color: #991b1b;
}

/* Gauge bar styling */
#gaugeBar {
  position: relative;
  transition: all 0.3s ease;
}

#gaugeWarningBand,
#gaugeDangerBand {
  pointer-events: none;
  transition: opacity 0.2s ease;
}

#gaugeMarker {
  transition: top 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

/* Chart container */
#chart {
  max-height: 280px;
  width: 100%;
  min-height: 250px;
}

/* Custom scrollbar for modal table */
#stationsTbody::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

#stationsTbody::-webkit-scrollbar-track {
  background: #f3f4f6;
  border-radius: 10px;
}

#stationsTbody::-webkit-scrollbar-thumb {
  background: #c7d2fe;
  border-radius: 10px;
  border: 2px solid #f3f4f6;
}

#stationsTbody::-webkit-scrollbar-thumb:hover {
  background: #818cf8;
}

/* Modal animation */
#tableModal {
  transition: opacity 0.2s ease;
}

#tableModal.show {
  opacity: 1;
  pointer-events: all;
}

#tableModal .transform {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#tableModal.show .transform {
  transform: translateY(0);
}

/* Loading state for chart */
#chart.loading {
  opacity: 0.5;
  pointer-events: none;
  position: relative;
}

#chart.loading::after {
  content: "Loading...";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 14px;
  color: #6b7280;
  font-weight: 500;
}

/* Button hover effects */
#btnDownload,
#btnFit,
#openTableBtn {
  transition: all 0.2s ease;
}

#btnDownload:hover,
#btnFit:hover,
#openTableBtn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 15px -3px rgba(79, 70, 229, 0.3);
}

#btnDownload:active,
#btnFit:active,
#openTableBtn:active {
  transform: translateY(0);
}

/* Live indicator animation */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(1.1);
  }
}

.live-indicator {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Focus styles for accessibility */
*:focus-visible {
  outline: 2px solid #4f46e5;
  outline-offset: 2px;
  border-radius: 4px;
}

/* Responsive adjustments */
@media (max-width: 640px) {
  .grid-cols-2 {
    gap: 0.75rem;
  }
  
  .grid-cols-2 > div {
    padding: 0.75rem;
  }
  
  #map {
    height: 35vh;
  }
  
  #chart {
    height: 200px;
  }
}

/* Print styles */
@media print {
  .leaflet-control-zoom,
  #btnDownload,
  #btnFit,
  #openTableBtn,
  .live-indicator {
    display: none !important;
  }
  
  body {
    background: white;
  }
  
  .rounded-2xl {
    border: 1px solid #e5e7eb;
    box-shadow: none;
  }
}

/* Modal - osiguraj da je iznad svega */
#tableModal {
  z-index: 9999 !important;
}

#tableModal .fixed {
  z-index: 10000 !important;
}

#modalOverlay {
  z-index: 9999 !important;
}

#tableModal > div > div {
  z-index: 10001 !important;
  position: relative;
}

/* Osiguraj da Leaflet mapa ima manji z-index */
.leaflet-container {
  z-index: 1 !important;
}

.leaflet-control-container {
  z-index: 2 !important;
}

.leaflet-popup,
.leaflet-tooltip {
  z-index: 1000 !important;
}

/* Header ne smije biti iznad modala */
header.sticky {
  z-index: 40 !important;
}