/* ==========================================================================
   NEXUSNET BILLING RT/RW NET - VIEWS MOBILE SPECIFIC STYLES v2.0
   Comprehensive mobile fixes for all admin & customer pages
   ========================================================================== */

/* ==========================================================================
   ADMIN DASHBOARD & STATISTICS CARDS
   ========================================================================== */
@media (max-width: 768px) {
  /* Dashboard stat cards */
  .dashboard-stats,
  .stats-grid,
  .stats-container {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .stat-card,
  .card.stat-card,
  .stat-box {
    width: 100% !important;
    margin-bottom: 12px !important;
  }

  .stat-card h3,
  .stat-card .stat-value {
    font-size: 1.5rem !important;
  }

  /* Chart containers */
  .chart-container,
  .chart-wrapper {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  canvas {
    max-width: 100% !important;
    height: auto !important;
  }
}

/* ==========================================================================
   TABLES - RESPONSIVE SCROLLABLE & CARD LAYOUT
   ========================================================================== */
@media (max-width: 768px) {
  /* Wrapper for horizontal scroll */
  .table-responsive {
    width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem !important;
  }

  /* Table base styling */
  table {
    min-width: 600px !important;
    font-size: 13px !important;
  }

  table th,
  table td {
    padding: 8px 6px !important;
    white-space: nowrap;
  }

  /* Action buttons in tables */
  table .btn,
  table button {
    font-size: 11px !important;
    padding: 4px 8px !important;
    min-height: 32px !important;
  }

  /* Table filters & toolbar */
  .table-filters,
  .table-toolbar {
    flex-direction: column !important;
    gap: 8px !important;
  }

  .table-filters .form-control,
  .table-toolbar .form-control {
    width: 100% !important;
  }

  /* Pagination */
  .pagination {
    flex-wrap: wrap !important;
    justify-content: center !important;
  }

  .pagination .page-item {
    margin: 2px !important;
  }

  .pagination .page-link {
    padding: 6px 10px !important;
    font-size: 13px !important;
  }
}

/* ==========================================================================
   FORMS & INPUTS
   ========================================================================== */
@media (max-width: 768px) {
  /* Form groups stack vertically */
  .form-group,
  .form-row,
  .row.form-row {
    margin-bottom: 12px !important;
  }

  .form-group label {
    margin-bottom: 6px !important;
    font-weight: 500 !important;
  }

  /* All input fields */
  .form-control,
  input.form-control,
  select.form-control,
  textarea.form-control {
    width: 100% !important;
    min-height: 44px !important;
    font-size: 16px !important; /* Prevents iOS zoom */
    padding: 10px 12px !important;
    border-radius: 8px !important;
  }

  textarea.form-control {
    min-height: 100px !important;
  }

  /* Select dropdowns */
  select.form-control {
    background-position: right 10px center !important;
    padding-right: 36px !important;
  }

  /* Input groups (prepend/append) */
  .input-group {
    flex-wrap: nowrap !important;
  }

  .input-group .input-group-text {
    font-size: 14px !important;
    padding: 10px !important;
  }

  /* Form buttons */
  .form-actions,
  .form-buttons {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    margin-top: 16px !important;
  }

  .form-actions .btn,
  .form-buttons .btn {
    width: 100% !important;
  }

  /* Inline form to stacked */
  .form-inline {
    flex-direction: column !important;
    align-items: stretch !important;
  }

  .form-inline .form-group {
    width: 100% !important;
  }
}

/* ==========================================================================
   MODALS & DIALOGS
   ========================================================================== */
@media (max-width: 768px) {
  .modal {
    padding: 0 !important;
  }

  .modal-dialog {
    margin: 10px !important;
    max-width: calc(100vw - 20px) !important;
    width: calc(100vw - 20px) !important;
  }

  .modal-content {
    border-radius: 12px !important;
    max-height: 90vh !important;
    overflow: hidden !important;
  }

  .modal-header {
    padding: 16px !important;
  }

  .modal-title {
    font-size: 1.1rem !important;
  }

  .modal-body {
    padding: 16px !important;
    max-height: calc(90vh - 140px) !important;
    overflow-y: auto !important;
  }

  .modal-footer {
    padding: 12px 16px !important;
    flex-direction: column !important;
    gap: 8px !important;
  }

  .modal-footer .btn {
    width: 100% !important;
    margin: 0 !important;
  }

  /* Close button accessible */
  .modal-header .close,
  .modal-header .btn-close {
    padding: 12px !important;
    font-size: 1.5rem !important;
  }
}

/* ==========================================================================
   BUTTONS & ACTION GROUPS
   ========================================================================== */
@media (max-width: 768px) {
  /* Button base */
  .btn {
    min-height: 44px !important;
    min-width: 44px !important;
    padding: 10px 16px !important;
    font-size: 14px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
  }

  /* Button groups */
  .btn-group {
    flex-wrap: wrap !important;
    gap: 6px !important;
  }

  .btn-group .btn {
    flex: 1 1 auto !important;
  }

  /* Action button groups (page headers) */
  .page-actions,
  .content-actions,
  .d-flex.gap-2 {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  /* Dropdown buttons */
  .dropdown-menu {
    font-size: 14px !important;
  }

  .dropdown-item {
    padding: 12px 16px !important;
    min-height: 44px !important;
  }
}

/* ==========================================================================
   KEUANGAN / LAPORAN (Finance Reports)
   ========================================================================== */
@media (max-width: 768px) {
  /* Report filters */
  .report-filters,
  .laporan-filters {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
  }

  .report-filters .form-group,
  .laporan-filters .form-group {
    width: 100% !important;
  }

  /* Report summary cards */
  .summary-cards,
  .report-summary {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  /* Buku Kas table */
  .buku-kas-table {
    font-size: 12px !important;
  }

  .buku-kas-table td {
    padding: 6px 4px !important;
  }

  /* Export buttons */
  .export-buttons,
  .btn-export-group {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
  }

  .export-buttons .btn {
    width: 100% !important;
  }
}

/* ==========================================================================
   VOUCHER / HOTSPOT (Customer Portal)
   ========================================================================== */
@media (max-width: 768px) {
  /* Voucher paket cards */
  .voucher-paket-grid,
  .paket-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .paket-card,
  .voucher-card {
    width: 100% !important;
  }

  .paket-card .card-title {
    font-size: 1.2rem !important;
  }

  .paket-card .price {
    font-size: 1.5rem !important;
    font-weight: 700 !important;
  }

  .paket-card .btn {
    width: 100% !important;
  }

  /* Voucher detail (QRIS, payment instructions) */
  .payment-qr,
  .qris-container {
    text-align: center !important;
    padding: 16px !important;
  }

  .payment-qr img,
  .qris-container img {
    max-width: 280px !important;
    width: 100% !important;
    height: auto !important;
  }

  .payment-instructions {
    font-size: 14px !important;
    line-height: 1.6 !important;
  }

  /* Riwayat voucher table */
  .riwayat-voucher-table {
    min-width: 500px !important;
  }
}

/* ==========================================================================
   PELANGGAN / TAGIHAN (Customer & Invoice)
   ========================================================================== */
@media (max-width: 768px) {
  /* Customer list/table */
  .customer-table {
    min-width: 600px !important;
  }

  /* Invoice cards */
  .invoice-list,
  .tagihan-list {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
  }

  .invoice-card,
  .tagihan-card {
    padding: 12px !important;
  }

  .invoice-card .invoice-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 8px !important;
  }

  .invoice-card .invoice-amount {
    font-size: 1.3rem !important;
    font-weight: 700 !important;
  }

  /* Payment button prominent */
  .btn-bayar,
  .btn-pay {
    width: 100% !important;
    min-height: 48px !important;
    font-size: 16px !important;
    font-weight: 600 !important;
  }
}

/* ==========================================================================
   ALERTS & NOTIFICATIONS
   ========================================================================== */
@media (max-width: 768px) {
  .alert {
    font-size: 14px !important;
    padding: 12px !important;
    border-radius: 8px !important;
  }

  .alert .btn-close {
    padding: 8px !important;
  }

  /* Toast notifications */
  .toast,
  .notification {
    max-width: calc(100vw - 24px) !important;
    font-size: 14px !important;
  }
}

/* ==========================================================================
   BREADCRUMB & NAVIGATION
   ========================================================================== */
@media (max-width: 768px) {
  .breadcrumb {
    font-size: 13px !important;
    padding: 8px 0 !important;
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    white-space: nowrap !important;
  }

  .breadcrumb-item {
    display: inline-block !important;
  }
}

/* ==========================================================================
   TABS
   ========================================================================== */
@media (max-width: 768px) {
  .nav-tabs {
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    border-bottom: 2px solid #e5e7eb !important;
  }

  .nav-tabs .nav-link {
    font-size: 14px !important;
    padding: 10px 16px !important;
    white-space: nowrap !important;
  }

  .tab-content {
    padding-top: 16px !important;
  }
}

/* ==========================================================================
   CARDS
   ========================================================================== */
@media (max-width: 768px) {
  .card {
    margin-bottom: 12px !important;
    border-radius: 12px !important;
  }

  .card-header {
    padding: 12px 16px !important;
    font-size: 1rem !important;
  }

  .card-body {
    padding: 16px !important;
  }

  .card-footer {
    padding: 12px 16px !important;
  }

  /* Card title with actions */
  .card-header .d-flex {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 10px !important;
  }

  .card-header .btn-group {
    width: 100% !important;
  }
}

/* ==========================================================================
   EXTRA SMALL DEVICES (< 480px)
   ========================================================================== */
@media (max-width: 480px) {
  body {
    font-size: 13px !important;
  }

  h1, .h1 { font-size: 1.5rem !important; }
  h2, .h2 { font-size: 1.3rem !important; }
  h3, .h3 { font-size: 1.1rem !important; }
  h4, .h4 { font-size: 1rem !important; }

  .btn {
    font-size: 13px !important;
    padding: 8px 14px !important;
  }

  table {
    min-width: 500px !important;
    font-size: 12px !important;
  }

  .modal-dialog {
    margin: 5px !important;
    max-width: calc(100vw - 10px) !important;
  }
}
