/* ============================================================
   MOBILE.CSS — Responsive mobile-first cho 8 trang
   Nguyên tắc: Ẩn table desktop, hiện card list trên mobile
   ============================================================ */

/* ============================================================
   BASE — Ẩn mobile cards trên desktop
   ============================================================ */
.mobile-cards { display: none; }
.mobile-actions-fab { display: none; }
.mobile-filter-btn { display: none; }

/* ============================================================
   BREAKPOINT < 768px
   ============================================================ */
@media (max-width: 768px) {

  /* ---------- Ẩn table desktop, hiện card ---------- */
  .table-wrap.desktop-only { display: none !important; }
  .mobile-cards { display: block; }

  /* ---------- Content padding ---------- */
  .content {
    padding: 12px;
    padding-bottom: calc(var(--bottomnav-h) + 20px);
  }

  /* ---------- Header của trang ---------- */
  .page-header {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
  }
  .page-header .page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-900);
  }
  .page-header .page-actions {
    display: flex;
    gap: 8px;
    width: 100%;
  }
  .page-header .page-actions .btn {
    flex: 1;
    justify-content: center;
    font-size: 13px;
    padding: 10px 12px;
  }
  .page-header .page-actions .btn-secondary,
  .page-header .page-actions .btn-extra {
    display: none;
  }

  /* Menu ⋯ cho action phụ */
  .mobile-more-menu {
    display: inline-flex;
    flex: 0 0 auto;
    width: 44px;
  }

  /* ---------- Search input ---------- */
  .mobile-search {
    width: 100% !important;
    max-width: 100% !important;
    margin-bottom: 12px;
  }

  /* ============================================================
     CARD LIST
     ============================================================ */
  .m-card {
    background: #fff;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border: 1px solid var(--gray-100);
    position: relative;
    transition: box-shadow 0.15s, transform 0.15s;
  }
  .m-card:active {
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    transform: scale(0.99);
  }

  .m-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
    gap: 8px;
  }
  .m-card-title {
    font-weight: 700;
    color: #2e7d32;
    font-size: 14px;
    line-height: 1.3;
    flex: 1;
    word-break: break-word;
  }
  .m-card-badge {
    flex: 0 0 auto;
  }

  .m-card-body {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 13px;
    color: var(--gray-700);
  }
  .m-card-row {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    line-height: 1.4;
  }
  .m-card-row .icon {
    flex: 0 0 auto;
    width: 18px;
    text-align: center;
    opacity: 0.85;
  }
  .m-card-row .text {
    flex: 1;
    word-break: break-word;
  }
  .m-card-row .text strong {
    color: var(--gray-900);
  }
  .m-card-row.muted {
    color: var(--gray-500);
    font-size: 12px;
  }

  .m-card-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--gray-100);
  }
  .m-card-footer .btn {
    font-size: 12px;
    padding: 6px 12px;
  }

  /* ============================================================
     FAB (Floating Action Button) — Nút thêm nổi bật
     ============================================================ */
  .mobile-actions-fab {
    display: flex;
    position: fixed;
    right: 16px;
    bottom: calc(var(--bottomnav-h) + 16px);
    z-index: 80;
    gap: 8px;
    flex-direction: column;
  }
  .fab-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #2e7d32;
    color: #fff;
    border: none;
    box-shadow: 0 4px 12px rgba(46,125,50,0.4);
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s;
  }
  .fab-btn:active {
    transform: scale(0.95);
  }
  .fab-btn.secondary {
    background: #fff;
    color: #2e7d32;
    border: 1px solid var(--gray-200);
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    font-size: 20px;
    width: 48px;
    height: 48px;
  }

  /* ============================================================
     BOTTOM SHEET — Filter / Menu
     ============================================================ */
  .bottom-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 85vh;
    background: #fff;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -8px 24px rgba(0,0,0,0.15);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 200;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .bottom-sheet.open {
    transform: translateY(0);
  }
  .bottom-sheet-handle {
    padding: 8px 0 4px 0;
    text-align: center;
    flex: 0 0 auto;
  }
  .bottom-sheet-handle::before {
    content: '';
    display: inline-block;
    width: 40px;
    height: 4px;
    background: var(--gray-300);
    border-radius: 2px;
  }
  .bottom-sheet-header {
    padding: 12px 20px;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: 0 0 auto;
  }
  .bottom-sheet-header h3 {
    font-size: 16px;
    margin: 0;
  }
  .bottom-sheet-body {
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1 1 auto;
  }
  .bottom-sheet-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--gray-100);
    display: flex;
    gap: 8px;
    flex: 0 0 auto;
  }
  .bottom-sheet-footer .btn {
    flex: 1;
    justify-content: center;
  }
  .bottom-sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 199;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
  }
  .bottom-sheet-backdrop.show {
    opacity: 1;
    pointer-events: auto;
  }

  /* ============================================================
     DISPATCH — Tab switcher 4 cột
     ============================================================ */
  .dispatch-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: #fff;
    border-radius: 10px;
    margin-bottom: 12px;
    overflow-x: auto;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  }
  .dispatch-tab {
    flex: 1;
    min-width: 90px;
    padding: 10px 8px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-weight: 600;
    font-size: 12px;
    color: var(--gray-500);
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.15s;
  }
  .dispatch-tab .count {
    display: inline-block;
    background: var(--gray-200);
    color: var(--gray-700);
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 11px;
    margin-left: 4px;
  }
  .dispatch-tab.active {
    background: #2e7d32;
    color: #fff;
  }
  .dispatch-tab.active .count {
    background: rgba(255,255,255,0.3);
    color: #fff;
  }

  /* Ẩn cột không active trên mobile */
  .grid.grid-4#board {
    grid-template-columns: 1fr !important;
    gap: 0 !important;
  }
  .grid.grid-4#board > .card {
    display: none;
  }
  .grid.grid-4#board > .card.m-active {
    display: block;
  }

  /* ============================================================
     DASHBOARD — KPI 4 cột → 2x2
     ============================================================ */
  .grid-4.kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }
  .kpi {
    padding: 12px !important;
  }
  .kpi .kpi-value {
    font-size: 22px !important;
  }
  .kpi .kpi-label {
    font-size: 10px !important;
  }
  .kpi .kpi-icon {
    font-size: 18px !important;
  }

  /* ============================================================
     CONTROL CENTER — đã có tab từ Package trước
     ============================================================ */
  /* Giữ nguyên */

  /* ============================================================
     ROUTES — Grid 3 cột → 1 cột
     ============================================================ */
  .grid.grid-3#route-list {
    grid-template-columns: 1fr !important;
  }

  /* ============================================================
     WASTE / DROPOFF — Grid 4, 3 cột → 2x2
     ============================================================ */
  .grid.grid-4.waste-kpi {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .grid.grid-3.dropoff-grid {
    grid-template-columns: 1fr !important;
  }

  /* ============================================================
     BOTTOM NAV — Đảm bảo hiển thị
     ============================================================ */
  .bottom-nav {
    display: flex !important;
  }

  /* ============================================================
     TYPography
     ============================================================ */
  h1 { font-size: 20px !important; }
  h2 { font-size: 17px !important; }
  h3 { font-size: 15px !important; }

  /* Bảng con (trong modal) — vẫn cuộn ngang */
  .modal-body .table-wrap table {
    min-width: auto;
  }
}

/* ============================================================
   BREAKPOINT < 480px — Màn hình nhỏ
   ============================================================ */
@media (max-width: 480px) {
  .m-card {
    padding: 12px;
    border-radius: 10px;
  }
  .m-card-title {
    font-size: 13px;
  }
  .m-card-body {
    font-size: 12px;
  }
  .content {
    padding: 10px;
  }

  .grid.grid-4.kpi-grid,
  .grid.grid-4.waste-kpi {
    gap: 8px !important;
  }
  .kpi .kpi-value {
    font-size: 20px !important;
  }
}
