/* ==========================================================================
   Atlas Historique de l'ALN (1954-1962) - Stylesheet
   Modern Digital Humanities & Cartography UI
   ========================================================================== */

:root {
  /* Dark Theme Palette (Default) */
  --bg-primary: #0f141c;
  --bg-secondary: #161f2e;
  --bg-tertiary: #1f2b3e;
  --bg-card: #182232;
  --bg-card-hover: #223046;
  --border-color: #2b394f;
  --border-light: #374863;
  --bg-input: #121a27;
  
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --accent-green: #22c55e;
  --accent-red: #ef4444;
  --accent-blue: #3b82f6;
  --accent-amber: #f59e0b;
  --accent-cyan: #06b6d4;

  /* Wilaya Colors */
  --w1-color: #c0392b;
  --w2-color: #2c3e50;
  --w3-color: #27ae60;
  --w4-color: #16a085;
  --zaa-color: #e74c3c;
  --w5-color: #2980b9;
  --w6-color: #f39c12;
  --emg-color: #d35400;
  --w7-color: #8e44ad;

  --sidebar-width: 440px;
  --header-height: 64px;
  --drawer-width: 520px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.6);
  --transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --border-color: #e2e8f0;
  --border-light: #cbd5e1;
  --bg-input: #ffffff;
  
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;
  
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.12);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.18);
}

/* Base Reset & Typography */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100vh;
  height: 100dvh;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  color: var(--text-main);
}

button, input, select {
  font-family: inherit;
  font-size: 0.9rem;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

/* Header */
.app-header {
  height: var(--header-height);
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  z-index: 1000;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.flag-icon {
  font-size: 1.8rem;
  line-height: 1;
}

.brand-title {
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.badge-version {
  font-size: 0.7rem;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  background-color: rgba(34, 197, 94, 0.15);
  color: #4ade80;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* Mobile View Tabs */
.mobile-view-tabs {
  display: none;
}

/* Buttons & Icon Buttons */
.icon-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.icon-btn:hover {
  background-color: var(--bg-tertiary);
  border-color: var(--border-light);
}

.standalone-site [data-repo-only], .standalone-site a[hidden] { display: none !important; }
.nav-btn { text-decoration: none; }

.icon {
  width: 18px;
  height: 18px;
}

.icon-inline {
  width: 15px;
  height: 15px;
  display: inline-block;
  vertical-align: middle;
}

.nav-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.nav-btn:hover {
  background-color: var(--border-color);
}

/* Language Toggle Button */
.lang-toggle-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: 'Cairo', 'Inter', sans-serif;
  font-size: 0.85rem;
}

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

.lang-flag {
  font-size: 1.05rem;
  line-height: 1;
}

.lang-label {
  letter-spacing: 0.02em;
}

.sun-icon { display: none; }
[data-theme="light"] .sun-icon { display: block; }
[data-theme="light"] .moon-icon { display: none; }

/* Dropdown */
.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.4rem;
  min-width: 190px;
  display: none;
  z-index: 1050;
}

.dropdown-menu.show {
  display: block;
}

.dropdown-item {
  display: block;
  padding: 0.55rem 0.85rem;
  color: var(--text-main);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  transition: var(--transition);
}

.dropdown-item:hover {
  background-color: var(--bg-tertiary);
  color: var(--accent-blue);
}

/* Main Container Layout */
.main-container {
  display: flex;
  flex: 1;
  width: 100%;
  height: calc(100vh - var(--header-height));
  height: calc(100dvh - var(--header-height));
  min-height: 0;
  position: relative;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  height: 100%;
  min-height: 0;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), margin-left 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 800;
  overflow: hidden;
}

.sidebar.collapsed {
  margin-left: calc(-1 * var(--sidebar-width));
}

/* Search Box */
.search-box {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 1.65rem;
  width: 16px;
  height: 16px;
  color: var(--text-dim);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 0.65rem 2.2rem 0.65rem 2.3rem;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 16px; /* Prevents auto-zoom on mobile iOS */
  transition: var(--transition);
}

.search-box input:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.clear-btn {
  position: absolute;
  right: 1.65rem;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.2rem;
  cursor: pointer;
  display: none;
  width: 20px;
  height: 20px;
  line-height: 1;
}

.clear-btn.visible {
  display: block;
}

/* Results Count Bar */
.results-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.8rem;
}

