/*
 * table-consistency.css
 * ─────────────────────────────────────────────────────────────
 * Single source of truth untuk konsistensi lebar layout & tabel.
 * Menjamin konsistensi visual 100% pixel-perfect antar seluruh tab:
 * Tugas, Riwayat, Kontrol Foto, Penempatan, Laporan, dan tab masa depan.
 * ─────────────────────────────────────────────────────────────
 */

/* ═══════════════════════════════════════════════
   1. GLOBAL DESKTOP SCROLLBAR STABILITY
   Mencegah pergeseran 15px saat berpindah antara
   tab pendek (Riwayat) dan tab panjang (Foto/Tugas).
   ═══════════════════════════════════════════════ */
html {
  scrollbar-gutter: stable;
}

/* ═══════════════════════════════════════════════
   2. TABLE-SCROLL CONTAINER — konsisten di semua tab
   ═══════════════════════════════════════════════ */
.table-scroll {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #9eb1ca #edf2f7;
}

/* ═══════════════════════════════════════════════
   3. GLOBAL TABLE — reset & fluid
   ═══════════════════════════════════════════════ */
table {
  min-width: 0;
}

/* ═══════════════════════════════════════════════
   4. DESKTOP OPTIMIZATION (min-width: 801px)
      Standarisasi Container & Table Width di Desktop
   ═══════════════════════════════════════════════ */
