/* ==========================================================================
   mobile.css — lapisan tampilan mobile untuk Dashboard Voucher Fokus777
   --------------------------------------------------------------------------
   Aplikasi ini tidak memakai Bootstrap, jadi file ini berdiri sendiri.
   Semua aturan hanya aktif di layar < 900px. Tampilan desktop tidak berubah.
   Dimuat setelah style.css dan setelah <style> bawaan tiap halaman.
   ========================================================================== */

:root {
  --mnav-h: 58px;
  --mtap: 44px;
  --hijau: #22c55e;
  --biru: #3b82f6;
}

/* ==========================================================================
   1. DASAR
   ========================================================================== */
@media (max-width: 899.98px) {

  html { -webkit-text-size-adjust: 100%; }

  body {
    overflow-x: hidden;
    margin: 0 !important;
    padding: 12px 12px calc(var(--mnav-h) + env(safe-area-inset-bottom) + 14px) !important;
    /* background-attachment: fixed bikin berat dan sering berkedip di HP */
    background-attachment: scroll !important;
  }

  h1 { font-size: 1.35rem; margin: 12px 0 10px; }
  h2 { font-size: 1.15rem; }
  h3 { font-size: 1.05rem; }

  img { max-width: 100%; height: auto; }

  /* ---- Area sentuh ---- */
  button,
  input[type="submit"],
  input[type="button"],
  .btn,
  a.btn {
    min-height: var(--mtap);
    font-size: 16px;
  }

  input, select, textarea {
    font-size: 16px;          /* mencegah iOS zoom otomatis saat mengetik */
    min-height: var(--mtap);
    box-sizing: border-box;
    max-width: 100%;
  }

  textarea { min-height: 110px; }
}

/* ==========================================================================
   2. TOPBAR — menu disembunyikan di balik tombol
   ========================================================================== */
@media (max-width: 899.98px) {

  .topbar {
    padding: 10px 12px !important;
    gap: 8px !important;
    align-items: center !important;
  }

  .topbar h1 {
    font-size: 16px !important;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Tombol menu dibuat oleh mobile.js */
  .mtoggle {
    flex: none;
    width: var(--mtap);
    height: var(--mtap);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex-direction: column;
    background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .25);
    border-radius: 10px;
    cursor: pointer;
    padding: 0;
  }
  .mtoggle span {
    display: block;
    width: 18px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
  }

  /* Daftar tautan: tertutup dulu, dibuka lewat tombol */
  .topbar .nav-buttons {
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0 !important;
    max-height: 0;
    overflow: hidden;
    transition: max-height .25s ease;
  }

  .topbar .nav-buttons.mbuka {
    max-height: 70vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    margin-top: 8px;
  }

  .topbar .nav-buttons a {
    background: transparent !important;
    border: 0 !important;
    border-bottom: 1px solid rgba(255, 255, 255, .12) !important;
    border-radius: 0 !important;
    padding: 13px 4px !important;
    text-align: left;
    transform: none !important;
    white-space: normal !important;
  }

  .topbar .nav-buttons a.mnav-aktif {
    box-shadow: inset 3px 0 0 var(--hijau);
    padding-left: 12px !important;
    font-weight: 700;
  }

  .navbar-spacer { display: none; }
}

/* ==========================================================================
   3. TAB BAR BAWAH (dibuat oleh mobile.js)
   ========================================================================== */
.mnav { display: none; }