.results-count {
  font-weight: 600;
  color: var(--text-muted);
}

.reset-link-btn {
  background: none;
  border: none;
  color: var(--accent-blue);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 500;
  text-decoration: underline;
}

.reset-link-btn:hover {
  color: #60a5fa;
}

/* Filters Container */
.filters-container {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  background-color: var(--bg-secondary);
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.filter-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--text-dim);
}

/* Wilaya Chips */
.wilaya-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.chip {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.28rem 0.55rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  transition: var(--transition);
}

.chip:hover {
  border-color: var(--border-light);
  color: var(--text-main);
}

.chip.active {
  background-color: var(--bg-tertiary);
  color: #ffffff;
  border-color: var(--border-light);
  box-shadow: inset 0 0 0 1px currentColor;
}

.chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Year Selector */
.year-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.year-btn {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
  font-family: 'JetBrains Mono', monospace;
  cursor: pointer;
  transition: var(--transition);
}

.year-btn:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-main);
}

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

/* Select */
.custom-select {
  width: 100%;
  padding: 0.45rem 0.65rem;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  outline: none;
  cursor: pointer;
  transition: var(--transition);
}

.custom-select:focus {
  border-color: var(--accent-blue);
}

/* Operations List */
.operations-list-header {
  padding: 0.65rem 1rem 0.4rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.list-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.scroll-filters-btn {
  display: none;
  align-items: center;
  gap: 0.25rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--accent-blue);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.scroll-filters-btn:hover {
  background: var(--border-color);
  color: #ffffff;
}

.scroll-filters-btn .icon-inline {
  width: 13px;
  height: 13px;
}

.operations-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0.75rem 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Operation Card */
.op-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.85rem;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.op-card:hover {
  background-color: var(--bg-card-hover);
  border-color: var(--border-light);
  transform: translateY(-1px);
}

.op-card.selected {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 1px var(--accent-blue);
  background-color: var(--bg-card-hover);
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.card-id {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-dim);
}

.card-badge {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  color: #fff;
  white-space: nowrap;
}

.card-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.3;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.card-meta-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.card-meta-item svg {
  width: 13px;
  height: 13px;
  color: var(--text-dim);
}

.card-action-type {
  font-size: 0.7rem;
  color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.1);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  display: inline-block;
  align-self: flex-start;
  font-weight: 500;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}
.empty-state svg {
  width: 42px;
  height: 42px;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
}
.empty-state h4 {
  font-size: 1rem;
  margin-bottom: 0.35rem;
  color: var(--text-main);
}
.empty-state p {
  font-size: 0.85rem;
}

/* Map Wrapper & Map Container */
.map-wrapper {
  flex: 1;
  height: 100%;
  min-height: 100%;
  min-width: 0;
  position: relative;
  overflow: hidden;
  background-color: #0b0f15;
}

#map {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100% !important;
  height: 100% !important;
  min-height: 100% !important;
  z-index: 10;
  background-color: #0b0f15;
}

/* Base Tile Styling - 100% Free & Open (No API Key Required) */
[data-theme="dark"] .osm-tiles .leaflet-tile {
  filter: brightness(0.65) invert(1) contrast(2.2) hue-rotate(200deg) saturate(0.3);
}

[data-theme="light"] .osm-tiles .leaflet-tile {
  filter: none;
}

.topo-tiles .leaflet-tile,
.satellite-tiles .leaflet-tile {
  filter: none !important;
}