@media (min-width: 801px) {

  /* A. STANDARISASI SINGLE-CARD PANEL (Penempatan, Riwayat, Master Karyawan, dll)
     Menyamakan padding panel standar menjadi 16px (var(--space-4))
     sehingga lebar inner content sejajar sempurna dengan card Tugas & Foto */
  .app-page-content > .panel {
    padding: 16px !important;
    border-radius: var(--radius-card, 12px) !important;
    box-sizing: border-box !important;
  }

  /* B. MULTI-CARD TABS: Hapus duplikasi padding luar pada tab yang memiliki kartu per-tim
     (Kontrol Foto & Laporan Goreng Sisa) agar kartu per-tim membentang 100% penuh.
     Menggunakan selector ganda (class/attribute dan :has) agar 100% kompatibel di SEMUA browser. */
  .app-page-content .photo-report-panel,
  .app-page-content > .panel[data-operational-report],
  .app-page-content .panel:has(.report-team),
  .app-page-content .panel:has(.photo-team-section) {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
  }

  /* C. Hilangkan border-bottom header di Kontrol Foto & Laporan karena outer panel transparan */
  .app-page-content .photo-report-head,
  .app-page-content .report-head {
    border-bottom: none !important;
    margin-bottom: 16px !important;
    padding-bottom: 0 !important;
  }

  #report-content {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
  }

  /* D. STANDARISASI TEAM CARDS (Laporan .report-team & Kontrol Foto .photo-team-section)
     Keduanya kini memiliki styling kartu utama yang identik: lebar 100%, padding 16px */
  .app-page-content .report-team,
  .app-page-content .photo-team-section {
    width: 100% !important;
    box-sizing: border-box !important;
    padding: 16px !important;
    margin-top: 16px !important;
    margin-bottom: 16px !important;
    border: 1px solid var(--color-border, #e2e8f0) !important;
    border-radius: var(--radius-card, 12px) !important;
    background: var(--color-surface, #ffffff) !important;
    box-shadow: var(--shadow-xs, 0 1px 2px rgba(0,0,0,0.05)) !important;
  }

  /* Header banner kartu per tim rapi menyentuh batas kartu */
  .app-page-content .report-team .team-heading {
    margin: -16px -16px 16px !important;
    padding: 12px 16px !important;
    border-radius: 11px 11px 0 0 !important;
  }
  .app-page-content .photo-team-heading {
    margin: -16px -16px 16px !important;
    padding: 12px 16px !important;
    border-radius: 11px 11px 0 0 !important;
  }

  /* E. TABLE CONTAINER & TABLE LEBAR PENUH 100% */
  .app-page-content .table-scroll {
    width: 100% !important;
    box-sizing: border-box !important;
    margin: 0 !important;
  }

  .app-page-content table {
    width: 100% !important;
    min-width: 100% !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    table-layout: auto !important;
  }

  /* F. PROPORSI KOLOM TABEL DESKTOP */
  /* Kontrol Foto */
  .photo-report-table th,
  .photo-report-table td {
    width: auto !important;
  }
  .photo-report-table th:first-child,
  .photo-report-table td:first-child {
    width: 15% !important;
    min-width: 120px;
  }
  .photo-report-table th:nth-child(2),
  .photo-report-table td:nth-child(2) {
    width: 13% !important;
    min-width: 110px;
  }
  .photo-report-table th:nth-child(n+3):nth-child(-n+8),
  .photo-report-table td:nth-child(n+3):nth-child(-n+8) {
    width: 9% !important;
    text-align: center;
  }
  .photo-report-table th:last-child,
  .photo-report-table td:last-child {
    width: 18% !important;
    min-width: 130px;
  }

  /* Laporan (Goreng & Sisa) */
  .report-table th:first-child,
  .report-table td:first-child {
    width: 25% !important;
    min-width: 140px;
  }
  .report-table th:nth-child(2),
  .report-table td:nth-child(2),
  .report-table th:nth-child(3),
  .report-table td:nth-child(3),
  .report-table th:nth-child(4),
  .report-table td:nth-child(4) {
    width: 15% !important;
    min-width: 90px;
  }
  .report-table th:last-child,
  .report-table td:last-child {
    width: 30% !important;
    min-width: 150px;
  }

  /* Penempatan */
  .placement-guide-table {
    width: 100% !important;
    table-layout: auto !important;
  }
}

/* ═══════════════════════════════════════════════
   5. MOBILE OPTIMIZATION (max-width: 800px)
      Prioritas untuk 90% akses via smartphone
   ═══════════════════════════════════════════════ */
@media (max-width: 800px) {

  /* Petunjuk scroll horizontal otomatis di HP */
  .table-scroll::before {
    content: 'Geser tabel ←→ untuk lihat kolom lainnya';
    display: block;
    padding: 6px 10px;
    color: #64748b;
    background: #f8fbff;
    border-bottom: 1px solid #e8edf4;
    font-size: 11px;
    text-align: right;
    letter-spacing: .01em;
  }

  /* Tabel ringkas tanpa scroll di mobile: sembunyikan petunjuk */
  .report-team .table-scroll::before,
  .dashboard-report-30 .table-scroll::before {
    display: none;
  }

  /* Font input 16px: wajib untuk mencegah auto-zoom di browser iOS/Safari */
  .table-scroll input,
  .table-scroll select,
  .table-scroll textarea {
    font-size: 16px !important;
    min-height: 38px;
  }

  /* Kolom pertama sticky agar nama outlet/tanggal selalu terlihat saat digeser */
  .table-scroll th:first-child,
  .table-scroll td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: #fff;
  }
  .table-scroll th:first-child {
    background: #f5f8fc;
    z-index: 3;
  }

  /* Min-width terkontrol per tabel di mobile agar kolom tidak berdempetan */
  .placement-guide-table { min-width: 720px; }

  /* Penempatan: beri ruang yang cukup untuk outlet, personil, dan status. */
  .placement-guide-table {
    width: 600px !important;
    min-width: 600px !important;
    table-layout: fixed;
  }
  .placement-guide-table th:nth-child(1),
  .placement-guide-table td:nth-child(1) { width: 42px; }
  .placement-guide-table th:nth-child(2),
  .placement-guide-table td:nth-child(2) { width: 100px; }
  .placement-guide-table th:nth-child(3),
  .placement-guide-table td:nth-child(3) { width: 100px; }
  .placement-guide-table th:nth-child(4),
  .placement-guide-table td:nth-child(4) { width: 77px; }
  .placement-guide-table th:nth-child(5),
  .placement-guide-table td:nth-child(5) { width: 100px; }
  .placement-guide-table th:nth-child(6),
  .placement-guide-table td:nth-child(6) { width: 80px; }
  .placement-guide-table th:nth-child(7),
  .placement-guide-table td:nth-child(7) { width: 100px; }
  .placement-guide-table th { white-space: normal; line-height: 1.2; }
  .placement-guide-table input,
  .placement-guide-table select { box-sizing: border-box; width: 100%; min-width: 0; }

  /* Laporan di mobile */
  .report-team .report-table { min-width: 500px; table-layout: fixed; }
  .report-team .report-table th:first-child,
  .report-team .report-table td:first-child { min-width: 115px; width: 115px; }
  .report-team .report-table th:nth-child(2),
  .report-team .report-table td:nth-child(2),
  .report-team .report-table th:nth-child(3),
  .report-team .report-table td:nth-child(3),
  .report-team .report-table th:nth-child(4),
  .report-team .report-table td:nth-child(4) { min-width: 80px; width: 80px; }
  .report-team .report-table th:nth-child(5),
  .report-team .report-table td:nth-child(5) { min-width: 130px; width: 130px; }
  .report-team .report-table input { min-width: 0; width: 100%; box-sizing: border-box; padding: 7px 4px; }

  /* Foto di mobile */
  .photo-report-table { min-width: 740px; table-layout: fixed; }
  .photo-team-section .photo-report-table th:first-child,
  .photo-team-section .photo-report-table td:first-child { min-width: 100px; width: 100px; }
  .photo-team-section .photo-report-table th:nth-child(2),
  .photo-team-section .photo-report-table td:nth-child(2) { min-width: 88px; width: 88px; }
  .photo-team-section .photo-report-table th:nth-child(3),
  .photo-team-section .photo-report-table td:nth-child(3),
  .photo-team-section .photo-report-table th:nth-child(4),
  .photo-team-section .photo-report-table td:nth-child(4),
  .photo-team-section .photo-report-table th:nth-child(5),
  .photo-team-section .photo-report-table td:nth-child(5),
  .photo-team-section .photo-report-table th:nth-child(6),
  .photo-team-section .photo-report-table td:nth-child(6),
  .photo-team-section .photo-report-table th:nth-child(7),
  .photo-team-section .photo-report-table td:nth-child(7),
  .photo-team-section .photo-report-table th:nth-child(8),
  .photo-team-section .photo-report-table td:nth-child(8) { min-width: 68px; width: 68px; }
  .photo-team-section .photo-report-table th:last-child,
  .photo-team-section .photo-report-table td:last-child { min-width: 125px; width: 125px; }
  .photo-team-section .photo-report-table input { min-width: 0; width: 100%; box-sizing: border-box; }
  .photo-team-section .photo-report-table thead th { font-size: 10px; line-height: 1.15; white-space: normal; overflow-wrap: anywhere; padding: 5px 3px; }
  .photo-team-section .photo-report-table td { padding: 4px 3px; }

  /* Queue dan riwayat di mobile */
  .issue-queue-table { min-width: 680px; }
  .visit-trace-table { min-width: 720px; }
  .photo-history-table { min-width: 900px; }
  .report-history-results table { min-width: 700px; }

  /* Dashboard 30 hari di mobile */
  .dashboard-report-30-table { min-width: 0; width: 100%; }
  .dashboard-report-30-table td,
  .dashboard-report-30-table th { white-space: nowrap; }
}

