/**
 * IQ-SIGNAL-HUB — Responsive Layout (v4)
 * Canonical Reference: docs/MASTER_SPEC.md Section 5.3
 */

/* Shell Root Container */
.app-shell {
  display: flex;
  min-height: 100vh;
  width: 100%;
  position: relative;
  background-color: var(--bg);
}

/* Sidebar (Desktop >= 1024px) */
.app-sidebar {
  width: var(--sidebar-width);
  background-color: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  right: 0;
  z-index: 100;
  transition: width var(--transition-speed) ease, transform var(--transition-speed) ease;
  overflow-y: auto;
}

.sidebar-header {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
}

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

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--grad-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #070B14;
  font-weight: 900;
  font-size: 20px;
  box-shadow: 0 0 16px rgba(212, 175, 55, 0.3);
}

.brand-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: 0.5px;
}

.brand-badge {
  font-size: 14px;
  color: var(--gold);
  background: rgba(212, 175, 55, 0.12);
  border: 1px solid var(--border-gold);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.sidebar-nav {
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 16px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-speed) ease;
  min-height: 48px;
}

.nav-link:hover {
  background-color: var(--surface-2);
  color: var(--text);
}

.nav-link.active {
  background: var(--grad-surface);
  color: var(--gold);
  border: 1px solid var(--border-gold);
  box-shadow: var(--glow-gold);
}

.nav-icon {
  width: 22px;
  height: 22px;
  stroke-width: 2;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Main Content Area */
.app-main {
  flex: 1;
  margin-right: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-right var(--transition-speed) ease;
  width: calc(100% - var(--sidebar-width));
}

/* Sticky Topbar */
.app-topbar {
  height: var(--topbar-height);
  background: rgba(14, 22, 38, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

/* Permanent Status Pill (Section 5.5) */
.system-status-bar {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  background-color: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 6px 16px;
  font-size: 14px;
}

.status-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
}

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

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

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

/* Topbar Kill Switch Action */
.btn-kill-switch {
  background: var(--grad-danger);
  color: #FFFFFF;
  border-radius: var(--radius-sm);
  padding: 8px 18px;
  font-weight: 700;
  font-size: 15px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: var(--glow-danger);
  min-height: 44px;
}

.btn-kill-switch:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

/* Page Content Viewport */
.page-viewport {
  flex: 1;
  padding: 32px;
  max-width: var(--content-max-width);
  width: 100%;
  margin: 0 auto;
}

/* Mobile Bottom Navigation (< 768px) */
.mobile-bottom-nav {
  display: none;
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */

/* Tablet (768px to 1023px): Collapsed Sidebar */
@media (min-width: 768px) and (max-width: 1023px) {
  .app-sidebar {
    width: var(--sidebar-collapsed-width);
  }
  .brand-title, .brand-badge, .nav-label, .sidebar-footer {
    display: none;
  }
  .app-main {
    margin-right: var(--sidebar-collapsed-width);
    width: calc(100% - var(--sidebar-collapsed-width));
  }
  .sidebar-header {
    justify-content: center;
    padding: 0;
  }
  .nav-link {
    justify-content: center;
    padding: 12px 0;
  }
}

/* Mobile (< 768px) */
@media (max-width: 767px) {
  .app-sidebar {
    display: none; /* Hidden on mobile; bottom nav replaces it */
  }

  .app-main {
    margin-right: 0;
    width: 100%;
    padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 16px));
  }

  .app-topbar {
    padding: 0 16px;
    height: 64px;
  }

  .page-viewport {
    padding: 16px;
  }

  /* Fixed Bottom Nav with 5 Tabs */
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: rgba(14, 22, 38, 0.95);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--border);
    z-index: 100;
    align-items: center;
    justify-content: space-around;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--text-dim);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    flex: 1;
    height: 100%;
  }

  .bottom-nav-item.active {
    color: var(--gold);
  }

  .bottom-nav-item svg {
    width: 20px;
    height: 20px;
  }
}