/* Map Floating Controls */
.map-floating-controls {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 750;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.map-ctrl-select {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.42rem 0.65rem;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  outline: none;
  font-family: inherit;
  transition: var(--transition);
}

.map-ctrl-select:hover,
.map-ctrl-select:focus {
  background-color: var(--bg-tertiary);
  border-color: var(--border-light);
}

.map-ctrl-select option {
  background-color: var(--bg-secondary);
  color: var(--text-main);
}

.map-ctrl-btn {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  transition: var(--transition);
}

.map-ctrl-btn:hover {
  background-color: var(--bg-tertiary);
  border-color: var(--border-light);
}

/* Map Legend */
.map-legend {
  position: absolute;
  bottom: 1.5rem;
  right: 1.5rem;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.75rem 1rem;
  z-index: 750;
  max-width: 290px;
  display: block;
  transition: var(--transition);
}

.map-legend.hidden {
  display: none;
}

.legend-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.35rem;
}

.close-mini-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.1rem;
  cursor: pointer;
}

.legend-items {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Detail Drawer */
.detail-drawer {
  position: absolute;
  top: 0;
  right: 0;
  width: var(--drawer-width);
  height: 100%;
  background-color: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  z-index: 900;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}

.detail-drawer.open {
  transform: translateX(0);
}
.detail-drawer:not(.open) { visibility: hidden; pointer-events: none; }
@media (max-width: 900px) {
  .sidebar:not(.mobile-open) { visibility: hidden; pointer-events: none; }
}

.drawer-header {
  padding: 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-header-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.drawer-back-btn {
  display: none;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.drawer-back-btn:hover {
  background: var(--bg-tertiary);
  border-color: var(--accent-blue);
  color: var(--accent-blue);
}

.drawer-back-btn .icon {
  width: 14px;
  height: 14px;
}

.op-id-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--bg-primary);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--border-color);
}

.op-wilaya-badge {
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
}

.close-drawer-btn {
  color: var(--text-dim);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.drawer-title {
  font-size: 1.35rem;
  line-height: 1.3;
}

.drawer-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem;
}

.meta-block {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.meta-block-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.meta-block-value {
  font-size: 0.85rem;
  color: var(--text-main);
  font-weight: 500;
}

.section-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.description-text {
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text-muted);
}

.impact-box {
  background: rgba(34, 197, 94, 0.08);
  border: 1px solid rgba(34, 197, 94, 0.25);
  border-left: 4px solid var(--accent-green);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text-main);
}

/* Losses Table */
.losses-table {
  width: 100%;
  border-collapse: collapse;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  font-size: 0.85rem;
}

.losses-table th, .losses-table td {
  padding: 0.65rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.losses-table th {
  background-color: var(--bg-tertiary);
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
}

.losses-table tr:last-child td {
  border-bottom: none;
}

/* Sources List */
.sources-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.source-item {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text-main);
  transition: var(--transition);
}

.source-item:hover {
  background-color: var(--bg-tertiary);
  border-color: var(--accent-blue);
  color: var(--accent-blue);
}

.source-title {
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.4;
}

.source-badge {
  font-size: 0.68rem;
  background-color: var(--border-color);
  color: var(--text-dim);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  white-space: nowrap;
}

/* Modal Statistics */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.open {
  display: flex;
}

.modal-container {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 860px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-title {
  font-size: 1.25rem;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  flex: 1 1 auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

/* KPIs */
.stats-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.kpi-card {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.kpi-value {
  font-size: 1.75rem;
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  color: var(--accent-blue);
  margin-bottom: 0.2rem;
}

.kpi-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-weight: 500;
}

/* Charts Grid */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}

.chart-box {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
}

.chart-box-wide {
  grid-column: span 2;
}

.chart-title {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.85rem;
  font-weight: 600;
}

/* Custom Marker Styling in Leaflet */
.custom-pin-marker {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.custom-pin-marker:hover {
  transform: scale(1.3);
  z-index: 1000 !important;
}

.marker-cluster-small, .marker-cluster-medium, .marker-cluster-large {
  background-color: rgba(30, 41, 59, 0.7) !important;
}

.marker-cluster-small div, .marker-cluster-medium div, .marker-cluster-large div {
  background-color: rgba(59, 130, 246, 0.85) !important;
  color: #fff !important;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
}

/* Methodology Modal Styling */
.modal-container-lg {
  max-width: 940px;
}

.methodology-body {
  gap: 1.25rem;
}

.methodology-banner {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent-blue);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
}

.methodology-lead {
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text-main);
  margin: 0;
}