/* ═══════════════════════════════════════════════
   6. SMALL MOBILE OPTIMIZATION (max-width: 480px)
   ═══════════════════════════════════════════════ */
@media (max-width: 480px) {
  .placement-guide-table { min-width: 600px; }
  .photo-report-table { min-width: 680px; }
  .issue-queue-table { min-width: 620px; }
  .visit-trace-table { min-width: 680px; }

  .table-scroll th,
  .table-scroll td { padding: 5px 4px; font-size: 12px; }
  .table-scroll th { font-size: 10px; }
}

/* Pada HP sangat kecil, prioritaskan tiga informasi inti penempatan. */
@media (max-width: 400px) {
  .placement-guide-table {
    width: 640px !important;
    min-width: 640px !important;
  }
  .placement-guide-table th:nth-child(1),
  .placement-guide-table td:nth-child(1) { width: 72px; }
  .placement-guide-table th:nth-child(2),
  .placement-guide-table td:nth-child(2) { width: 95px; }
  .placement-guide-table th:nth-child(3),
  .placement-guide-table td:nth-child(3) { width: 100px; }
  .placement-guide-table th:nth-child(4),
  .placement-guide-table td:nth-child(4) { width: 77px; }
  .placement-guide-table th:nth-child(5),
  .placement-guide-table td:nth-child(5) { width: 95px; }
  .placement-guide-table th:nth-child(6),
  .placement-guide-table td:nth-child(6) { width: 80px; }
  .placement-guide-table th:nth-child(7),
  .placement-guide-table td:nth-child(7) { width: 95px; }
}

/* Lebarkan kolom penempatan untuk ponsel tanpa menghapus No / Outlet ID. */
@media (min-width: 401px) and (max-width: 600px) {
  .placement-guide-table {
    width: 740px !important;
    min-width: 740px !important;
  }
  .placement-guide-table th:nth-child(1),
  .placement-guide-table td:nth-child(1) { width: 72px; }
  .placement-guide-table th:nth-child(2),
  .placement-guide-table td:nth-child(2) { width: 120px; }
  .placement-guide-table th:nth-child(3),
  .placement-guide-table td:nth-child(3) { width: 120px; }
  .placement-guide-table th:nth-child(4),
  .placement-guide-table td:nth-child(4) { width: 90px; }
  .placement-guide-table th:nth-child(5),
  .placement-guide-table td:nth-child(5) { width: 110px; }
  .placement-guide-table th:nth-child(6),
  .placement-guide-table td:nth-child(6) { width: 90px; }
  .placement-guide-table th:nth-child(7),
  .placement-guide-table td:nth-child(7) { width: 110px; }
}

.placement-guide-table th:first-child {
  text-transform: none !important;
}
