/*
 * mobile.css — imotrack
 * Mobile-only overrides (≤ 767px). Desktop layout is UNTOUCHED.
 */

@media (max-width: 767px) {

/* ═══════════════════════════════════════════════════════════════
   PREVENT HORIZONTAL OVERFLOW
   ═══════════════════════════════════════════════════════════════ */

  html, body {
    overflow-x: hidden;
  }

/* ═══════════════════════════════════════════════════════════════
   SIDEBAR — hidden by default, full drawer on toggle
   ═══════════════════════════════════════════════════════════════ */

  /* Hide sidebar completely — no 50px strip eating content space */
  .sidebar {
    width: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    transition: width .22s ease;
  }

  /* Main content takes full width */
  .main-content {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 20px !important;
    padding-right: 20px !important;
    padding-top: 16px !important;
    overflow-x: hidden;
    box-sizing: border-box;
  }

  /* Bootstrap row negative margins fix */
  .main-content .row {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
  .container-fluid {
    padding-left: 0 !important;
    padding-right: 0 !important;
    overflow-x: hidden;
  }

  /* Open state: sidebar slides in as overlay */
  .sidebar.mob-open {
    width: 240px !important;
    padding: 0.75rem 0.75rem !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    z-index: 200 !important;
  }
  .sidebar.mob-open .sb-label   { display: inline !important; }
  .sidebar.mob-open .sb-section { display: block !important; }
  .sidebar.mob-open .sb-user    { display: block !important; }
  .sidebar.mob-open .nav-link {
    justify-content: flex-start !important;
    text-align: left !important;
    padding: .55rem .75rem !important;
  }
  .sidebar.mob-open .nav-link i { margin-right: .5rem !important; }
  .sidebar.mob-open .brand      { font-size: inherit !important; padding-left: .5rem !important; }

  /* Backdrop overlay */
  .mob-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 199;
  }
  .mob-overlay.open { display: block; }

  /* Hamburger FAB — bottom left */
  .mob-menu-btn {
    position: fixed;
    bottom: 20px;
    left: 16px;
    z-index: 201;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #1a1a2e;
    border: none;
    color: #fff;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0,0,0,.35);
    cursor: pointer;
  }

/* ═══════════════════════════════════════════════════════════════
   PAGE HEADERS — stack title + action button
   ═══════════════════════════════════════════════════════════════ */

  .main-content > .d-flex.justify-content-between,
  .main-content > .mb-4.d-flex {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 8px !important;
  }

/* ═══════════════════════════════════════════════════════════════
   TOUCH TARGETS
   ═══════════════════════════════════════════════════════════════ */

  .btn     { min-height: 40px; }
  .btn-sm  { min-height: 36px; }
  .btn.py-0, .btn-sm.py-0 { padding: 6px 10px !important; }

/* ═══════════════════════════════════════════════════════════════
   FORMS
   ═══════════════════════════════════════════════════════════════ */

  .form-control, .form-select { font-size: .9rem !important; }
  .form-control-sm, .form-select-sm { min-height: 36px; font-size: .9rem !important; }

/* ═══════════════════════════════════════════════════════════════
   MODALS — bottom sheet
   ═══════════════════════════════════════════════════════════════ */

  .modal-dialog {
    margin: 0 !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
  }
  .modal-content {
    border-radius: 20px 20px 0 0 !important;
  }
  /* PDF viewer: full screen */
  #invoiceViewerModal .modal-dialog {
    top: 0 !important;
    height: 100% !important;
  }
  #invoiceViewerModal .modal-content {
    height: 100% !important;
    border-radius: 0 !important;
  }
  #invoiceViewerModal iframe {
    height: calc(100vh - 120px) !important;
  }

/* ═══════════════════════════════════════════════════════════════
   DASHBOARD
   ═══════════════════════════════════════════════════════════════ */

  .bell-dropdown {
    min-width: min(90vw, 260px) !important;
    right: 0 !important;
    left: auto !important;
  }
  .tenant-row  { gap: 8px; padding: 10px 12px; }
  .tenant-name { font-size: .85rem; }
  .tenant-meta { font-size: .72rem; }
  .days-badge  { font-size: .7rem; padding: 3px 8px; white-space: nowrap; }