.methodology-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.methodology-card {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.card-icon-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-blue);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.methodology-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}

.methodology-card p {
  font-size: 0.82rem;
  color: var(--text-dim);
  line-height: 1.5;
  margin: 0;
}

.methodology-list {
  margin: 0;
  padding-left: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-dim);
}

.methodology-list strong {
  color: var(--text-main);
}

.methodology-footer-callout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  flex-wrap: wrap;
}

.methodology-footer-callout h4 {
  font-size: 0.95rem;
  margin: 0 0 0.25rem 0;
  color: var(--text-main);
}

.methodology-footer-callout p {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin: 0;
}

.methodology-footer-callout a {
  color: var(--accent-blue);
}

/* ==========================================================================
   Comprehensive Mobile & Tablet Responsive Design System
   ========================================================================== */

/* Tablet & Mobile Screens (<= 900px) */
@media (max-width: 900px) {
  :root {
    --sidebar-width: 100%;
    --drawer-width: 100%;
    --header-height: 58px;
  }

  .brand-subtitle {
    display: none;
  }

  /* Floating Bottom Navigation (Ergonomic Thumb Bar) */
  .mobile-view-tabs {
    position: fixed;
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    z-index: 1200;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(22, 31, 46, 0.94);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    padding: 5px;
    border-radius: 9999px;
    border: 1px solid var(--border-light);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.55);
    transition: opacity 0.25s ease, transform 0.25s ease;
  }

  [data-theme="light"] .mobile-view-tabs {
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    border-color: var(--border-color);
  }

  .tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.45rem 1.1rem;
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
    transition: var(--transition);
    min-height: 42px;
  }

  .tab-btn.active {
    background: var(--accent-blue);
    color: #ffffff;
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.4);
  }

  /* Hide bottom tabs when drawer or modal is active to prevent visual clash */
  body.drawer-open .mobile-view-tabs,
  body.modal-open .mobile-view-tabs {
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 25px);
  }

  /* Sidebar: Fullscreen Slide-in with unified natural scroll */
  .sidebar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    z-index: 850;
    transform: translateX(-100%);
    margin-left: 0 !important;
    background: var(--bg-secondary);
    border: none;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .search-box {
    flex-shrink: 0;
  }

  .results-bar {
    flex-shrink: 0;
  }

  .filters-container {
    max-height: none;
    overflow: visible;
    flex-shrink: 0;
    padding: 0.75rem 1rem;
    gap: 0.75rem;
  }

  .chip {
    padding: 0.35rem 0.65rem;
    font-size: 0.78rem;
    min-height: 34px;
  }

  .year-btn {
    min-height: 34px;
    min-width: 46px;
    font-size: 0.78rem;
  }

  .operations-list-header {
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 30;
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    flex-shrink: 0;
  }

  .scroll-filters-btn {
    display: inline-flex;
  }

  .operations-list {
    overflow: visible;
    flex: none;
    min-height: auto;
    padding-bottom: calc(6.5rem + env(safe-area-inset-bottom, 0px));
  }

  .op-card {
    padding: 0.85rem 1rem;
  }

  .op-card:active {
    transform: scale(0.99);
    background-color: var(--bg-card-hover);
  }

  /* Detail Drawer on Mobile */
  .detail-drawer {
    width: 100%;
    z-index: 1300;
    border: none;
  }

  .drawer-header {
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 20;
    padding: 0.85rem 1rem;
  }

  .drawer-back-btn {
    display: inline-flex;
  }

  .drawer-body {
    padding: 1rem;
    padding-bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px));
    -webkit-overflow-scrolling: touch;
  }

  .drawer-title {
    font-size: 1.15rem;
    line-height: 1.35;
  }

  .drawer-meta-grid {
    grid-template-columns: 1fr;
    padding: 0.75rem;
    gap: 0.6rem;
  }

  .drawer-meta-grid .meta-block[style*="span 2"] {
    grid-column: span 1 !important;
  }

  .losses-table th, .losses-table td {
    padding: 0.55rem 0.7rem;
    font-size: 0.8rem;
    word-break: break-word;
  }

  .source-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
    padding: 0.75rem;
  }

  .source-badge {
    align-self: flex-start;
  }

  /* Modals on Mobile */
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
    width: 100vw;
    width: 100dvw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  .modal-container {
    width: 100%;
    max-width: 100%;
    height: 88vh;
    height: 88dvh;
    max-height: 88vh;
    max-height: 88dvh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-bottom: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .modal-header {
    flex-shrink: 0;
    padding: 0.85rem 1rem;
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 10;
  }

  .modal-title {
    font-size: 1rem;
  }

  .modal-body,
  .methodology-body,
  .contact-body,
  .api-modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1rem 1rem calc(6.5rem + env(safe-area-inset-bottom, 0px)) 1rem !important;
  }

  .stats-kpis {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }

  .kpi-card {
    padding: 0.75rem;
  }

  .kpi-value {
    font-size: 1.35rem;
  }

  .kpi-label {
    font-size: 0.72rem;
  }

  .charts-grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  .chart-box {
    padding: 0.75rem;
  }

  .chart-box-wide {
    grid-column: span 1;
  }

  .methodology-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .methodology-banner {
    padding: 0.85rem;
  }

  .methodology-lead {
    font-size: 0.85rem;
  }

  .methodology-card {
    padding: 0.85rem;
  }

  .methodology-footer-callout {
    flex-direction: column;
    align-items: stretch;
    padding: 0.85rem;
    gap: 0.6rem;
  }

  .methodology-footer-callout .btn-primary {
    justify-content: center;
    text-align: center;
  }
}

