/* ═══════════════════════════════════════════════
   NAIL TURN — mobile.css  v2
   ═══════════════════════════════════════════════ */

/* ── TABLET ≤ 1024px ── */
@media (max-width: 1024px) {
  .stat-pills { gap: 4px; }
  .stat-pill  { padding: 5px 10px; gap: 6px; }
  .sp-val     { font-size: 15px; }
  .sp-rev .sp-val, .sp-tip .sp-val { font-size: 13px; }
}

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

  /* ---------- TOPBAR ---------- */
  .topbar-inner {
    flex-wrap: wrap;
    height: auto;
    min-height: 48px;
    padding: 8px 12px 4px;
    gap: 6px;
  }
  .brand { margin-right: 0; flex-shrink: 0; }
  .topbar-right { margin-left: auto; flex-shrink: 0; }
  .stat-pills {
    order: 3;
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 2px 0 4px;
    gap: 5px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .stat-pills::-webkit-scrollbar { display: none; }
  .stat-pill { flex-shrink: 0; }

  /* ---------- LAYOUT ---------- */
  .sidebar { display: none !important; }

  .app-body {
    /* dùng dvh + padding-bottom thay vì trừ topbar height */
    height: auto;
    min-height: calc(100dvh - 48px);
    overflow: visible;
  }

  .main-content {
    padding: 10px 12px;
    padding-bottom: 72px; /* chỗ cho bottom nav */
    overflow-y: auto;
    height: calc(100dvh - 48px);
    box-sizing: border-box;
  }

  /* ---------- BOTTOM NAV ---------- */
  .bottom-nav {
    display: flex !important;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 56px;
    background: var(--surface);
    border-top: 1px solid var(--br2);
    box-shadow: 0 -4px 16px rgba(0,0,0,.08);
    z-index: 400;
    align-items: stretch;
    padding: 0 4px;
  }
  .bottom-nav .nav-btn {
    flex: 1;
    height: 100%;
    width: auto;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 600;
    gap: 2px;
    padding: 4px 0;
  }

  /* ---------- ACTION BAR ---------- */
  .action-bar { flex-direction: column; gap: 8px; }
  .next-worker-card {
    padding: 10px 12px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .nwc-name { font-size: 15px; }
  /* buttons bên phải next-worker-card */
  .nwc-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    flex-shrink: 0;
  }

  /* ---------- MULTI BAR ---------- */
  .multi-bar { flex-direction: column; gap: 6px; align-items: flex-start; }

  /* ---------- SEARCH BAR ---------- */
  .search-filter-bar { flex-wrap: wrap; gap: 6px; }
  .search-wrap { max-width: 100%; flex: 1; min-width: 0; }
  .filter-tabs { flex-wrap: wrap; gap: 3px; }

  /* ---------- STAFF CARD ---------- */
  .sc-body { padding: 8px 10px 8px 14px; gap: 8px; }
  .sc-name { font-size: 13px; }
  .sc-avatar { width: 34px; height: 34px; font-size: 10px; }
  .sc-actions { gap: 4px; }
  .qa-btn { padding: 5px 9px; font-size: 11px; }

  /* ---------- POPUP ---------- */
  .popup-overlay {
    padding: 0;
    align-items: flex-end;
  }
  .popup {
    width: 100%;
    max-width: 100%;
    max-height: 90dvh;
    border-radius: 20px 20px 0 0;
  }
  .popup-body { gap: 10px; }
  .pt-val { font-size: 36px; }

  /* ---------- DATA TABLE ---------- */
  .data-table-wrap { overflow-x: auto; }
  .data-table { min-width: 480px; }

  /* ---------- REPORT ---------- */
  .report-grid-4 { grid-template-columns: 1fr 1fr !important; gap: 8px !important; }
  .rsc-val { font-size: 18px; }

  /* ---------- TAB HEADER ---------- */
  .tab-header { flex-wrap: wrap; gap: 8px; }
}

/* ── SMALL PHONE ≤ 480px ── */
@media (max-width: 480px) {
  .sp-label { display: none; }
  .brand-name { font-size: 13px; }

  /* Kanban: scroll ngang, mỗi cột ~80vw */
  .kanban-mobile-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -12px;
    padding: 0 12px 8px;
    scrollbar-width: none;
  }
  .kanban-mobile-wrap::-webkit-scrollbar { display: none; }

  /* f-row stack dọc */
  .f-row { flex-direction: column; }

  /* btn-row nhỏ hơn */
  .btn-sm { padding: 8px 10px; font-size: 11px; }
}

/* ── SAFE AREA — chỉ áp dụng trên mobile ── */
@media (max-width: 768px) {
  @supports (padding-bottom: env(safe-area-inset-bottom)) {
    .bottom-nav {
      height: calc(56px + env(safe-area-inset-bottom));
      padding-bottom: env(safe-area-inset-bottom);
    }
    .main-content {
      padding-bottom: calc(68px + env(safe-area-inset-bottom));
    }
  }
}
