/* CSS Custom Properties for Theming (Permanent Light Mode) */
:root {
  --font-primary: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  
  --bg-app: #f4f6f9;
  --bg-sidebar: rgba(255, 255, 255, 0.95);
  --border-ui: rgba(0, 0, 0, 0.08);
  --border-focus: rgba(0, 119, 182, 0.5);
  
  --text-main: #1f2937;
  --text-muted: #4b5563;
  --text-active: #0077b6;
  
  --accent-color: #0077b6;
  --accent-glow: rgba(0, 119, 182, 0.12);
  --success-color: #059669;
  --warning-color: #d97706;
  --danger-color: #dc2626;
  
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  --shadow-glow: 0 0 15px rgba(0, 119, 182, 0.12);
}

/* Saramiqra font for Sindhi language */
@font-face {
  font-family: 'Saramiqra';
  src: url('fonts/SaremIqra.woff2') format('woff2'),
       url('fonts/SaremIqra.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* Base resets */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body, html {
  width: 100%;
  height: 100%;
  font-family: var(--font-primary);
  background-color: var(--bg-app);
  color: var(--text-main);
  overflow: hidden;
}

/* App container takes entire viewport (fixed locks layout from dynamic scroll offsets) */
.app-container {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  overflow: hidden;
}

/* Application Header Top Bar */
.app-header {
  width: 100%;
  height: 60px;
  background: #ffffff;
  border-bottom: 1px solid var(--border-ui);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 1010;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 15px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-logo {
  color: var(--accent-color);
  filter: drop-shadow(0 2px 4px var(--accent-glow));
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: var(--text-main);
  line-height: 1.1;
}

.brand-subtitle {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.brand-badge {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 4px;
}

/* Language Selector */
.lang-selector {
  display: flex;
  gap: 4px;
}

.lang-btn {
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid var(--border-ui);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-primary);
  line-height: 1.4;
}

.lang-btn:hover {
  border-color: var(--accent-color);
  color: var(--accent-color);
}

.lang-btn.active {
  background: var(--accent-color);
  color: #ffffff;
  border-color: var(--accent-color);
}

/* Layout below top header */
.main-content-layout {
  display: flex;
  flex: 1;
  width: 100%;
  height: calc(100% - 60px);
  position: relative;
  overflow: hidden;
}

/* Sidebar Drawer */
.sidebar {
  width: 380px;
  height: 100%;
  background: var(--bg-sidebar);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-right: 1px solid var(--border-ui);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  box-shadow: var(--shadow-lg);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
}

.sidebar-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-ui);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: 0.3px;
}
body.lang-sd .sidebar-title {
    font-size: 1.08rem;
}

/* Sidebar Close Button */
.sidebar-close-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.8rem;
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s;
}

.sidebar-close-btn:hover {
  color: var(--danger-color);
}

/* Scrollable Content */
.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Search Box */
.search-container {
  position: relative;
}

.search-input {
  width: 100%;
  padding: 12px 16px 12px 40px;
  border-radius: 8px;
  border: 1px solid var(--border-ui);
  background: rgba(0, 0, 0, 0.02);
  color: var(--text-main);
  font-family: var(--font-primary);
  font-size: 0.9rem;
  outline: none;
  transition: all 0.2s;
}

body.lang-sd .search-input {
    font-size: 0.98rem;
}
.search-input:focus {
  border-color: var(--accent-color);
  box-shadow: var(--shadow-glow);
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-results {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  width: 100%;
  background: #ffffff;
  border: 1px solid var(--border-ui);
  border-radius: 8px;
  max-height: 250px;
  overflow-y: auto;
  z-index: 1010;
  display: none;
  box-shadow: var(--shadow-lg);
}

.search-result-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-ui);
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover {
  background: rgba(0, 0, 0, 0.02);
}

.search-result-type {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--accent-color);
  font-weight: 600;
  background: var(--accent-glow);
  padding: 1px 5px;
  border-radius: 3px;
}

/* Division / District List Styling */
.section-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 1px;
  margin-bottom: 10px;
  margin-top: 5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-ui);
  padding-bottom: 6px;
}
body.lang-sd .section-title {
    font-size: 0.92rem;
}

.division-group-container {
  margin-bottom: 15px;
}

.division-group-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
body.lang-sd .division-group-title {
    font-size: 0.88rem;
}

.division-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.district-list-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.district-list-item {
  background: rgba(0, 0, 0, 0.02);
  border: 1px solid var(--border-ui);
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
body.lang-sd .district-list-item {
    font-size: 0.90rem;
}

.district-list-item:hover {
  background: var(--accent-glow);
  border-color: var(--accent-color);
  color: var(--text-active);
}

/* District Details Panel */
.info-panel {
  border: 1px solid var(--border-ui);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.5);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all 0.3s;
}

