/* ==========================================================================
   mobile.css — lapisan tampilan mobile untuk Dashboard Fokus (25k)
   --------------------------------------------------------------------------
   Semua aturan hanya aktif di layar < 992px. Tampilan desktop tidak berubah.
   Dimuat dari navbar.php (head), jadi berlaku di semua halaman.
   ========================================================================== */

:root {
  --mnav-h: 58px;
  --mtap: 44px;
}

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

  html { -webkit-text-size-adjust: 100%; }
  body { overflow-x: hidden; }
  body::before { background-attachment: scroll; }

  .container,
  .container-fluid { padding-left: 14px; padding-right: 14px; }

  body.has-mnav {
    padding-bottom: calc(var(--mnav-h) + env(safe-area-inset-bottom) + 8px);
  }

  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.3rem; }
  h3 { font-size: 1.15rem; }
  h4 { font-size: 1.05rem; }
  h5 { font-size: 1rem; }

  .card { border-radius: 12px; }
  .card-body, .card.p-3 { padding: 14px !important; }

  .row > [class*="col-"] { margin-bottom: 12px; }
  .row.g-0 > [class*="col-"],
  .row.gx-0 > [class*="col-"] { margin-bottom: 0; }

  /* ---- Area sentuh & input ---- */
  .btn, .nav-link, .page-link {
    min-height: var(--mtap);
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .btn-sm { min-height: 38px; }

  .form-control, .form-select {
    min-height: var(--mtap);
    font-size: 16px;        /* mencegah iOS zoom otomatis saat mengetik */
  }
  .form-control-sm, .form-select-sm { min-height: 38px; font-size: 16px; }

  textarea.form-control { min-height: 110px; }

  .form-check-input { width: 1.25em; height: 1.25em; margin-top: .15em; }

  /* Tombol di dalam form selebar layar, kecuali di tabel / grup tombol */
  .card form .btn:not(.btn-sm):not(.btn-close) { width: 100%; }
  .card form .btn + .btn { margin-top: 8px; }
  .btn-group .btn, .btn-group-sm .btn,
  .table .btn, td .btn, .input-group .btn {
    width: auto !important;
    margin-top: 0 !important;
  }
  td .btn + .btn { margin-left: 4px; }
}

/* ==========================================================================
   2. NAVBAR
   ========================================================================== */
@media (max-width: 991.98px) {

  .navbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    padding-top: .35rem;
    padding-bottom: .35rem;
  }

  .navbar-brand {
    font-size: 1.05rem;
    max-width: 60vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .navbar-toggler {
    min-height: var(--mtap);
    min-width: var(--mtap);
    padding: .25rem .5rem;
  }
  .navbar-toggler:focus { box-shadow: none; }

  .navbar-collapse {
    max-height: 72vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    margin-top: .5rem;
  }

  .navbar-nav .nav-item + .nav-item {
    border-top: 1px solid rgba(255, 255, 255, .08);
  }

  .navbar-nav .nav-link {
    justify-content: flex-start;
    padding: .7rem .25rem;
    font-size: 1rem;
  }

  .navbar-nav .nav-link.active {
    font-weight: 600;
    box-shadow: inset 3px 0 0 #6ea8fe;
    padding-left: .75rem;
  }

  /* Badge jumlah push subscriber */
  #pushMini {
    justify-content: center;
    margin: .6rem 0 0 !important;
    padding: .55rem 12px !important;
    min-height: var(--mtap);
  }

  /* Nama user + tombol logout */
  .navbar-text {
    display: block;
    margin: .6rem 0 0 !important;
    padding: .5rem .25rem;
    border-top: 1px solid rgba(255, 255, 255, .08);
    font-size: .9rem;
  }

  .navbar .nav-link.text-danger {
    justify-content: center;
    margin-bottom: calc(.5rem + env(safe-area-inset-bottom));
    border: 1px solid rgba(220, 53, 69, .5);
    border-radius: 8px;
  }
}

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

