/* ==========================================================================
   NEXUSNET BILLING RT/RW NET - MOBILE RESPONSIVE OVERHAUL v2.0
   Strictly scoped to mobile/tablet devices via media queries.
   Desktop layout remains 100% untouched.
   ========================================================================== */

/* Variables */
:root {
  --mob-nav-height: 60px;
  --mob-top-height: 56px;
  --touch-min: 44px;
}

/* ==========================================================================
   1. GLOBAL MOBILE RESETS & BASE (< 768px)
   ========================================================================== */
@media (max-width: 768px) {
  *, *::before, *::after {
    box-sizing: border-box;
  }

  body {
    overflow-x: hidden !important;
    font-size: 14px !important;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
  }

  /* Prevent horizontal overflow on main containers */
  .container, .container-fluid, .main-content, .admin-main, .card, .row {
    max-width: 100% !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  /* Tables wrapper */
  .table-responsive, .table-container, table {
    width: 100% !important;
    overflow-x: auto !important;
    display: block !important;
    -webkit-overflow-scrolling: touch;
  }

  /* Form inputs & buttons */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="tel"],
  input[type="date"],
  input[type="search"],
  select,
  textarea {
    width: 100% !important;
    min-height: 44px !important;
    font-size: 16px !important; /* Prevents iOS zoom */
    padding: 8px 12px !important;
    border-radius: 8px !important;
  }

  button, .btn {
    min-height: 44px !important;
    min-width: 44px !important;
    padding: 10px 16px !important;
    font-size: 14px !important;
    border-radius: 8px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px;
    white-space: normal !important;
  }

  /* Stat cards / Dashboard grids */
  .grid, .row.row-cols-1, .row.row-cols-md-2, .row.row-cols-lg-4, 
  .dashboard-stats, .stats-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .col, .col-md-3, .col-md-4, .col-md-6, .col-md-8, .col-md-12 {
    width: 100% !important;
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }

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

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

  /* Navigation & Header */
  .admin-layout {
    display: block !important;
    padding-top: var(--mob-top-height);
  }

  .admin-sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    width: 280px !important;
    height: 100dvh !important;
    z-index: 1050 !important;
    transform: translateX(-100%) !important;
    transition: transform 0.3s ease-in-out !important;
    background: #0f172a !important;
  }

  .admin-sidebar.show, 
  .admin-sidebar.drawer-open,
  .sidebar.show {
    transform: translateX(0) !important;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1040;
    display: none;
  }
  .sidebar-backdrop.show {
    display: block;
  }

  /* Topbar mobile toggle */
  .mobile-topbar, .topbar-mobile {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--mob-top-height);
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 1030;
  }

  /* Page headers & toolbars */
  .page-header, .content-header, .d-flex.justify-content-between {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
  }

  .page-header .btn-group, .content-header .actions, .toolbar {
    width: 100% !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  .page-header .btn, .content-header .btn {
    flex: 1 !important;
  }
}

/* ==========================================================================
   2. 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; }

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

  .btn, button {
    font-size: 13px !important;
    padding: 8px 12px !important;
  }
}