/* Smartphone Screens (<= 768px) */
@media (max-width: 768px) {
  :root {
    --header-height: 54px;
  }

  .app-header {
    padding: 0 0.75rem;
    gap: 0.5rem;
  }

  .header-left {
    gap: 0.4rem;
    min-width: 0;
    flex: 0 0 auto;
  }

  .brand {
    gap: 0;
    min-width: 0;
  }

  .brand-text {
    display: none !important;
  }

  .flag-icon {
    font-size: 1.6rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
  }

  .header-right {
    gap: 0.3rem;
    flex: 1;
    justify-content: flex-end;
  }

  .nav-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    justify-content: center;
    min-width: 36px;
    border-radius: var(--radius-sm);
  }

  .nav-btn span {
    display: none; /* Icon only */
  }

  .lang-toggle-btn {
    padding: 0.25rem 0.5rem;
    height: 36px;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
    gap: 0.25rem;
  }

  .icon-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: var(--radius-sm);
  }

  #toggle-sidebar-btn {
    display: none; /* Replaced by bottom nav pill */
  }

  /* Floating Map Controls on Mobile */
  .map-floating-controls {
    top: 0.65rem;
    right: 0.65rem;
    gap: 0.3rem;
    max-width: calc(100vw - 1.3rem);
  }

  .map-ctrl-select {
    max-width: 140px;
    height: 36px;
    font-size: 0.75rem;
    padding: 0.3rem 0.5rem;
  }

  .map-ctrl-btn {
    height: 36px;
    padding: 0.35rem 0.6rem;
    font-size: 0.75rem;
  }

  /* Elevate Leaflet zoom controls above bottom pill */
  .leaflet-bottom.leaflet-right {
    bottom: calc(4.75rem + env(safe-area-inset-bottom, 0px)) !important;
    right: 0.75rem !important;
  }

  .leaflet-bottom.leaflet-left {
    bottom: calc(4.75rem + env(safe-area-inset-bottom, 0px)) !important;
    left: 0.75rem !important;
  }

  /* Floating Legend on Mobile */
  .map-legend {
    position: fixed;
    bottom: calc(4.75rem + env(safe-area-inset-bottom, 0px));
    left: 0.75rem;
    right: 0.75rem;
    width: auto;
    max-width: 380px;
    margin: 0 auto;
    max-height: 50vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    z-index: 1150;
    box-shadow: 0 10px 32px rgba(0,0,0,0.65);
  }
}