@media (max-width: 991.98px) {
  .mnav {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 1040;
    background: #ffffff;
    border-top: 1px solid #dee2e6;
    box-shadow: 0 -2px 14px rgba(0, 0, 0, .06);
    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: #6c757d;
    font-size: 11px;
    line-height: 1;
    background: none;
    border: 0;
    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: #0d6efd; font-weight: 600; }
  .mnav a:active { background: #f1f3f5; }
}

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

  .table-responsive {
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
  }

  .mscroll-hint {
    display: block;
    font-size: 12px;
    color: #6c757d;
    margin: 0 0 6px;
  }

  .table > :not(caption) > * > * { padding: .5rem .5rem; }

  /* Lebar kolom yang dipatok di HTML diabaikan di layar kecil */
  .table th[style*="width"],
  .table td[style*="width"] { width: auto !important; }

  /* Sel yang dipotong dengan ellipsis dibiarkan melipat penuh */
  .table td[style*="max-width"] {
    max-width: none !important;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
  }

  .ua-cell { max-width: none !important; }

  /* Matriks hak akses: kolom pertama tetap terlihat saat digeser */
  th.sticky-col,
  td.sticky-col {
    position: sticky;
    left: 0;
    z-index: 2;
    background: #fff;
    min-width: 140px !important;
  }

  /* Lebar minimum kolom yang dipatok di HTML dilonggarkan */
  .table th[style*="min-width"] { min-width: 0 !important; }

  
}

/* ---- Mode kartu: tiap baris tabel jadi satu kartu (hanya HP) ---- */
@media (max-width: 575.98px) {

  table.mobile-cards { border: 0 !important; background: transparent; }
  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: #fff;
    border: 1px solid #dee2e6;
    border-radius: 10px;
    padding: 6px 10px;
    margin-bottom: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .05);
  }

  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;
    max-width: none !important;
    overflow: visible !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: 600;
    color: #6c757d;
    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;
  }

  /* Tabel bertema gelap (logs, bot monitor) */
  table.mobile-cards.table-dark tr,
  .bg-dark table.mobile-cards tr {
    background: rgba(20, 20, 26, .92);
    border-color: #333;
  }
  table.mobile-cards.table-dark td::before { color: #9ca3af; }
}

/* ==========================================================================
   5. HALAMAN BERANDA & TATA LETAK
   ========================================================================== */
@media (max-width: 991.98px) {

  .page-body {
    padding-left: 12px;
    padding-right: 12px;
  }

  /* Kartu angka sudah col-6 dari sananya — tinggal dirapikan ukurannya */
  .card-body h3, .card-body .h3, .card .stat { font-size: 1.4rem; }
  .card-body h5, .card-body .h5 { font-size: .95rem; }

  /* Baris judul + tombol di dalam kartu */
  .card-body > .d-flex.justify-content-between {
    flex-wrap: wrap;
    gap: 8px;
  }
}

@media (max-width: 767.98px) {
  /* Tombol pintasan di beranda jadi dua kolom rapi */
  .card-body > .d-flex.flex-wrap.gap-2 > .btn {
    flex: 1 1 calc(50% - .5rem);
    min-width: 0;
    font-size: .875rem;
    padding-left: .5rem;
    padding-right: .5rem;
  }
}

/* ==========================================================================
   6. PANEL, MODAL, PAGINATION
   ========================================================================== */
@media (max-width: 991.98px) {

  .detail-panel {
    width: 100% !important;
    max-width: 100% !important;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .modal-dialog { margin: .5rem; max-width: calc(100% - 1rem); }
  .modal-body {
    max-height: 70vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .modal-footer .btn { flex: 1 1 auto; }

  .pagination { flex-wrap: wrap; gap: 6px; justify-content: center; }
  .pagination a, .page-link { min-width: var(--mtap); min-height: var(--mtap); }

  select[style*="max-width"] { max-width: 100% !important; }
  .preset-select { width: 100% !important; }
}

/* ==========================================================================
   7. AKSESIBILITAS
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .detail-panel { transition: none !important; }
}

:focus-visible {
  outline: 3px solid rgba(13, 110, 253, .55);
  outline-offset: 2px;
}
