/* WT-DDS Central Administrative Web Portal & Command Center
   Government of Maharashtra - District Drought Relief Monitoring Portal
   District: Beed (बीड)
   Design System & Styling with Vertical Left Sidebar
*/

:root {
  --sidebar-width: 270px;
  --primary-navy: #09213d;
  --primary-navy-dark: #051324;
  --primary-navy-light: #133a68;
  --accent-saffron: #f37021;
  --accent-gold: #ff9933;
  --gov-green: #128807;
  --gov-green-light: #e8f5e9;
  --alert-red: #dc2626;
  --alert-red-light: #fee2e2;
  --warning-amber: #d97706;
  --warning-amber-light: #fef3c7;
  --info-cyan: #0284c7;
  --info-cyan-light: #e0f2fe;
  --slate-bg: #f8fafc;
  --card-bg: #ffffff;
  --border-color: #e2e8f0;
  --text-primary: #0f172a;
  --text-muted: #64748b;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-marathi: 'Noto Sans Devanagari', 'Inter', sans-serif;
}

body {
  font-family: var(--font-sans);
  background-color: var(--slate-bg);
  color: var(--text-primary);
  min-height: 100vh;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

.marathi-font {
  font-family: var(--font-marathi);
}

/* ==========================================================================
   VERTICAL LEFT SIDEBAR
   ========================================================================== */
#appSidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: linear-gradient(180deg, #07192d 0%, #0c2647 60%, #081d33 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  color: #ffffff;
  z-index: 1050;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease, width 0.3s ease;
  box-shadow: 4px 0 15px rgba(0, 0, 0, 0.15);
}

/* Sidebar Brand Header */
.sidebar-header {
  padding: 16px 14px;
  border-bottom: 2px solid var(--accent-saffron);
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-emblem {
  width: 42px;
  height: 42px;
  min-width: 42px;
  border-radius: 50%;
  background: radial-gradient(circle, #ff9933 0%, #138808 100%);
  border: 2px solid #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.15rem;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.sidebar-title h2 {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  margin: 0;
  line-height: 1.2;
  color: #ffffff;
}

.sidebar-title .marathi-sub {
  font-size: 0.72rem;
  color: #fed7aa;
  margin: 0;
}

.sidebar-title .district-tag {
  font-size: 0.68rem;
  color: #86efac;
  font-weight: 600;
  text-transform: uppercase;
}

/* Sidebar Nav Body */
.sidebar-nav-container {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8px;
  scrollbar-width: thin;
}

.sidebar-nav-container::-webkit-scrollbar {
  width: 4px;
}
.sidebar-nav-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.sidebar-category-header {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 10px 10px 4px;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.cat-ops { color: #7dd3fc; }
.cat-res { color: #fde047; }
.cat-gov { color: #d8b4fe; }

/* Sidebar Nav Pills */
.sidebar-nav {
  list-style: none;
  padding: 0;
  margin: 0 0 8px 0;
}

.sidebar-nav .nav-item {
  margin-bottom: 3px;
}

.sidebar-nav .nav-link {
  color: #cbd5e1;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-decoration: none;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.sidebar-nav .nav-link .nav-link-content {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-nav .nav-link i {
  font-size: 1rem;
  width: 18px;
  text-align: center;
  opacity: 0.85;
}

.sidebar-nav .nav-link:hover {
  color: #ffffff;
  background-color: rgba(255, 255, 255, 0.09);
  transform: translateX(2px);
}

.sidebar-nav .nav-link.active {
  color: #ffffff;
  background: linear-gradient(90deg, rgba(243, 112, 33, 0.9) 0%, rgba(243, 112, 33, 0.75) 100%);
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(243, 112, 33, 0.35);
  border-color: rgba(255, 255, 255, 0.2);
}

.sidebar-nav .nav-link.active i {
  opacity: 1;
}

.sidebar-nav .badge-pill {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 8px;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.3);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.officer-badge-box {
  display: flex;
  align-items: center;
  gap: 10px;
}

.officer-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #f37021;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: #ffffff;
}

/* ==========================================================================
   MAIN CONTENT WRAPPER (RIGHT SIDE)
   ========================================================================== */
#mainWrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.3s ease;
}

/* Top Command Bar */
.command-top-bar {
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  padding: 10px 20px;
  position: sticky;
  top: 0;
  z-index: 1030;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.tenant-badge {
  background: #f0fdf4;
  border: 1px solid #86efac;
  color: #166534;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 5px 12px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.session-indicator {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  color: #334155;
  font-size: 0.78rem;
  padding: 4px 10px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.live-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #10b981;
  display: inline-block;
  animation: pulseGlowGreen 2s infinite;
}

/* Sidebar Overlay for Mobile */
.sidebar-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1045;
}

@media (max-width: 991.98px) {
  #appSidebar {
    transform: translateX(-100%);
  }
  #appSidebar.sidebar-open {
    transform: translateX(0);
  }
  #mainWrapper {
    margin-left: 0;
  }
  .sidebar-backdrop.active {
    display: block;
  }
}

/* ==========================================================================
   CARDS, KPI METRICS, TABLES & CONTAINERS
   ========================================================================== */
.kpi-card.is-loading,
[data-live-block].is-loading {
  opacity: 0.55;
  pointer-events: none;
  position: relative;
}
.kpi-card.is-loading::after,
[data-live-block].is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35), transparent);
  animation: beedKpiShimmer 1.1s infinite;
}
@keyframes beedKpiShimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
#syncStatusHint {
  font-size: 0.72rem;
  white-space: nowrap;
}

