/**
 * AIS Suite — Unified Maritime Intelligence Dashboard Design System
 * Mobile-first responsive styles with WCAG AA accessibility, 44px touch targets,
 * and consistent theme variables.
 */

:root {
  /* Colors */
  --color-bg: #070e1b;
  --color-bg-elevated: #0f1a2e;
  --color-bg-overlay: rgba(15, 26, 46, 0.95);
  --color-text: #f1f5f9;
  --color-text-muted: #94a3b8;
  --color-dim: #64748b;
  --color-border: rgba(56, 189, 248, 0.22);
  --color-border-hover: rgba(56, 189, 248, 0.5);

  --color-primary: #0ea5e9;
  --color-primary-hover: #0284c7;
  --color-primary-glow: rgba(14, 165, 233, 0.35);
  --color-accent: #38bdf8;

  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-error: #ef4444;

  /* Provider Colors */
  --mt-color: #2563eb;
  --mst-color: #f97316;
  --stream-color: #10b981;

  /* Vessel Type Colors (High Contrast) */
  --cargo: #22c55e;
  --tanker: #ef4444;
  --fishing: #f97316;
  --passenger: #3b82f6;
  --tug: #a855f7;
  --hsc: #eab308;
  --pleasure: #06b6d4;
  --other: #94a3b8;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;

  /* Typography */
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-size-xs: 12px;
  --font-size-sm: 14px;
  --font-size-md: 16px;  /* Base body size (prevents auto-zoom on iOS Safari) */
  --font-size-lg: 18px;
  --font-size-xl: 22px;
  --font-size-2xl: 28px;
  --line-height: 1.55;

  /* Touch & Interaction */
  --touch-min: 44px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 16px var(--color-primary-glow);

  /* Layout Dimensions */
  --header-height: 60px;
  --footer-height: 42px;
  --panel-width: 380px;
  --transition-fast: 0.15s ease;
  --transition: 0.25s ease;
}

/* =========================================================================
   1. RESET & BASE STYLES
   ========================================================================= */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-family);
  font-size: var(--font-size-md);
  line-height: var(--line-height);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: #7dd3fc;
}

/* Accessible focus outline */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* =========================================================================
   2. FORM CONTROLS & TOUCH TARGETS (Min 44px)
   ========================================================================= */
.ctl-select,
.ctl-input,
.btn {
  min-height: var(--touch-min);
  font-family: inherit;
  font-size: var(--font-size-sm);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast);
}

.ctl-select,
.ctl-input {
  background: rgba(15, 23, 42, 0.95);
  color: var(--color-text);
  padding: 8px 12px;
  display: inline-flex;
  align-items: center;
}

.ctl-select:focus,
.ctl-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 10px var(--color-primary-glow);
  outline: none;
}

.ctl-select optgroup {
  background: var(--color-bg-elevated);
  color: var(--color-accent);
  font-weight: 600;
}

.ctl-select option {
  background: var(--color-bg-elevated);
  color: var(--color-text);
  padding: 8px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 8px 16px;
  font-weight: 600;
  cursor: pointer;
  background: linear-gradient(135deg, var(--color-primary), var(--mt-color));
  color: #ffffff;
  border: none;
  box-shadow: var(--shadow-sm);
}

.btn:hover {
  filter: brightness(1.12);
  box-shadow: var(--shadow-glow);
}

.btn:active {
  transform: scale(0.98);
}

.btn-secondary {
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid var(--color-border);
  color: var(--color-text);
}

.btn-secondary:hover {
  background: rgba(51, 65, 85, 0.95);
  border-color: var(--color-border-hover);
}

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

/* =========================================================================
   3. HEADER & NAVIGATION BAR
   ========================================================================= */
header.topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  z-index: 1000;
  background: var(--color-bg-overlay);
  border-bottom: 1px solid var(--color-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-md);
  box-shadow: var(--shadow-md);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #0284c7, #2563eb);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: var(--shadow-glow);
}