.info-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

body.lang-sd .info-title {
    font-size: 1.28rem;
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  font-size: 0.8rem;
}

.info-grid-item {
  background: rgba(0, 0, 0, 0.01);
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border-ui);
}

.info-grid-label {
  color: var(--text-muted);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

body.lang-sd .info-grid-label {
    font-size: 0.76rem;
}

body.lang-sd .info-grid-value {
    font-size: 0.96rem;
}

.info-grid-value {
  font-weight: 600;
}

/* Sub-districts / Talukas items */
.sub-items-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  margin-top: 5px;
  border-bottom: 1px dashed var(--border-ui);
  padding-bottom: 4px;
}

.sub-items-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sub-item-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.02);
  border: 1px solid var(--border-ui);
  color: var(--text-main);
  transition: all 0.2s;
  cursor: pointer;
}

body.lang-sd .sub-item-badge {
    font-size: 0.82rem;
}
.sub-item-badge:hover {
  border-color: var(--accent-color);
  color: var(--text-active);
  background: var(--accent-glow);
}

/* Action Button */
.btn-primary {
  width: 100%;
  padding: 10px;
  border-radius: 6px;
  border: none;
  background: var(--accent-color);
  color: #fff;
  font-family: var(--font-primary);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 5px;
}

.btn-primary:hover {
  background: #005f8d;
  box-shadow: 0 0 10px var(--accent-glow);
}

/* Map area container */
.map-container {
  flex: 1;
  height: 100%;
  position: relative;
}

#map {
  width: 100%;
  height: 100%;
}

/* Offline Custom Grid Backgrounds */
.vector-only-light {
  background: #f4f6f9 !important;
  background-image: radial-gradient(rgba(0, 0, 0, 0.035) 1.5px, transparent 0),
                    radial-gradient(rgba(0, 0, 0, 0.035) 1.5px, transparent 0);
  background-size: 40px 40px;
  background-position: 0 0, 20px 20px;
}

/* Custom Floating Map Controls */
.map-controls-bottom-right {
  position: absolute;
  bottom: 30px;
  right: 15px;
  z-index: 1001;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.map-control-btn {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--bg-sidebar);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-ui);
  color: var(--text-main);
  font-family: var(--font-primary);
  font-size: 1.2rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  transition: all 0.2s;
}

.map-control-btn:hover {
  border-color: var(--accent-color);
  color: var(--accent-color);
  box-shadow: var(--shadow-glow);
}

.map-control-btn svg {
  stroke: currentColor;
  fill: none;
}

.mobile-info-btn {
  display: none; /* Hidden on desktop */
}

@keyframes pulse-info {
  0% { box-shadow: 0 0 0 0 rgba(0, 119, 182, 0.7); }
  70% { box-shadow: 0 0 0 10px rgba(0, 119, 182, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 119, 182, 0); }
}

.mobile-info-btn.pulse {
  animation: pulse-info 1.5s infinite;
}

/* Leaflet scale line styling overrides */
.leaflet-bar {
  display: none !important; /* Hide default zoom controls */
}

.leaflet-control-scale-line {
  background: rgba(255, 255, 255, 0.9) !important;
  color: var(--text-main) !important;
  border: 1px solid var(--border-ui) !important;
  border-top: none !important;
  font-family: var(--font-primary);
  font-weight: 500;
  border-radius: 2px;
}

.leaflet-bottom.leaflet-left {
  margin-bottom: 15px;
  margin-left: 15px;
}

.leaflet-bottom.leaflet-right {
  margin-bottom: 15px;
  margin-right: 75px;
}

/* Custom Leaflet elements */
.leaflet-popup-content-wrapper {
  background: rgba(255, 255, 255, 0.95) !important;
  backdrop-filter: blur(8px);
  color: var(--text-main) !important;
  border: 1px solid var(--border-ui);
  border-radius: 8px !important;
  padding: 4px;
  box-shadow: var(--shadow-lg) !important;
}

.leaflet-popup-tip {
  background: rgba(255, 255, 255, 0.95) !important;
  border: 1px solid var(--border-ui);
}

.leaflet-container {
  background: transparent !important;
}

/* Permanent District Labels styled as divIcon text */
.district-label-marker {
  background: transparent;
  border: none;
  text-align: center;
  pointer-events: none; /* Clicks bypass the label to the polygon */
}

.district-label-text {
  font-family: var(--font-primary);
  font-weight: 700;
  font-size: 0.65rem;
  color: rgba(31, 41, 55, 0.75);
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.9);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: opacity 0.3s;
}

body.lang-sd .district-label-text {
    font-size: 0.78rem;
}