/* Page data-load banner — labels stay visible; counters shimmer */
.wt-data-load-banner {
  position: sticky;
  top: 0;
  z-index: 1080;
  display: none;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.85rem;
  background: #eef6ff;
  border-bottom: 1px solid #c9dff7;
  color: #1e3a5f;
  font-size: 0.82rem;
  font-weight: 600;
}
.wt-data-load-banner.is-visible {
  display: flex;
}
.wt-data-load-banner.is-slow {
  background: #fff8e8;
  border-bottom-color: #f0d9a5;
  color: #5c4310;
}
.wt-data-load-banner.is-error {
  background: #fdeeee;
  border-bottom-color: #f0c2c2;
  color: #7a1f1f;
}
.wt-data-load-banner .wt-load-eta {
  font-weight: 500;
  margin-left: auto;
}
.wt-data-load-banner .wt-load-retry {
  flex-shrink: 0;
}
html.wt-awaiting-live .kpi-value,
body.wt-data-loading .kpi-value {
  opacity: 0.45;
}
html.wt-awaiting-live .kpi-card,
body.wt-data-loading .kpi-card {
  position: relative;
}

.kpi-card {
  background: #ffffff;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
  height: 100%;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.kpi-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
}

.kpi-card.kpi-navy::before { background-color: var(--primary-navy-light); }
.kpi-card.kpi-green::before { background-color: var(--gov-green); }
.kpi-card.kpi-blue::before { background-color: var(--info-cyan); }
.kpi-card.kpi-amber::before { background-color: var(--warning-amber); }
.kpi-card.kpi-red::before { background-color: var(--alert-red); }
.kpi-card.kpi-purple::before { background-color: #8b5cf6; }

.kpi-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.kpi-title {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 4px;
}

.kpi-value {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
  margin-bottom: 2px;
}

.kpi-subtext {
  font-size: 0.74rem;
  color: #64748b;
  margin: 0;
}

/* Tactical GIS Map and Exception Split Screen */
.tactical-map-container {
  height: 520px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  position: relative;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  background-color: #e5e7eb;
}

#dashboardMap, #trackerMap {
  width: 100%;
  height: 100%;
  min-height: 420px;
  z-index: 1;
  background: #dbe3ea;
}

/* Leaflet must sit above overlays but below floating legend */
#dashboardMap .leaflet-pane,
#trackerMap .leaflet-pane {
  z-index: 2;
}
#dashboardMap .leaflet-control-container,
#trackerMap .leaflet-control-container {
  z-index: 400;
}
.custom-leaflet-icon {
  background: transparent !important;
  border: none !important;
}
/* Keep letter pins crisp above tiles */
.leaflet-marker-icon.custom-leaflet-icon {
  overflow: visible !important;
}
.btn-xs {
  font-size: 0.7rem;
  line-height: 1.2;
}

.map-floating-overlay {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 500;
  max-width: min(280px, calc(100% - 24px));
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-radius: 8px;
  padding: 8px 12px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  font-size: 0.78rem;
  pointer-events: none; /* map pan/zoom under legend */
}
.map-floating-overlay .btn,
.map-floating-overlay a,
.map-floating-overlay button {
  pointer-events: auto;
}
#dashboardMap[data-map-empty="1"]::after,
#trackerMap[data-map-empty="1"]::after {
  content: "Beed map ready — waiting for tanker GPS / source markers";
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 450;
  background: rgba(15, 23, 42, 0.78);
  color: #f8fafc;
  font-size: 0.72rem;
  padding: 6px 10px;
  border-radius: 6px;
  pointer-events: none;
}

