/* Shared mobile layout — collapsible sidebars, touch-friendly nav */
@media (max-width: 768px) {
  :root {
    --platform-nav-height: 56px;
  }

  /* ── Collapsible app sidebar (LIA, Training) ── */
  body.has-app-sidebar #sidebar {
    position: fixed;
    top: var(--platform-nav-height, 56px);
    left: 0;
    bottom: 0;
    width: min(300px, 88vw);
    max-width: 88vw;
    z-index: 8500;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.35);
  }

  body.has-app-sidebar.sidebar-open #sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    top: var(--platform-nav-height, 56px);
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 8400;
    background: rgba(3, 7, 15, 0.55);
    backdrop-filter: blur(2px);
  }

  body.sidebar-open .sidebar-backdrop {
    display: block;
  }

  body.has-app-sidebar #main {
    width: 100%;
    flex: 1;
    min-width: 0;
  }

  .sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 10px;
    border: 1px solid var(--border, #1e2d45);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text, #e5e7eb);
    font-size: 20px;
    cursor: pointer;
    flex-shrink: 0;
  }

  .sidebar-toggle:active {
    background: rgba(255, 255, 255, 0.08);
  }

  /* Training / LIA header stacks on narrow screens */
  .main-header {
    flex-wrap: wrap;
    padding: 12px 14px !important;
    gap: 10px !important;
  }

  .main-header > div:first-child {
    flex: 1;
    min-width: 0;
  }

  .main-header h2,
  #topbar h2 {
    font-size: 16px !important;
  }

  .mode-tabs {
    width: 100%;
    justify-content: stretch;
  }

  .mode-tab {
    flex: 1;
    text-align: center;
    padding: 10px 8px !important;
  }

  .main-body {
    padding: 16px 14px !important;
  }

  .ask-msg.user,
  .ask-msg.tutor {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  .practice-card,
  .practice-start,
  .learn-content {
    max-width: 100% !important;
  }

  /* LIA mobile */
  #topbar {
    padding: 10px 14px !important;
    gap: 10px !important;
  }

  #messages {
    padding: 16px 0 !important;
  }

  .msg-row {
    padding: 12px 14px !important;
  }

  .suggestion-grid {
    grid-template-columns: 1fr !important;
    max-width: 100% !important;
  }

  #welcome {
    padding: 24px 16px !important;
  }

  #welcome h2 {
    font-size: 22px !important;
  }

  .input-wrap {
    padding: 0 10px 8px !important;
  }

  .mobile-lia-notice {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 12px;
    padding: 32px 20px;
    margin: 16px;
    border-radius: 14px;
    border: 1px solid rgba(59, 130, 246, 0.25);
    background: rgba(59, 130, 246, 0.08);
    color: #94a3b8;
    font-size: 14px;
    line-height: 1.6;
  }

  .mobile-lia-notice strong {
    color: #e5e7eb;
    font-size: 15px;
  }

  .mobile-lia-notice a {
    color: #60a5fa;
    text-decoration: none;
    font-weight: 600;
  }
}

@media (min-width: 769px) {
  .sidebar-toggle {
    display: none !important;
  }

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

  .mobile-lia-notice {
    display: none !important;
  }
}

/* Bigger touch targets for top nav icons on mobile */
@media (max-width: 768px) {
  .platform-nav-tab {
    padding: 8px 6px !important;
    min-width: 40px;
    min-height: 40px;
    justify-content: center;
  }

  .platform-nav-tab .tab-icon {
    font-size: 20px;
    line-height: 1;
  }

  .platform-nav-logo img {
    height: 32px;
  }

  .platform-nav-tabs {
    gap: 4px;
  }

  #platformNavSignOut {
    padding: 6px 10px;
    min-height: 36px;
  }

  .platform-nav-user img {
    width: 32px;
    height: 32px;
  }
}

/* Dashboard responsive grid */
@media (max-width: 480px) {
  .dash-grid {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 768px) {
  .wrap {
    padding-left: 14px !important;
    padding-right: 14px !important;
  }
}