.brand-text h1 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: #ffffff;
  line-height: 1.2;
}

.brand-text span {
  font-size: 11px;
  color: var(--color-accent);
  font-weight: 500;
}

.controls-group {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: nowrap;
}

/* Search autocomplete wrapper */
.search-wrapper {
  position: relative;
  width: 240px;
}

.search-wrapper input {
  width: 100%;
}

.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 320px;
  overflow-y: auto;
  display: none;
  z-index: 2000;
}

.search-item {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--font-size-sm);
  min-height: var(--touch-min);
  transition: background var(--transition-fast);
}

.search-item:hover,
.search-item:focus {
  background: rgba(56, 189, 248, 0.14);
}

.search-item .name {
  font-weight: 600;
  color: #ffffff;
}

.search-item .sub {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

/* =========================================================================
   4. MAIN VIEWPORT & MAP CONTAINER
   ========================================================================= */
#viewport {
  position: absolute;
  top: var(--header-height);
  bottom: var(--footer-height);
  left: 0;
  right: 0;
  background: #06111f;
  overflow: hidden;
}

#map-leaflet, #map-gl {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* Floating Tools / Legend */
.floating-tools {
  position: absolute;
  top: calc(var(--header-height) + 12px);
  left: 14px;
  z-index: 900;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  max-width: 280px;
}

.tool-card {
  background: var(--color-bg-overlay);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-md);
  font-size: var(--font-size-sm);
}

.tool-card h3 {
  font-size: var(--font-size-xs);
  color: var(--color-accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
}

.legend-items {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  margin-top: 6px;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
  flex-shrink: 0;
}

/* Standalone Map Panel (map.html / map_gl.html) */
.standalone-panel {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 1000;
  background: var(--color-bg-overlay);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px;
  width: 320px;
  max-width: calc(100vw - 28px);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.standalone-panel .panel-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.standalone-panel .panel-brand .logo {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--color-primary), var(--mt-color));
  font-size: 18px;
}

.standalone-panel h1 {
  font-size: var(--font-size-md);
  font-weight: 700;
  color: #ffffff;
}

.standalone-panel .panel-sub {
  font-size: var(--font-size-xs);
  color: var(--color-accent);
  margin-bottom: 12px;
}

.control-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

/* Map Popups */
.leaflet-popup-content-wrapper,
.maplibregl-popup-content {
  background: var(--color-bg-elevated) !important;
  color: var(--color-text) !important;
  border: 1px solid var(--color-border) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-lg) !important;
  padding: 12px 14px !important;
  backdrop-filter: blur(12px);
  font-size: var(--font-size-sm) !important;
}

.leaflet-popup-tip {
  background: var(--color-bg-elevated) !important;
}

.maplibregl-popup-anchor-top .maplibregl-popup-tip { border-bottom-color: var(--color-bg-elevated) !important; }
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip { border-top-color: var(--color-bg-elevated) !important; }
.maplibregl-popup-anchor-left .maplibregl-popup-tip { border-right-color: var(--color-bg-elevated) !important; }
.maplibregl-popup-anchor-right .maplibregl-popup-tip { border-left-color: var(--color-bg-elevated) !important; }

/* =========================================================================
   5. BOTTOM FOOTER STATUS BAR
   ========================================================================= */
footer.statusbar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--footer-height);
  z-index: 1000;
  background: var(--color-bg-overlay);
  border-top: 1px solid var(--color-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-md);
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
  overflow-x: auto;
  white-space: nowrap;
}

.statusbar-left,
.statusbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 23, 42, 0.7);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

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

.status-dot.online {
  background: var(--color-success);
  box-shadow: 0 0 6px var(--color-success);
}

.status-dot.offline {
  background: var(--color-error);
}

/* =========================================================================
   6. SHIP INSPECTOR (Desktop Drawer / Mobile Bottom-Sheet)
   ========================================================================= */