.map-legend-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 4px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  margin-right: 4px;
  margin-bottom: 4px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.dot-green { background-color: #10b981; }
.dot-blue { background-color: #0284c7; }
.dot-orange { background-color: #f97316; }
.dot-red { background-color: #ef4444; }

/* Pulse animations */
@keyframes pulseGlowRed {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { box-shadow: 0 0 0 12px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

@keyframes pulseGlowGreen {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.pulsing-alert-marker {
  animation: pulseGlowRed 1.5s infinite;
  border-radius: 50%;
}

/* Exception card stream */
.exception-stream-box {
  height: 520px;
  overflow-y: auto;
  padding-right: 4px;
}

.exception-card {
  background: #ffffff;
  border-radius: 8px;
  border: 1px solid #fee2e2;
  border-left: 4px solid var(--alert-red);
  padding: 12px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.exception-card:hover {
  background: #fff5f5;
  box-shadow: 0 3px 8px rgba(220, 38, 38, 0.15);
  transform: translateX(3px);
}

.exception-card.warning-level {
  border-color: #fef3c7;
  border-left-color: var(--warning-amber);
}
.exception-card.warning-level:hover {
  background: #fffbeb;
  box-shadow: 0 3px 8px rgba(217, 119, 6, 0.15);
}

.exception-time {
  font-size: 0.7rem;
  color: #94a3b8;
  font-weight: 600;
}

/* Custom Cards & Tables */
.custom-card {
  background: #ffffff;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  margin-bottom: 20px;
}

.custom-card-header {
  background-color: #ffffff;
  border-bottom: 1px solid var(--border-color);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 10px 10px 0 0;
  flex-wrap: wrap;
  gap: 10px;
}

.custom-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #1e293b;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.custom-table {
  font-size: 0.82rem;
  margin-bottom: 0;
}

.custom-table thead th {
  background-color: #f8fafc;
  color: #475569;
  font-weight: 700;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #cbd5e1;
  padding: 10px 12px;
  white-space: nowrap;
}

.custom-table tbody td {
  padding: 10px 12px;
  vertical-align: middle;
  border-bottom: 1px solid #f1f5f9;
}

.custom-table tbody tr:hover {
  background-color: #f8fafc;
}

/* Telemetry Drawer */
.telemetry-drawer {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.gauge-chip {
  background: #f1f5f9;
  border-radius: 6px;
  padding: 8px 12px;
  text-align: center;
}
.gauge-chip .label {
  font-size: 0.7rem;
  color: #64748b;
  text-transform: uppercase;
  font-weight: 600;
}
.gauge-chip .val {
  font-size: 1.15rem;
  font-weight: 700;
  color: #0f172a;
}

/* Route Replay Controls */
.replay-scrubber-box {
  background: #0f172a;
  color: #ffffff;
  border-radius: 8px;
  padding: 12px 18px;
  margin-top: 12px;
}

.replay-slider {
  cursor: pointer;
}

/* Watermark in Cryptographic Photos */
.watermark-overlay {
  position: relative;
  display: inline-block;
  overflow: hidden;
  border-radius: 8px;
  border: 2px solid #0f172a;
  width: 100%;
  max-width: 500px;
  background: #000000;
}

.watermark-badge {
  position: absolute;
  bottom: 8px;
  left: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.85);
  color: #00ff66;
  font-family: monospace;
  font-size: 0.7rem;
  padding: 6px 10px;
  border-radius: 4px;
  border-left: 3px solid #00ff66;
  line-height: 1.3;
}

/* Hub Classification Category Tags */
.hub-category-tag {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.hub-tag-ops { background: #e0f2fe; color: #0369a1; }
.hub-tag-res { background: #fef3c7; color: #b45309; }
.hub-tag-gov { background: #f3e8ff; color: #7e22ce; }

/* Print styling */
@media print {
  #appSidebar, .command-top-bar, .btn-print-hide, .modal, .toast-container {
    display: none !important;
  }
  #mainWrapper {
    margin-left: 0 !important;
  }
  .tab-pane {
    display: block !important;
    opacity: 1 !important;
  }
  body {
    background: #ffffff;
    font-size: 11pt;
  }
}

/* Exception Trip Cards Scrollable Container */
.exception-scroll-list {
  max-height: 540px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
  padding-right: 4px;
}
.exception-scroll-list::-webkit-scrollbar {
  width: 5px;
}
.exception-scroll-list::-webkit-scrollbar-track {
  background: transparent;
}
.exception-scroll-list::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
.exception-scroll-list::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Hide Feedbacks option from sidebar across all pages */
#tab-feedbacks-btn,
li.nav-item:has(#tab-feedbacks-btn) {
  display: none !important;
}
