/* ==========================================================================
   LABTECH24 — responsive behaviour
   Breakpoints: <=1400 laptop · <=1199 tablet landscape · <=991 tablet
                <=767 phone · <=575 small phone
   ========================================================================== */

/* Collapsed rail (toggled by the header button on desktop) */
@media (min-width: 992px) {
  body.sidebar-collapsed { --sidebar-width: var(--sidebar-width-collapsed); }
  body.sidebar-collapsed .sidebar__brand {
    padding: 14px 0;
    justify-content: center;
  }
  body.sidebar-collapsed .brand-logo { display: none; }
  body.sidebar-collapsed .brand-mark { display: grid; }
  body.sidebar-collapsed .brand-text,
  body.sidebar-collapsed .nav-group-label,
  body.sidebar-collapsed .nav-item span,
  body.sidebar-collapsed .nav-item .nav-count,
  body.sidebar-collapsed .sidebar-user__text,
  body.sidebar-collapsed .sidebar-user__actions { display: none; }
  body.sidebar-collapsed .nav-group-label { height: 12px; }
  body.sidebar-collapsed .nav-item { justify-content: center; padding: 9px 0; }
  body.sidebar-collapsed .nav-item.active::before { left: -12px; }
  body.sidebar-collapsed .sidebar-user { justify-content: center; }
}

@media (max-width: 1400px) {
  .search-global { width: 260px; flex-basis: 260px; }
  .content { padding: 22px 20px 44px; }
}

@media (max-width: 1199.98px) {
  .kpi__value { font-size: 24px; }
  .search-global { width: 200px; flex-basis: 200px; }
}

/* Tablet & below — drawer nav + tighter chrome (covers 768px portrait) */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .main { margin-left: 0; }

  .sidebar-scrim {
    position: fixed; inset: 0; z-index: 1040;
    background: rgba(16, 24, 40, .45);
    opacity: 0; pointer-events: none;
    transition: opacity .2s var(--ease);
  }
  body.sidebar-open .sidebar-scrim { opacity: 1; pointer-events: auto; }
  body.sidebar-open { overflow: hidden; }

  .topbar {
    position: sticky;
    padding: 0 14px;
    gap: 8px;
  }
  .search-global {
    width: auto;
    flex: 1 1 auto;
    max-width: none;
    min-width: 0;
  }
  .breadcrumb-line { display: none; }
  .user-chip__text { display: none; }
  .user-chip { padding: 4px; }
  .topbar__divider { display: none; }

  .content { padding: 18px 16px 40px; }

  .page-head h1 { font-size: 20px; }
  .page-head__actions { width: 100%; margin-left: 0; }
  .page-head__actions .btn { flex: 1 1 auto; }
  .page-head__actions .role-switch { flex: 1 1 100%; }

  .filter-bar .form-select,
  .filter-bar .form-control {
    max-width: none !important;
    min-width: 0;
    flex: 1 1 140px;
  }
  .filter-bar .search-wrap { flex: 1 1 180px; max-width: none; }

  .kpi__label { line-height: 1.3; }
  .chart-box { height: 240px; }

  .modal-dialog { margin: 12px; }
}

@media (max-width: 767.98px) {
  .content { padding: 16px 12px 36px; }
  .topbar { padding: 0 12px; gap: 6px; }
  .topbar__title { font-size: 14px; }

  .search-global { display: none; }
  .search-global.is-open {
    display: block;
    position: absolute;
    left: 10px; right: 10px; top: 10px;
    width: auto;
    flex: none;
    z-index: 5;
  }
  .search-global kbd { display: none; }

  .page-head h1 { font-size: 19px; }
  .page-head p { font-size: 13px; }

  .kpi { padding: 14px; }
  .kpi__value { font-size: 22px; }
  .kpi__meta { font-size: 12px; }

  .filter-bar { padding: 12px 14px; }
  .filter-bar > * { flex: 1 1 100%; }
  .filter-bar .search-wrap { max-width: none; }
  .filter-bar .form-select,
  .filter-bar .form-control { flex: 1 1 100%; }

  .card-ui__head, .card-ui__body { padding: 14px; }
  .card-ui__head { flex-wrap: wrap; }
  .card-ui__head .head-actions { margin-left: 0; width: 100%; }

  .card-ui__foot { padding: 12px 14px; }
  .card-ui__foot .btn { flex: 1 1 auto; }

  .table-foot { padding: 12px 14px; }
  .pagination-ui { margin-left: 0; width: 100%; justify-content: center; flex-wrap: wrap; }

  .notif-menu { width: calc(100% - 24px); max-width: 372px; }
  .toast-stack { right: 12px; left: 12px; bottom: 12px; width: auto; max-width: none; }

  .chart-box { height: 220px; }
  .dl-ui { grid-template-columns: 1fr; }
  .dl-ui dt { border-bottom: 0; padding-bottom: 0; }
  .dl-ui dd { text-align: left; padding-top: 2px; }

  .modal-body, .modal-header, .modal-footer { padding-left: 16px; padding-right: 16px; }
  .modal-footer { flex-wrap: wrap; }
  .modal-footer .btn { flex: 1 1 auto; }

  .fc .fc-toolbar { flex-direction: column; gap: 10px; align-items: flex-start; }
  .fc .fc-toolbar-chunk { display: flex; flex-wrap: wrap; gap: 6px; }

  .role-switch { width: 100%; justify-content: space-between; }
  .role-switch select { flex: 1 1 auto; min-width: 0; }
}

/* Card-style tables on tablet and below (too many columns to stay readable as a table) */
@media (max-width: 991.98px) {
  .table-stack thead { display: none; }
  .table-stack,
  .table-stack tbody,
  .table-stack tr,
  .table-stack td { display: block; width: 100%; }
  .table-stack tr {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin: 12px 14px;
    background: #fff;
    overflow: hidden;
  }
  .table-stack tbody td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 9px 13px;
    border-bottom: 1px solid var(--border);
    white-space: normal;
    text-align: right;
  }
  .table-stack tbody td::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--text-muted);
    text-align: left;
    flex: 0 0 auto;
  }
  .table-stack tbody td:last-child { border-bottom: 0; }
  .table-stack tbody td.row-actions::before { content: none; }
  .table-stack .person-cell { justify-content: flex-end; min-width: 0; }
  .table-stack .row-actions { width: auto; justify-content: flex-end; }
}

@media (max-width: 575.98px) {
  .kpi__top { margin-bottom: 10px; }
  .kpi__label { font-size: 11.5px; }
  .page-head { margin-bottom: 16px; }
  .btn-group-seg { width: 100%; }
  .btn-group-seg button { flex: 1 1 auto; }

  .login-visual { padding: 24px 18px; min-height: 180px; }
  .login-visual h1 { font-size: 24px; }
  .login-panel { padding: 24px 16px 36px; }
  .login-card { padding: 22px 18px; }
}

@media print {
  .sidebar, .topbar, .page-head__actions, .filter-bar, .table-foot, .toast-stack { display: none !important; }
  .main { margin-left: 0; }
  .content { padding: 0; max-width: none; }
  .card-ui { box-shadow: none; break-inside: avoid; }
  body { background: #fff; }
}