@media (max-width: 899.98px) {
  .mnav {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 9998;
    background: #ffffff;
    border-top: 1px solid #d8dee6;
    box-shadow: 0 -2px 14px rgba(0, 0, 0, .08);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .mnav a {
    flex: 1 1 0;
    min-width: 0;
    height: var(--mnav-h);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    text-decoration: none;
    color: #6b7280;
    font-size: 11px;
    line-height: 1;
    padding: 0 2px;
  }

  .mnav a span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mnav a svg { width: 21px; height: 21px; flex: none; }
  .mnav a.mnav-on { color: #16a34a; font-weight: 700; }
  .mnav a:active { background: #f1f5f9; }
}

/* ==========================================================================
   4. TABEL
   ========================================================================== */
@media (max-width: 899.98px) {

  .mtabel-bungkus {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
  }

  .mscroll-hint {
    display: block;
    font-size: 12px;
    color: #475569;
    background: rgba(255, 255, 255, .85);
    padding: 4px 8px;
    border-radius: 6px;
    margin: 0 0 6px;
  }

  table { font-size: .9rem; }
  th, td { padding: 6px !important; }
}

/* ---- Mode kartu: tiap baris jadi satu kartu ---- */
@media (max-width: 620px) {

  table.mobile-cards {
    border: 0 !important;
    background: transparent !important;
    border-collapse: separate;
    border-spacing: 0;
  }

  table.mobile-cards thead { display: none; }

  table.mobile-cards,
  table.mobile-cards tbody,
  table.mobile-cards tr,
  table.mobile-cards td {
    display: block;
    width: 100%;
  }

  table.mobile-cards tr {
    background: rgba(255, 255, 255, .95);
    border: 1px solid #dfe4ea;
    border-radius: 10px;
    padding: 6px 10px;
    margin-bottom: 10px;
    box-shadow: 0 2px 6px rgba(16, 23, 40, .06);
  }

  table.mobile-cards td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    border: 0 !important;
    border-bottom: 1px solid #f1f3f5 !important;
    padding: 8px 0 !important;
    text-align: left !important;
    white-space: normal !important;
    min-width: 0;
  }

  table.mobile-cards tr td:last-child { border-bottom: 0 !important; }

  table.mobile-cards td::before {
    content: attr(data-label);
    flex: 0 0 38%;
    max-width: 38%;
    font-size: 12px;
    font-weight: 700;
    color: #64748b;
    line-height: 1.35;
  }

  table.mobile-cards td > * {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  table.mobile-cards td[colspan]::before { content: none; }
  table.mobile-cards td[colspan] {
    justify-content: center;
    text-align: center !important;
  }

  table.mobile-cards td.mcard-actions { flex-wrap: wrap; gap: 8px; }
  table.mobile-cards td.mcard-actions::before {
    flex-basis: 100%;
    max-width: 100%;
    margin-bottom: 2px;
  }
}

/* ==========================================================================
   5. FORM, FILTER, KARTU RINGKASAN
   ========================================================================== */
@media (max-width: 899.98px) {

  .filters {
    padding: 12px !important;
    border-radius: 10px !important;
  }

  .filters form,
  form {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  /* Form yang sengaja dibuat sebaris di desktop ikut menumpuk di HP */
  form[style*="inline"] {
    display: flex !important;
    margin-right: 0 !important;
    margin-bottom: 12px;
  }

  .filters label,
  form label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 14px;
  }

  .filters input,
  .filters select,
  .filters button,
  form input,
  form select,
  form button {
    width: 100%;
    margin: 0;
  }

  /* Tautan yang dibuat mirip tombol */
  a.btn,
  a[style*="background"][style*="padding"] {
    display: block !important;
    text-align: center;
    padding: 12px !important;
    margin-bottom: 10px;
    border-radius: 8px !important;
  }

  .filters a { margin-right: 0; }

  /* Kartu ringkasan */
  .summary-wrap {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  .summary-card {
    padding: 12px 14px !important;
    border-radius: 12px !important;
  }
  .summary-card .value { font-size: 19px !important; }

  /* Kartu statistik di halaman utama */
  .stats {
    flex-direction: column;
    gap: 10px;
  }
  .stats div {
    width: auto !important;
    box-sizing: border-box;
  }

  /* Halaman login */
  .container {
    max-width: 100% !important;
    margin: 24px auto !important;
  }
}

/* ==========================================================================
   6. AKSESIBILITAS
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .topbar .nav-buttons { transition: none !important; }
}

:focus-visible {
  outline: 3px solid rgba(34, 197, 94, .6);
  outline-offset: 2px;
}
