/* =================================================================
   GanaIT Workforce Portal — Mobile & Responsive Overrides
   Session 4 | 2026-06-01
   ================================================================= */

/* ─── Reset & Base ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body { overflow-x: hidden; -webkit-text-size-adjust: 100%; }
img  { max-width: 100%; height: auto; }

/* ─── Sidebar: slide-in drawer on mobile ───────────────────────── */
@media (max-width: 991.98px) {

  #sidebar,
  .sidebar,
  .left-panel,
  .nav-sidebar,
  .sidebar-wrapper,
  [class*="sidebar-"] {
    position: fixed !important;
    top: 0;
    left: -285px;
    height: 100vh !important;
    width: 270px !important;
    z-index: 1055;
    overflow-y: auto;
    overflow-x: hidden;
    transition: left 0.28s cubic-bezier(0.4,0,0.2,1);
    box-shadow: none;
  }

  #sidebar.mobile-open,
  .sidebar.mobile-open {
    left: 0 !important;
    box-shadow: 4px 0 24px rgba(0,0,0,0.28) !important;
  }

  #ganait-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1050;
    cursor: pointer;
  }
  #ganait-sidebar-overlay.show { display: block; }

  /* Main content full-width when sidebar is off-canvas */
  .main-content,
  #main-content,
  .content-wrapper,
  .page-wrapper,
  .content-area {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  /* Sidebar nav wrapper: don't stretch to fill height on mobile — let items stack naturally */
  .sidebar > .flex-grow-1 {
    flex-grow: 0 !important;
  }

  /* Hamburger toggle button */
  .ganait-hamburger {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    margin-right: 10px;
    flex-shrink: 0;
    padding: 0;
    color: inherit;
  }
  .ganait-hamburger svg { width: 20px; height: 20px; fill: none; }

  /* Sticky top bar */
  .navbar, .top-nav, .topbar, .top-bar, header nav {
    position: sticky !important;
    top: 0;
    z-index: 1030;
  }
}

@media (min-width: 992px) {
  .ganait-hamburger     { display: none !important; }
  #ganait-sidebar-overlay { display: none !important; }
}

/* ─── Tables: horizontal scroll wrapper ────────────────────────── */
@media (max-width: 767.98px) {

  .ganait-table-wrap {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 6px;
  }

  .table th { white-space: nowrap; font-size: 13px; padding: 8px 6px; }
  .table td { font-size: 14px; padding: 8px 6px; }

  /* Card-style rows (timesheets, status reports) */
  .table-card-mobile thead { display: none !important; }
  .table-card-mobile tr {
    display: block;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    margin-bottom: 10px;
    padding: 4px 8px;
    background: #fff;
  }
  .table-card-mobile td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 4px;
    border: none;
    border-bottom: 1px solid #f1f3f5;
    font-size: 13px;
  }
  .table-card-mobile td:last-child { border-bottom: none; }
  .table-card-mobile td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 11px;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-right: 8px;
    flex-shrink: 0;
    min-width: 80px;
  }
  /* Action cells with no label should not reserve label space */
  .table-card-mobile td:not([data-label])::before {
    min-width: 0;
    margin-right: 0;
  }
}

/* ─── Bootstrap grid: force single-column on xs ────────────────── */
@media (max-width: 575.98px) {
  .row > [class*="col-md-"],
  .row > [class*="col-lg-"] {
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }
  .form-row > [class*="col-"] {
    padding-right: 6px;
    padding-left: 6px;
  }
}

/* ─── Cards ─────────────────────────────────────────────────────── */
@media (max-width: 767.98px) {
  .card        { margin-bottom: 14px; }
  .card-body   { padding: 14px 12px; }
  .card-header { padding: 10px 12px; }
}

/* ─── Stat / summary grids (dashboard) ─────────────────────────── */
@media (max-width: 575.98px) {
  .stats-row,
  .row.stats {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
  }
  .stats-row > *,
  .row.stats > * {
    width: 100% !important;
    padding: 0 !important;
    max-width: 100% !important;
    flex: none !important;
  }
}

/* ─── Page headers ──────────────────────────────────────────────── */
@media (max-width: 575.98px) {
  h1, .h1 { font-size: 1.35rem !important; }
  h2, .h2 { font-size: 1.2rem !important; }
  h3, .h3 { font-size: 1.05rem !important; }
  .page-title { font-size: 1.2rem !important; }

  /* Flex headers that contain a title + action button */
  .d-flex.justify-content-between.align-items-center,
  .d-flex.align-items-center.justify-content-between {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }
  .d-flex.justify-content-between.align-items-center > *:last-child {
    width: 100%;
  }
}