.inspector-panel {
  position: absolute;
  top: var(--header-height);
  bottom: var(--footer-height);
  right: 0;
  width: var(--panel-width);
  background: var(--color-bg-overlay);
  border-left: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 1500;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: transform var(--transition);
}

.insp-header {
  padding: var(--space-md);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-sm);
}

.insp-title h3 {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: #ffffff;
  word-break: break-word;
}

.insp-title span {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

.insp-close {
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  width: var(--touch-min);
  height: var(--touch-min);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.insp-close:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

.insp-content {
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* Metric cards grid */
.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm);
}

.metric-card {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.metric-label {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.metric-val {
  font-size: var(--font-size-md);
  font-weight: 700;
  color: #ffffff;
  margin-top: 2px;
}

/* Detail info table */
.info-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

.info-table tr {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.info-table td {
  padding: 8px 4px;
}

.info-table .lbl {
  color: var(--color-text-muted);
  width: 42%;
}

.info-table .val {
  color: #ffffff;
  font-weight: 500;
  text-align: right;
  word-break: break-all;
}

/* Badge tags */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: #ffffff;
}

/* Compare section */
.compare-section {
  margin-top: var(--space-md);
  background: rgba(15, 23, 42, 0.6);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  padding: 10px 12px;
  font-size: var(--font-size-xs);
}

.compare-section h4 {
  font-size: var(--font-size-xs);
  color: var(--color-accent);
  margin-bottom: 8px;
  text-transform: uppercase;
}

/* =========================================================================
   7. LOADING & EMPTY STATES
   ========================================================================= */
.loading-spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
  color: var(--color-text-muted);
  text-align: center;
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: var(--space-md);
  opacity: 0.6;
}

/* =========================================================================
   8. RESPONSIVE BREAKPOINTS
   ========================================================================= */

/* Mobile view (<= 768px): Header compact, inspector bottom-sheet */
@media (max-width: 768px) {
  :root {
    --header-height: 56px;
    --footer-height: 38px;
  }

  header.topbar {
    padding: 0 var(--space-sm);
  }

  .brand-text h1 {
    font-size: 15px;
  }

  .brand-text span {
    display: none;
  }

  /* Compact controls on mobile */
  .controls-group {
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: calc(100vw - 120px);
    padding-bottom: 2px;
  }

  .search-wrapper {
    width: 140px;
    flex-shrink: 0;
  }

  .ctl-select,
  .ctl-input {
    font-size: var(--font-size-sm);
    padding: 6px 8px;
    flex-shrink: 0;
  }

  /* Floating tools collapsible / compact on mobile */
  .floating-tools {
    top: calc(var(--header-height) + 8px);
    left: 8px;
    max-width: 200px;
  }

  .legend-items {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  /* Standalone panel on mobile */
  .standalone-panel {
    top: 8px;
    left: 8px;
    right: 8px;
    width: auto;
    max-width: none;
  }

  /* Bottom sheet for mobile */
  .inspector-panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100vw;
    max-height: 75vh;
    border-left: none;
    border-top: 2px solid var(--color-primary);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.7);
  }

  /* Bottom handle bar for dragging */
  .insp-header {
    position: relative;
    padding-top: var(--space-md);
  }

  .insp-header::before {
    content: '';
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 44px;
    height: 4px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: var(--radius-full);
  }

  /* Footer scrollable on small devices */
  footer.statusbar {
    padding: 0 var(--space-sm);
    gap: var(--space-sm);
  }

  .statusbar-left {
    gap: var(--space-sm);
  }
}

/* Tablet view (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
  :root {
    --panel-width: 340px;
  }

  .search-wrapper {
    width: 180px;
  }
}

/* =========================================================================
   9. DISCOVERY DASHBOARD LAYOUT (Outletbuddy Style)
   ========================================================================= */

.app-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background-color: #f1f5f9;
}

