/* ═══════════════════════════════════════════════════════════
   LAYOUT — Full-Screen SPA Grid with Tab Panels
   ═══════════════════════════════════════════════════════════ */

#app {
  display: grid;
  grid-template-rows: var(--topbar-h) var(--nav-h) 1fr var(--statusbar-h);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ── Tab Content Container ── */
.tab-content {
  position: relative;
  overflow: hidden;
  min-height: 0;
}

/* Individual tab panels */
.tab-panel {
  display: none;
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.tab-panel.is-active {
  display: flex;
  flex-direction: column;
}

/* Scrollable tab panels (overview, dubai, signals, broadcasts) */
.tab-panel--scroll {
  overflow-y: auto;
  overflow-x: hidden;
}

.tab-panel--scroll.is-active {
  display: block;
}

/* ── Section Containers (used inside scrollable tab panels) ── */
.section {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-8) var(--space-6);
}

.section--full {
  max-width: none;
  padding-left: 0;
  padding-right: 0;
}

.section__header {
  margin-bottom: var(--space-8);
  text-align: center;
}

.section__header h2 {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  letter-spacing: -0.01em;
  margin-bottom: var(--space-2);
}

.section__header p {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.section__header-line {
  width: 48px;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
  margin: var(--space-4) auto 0;
  border-radius: var(--radius-full);
}

/* ── Map Tab — fills entire content area ── */
.tab-panel--map.is-active {
  display: flex;
  flex-direction: row;
}

.tab-panel--map .main {
  position: relative;
  overflow: hidden;
  display: flex;
  flex: 1;
  min-height: 0;
}

/* ── Map Wrap ── */
.map-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* ── Sidebar Toggle Button ── */
.sidebar-toggle {
  position: absolute;
  top: 50%;
  right: var(--space-4);
  transform: translateY(-50%);
  z-index: var(--z-panel);
  width: 36px;
  height: 36px;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--surface-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: var(--text-lg);
  transition: all var(--duration-normal) var(--ease-out);
}

.sidebar-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — Tablet (< 1200px)
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 1199px) {
  :root {
    --sidebar-w: 320px;
  }
}

@media (max-width: 1023px) {
  .section {
    padding-left: var(--space-5);
    padding-right: var(--space-5);
  }

  .sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(380px, 85vw) !important;
    z-index: var(--z-sidebar);
    transform: translateX(100%);
    transition: transform var(--duration-slow) var(--ease-out);
    box-shadow: var(--shadow-xl);
  }

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

  .sidebar-toggle {
    display: flex;
    right: var(--space-3);
    top: var(--space-3);
    transform: none;
  }
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — Mobile (< 768px)
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  :root {
    --topbar-h: 44px;
    --nav-h: 48px;
    --statusbar-h: 28px;
  }

  .section {
    padding: var(--space-5) var(--space-3);
  }

  .section--full {
    padding: 0;
  }

  .section__header {
    margin-bottom: var(--space-5);
    padding: 0 var(--space-2);
  }

  .section__header h2 {
    font-size: var(--text-xl);
  }

  .section__header p {
    font-size: var(--text-xs);
  }

  /* Map tab: stack vertically, sidebar below map */
  .tab-panel--map.is-active {
    flex-direction: column;
  }

  .tab-panel--map .main {
    flex-direction: column;
  }

  .tab-panel--map .map-wrap {
    flex: 1;
    min-height: 55vh;
  }

  .tab-panel--map .sidebar {
    position: relative;
    width: 100% !important;
    height: auto;
    max-height: 40vh;
    flex-shrink: 0;
    transform: none;
    border-left: none;
    border-top: 1px solid var(--border-subtle);
  }

  .sidebar-toggle {
    display: none !important;
  }

  /* Country panel: smaller on mobile */
  .country-panel {
    bottom: var(--space-2);
    left: var(--space-2);
    right: auto;
    width: 260px;
    max-height: 50vh;
    overflow-y: auto;
  }
}