/* ─── Forms ─────────────────────────────────────────────────────── */
@media (max-width: 575.98px) {
  .form-group, .mb-3   { margin-bottom: 12px !important; }
  .form-control,
  .form-select         { font-size: 14px !important; min-height: 44px; }
  label                { font-size: 14px; font-weight: 600; }
  .form-actions .btn,
  .card-footer .btn    { width: 100%; margin-bottom: 8px; }
}

/* ─── Buttons ───────────────────────────────────────────────────── */
@media (max-width: 575.98px) {
  .btn    { min-height: 44px; font-size: 13px; }
  .btn-sm { min-height: 40px; font-size: 12px; }
  .btn-toolbar,
  .action-buttons { flex-wrap: wrap !important; gap: 6px !important; }
}

/* ─── Mobile-stack: flex-end button rows go full-width on xs ────── */
@media (max-width: 575.98px) {
  .mobile-stack-btns {
    flex-direction: column !important;
  }
  .mobile-stack-btns .btn {
    width: 100% !important;
  }
}

/* ─── Modals ────────────────────────────────────────────────────── */
@media (max-width: 575.98px) {
  .modal-dialog   { margin: 8px !important; max-width: calc(100vw - 16px) !important; }
  .modal-header   { padding: 12px 14px; }
  .modal-body     { padding: 12px 14px; }
  .modal-footer   { padding: 10px 14px; flex-wrap: wrap; gap: 6px; }
  .modal-footer .btn { flex: 1 1 auto; }
}

/* ─── Badges / pills ────────────────────────────────────────────── */
@media (max-width: 575.98px) {
  .badge { font-size: 11px !important; padding: 3px 7px !important; }
}

/* ─── Assignment / Placement hero card ─────────────────────────── */
@media (max-width: 767.98px) {
  .placement-hero .hero-header,
  .assignment-card .header-row {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 8px !important;
  }
  .placement-meta-grid { grid-template-columns: 1fr !important; }
}

/* ─── Profile page ──────────────────────────────────────────────── */
@media (max-width: 767.98px) {
  .profile-header {
    flex-direction: column !important;
    text-align: center;
    gap: 12px;
  }
  .profile-avatar { margin: 0 auto; }
}

/* ─── Leave balance grid ────────────────────────────────────────── */
@media (max-width: 575.98px) {
  .leave-balance-grid,
  .balance-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 8px !important; }
}

/* ─── Quick actions ─────────────────────────────────────────────── */
@media (max-width: 575.98px) {
  .quick-actions { flex-wrap: wrap; gap: 8px; }
  .quick-actions .btn,
  .quick-actions a {
    flex: 1 1 calc(50% - 4px);
    text-align: center;
    font-size: 13px;
    padding: 8px 6px;
  }
}

/* ─── Pagination ────────────────────────────────────────────────── */
@media (max-width: 575.98px) {
  .pagination { flex-wrap: wrap; justify-content: center; gap: 2px; }
  .page-link  { padding: 5px 9px; font-size: 12px; }
}

/* ─── Timeline / Activity ───────────────────────────────────────── */
@media (max-width: 575.98px) {
  .timeline-item { padding-left: 40px !important; }
  .timeline-icon { width: 28px !important; height: 28px !important; font-size: 12px !important; }
}

/* ─── Utility ───────────────────────────────────────────────────── */
.show-on-mobile { display: none; }

@media (max-width: 767.98px) {
  .hide-on-mobile    { display: none !important; }
  .show-on-mobile    { display: block !important; }
  .text-center-mobile { text-align: center !important; }
  .w-full-mobile     { width: 100% !important; }
  .p-sm-mobile       { padding: 8px !important; }
}

/* ─── iOS safe-area insets (notch / home bar) ───────────────────── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  body { padding-bottom: env(safe-area-inset-bottom); }
}

/* ─── Restore touch-target height on compact py-0 buttons ───────── */
@media (max-width: 575.98px) {
  .btn.py-0, .btn-sm.py-0 {
    padding-top: 0.375rem !important;
    padding-bottom: 0.375rem !important;
    min-height: 44px !important;
  }
}

/* ─── Keyboard / switch-access focus ring ───────────────────────── */
.ganait-hamburger:focus-visible {
  outline: 3px solid #2e75b6;
  outline-offset: 2px;
}