/* ═══════════════════════════════════════════════════════════════
   PROPERTY DETAIL — TABS (horizontal scroll)
   ═══════════════════════════════════════════════════════════════ */

  .prop-tab-nav {
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .prop-tab-nav::-webkit-scrollbar { display: none; }
  .prop-tab-btn {
    white-space: nowrap;
    flex-shrink: 0;
    padding: 8px 12px !important;
    font-size: .78rem !important;
  }

/* ═══════════════════════════════════════════════════════════════
   PROPERTY DETAIL — EXPENSE FILTER (stack vertically)
   ═══════════════════════════════════════════════════════════════ */

  .filter-card { padding: 12px !important; overflow-x: initial !important; }
  .filter-card .filter-controls {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
  }
  .filter-card .filter-controls > div,
  .filter-card .filter-controls > .d-flex { width: 100% !important; }
  .filter-card select,
  .filter-card input[type="date"],
  .filter-card input[type="number"] { width: 100% !important; box-sizing: border-box; }
  .filter-date-range {
    display: grid !important;
    grid-template-columns: 1fr auto 1fr !important;
    gap: 4px;
    align-items: end;
    width: 100% !important;
  }
  .filter-amounts {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px;
    width: 100% !important;
  }
  .filter-divider { display: none !important; }

/* ═══════════════════════════════════════════════════════════════
   TENANTS — filter + table buttons
   ═══════════════════════════════════════════════════════════════ */

  .tenants-filter-row { flex-direction: column !important; }
  .tenants-filter-row .col-auto { flex: 0 0 100%; max-width: 100%; }
  .tenants-filter-row select,
  .tenants-filter-row input { width: 100% !important; min-width: 0 !important; }
  .tenants-actions { gap: 4px !important; }

/* ═══════════════════════════════════════════════════════════════
   INNER WRAPPERS (mortgages, tax, account…)
   Some pages use max-width wrappers; ensure they don't overflow
   ═══════════════════════════════════════════════════════════════ */

  .main-content [style*="max-width"] {
    max-width: 100% !important;
    width: 100% !important;
  }
  /* But keep centered layout inside — just remove the fixed px cap */
  .main-content .wrap,
  .main-content > div[style*="max-width"] {
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

/* ═══════════════════════════════════════════════════════════════
   TAX EXPORT — stack header controls vertically
   ═══════════════════════════════════════════════════════════════ */

  /* Header row: stack left/right blocks */
  .wrap .d-flex.justify-content-between.align-items-start {
    flex-direction: column !important;
    gap: 12px !important;
  }
  /* Controls (selects + buttons): stack them */
  .wrap .d-flex.align-items-center.gap-2.flex-wrap {
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
    gap: 8px !important;
  }
  /* Form with selects: stack selects vertically */
  .wrap form.d-flex.align-items-center.gap-2 {
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
  }
  .wrap form select {
    width: 100% !important;
  }
  /* Download zip + Print buttons: full width */
  .wrap .btn.no-print {
    width: 100% !important;
    justify-content: center;
    text-align: center;
  }

/* ═══════════════════════════════════════════════════════════════
   MORTGAGES LIST
   ═══════════════════════════════════════════════════════════════ */

  .sum-panel { max-width: 100% !important; }
  /* Mortgage row header: allow text to wrap */
  .mtg-row-header { flex-wrap: wrap; gap: 6px; }

/* ═══════════════════════════════════════════════════════════════
   EXPENSE BATCH
   ═══════════════════════════════════════════════════════════════ */

  #drop-zone { padding: 2rem 1rem !important; }

/* ═══════════════════════════════════════════════════════════════
   EXPENSE FORM
   ═══════════════════════════════════════════════════════════════ */

  #existing-preview iframe { height: 220px !important; }

}
/* end @media (max-width: 767px) */