body.lang-sd .taluka-label-text {
    font-size: 0.72rem;
}

.district-label-text.faded {
  opacity: 0.15;
}

/* Permanent Taluka / City Labels styled as divIcon text */
.taluka-label-marker {
  background: transparent;
  border: none;
  text-align: center;
  pointer-events: none;
}

.taluka-label-text {
  position: relative;
  top: -12px; /* Shifts text visually above dot marker using CSS */
  font-family: var(--font-primary);
  font-weight: 600;
  font-size: 0.6rem;
  color: #374151;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.95);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Custom Marker Styling */
.custom-div-icon {
  background: transparent;
  border: none;
}

.taluka-marker-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid var(--accent-color);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  transition: all 0.2s;
}

.taluka-marker-dot:hover {
  transform: scale(1.3);
  background: var(--text-active);
}

/* Scrollbar styles */
.sidebar-content::-webkit-scrollbar {
  width: 6px;
}

.sidebar-content::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-content::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 3px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.2);
}

/* Sindhi language mode */
body.lang-sd {
  font-family: 'Saramiqra', sans-serif;
  line-height: 1.75;
}

body.lang-sd .brand-title,
body.lang-sd .brand-subtitle,
body.lang-sd .brand-badge,
body.lang-sd .sidebar-title,
body.lang-sd .section-title,
body.lang-sd .division-group-title,
body.lang-sd .district-list-item,
body.lang-sd .info-title,
body.lang-sd .info-grid-label,
body.lang-sd .info-grid-value,
body.lang-sd .info-desc,
body.lang-sd .sub-items-title,
body.lang-sd .sub-item-badge,
body.lang-sd .btn-primary,
body.lang-sd .search-result-type,
body.lang-sd .leaflet-popup-content-wrapper {
  font-weight: normal;
}

body.lang-sd .brand-title {
  font-size: 1.25rem;
}

body.lang-sd .brand-subtitle {
  font-size: 0.78rem;
}

body.lang-sd .brand-title,
body.lang-sd .brand-subtitle,
body.lang-sd .sidebar-title,
body.lang-sd .section-title,
body.lang-sd .division-group-title,
body.lang-sd .info-title,
body.lang-sd .info-desc,
body.lang-sd .info-grid-label,
body.lang-sd .info-grid-value,
body.lang-sd .sub-items-title,
body.lang-sd .sub-item-badge,
body.lang-sd .btn-primary,
body.lang-sd .search-input,
body.lang-sd .search-result-type,
body.lang-sd .brand-badge,
body.lang-sd .district-list-item {
  direction: rtl;
  text-align: right;
}

body.lang-sd strong {
  font-weight: normal;
}

body.lang-sd .lang-btn,
body.lang-sd .search-input,
body.lang-sd .search-result-item,
body.lang-sd .btn-primary,
body.lang-sd .map-control-btn,
body.lang-sd .leaflet-control-scale-line,
body.lang-sd .leaflet-popup-content-wrapper,
body.lang-sd .leaflet-popup-content,
body.lang-sd .district-label-text,
body.lang-sd .taluka-label-text {
  font-family: 'Saramiqra', sans-serif;
  font-weight: normal;
}

/* Responsive adjustments */
.menu-toggle {
  display: none; /* Hidden on desktop */
  background: transparent;
  border: none;
  color: var(--text-main);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 4px;
  transition: background 0.2s;
}

.menu-toggle:hover {
  background: rgba(0, 0, 0, 0.05);
}

@media (max-width: 768px) {
  .app-header {
    padding: 0 15px;
  }
  
  .brand-title {
    font-size: 0.95rem;
  }
  
  .brand-subtitle {
    font-size: 0.55rem;
  }
  
  .brand-badge {
    display: none; /* Hide offline badge on very small mobile headers */
  }

  .lang-btn {
    padding: 3px 8px;
    font-size: 0.7rem;
  }
  
  .menu-toggle {
    display: flex; /* Hamburger visible on mobile */
  }
  
  .sidebar {
    position: absolute;
    top: 0;
    left: -380px;
    height: 100%;
    width: 320px;
    z-index: 1009;
    box-shadow: 5px 0 25px rgba(0, 0, 0, 0.1);
    border-right: 1px solid var(--border-ui);
  }
  
  .sidebar.open {
    left: 0;
  }
  
  .sidebar-close-btn {
    display: block; /* Close button visible inside mobile drawer */
  }
  
  .map-controls-bottom-right {
    bottom: 85px; /* Shifted up to avoid mobile soft navigation overlay! */
  }

  .mobile-info-btn {
    display: flex; /* Info button visible on mobile */
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
  }
  
  .mobile-info-btn svg {
    stroke: white;
  }
}