/* Extra Small Phones (<= 480px) */
@media (max-width: 480px) {
  .header-left .brand-title {
    font-size: 0.85rem;
  }

  .header-left .badge-version {
    display: none;
  }

  .lang-toggle-btn .lang-label {
    font-size: 0.7rem;
  }

  .tab-btn {
    min-width: 110px;
    padding: 0.4rem 0.85rem;
    font-size: 0.8rem;
  }

  .stats-kpis {
    grid-template-columns: 1fr;
  }

  .map-ctrl-select {
    max-width: 115px;
    font-size: 0.7rem;
  }
}

/* ==========================================================================
   RTL & Arabic Typography Support (dir="rtl")
   ========================================================================== */
html[dir="rtl"] body {
  font-family: 'Cairo', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

html[dir="rtl"] .brand-title,
html[dir="rtl"] .modal-title,
html[dir="rtl"] .drawer-title,
html[dir="rtl"] .card-title,
html[dir="rtl"] .chart-title,
html[dir="rtl"] .methodology-card h3 {
  font-family: 'Cairo', sans-serif;
  letter-spacing: normal;
}

html[dir="rtl"] .methodology-lead,
html[dir="rtl"] .description-text,
html[dir="rtl"] .impact-box {
  font-family: 'Cairo', 'Inter', sans-serif;
  line-height: 1.7;
}

/* Sidebar in RTL */
html[dir="rtl"] .sidebar {
  border-right: none;
  border-left: 1px solid var(--border-color);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), margin-right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

html[dir="rtl"] .sidebar.collapsed {
  margin-left: 0;
  margin-right: calc(-1 * var(--sidebar-width));
}

@media (max-width: 900px) {
  html[dir="rtl"] .sidebar {
    left: auto;
    right: 0;
    transform: translateX(100%);
  }
  html[dir="rtl"] .sidebar.mobile-open {
    transform: translateX(0);
  }
  html[dir="rtl"] .detail-drawer {
    right: auto;
    left: 0;
    transform: translateX(-100%);
  }
  html[dir="rtl"] .detail-drawer.open {
    transform: translateX(0);
  }
  html[dir="rtl"] .drawer-back-btn svg {
    transform: rotate(180deg);
  }
  html[dir="rtl"] .map-floating-controls {
    right: auto;
    left: 0.65rem;
  }
}

/* Search Box in RTL */
html[dir="rtl"] .search-icon {
  left: auto;
  right: 1.85rem;
}

html[dir="rtl"] .search-box input {
  padding-left: 2.2rem;
  padding-right: 2.5rem;
}

html[dir="rtl"] .clear-btn {
  right: auto;
  left: 1.85rem;
}

/* Detail Drawer in RTL */
html[dir="rtl"] .detail-drawer {
  right: auto;
  left: 0;
  border-left: none;
  border-right: 1px solid var(--border-color);
  transform: translateX(-100%);
}

html[dir="rtl"] .detail-drawer.open {
  transform: translateX(0);
}

/* Dropdown Menu in RTL */
html[dir="rtl"] .dropdown-menu {
  right: auto;
  left: 0;
}

/* Legend in RTL */
html[dir="rtl"] .map-legend {
  left: auto;
  right: 1rem;
}

/* Methodology callout / banner in RTL */
html[dir="rtl"] .methodology-banner {
  border-left: none;
  border-right: 4px solid var(--accent-blue);
}

html[dir="rtl"] .impact-box {
  border-left: none;
  border-right: 4px solid var(--accent-green);
}

html[dir="rtl"] .losses-table th,
html[dir="rtl"] .losses-table td {
  text-align: right;
}

html[dir="rtl"] .source-badge {
  margin-left: 0;
  margin-right: auto;
}

html[dir="rtl"] .card-top,
html[dir="rtl"] .drawer-header-meta {
  flex-direction: row-reverse;
}




/* ==========================================================================
   Contact Modal & Form Styles
   ========================================================================== */
.modal-container-md {
  max-width: 600px;
}

.contact-body {
  padding: 1.4rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.contact-banner {
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent-green);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1.1rem;
  margin-bottom: 1.25rem;
}

[dir="rtl"] .contact-banner {
  border-left: 1px solid var(--border-color);
  border-right: 4px solid var(--accent-green);
}

.contact-lead {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin: 0;
}

.contact-form {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 580px) {
  .form-row {
    grid-template-columns: 1fr;
    gap: 1.1rem;
  }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.form-group label .required {
  color: #ef4444;
}

.form-input,
.form-select,
.form-textarea {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.88rem;
  padding: 0.65rem 0.85rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
  box-sizing: border-box;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.form-textarea {
  resize: vertical;
  min-height: 110px;
  line-height: 1.5;
}

.char-count {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-align: right;
  margin-top: 0.15rem;
}

[dir="rtl"] .char-count {
  text-align: left;
}

.contact-alert {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  line-height: 1.5;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: modalIn 0.2s ease;
}

.contact-alert.success {
  background-color: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.4);
  color: #22c55e;
}

.contact-alert.error {
  background-color: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #ef4444;
}

.contact-alert.hidden {
  display: none;
}

.contact-form-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.25rem;
}

.btn-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.6rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: none;
  background-color: var(--accent-blue);
  color: #ffffff;
  transition: all var(--transition);
  min-width: 170px;
}