.map-pane {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Floating Clean Sidebar */
.sidebar-pane {
  position: fixed;
  top: 16px;
  right: 16px;
  bottom: 16px;
  width: 28%;
  min-width: 360px;
  max-width: 460px;
  background: #ffffff;
  border-radius: 24px;
  box-shadow: 0 12px 36px rgba(15, 23, 42, 0.08), 0 2px 8px rgba(15, 23, 42, 0.04);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(226, 232, 240, 0.85);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
}

/* Sidebar Drag Handle (Mobile Bottom Sheet) */
.sidebar-drag-handle {
  display: none;
}

/* Sidebar Header */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  background: #ffffff;
  border-bottom: 1px solid #f1f5f9;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.sidebar-logo-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, #0284c7, #2563eb);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 18px;
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.25);
  flex-shrink: 0;
}

.sidebar-brand-title {
  font-size: 17px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.sidebar-brand-sub {
  font-size: 11px;
  color: #0284c7;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #475569;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.header-icon-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #cbd5e1;
}

/* Sidebar Search Box */
.sidebar-search {
  padding: 12px 18px 8px;
  background: #ffffff;
  position: relative;
}

.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input-wrap svg {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: #94a3b8;
  pointer-events: none;
}

.search-input-field {
  width: 100%;
  padding: 10px 14px 10px 38px;
  font-size: 14px;
  border-radius: 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #0f172a;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.search-input-field:focus {
  background: #ffffff;
  border-color: #0ea5e9;
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
}

.search-clear-btn {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px;
  display: none;
}

/* Sidebar 3 Control Tabs (Aktif / Nearest / Filter) */
.sidebar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 18px 12px;
  background: #ffffff;
  border-bottom: 1px solid #f1f5f9;
}

.control-tab {
  flex: 1;
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #475569;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
  user-select: none;
}

.control-tab:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.control-tab.active {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.28);
}

/* Status summary above list */
.sidebar-summary-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px 4px;
  font-size: 12px;
  color: #64748b;
  font-weight: 500;
}

.sidebar-summary-bar .total-count {
  font-weight: 700;
  color: #0f172a;
}

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: #059669;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
}

/* Ship List Scroll Area */
.sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ship-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: #ffffff;
  border: 1px solid #f1f5f9;
  cursor: pointer;
  transition: all 0.16s ease;
}

.ship-item:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
}

.ship-item.selected {
  background: #f0f9ff;
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.18);
}

