/* === mobile-responsive.css ===
   Mobile & Tablet Responsive Styles
   Makes the training platform usable on screens < 768px */

/* ===== MOBILE MENU TOGGLE BUTTON (hidden on desktop) ===== */
.mobile-menu-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1001;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--border-color, #e2e8f0);
  background: var(--card-bg, #fff);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.1);
  transition: background 0.2s;
  padding: 0;
}
.mobile-menu-toggle:hover {
  background: var(--bg-hover, #f1f5f9);
}
.mobile-menu-toggle svg {
  width: 20px;
  height: 20px;
  stroke: var(--text-primary, #0f172a);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
}

/* Mobile overlay when sidebar is open */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 99;
}
.sidebar-overlay.active {
  display: block;
}

/* ===== TABLET: max-width 1024px ===== */
@media (max-width: 1024px) {
  /* Remove min-width constraint on body */
  body { min-width: 0 !important; }

  /* KPI grid: 2 columns */
  .kpi-row { grid-template-columns: repeat(2, 1fr); }

  /* Reduce padding */
  .v40-content { padding: 16px 20px; }
  .v40-header { padding: 12px 20px; }
}

/* ===== MOBILE: max-width 768px ===== */
@media (max-width: 768px) {
  /* --- Sidebar: off-canvas by default --- */
  .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    bottom: 0;
    width: 260px;
    z-index: 200;
    transition: left 0.3s ease;
    overflow-y: auto;
  }
  .sidebar.open {
    left: 0;
  }

  /* --- Main content: full width --- */
  .main-wrap {
    margin-left: 0 !important;
    width: 100%;
  }

  /* --- Show hamburger button --- */
  .mobile-menu-toggle {
    display: flex;
  }

  /* --- Header adjustments --- */
  .v40-header {
    padding: 12px 16px 12px 56px; /* leave space for hamburger */
    flex-wrap: wrap;
    gap: 8px;
  }
  .v40-header .breadcrumb {
    font-size: 13px;
    width: 100%;
  }

  /* --- Content area --- */
  .v40-content {
    padding: 16px 12px;
  }

  /* --- KPI grid: single column --- */
  .kpi-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* --- Card grids: single column --- */
  .card-grid,
  .books-grid,
  .books-grid-wrapper,
  .textbook-grid,
  .cert-grid,
  .toolkit-grid {
    grid-template-columns: 1fr !important;
  }

  /* --- Continue learning banner: stack --- */
  .continue-banner {
    flex-direction: column;
    padding: 16px;
    gap: 12px;
  }
  .continue-progress {
    width: 100%;
    justify-content: space-between;
  }
  .continue-bar { width: 120px; }

  /* --- Timeline: scroll horizontally --- */
  .timeline-track {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
    min-width: 100%;
  }
  .timeline-stage { min-width: 100px; flex: 0 0 auto; }

  /* --- Tables: horizontal scroll wrapper --- */
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
  table thead, table tbody, table tr {
    display: table;
    width: 100%;
    table-layout: fixed;
  }
  table { min-width: 500px; }

  /* --- Textbook section --- */
  .textbook-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 16px;
  }
  .search-filter-bar {
    flex-direction: column;
    padding: 10px 16px;
    gap: 8px;
  }
  .search-box { max-width: 100%; width: 100%; }
  .filter-btns { flex-wrap: wrap; }

  /* --- Modals: fullscreen on mobile --- */
  .modal-overlay {
    padding: 0;
  }
  .modal-content, .modal-box {
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    border-radius: 0 !important;
    margin: 0 !important;
  }

  /* --- Header user area: compact --- */
  .header-user-area {
    gap: 8px;
  }
  .header-user-name { font-size: 12px !important; }
  .header-user-role { font-size: 11px !important; }
  .header-avatar { width: 28px !important; height: 28px !important; font-size: 11px !important; }
  .header-logout-btn { padding: 4px 8px !important; font-size: 11px !important; }

  /* --- Section title --- */
  .section-title { font-size: 14px; }

  /* --- Book cards: stack --- */
  .book-card {
    flex-direction: column;
  }
  .book-cover {
    width: 100% !important;
    height: 120px !important;
  }

  /* --- Footer --- */
  .footer { padding: 16px 12px; }
}

/* ===== SMALL MOBILE: max-width 480px ===== */
@media (max-width: 480px) {
  .v40-header {
    padding: 10px 12px 10px 52px;
  }
  .v40-content {
    padding: 12px 8px;
  }
  .kpi-card {
    padding: 12px 14px;
  }
  .kpi-value {
    font-size: 20px;
  }
  .continue-pct {
    font-size: 22px;
  }
}

/* ===== PRINT: hide sidebar/header ===== */
@media print {
  .sidebar, .mobile-menu-toggle, .theme-toggle-btn, .v40-header, .sidebar-overlay {
    display: none !important;
  }
  .main-wrap {
    margin-left: 0 !important;
  }
}