.btn-submit:hover:not(:disabled) {
  background-color: #2563eb;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.btn-submit:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.icon-send {
  width: 16px;
  height: 16px;
  transition: transform var(--transition);
}

[dir="rtl"] .icon-send {
  transform: scaleX(-1);
}

.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

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

@media (max-width: 580px) {
  .contact-body {
    padding: 1rem 1rem calc(6.5rem + env(safe-area-inset-bottom, 0px)) 1rem !important;
  }
  .btn-submit {
    width: 100%;
  }
}

/* ==========================================================================
   API Documentation Modal Styles
   ========================================================================== */

.api-modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.api-banner {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.api-badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.api-badge-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.api-badge-pill.open-badge {
  background: rgba(39, 174, 96, 0.15);
  color: #2ecc71;
  border-color: rgba(39, 174, 96, 0.3);
}

.api-badge-pill.auth-badge {
  background: rgba(14, 165, 233, 0.15);
  color: #38bdf8;
  border-color: rgba(14, 165, 233, 0.3);
}

.api-badge-pill.cdn-badge {
  background: rgba(142, 68, 173, 0.15);
  color: #c084fc;
  border-color: rgba(142, 68, 173, 0.3);
}

.api-lead {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

.api-base-url-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  overflow-x: auto;
}

.base-url-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}