.ship-avatar {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  color: #ffffff;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.avatar-mt { background: linear-gradient(135deg, #2563eb, #1d4ed8); }
.avatar-mst { background: linear-gradient(135deg, #f97316, #ea580c); }
.avatar-stream { background: linear-gradient(135deg, #10b981, #059669); }

.ship-item-content {
  flex: 1;
  min-width: 0;
}

.ship-item-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.ship-item-name {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ship-item-desc {
  font-size: 12px;
  color: #64748b;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ship-item-meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

/* Soft Pastel Badges */
.badge-soft {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-distance {
  background: #e0f2fe;
  color: #0369a1;
}

.badge-active {
  background: #d1fae5;
  color: #047857;
}

.badge-idle {
  background: #fef3c7;
  color: #b45309;
}

.badge-offline {
  background: #fee2e2;
  color: #b91c1c;
}

.badge-type {
  background: #f1f5f9;
  color: #475569;
}

/* Detail Card (Floating white card on center-left of map) */
.detail-card {
  position: fixed;
  left: 24px;
  top: 50%;
  transform: translateY(-50%);
  width: 360px;
  max-width: calc(100vw - 48px);
  background: #ffffff;
  border-radius: 24px;
  box-shadow: 0 16px 44px rgba(15, 23, 42, 0.12), 0 2px 8px rgba(15, 23, 42, 0.04);
  z-index: 1000;
  padding: 22px;
  border: 1px solid rgba(226, 232, 240, 0.85);
  animation: cardSlideIn 0.24s cubic-bezier(0.16, 1, 0.3, 1);
  display: none;
  flex-direction: column;
}

@keyframes cardSlideIn {
  from {
    opacity: 0;
    transform: translateY(calc(-50% + 16px)) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(-50%) scale(1);
  }
}

.detail-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.detail-card-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #64748b;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.detail-card-close:hover {
  background: #fee2e2;
  color: #ef4444;
  border-color: #fca5a5;
}

.detail-card-hero {
  display: flex;
  align-items: center;
  gap: 12px;
}

.detail-card-title h3 {
  font-size: 17px;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.2;
}

.detail-card-title p {
  font-size: 12px;
  color: #64748b;
  margin-top: 2px;
}

/* Verified & Score pill */
.detail-rating-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.verified-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 700;
  color: #0284c7;
  background: #e0f2fe;
  padding: 3px 8px;
  border-radius: 8px;
}

.score-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 700;
  color: #059669;
  background: #d1fae5;
  padding: 3px 8px;
  border-radius: 8px;
}

/* 2-Column Statistics Grid */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.detail-grid-item {
  background: #f8fafc;
  border: 1px solid #f1f5f9;
  border-radius: 12px;
  padding: 8px 10px;
}

.detail-grid-label {
  font-size: 10.5px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.detail-grid-val {
  font-size: 13.5px;
  font-weight: 700;
  color: #0f172a;
  margin-top: 2px;
}

/* Detail Info Table */
.detail-info-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  margin-bottom: 16px;
  border-top: 1px dashed #e2e8f0;
  padding-top: 10px;
}

.detail-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.detail-info-row .lbl {
  color: #64748b;
}

.detail-info-row .val {
  font-weight: 600;
  color: #0f172a;
}

/* Detail CTA Buttons */
.detail-actions {
  display: flex;
  gap: 8px;
}

.btn-detail-primary {
  flex: 2;
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #ffffff;
  border: none;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.25);
  transition: all 0.15s ease;
}

.btn-detail-primary:hover {
  filter: brightness(1.08);
  box-shadow: 0 6px 16px rgba(2, 132, 199, 0.35);
}

.btn-detail-secondary {
  flex: 1;
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #e2e8f0;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.btn-detail-secondary:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* Floating Location Button */
.btn-my-location {
  position: fixed;
  left: 20px;
  top: 20px;
  z-index: 900;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  color: #0284c7;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  transition: all 0.18s ease;
}

.btn-my-location:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.12);
  color: #0369a1;
}

/* Custom Marker Styles */
.ship-div-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.ship-div-inner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 11px;
  color: #ffffff;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease;
}

.ship-div-marker.selected .ship-div-inner {
  transform: scale(1.35);
  box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.45), 0 8px 20px rgba(0, 0, 0, 0.35);
  z-index: 9999 !important;
}

/* =========================================================================
   MARINE-TRAFFIC STYLE SHIP MARKERS & LEGEND
   ========================================================================= */
.ship-marker-wrapper {
  background: transparent !important;
  border: none !important;
}

.ship-marker {
  position: relative;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
  user-select: none;
  transition: transform 0.15s ease;
}

.ship-marker:hover {
  z-index: 1000 !important;
  transform: scale(1.25);
}

.ship-icon-inner {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: center center;
  transition: transform 0.2s ease;
}

.ship-icon {
  width: 100%;
  height: 100%;
  display: block;
}

/* Color per shiptype (MarineTraffic palette) */
.ship-marker[data-shiptype="0"] .ship-icon path { fill: #9ca3af; }  /* Unknown / VTS */
.ship-marker[data-shiptype="1"] .ship-icon path { fill: #f59e0b; }  /* Nav aid / Wreck */
.ship-marker[data-shiptype="2"] .ship-icon path { fill: #16a34a; }  /* Fishing */
.ship-marker[data-shiptype="3"] .ship-icon path { fill: #eab308; }  /* Tug / Special */
.ship-marker[data-shiptype="4"] .ship-icon path { fill: #06b6d4; }  /* High Speed Craft */
.ship-marker[data-shiptype="5"] .ship-icon path { fill: #ea580c; }  /* Tug / Pilot / SAR */
.ship-marker[data-shiptype="6"] .ship-icon path { fill: #3b82f6; }  /* Passenger */
.ship-marker[data-shiptype="7"] .ship-icon path { fill: #1d4ed8; }  /* Cargo */
.ship-marker[data-shiptype="8"] .ship-icon path { fill: #dc2626; }  /* Tanker */
.ship-marker[data-shiptype="9"] .ship-icon path { fill: #a855f7; }  /* Pleasure / Yacht */

/* Default fallback */
.ship-marker:not([data-shiptype]) .ship-icon path { fill: #0ea5e9; }

/* Selected state: highlighted + pulse animation */
.ship-marker.selected {
  z-index: 9999 !important;
  transform: scale(1.35);
}

.ship-marker.selected .ship-icon path {
  stroke: #ffffff;
  stroke-width: 2.2px;
}

.ship-marker.selected::after {
  content: '';
  position: absolute;
  inset: -6px;
  border: 2px solid #0284c7;
  border-radius: 50%;
  pointer-events: none;
  animation: markerPulse 1.6s ease-in-out infinite;
}

@keyframes markerPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.22); opacity: 0.5; }
}

/* Legend Floating Card */
.ship-legend-card {
  position: absolute;
  bottom: 24px;
  right: calc(28% + 24px);
  background: rgba(255, 255, 255, 0.95);
  border-radius: 16px;
  padding: 10px 14px;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.12);
  z-index: 900;
  font-size: 11px;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  max-width: 260px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.ship-legend-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 11px;
  margin-bottom: 6px;
  color: #334155;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 4px;
}

.ship-legend-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 8px;
}

.ship-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.2;
}

.ship-legend-icon {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

/* Mode Switcher Segmented Control */
.mode-switcher-bar {
  display: flex;
  background: #f1f5f9;
  border-radius: 12px;
  padding: 3px;
  gap: 3px;
  margin: 10px 0;
  border: 1px solid #e2e8f0;
}

.mode-switcher-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  transition: all 0.18s ease;
  min-height: 34px;
}

.mode-switcher-btn:hover {
  color: #0f172a;
}

.mode-switcher-btn.active {
  background: #ffffff;
  color: #0284c7;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

/* Modal Overlay & Card */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-dialog {
  background: #ffffff;
  border-radius: 24px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.16);
  padding: 24px;
  animation: cardSlideIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 800;
  color: #0f172a;
}

/* Clean Custom Leaflet & MapLibre Controls */
.leaflet-bottom.leaflet-left,
.maplibregl-ctrl-bottom-left {
  bottom: 20px !important;
  left: 20px !important;
}

.leaflet-control-zoom,
.maplibregl-ctrl-group {
  border: none !important;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.1) !important;
  border-radius: 14px !important;
  overflow: hidden;
}

.leaflet-control-zoom a,
.maplibregl-ctrl-group button {
  background: #ffffff !important;
  color: #0f172a !important;
  border: 1px solid #e2e8f0 !important;
  width: 36px !important;
  height: 36px !important;
  line-height: 36px !important;
  font-size: 16px !important;
  font-weight: 700 !important;
}

.leaflet-control-zoom a:hover,
.maplibregl-ctrl-group button:hover {
  background: #f8fafc !important;
  color: #0284c7 !important;
}

/* RESPONSIVE BREAKPOINTS (Desktop-first) */
@media (max-width: 1024px) {
  .sidebar-pane {
    width: 34%;
    min-width: 320px;
  }
  .detail-card {
    width: 320px;
  }
  .ship-legend-card {
    right: calc(34% + 20px);
  }
}

@media (max-width: 768px) {
  /* Prevent horizontal scrolling on mobile */
  html, body, .app-container {
    overflow-x: hidden !important;
    max-width: 100vw !important;
  }

  /* Sidebar transformed into Bottom Sheet */
  .sidebar-pane {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    min-width: 0;
    max-width: none;
    height: 52vh;
    min-height: 200px;
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -8px 36px rgba(15, 23, 42, 0.18);
    transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), height 0.15s ease;
    z-index: 1000;
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-bottom: none;
    display: flex;
    flex-direction: column;
  }

  .sidebar-pane.collapsed {
    transform: translateY(calc(100% - 66px)); /* Peek header + drag handle */
  }

  /* Drag handle for expand / collapse */
  .sidebar-drag-handle {
    display: block;
    width: 44px;
    height: 5px;
    background: #cbd5e1;
    border-radius: 3px;
    margin: 8px auto 2px auto;
    cursor: grab;
    touch-action: none;
    flex-shrink: 0;
  }

  .sidebar-drag-handle:active {
    background: #94a3b8;
    cursor: grabbing;
  }

  /* Sidebar header on mobile */
  .sidebar-header {
    padding: 8px 16px 10px;
    user-select: none;
  }

  .sidebar-brand-title {
    font-size: 15px;
  }

  .sidebar-brand-sub {
    font-size: 10px;
  }

  .header-icon-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  /* Mode switcher full width on mobile */
  .mode-switcher-bar {
    margin: 6px 16px 8px;
  }

  .mode-switcher-btn {
    min-height: 44px;
    font-size: 13px;
  }

  /* Search input full-width */
  .sidebar-search {
    padding: 4px 16px 8px;
  }

  .search-input-field {
    min-height: 44px;
    font-size: 16px !important; /* Prevents auto-zoom in iOS Safari */
  }

  .search-clear-btn {
    width: 36px;
    height: 36px;
    font-size: 14px;
  }

  /* Controls: horizontal touch scroll */
  .sidebar-controls {
    padding: 0 16px 8px;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .sidebar-controls::-webkit-scrollbar {
    display: none;
  }

  .control-tab {
    flex: 1;
    min-width: 90px;
    min-height: 44px;
    font-size: 13px;
    padding: 8px 12px;
  }

  .sidebar-summary-bar {
    padding: 6px 16px;
    font-size: 11.5px;
  }

  /* Ship items touch target */
  .ship-item {
    padding: 12px 16px;
    min-height: 64px;
  }

  /* Detail card as bottom sheet / bottom-bar */
  .detail-card {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    transform: none;
    width: 100%;
    max-width: none;
    max-height: 56vh;
    border-radius: 24px 24px 0 0;
    z-index: 1100; /* above sidebar */
    padding: 16px 18px 24px;
    box-shadow: 0 -8px 36px rgba(15, 23, 42, 0.22);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    animation: mobileCardSlideUp 0.24s cubic-bezier(0.16, 1, 0.3, 1);
  }

  @keyframes mobileCardSlideUp {
    from {
      opacity: 0;
      transform: translateY(100%);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .detail-card-close {
    width: 44px;
    height: 44px;
    font-size: 18px;
  }

  .btn-detail-primary,
  .btn-detail-secondary {
    min-height: 44px;
    font-size: 13.5px;
  }

  /* Location button top-left */
  .btn-my-location {
    top: 14px;
    left: 14px;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    z-index: 900;
  }

  /* Map controls above collapsed bottom sheet */
  .leaflet-bottom.leaflet-left,
  .maplibregl-ctrl-bottom-left {
    bottom: 76px !important;
    left: 14px !important;
    transition: bottom 0.3s ease;
  }

  /* Legend card on mobile */
  .ship-legend-card {
    position: fixed;
    top: 68px;
    right: 14px;
    left: 14px;
    bottom: auto;
    max-width: calc(100% - 28px);
    z-index: 950;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.16);
    border-radius: 16px;
    padding: 12px 14px;
  }

  .ship-legend-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px 12px;
  }

  /* Modal on mobile */
  .modal-dialog {
    padding: 20px;
    max-height: 85vh;
    overflow-y: auto;
  }
}
