/* =============================================
   WorkerHub.OS — Responsive CSS
   Mobile-first breakpoints
   ============================================= */

/* === TABLET (max 1024px) === */
@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-grid-full {
    grid-template-columns: 1fr;
  }

  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .stats-grid {
    gap: 1rem;
  }
}

/* === MOBILE (max 768px) === */
@media (max-width: 768px) {
  /* Sidebar jadi slide-in overlay */
  .sidebar {
    transform: translateX(-100%);
    z-index: 200;
    width: 260px;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .sidebar-close { display: flex; }

  .main-wrapper {
    margin-left: 0;
    padding-bottom: 70px; /* untuk mobile nav */
  }

  .menu-toggle { display: flex; }

  .topbar {
    padding: 0 1rem;
  }

  .topbar-avatar { display: none; }
  .bisnis-name { display: none; }
  .hide-mobile { display: none !important; }

  .mobile-nav { display: flex; }

  .page-content {
    padding: 1.25rem 1rem 1rem;
  }

  /* Tables jadi card layout di mobile */
  .table-wrapper {
    border: none;
    background: transparent;
    overflow-x: visible;
  }

  .table, .table thead, .table tbody, .table tr, .table th, .table td {
    display: block;
    width: 100%;
  }

  .table thead {
    display: none; /* Sembunyikan header tabel asli */
  }

  .table tbody tr {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    margin-bottom: 1.25rem;
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
  }

  .table tbody tr:hover {
    background: var(--color-surface-2);
  }

  .table td {
    border: none;
    border-bottom: 1px solid var(--color-border-2);
    padding: 0.75rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: right;
    min-height: 44px;
    font-size: 0.875rem;
  }

  .table td:first-child {
    display: block;
    text-align: left;
    border-bottom: 2px solid var(--color-border);
    padding-bottom: 0.85rem;
    margin-bottom: 0.5rem;
  }

  .table td:first-child div {
    font-size: 1.05rem !important;
  }

  .table td:last-child {
    border-bottom: none;
    padding-top: 1rem;
    padding-bottom: 0;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    text-align: left;
  }

  /* Ambil data-label untuk dijadikan header label kolom */
  .table td[data-label]::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--color-text-3);
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.05em;
    text-align: left;
    float: left;
  }

  .table td:first-child::before,
  .table td:last-child::before {
    display: none; /* Hilangkan label untuk barang/nama dan aksi */
  }

  .action-group {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .action-group .btn,
  .action-group form,
  .action-group form .btn {
    flex: 1 1 calc(50% - 4px);
    width: 100%;
    justify-content: center;
    margin: 0;
  }

  /* Grid adjustments */
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .metric-value {
    font-size: 1.25rem;
  }

  /* Auth card */
  .auth-card {
    padding: 1.75rem 1.25rem;
  }

  /* Filter bar */
  .filter-bar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    margin-bottom: 1.5rem;
  }

  .filter-bar > * {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0;
  }

  .filter-bar .form-control {
    height: 42px;
  }

  .filter-bar .btn {
    height: 42px;
    justify-content: center;
  }

  .filter-actions {
    display: flex !important;
    flex-direction: row;
    gap: 8px;
    width: 100% !important;
  }

  .filter-actions .btn {
    flex: 1;
    width: auto !important;
  }

  /* Page header */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  /* Landing page */
  .landing-hero {
    padding: 3.5rem 5% 3rem;
  }

  .hero-title {
    font-size: 1.9rem;
  }

  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
  }

  .stat-number {
    font-size: 1.8rem;
  }

  .landing-nav .btn-hero { display: none; }

  /* Form full width on mobile */
  .form-row { flex-direction: column; }

  /* Buttons */
  .btn {
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
  }

  /* Topbar title */
  .page-title {
    font-size: 1rem;
  }
}

/* === SMALL MOBILE (max 480px) === */
@media (max-width: 480px) {
  .metrics-grid {
    grid-template-columns: 1fr 1fr;
  }

  .metric-card {
    padding: 1rem;
    flex-direction: column;
    gap: 10px;
  }

  .hero-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-hero {
    justify-content: center;
  }

  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .feature-grid {
    grid-template-columns: 1fr;
  }

  .modal-box {
    padding: 1.5rem;
  }

  .auth-card {
    padding: 1.5rem 1rem;
  }

  /* On card layout (very small screens), show all stacked data including formerly hidden columns */
  .table .hide-mobile { display: flex !important; }

  /* Action buttons mobile */
  .action-group {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
  }
}

/* === FORM ROW === */
.form-row {
  display: flex;
  gap: 1rem;
}

.form-row .form-group {
  flex: 1;
  min-width: 0;
}

/* === SCROLLBAR STYLING === */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border-2); border-radius: 100px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-muted); }

/* === PRINT === */
@media print {
  .sidebar, .topbar, .mobile-nav, .app-footer,
  .btn, .filter-bar { display: none !important; }
  .main-wrapper { margin-left: 0; }
  body { background: white; color: black; }
}