.base-url-code {
  font-family: var(--font-mono, monospace);
  font-size: 0.82rem;
  color: var(--accent-blue);
  flex: 1;
  white-space: nowrap;
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.copy-btn:hover {
  background: var(--border-color);
  color: #ffffff;
}

.copy-btn .icon-inline {
  width: 13px;
  height: 13px;
}

.api-section-title {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 0.85rem 0;
}

.api-endpoint-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.api-endpoint-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  transition: var(--transition);
}

.api-endpoint-card:hover {
  border-color: var(--accent-blue);
}

.endpoint-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.http-badge {
  font-size: 0.68rem;
  font-weight: 800;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  text-transform: uppercase;
}

.http-badge.get {
  background: rgba(14, 165, 233, 0.2);
  color: #0ea5e9;
  border: 1px solid rgba(14, 165, 233, 0.4);
}

.endpoint-path {
  font-family: var(--font-mono, monospace);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
}

.endpoint-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.endpoint-params {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.param-tag {
  font-family: var(--font-mono, monospace);
  font-size: 0.72rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.endpoint-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.api-try-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-blue);
  background: rgba(14, 165, 233, 0.1);
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: var(--transition);
}

.api-try-btn:hover {
  background: rgba(14, 165, 233, 0.25);
  color: #ffffff;
}

/* Tabs & Code Snippets */
.api-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.api-tab-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.api-tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

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

.api-tab-content {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  overflow-x: auto;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

.tab-pane pre {
  margin: 0;
  font-family: var(--font-mono, monospace);
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text-primary);
}

.tab-pane code {
  font-family: inherit;
}

.api-footer-callout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.api-footer-callout h4 {
  margin: 0 0 0.35rem 0;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.api-footer-callout p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

@media (max-width: 600px) {
  .api-modal-body {
    padding: 1rem 1rem calc(6.5rem + env(safe-area-inset-bottom, 0px)) 1rem !important;
  }
  .api-base-url-box {
    flex-direction: column;
    align-items: flex-start;
  }
  .copy-btn {
    align-self: flex-end;
  }
}

/* Keep every navigation action reachable on narrow phones and smaller laptops. */
@media (min-width: 769px) and (max-width: 1450px) {
  .header-right .nav-btn span { display: none; }
  .header-right .nav-btn { padding: 8px; min-width: 36px; }
  .brand-title { flex-wrap: wrap; }
  .header-left { min-width: 0; }
}
@media (max-width: 768px) {
  :root { --header-height: 110px; }
  .app-header { align-items: center; }
  .header-right { flex-wrap: wrap; min-width: 0; max-width: calc(100% - 76px); }
  .header-right > * { flex-shrink: 0; }
  .header-right .nav-btn, .header-right .icon-btn { width: 44px; height: 44px; }
}
@media (max-width: 900px) {
  .sidebar { height: 100%; z-index: 1250; }
  .mobile-view-tabs { z-index: 1400; }
}
/* Reviewed assertions: evidence and conflicts remain readable in both directions. */
.scientific-claims { margin-block:1.5rem; overflow-wrap:anywhere; }
.scientific-claims h3 { font-size:1.1rem; }
.scientific-claim { border:1px solid var(--border-color, #666); border-inline-start:3px solid var(--accent-blue, #6ba9ff); border-radius:6px; padding:1rem; margin-block:1rem; }
.scientific-claim h4 { margin-block:0 .5rem; }
.claim-status,.claim-review { font-size:.85rem; }
.claim-conflict { font-weight:600; }
.claim-jump { background:transparent; color:var(--accent-blue, #6ba9ff); border:1px solid currentColor; padding:.5rem; margin-block:.25rem; min-height:44px; cursor:pointer; font:inherit; }
.claim-evidence { padding-inline-start:1.25rem; }
.scientific-claim a { color:var(--accent-blue, #6ba9ff); text-decoration:underline; }
.scientific-claim a:focus-visible { outline:2px solid currentColor; outline-offset:3px; }
.scientific-claim blockquote { margin-inline:.5rem; padding-inline-start:.75rem; border-inline-start:2px solid currentColor; white-space:pre-wrap; }
