/* ═══════════════════════════════════════════════════════════
   StreamPortal 2.0 - Responsive / Mobile
   Loaded after main.css and components.css
   ═══════════════════════════════════════════════════════════ */

/* ─── Sidebar Overlay ───────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 190;
  -webkit-tap-highlight-color: transparent;
}
.sidebar-overlay.active {
  display: block;
}

/* ─── Sidebar Close Button (mobile only, hidden on desktop) */
.sidebar-close-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  margin-left: auto;
  line-height: 1;
}

/* ─── Prevent background scroll when sidebar open ───────── */
body.sidebar-open {
  overflow: hidden;
}

/* ─── Tablet (≤ 1024px) ─────────────────────────────────── */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 200px;
  }

  .content-wrapper {
    padding: 16px;
  }

  .lane-pairs-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ─── Mobile (≤ 768px) ──────────────────────────────────── */
@media (max-width: 768px) {

  /* Sidebar: off-canvas drawer */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    width: 260px;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
  }

  /* Show close X inside sidebar on mobile */
  .sidebar-close-btn {
    display: block;
  }

  /* Main content: full width */
  .main-content {
    margin-left: 0;
  }

  /* Header: full width, compact */
  .app-header {
    left: 0;
    padding: 0 12px;
    height: 52px;
  }

  .main-content {
    padding-top: 52px;
  }

  .header-left {
    gap: 8px;
  }

  .page-title {
    font-size: 14px;
    max-width: 160px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Header right: compact */
  .user-role-label {
    display: none;
  }
  .user-badge {
    padding: 4px 8px;
    font-size: 12px;
  }
  .header-right .btn-sm {
    padding: 6px 8px;
    font-size: 11px;
  }

  /* Hamburger: always visible, good tap target */
  #sidebar-toggle {
    display: inline-flex;
    min-width: 40px;
    min-height: 40px;
    padding: 0;
    align-items: center;
    justify-content: center;
    font-size: 20px;
  }

  /* Content */
  .content-wrapper {
    padding: 12px;
  }

  /* Section headers */
  .section-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  /* Stats grid */
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .stat-card {
    padding: 12px;
    gap: 10px;
  }

  .stat-icon {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }

  .stat-value {
    font-size: 20px;
  }

  /* Grids: single column */
  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }

  .nodes-grid {
    grid-template-columns: 1fr;
  }

  /* Lane pairs: single column */
  .lane-pairs-grid {
    grid-template-columns: 1fr;
  }

  /* Tables: horizontal scroll */
  .card {
    padding: 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .data-table {
    min-width: 560px;
  }

  .data-table th,
  .data-table td {
    padding: 8px 10px;
    font-size: 12px;
  }

  /* Actions: bigger touch targets */
  .actions-cell {
    gap: 4px;
  }

  .btn-icon {
    min-width: 38px;
    min-height: 38px;
    font-size: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Forms: stack all rows to single column */
  .form-row {
    grid-template-columns: 1fr !important;
    gap: 0;
  }

  /* Prevent iOS zoom on input focus */
  .form-input,
  .form-select,
  .form-textarea {
    font-size: 16px;
    padding: 12px;
  }

  .form-checkbox-row {
    padding: 8px 0;
  }

  .form-checkbox {
    width: 22px;
    height: 22px;
  }

  /* Modals: bottom-sheet style on mobile */
  .modal-overlay {
    align-items: flex-end;
  }

  .modal,
  .modal.modal-wide {
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    border-radius: 16px 16px 0 0;
    margin: 0;
  }

  .modal-body {
    max-height: 68vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
  }

  .modal-header {
    padding: 14px 16px;
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 1;
    border-bottom: 1px solid var(--border-color);
  }

  .modal-footer {
    padding: 12px 16px;
    position: sticky;
    bottom: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
  }

  .modal-close {
    min-width: 40px;
    min-height: 40px;
    font-size: 20px;
  }

  /* Buttons: comfortable touch targets */
  .btn {
    min-height: 42px;
    padding: 10px 16px;
  }

  .btn-sm {
    min-height: 36px;
    padding: 8px 12px;
  }

  /* Tab navigation: scrollable horizontal */
  .tab-nav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    gap: 0;
    padding-bottom: 4px;
    flex-wrap: nowrap;
  }

  .tab-btn {
    padding: 10px 14px;
    font-size: 13px;
    flex-shrink: 0;
  }

  /* Badges */
  .badge {
    font-size: 10px;
    padding: 2px 6px;
  }

  .status-badge {
    font-size: 10px;
    padding: 2px 8px;
  }

  /* Auth page */
  .auth-card {
    margin: 16px;
    padding: 24px;
  }

  /* Flash messages */
  .flash-message {
    font-size: 12px;
    padding: 10px 12px;
  }

  /* Empty state */
  .empty-state {
    padding: 24px 12px;
  }

  /* Lane pair cards */
  .lane-pair-card {
    padding: 12px;
  }

  /* Audio stream rows in lane modal */
  .audio-stream-row {
    flex-wrap: wrap;
  }

  .audio-stream-row .form-group {
    min-width: 0;
  }

  /* Venue detail header badges */
  .venue-header-badges {
    flex-wrap: wrap;
    gap: 4px;
  }
}

/* ─── Small phones (≤ 480px) ────────────────────────────── */
@media (max-width: 480px) {

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

  .page-title {
    max-width: 100px;
    font-size: 13px;
  }

  /* Hide user name on very small screens */
  .user-badge span:nth-child(2) {
    display: none;
  }

  .header-right {
    gap: 4px;
  }

  .header-right .btn-sm {
    padding: 5px 6px;
    font-size: 10px;
  }

  .modal-body {
    padding: 10px;
  }

  .form-section-title {
    font-size: 12px;
  }

  /* Node badge cards */
  .node-badge {
    padding: 12px;
  }

  .node-name {
    font-size: 14px;
  }
}

/* ─── Desktop: hide mobile-only elements ────────────────── */
@media (min-width: 769px) {
  #sidebar-toggle {
    display: none;
  }

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

  .sidebar-close-btn {
    display: none !important;
  }
}
