/* ============================================================
   mobile.css — Succora Connect shared mobile styles
   Applied via media query — zero impact on desktop
   ============================================================ */

:root {
  --mobile-nav-h: 62px;
  --mobile-safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ============================================================
   BASE MOBILE RESETS
   ============================================================ */
@media (max-width: 768px) {
  html, body {
    max-width: 100vw !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
  }

  *, *::before, *::after {
    box-sizing: border-box !important;
  }

  body {
    padding-bottom: calc(var(--mobile-nav-h) + var(--mobile-safe-bottom) + 8px) !important;
  }
}

/* ============================================================
   BOTTOM NAV BAR
   ============================================================ */
.mobile-bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  .mobile-bottom-nav:not([style*="display:none"]):not([style*="display: none"]) {
    display: flex !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: calc(var(--mobile-nav-h) + var(--mobile-safe-bottom)) !important;
    padding-bottom: var(--mobile-safe-bottom) !important;
    background: #ffffff !important;
    border-top: 1px solid #E5E7EB !important;
    box-shadow: 0 -2px 16px rgba(0,0,0,0.1) !important;
    z-index: 10000 !important;
    align-items: stretch !important;
    transform: none !important;
    top: auto !important;
  }

  .mobile-bottom-nav a,
  .mobile-bottom-nav button {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 3px !important;
    text-decoration: none !important;
    background: none !important;
    border: none !important;
    border-radius: 0 !important;
    cursor: pointer !important;
    font-family: inherit !important;
    padding: 6px 2px !important;
    color: #9CA3AF !important;
    transition: color 0.15s !important;
    position: relative !important;
    -webkit-tap-highlight-color: transparent !important;
    min-height: unset !important;
    min-width: unset !important;
    box-shadow: none !important;
  }

  .mobile-bottom-nav a.active,
  .mobile-bottom-nav button.active {
    color: #7C3AED !important;
  }

  .mobile-bottom-nav.provider a.active,
  .mobile-bottom-nav.provider button.active {
    color: #D97706 !important;
  }

  .mobile-bottom-nav .tab-icon {
    font-size: 20px !important;
    line-height: 1 !important;
  }

  .mobile-bottom-nav .tab-label {
    font-size: 10px !important;
    font-weight: 600 !important;
    letter-spacing: 0.2px !important;
    line-height: 1 !important;
  }

  .mobile-bottom-nav .tab-badge {
    position: absolute !important;
    top: 4px !important;
    left: calc(50% + 4px) !important;
    background: #EF4444 !important;
    color: #fff !important;
    font-size: 9px !important;
    font-weight: 700 !important;
    min-width: 14px !important;
    height: 14px !important;
    border-radius: 999px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 3px !important;
  }
}

/* ============================================================
   TOP NAV — slim on mobile, hide links
   ============================================================ */
@media (max-width: 768px) {
  /* Hide entire top nav on mobile — bottom nav replaces it */
  nav:not(.mobile-bottom-nav) {
    display: none !important;
  }

  /* Compensate — no top nav means no offset needed */
  .page-wrap {
    padding-top: 16px !important;
  }
}

/* ============================================================
   NOTIFICATION DROPDOWN — portal out of nav, above bottom bar
   ============================================================ */
@media (max-width: 768px) {
  .notif-dropdown {
    position: fixed !important;
    bottom: calc(var(--mobile-nav-h) + var(--mobile-safe-bottom) + 8px) !important;
    top: auto !important;
    left: 8px !important;
    right: 8px !important;
    width: auto !important;
    max-height: 65vh !important;
    overflow-y: auto !important;
    border-radius: 16px !important;
    z-index: 9999 !important;
  }
}

/* ============================================================
   PAGE LAYOUT
   ============================================================ */
@media (max-width: 768px) {
  .page-wrap {
    padding: 16px 3px calc(var(--mobile-nav-h) + var(--mobile-safe-bottom) + 20px) 3px !important;
    max-width: 100% !important;
  }

  .section-card,
  .lb-card,
  .dash-card,
  .card {
    width: 100% !important;
    box-sizing: border-box !important;
    max-width: 100% !important;
  }

  .dash-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 0 !important;
  }

  .dash-grid > div {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  .stats-row {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
  }

  .section-card, .card, .dash-card, .lb-card {
    border-radius: 12px !important;
    padding: 14px !important;
  }

  .lb-card { position: static !important; }
}

@media (max-width: 390px) {
  .stats-row { grid-template-columns: 1fr !important; }
  .page-wrap { padding-left: 10px !important; padding-right: 10px !important; }
}

/* ============================================================
   TOUCH TARGETS
   ============================================================ */
@media (max-width: 768px) {
  input, select, textarea {
    font-size: 16px !important;
  }

  /* Date inputs — force native picker on iOS/Android */
  input[type="date"],
  input[type="time"] {
    -webkit-appearance: none !important;
    appearance: none !important;
    min-height: 44px !important;
    cursor: pointer !important;
    width: 100% !important;
  }

  .booking-actions {
    flex-direction: column !important;
  }

  .btn-card-accept,
  .btn-card-decline,
  .btn-card-profile {
    width: 100% !important;
    text-align: center !important;
    min-height: 44px !important;
  }
}

/* ============================================================
   MODALS — bottom sheet on mobile
   ============================================================ */
@media (max-width: 768px) {
  .modal-overlay,
  .modal-bg,
  [class*="modal-bg"],
  [id$="-modal"][style*="flex"] {
    align-items: flex-end !important;
    padding: 0 !important;
  }

  .modal-card,
  .modal-box,
  .modal-inner {
    border-radius: 20px 20px 0 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    max-height: 88vh !important;
    overflow-y: auto !important;
    padding: 20px 16px calc(16px + var(--mobile-safe-bottom)) !important;
    margin: 0 !important;
  }
}

/* ============================================================
   TABLES — horizontal scroll
   ============================================================ */
@media (max-width: 768px) {
  .data-table-wrap,
  .table-wrap {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .data-table { min-width: 500px !important; }
}

/* ============================================================
   CHAT PANEL — full screen
   ============================================================ */
@media (max-width: 768px) {
  .chat-overlay { padding: 0 !important; }

  .chat-panel {
    width: 100% !important;
    max-width: 100% !important;
    height: 100vh !important;
    border-radius: 0 !important;
  }
}

/* ============================================================
   ADMIN / SUPPORT SIDEBAR
   ============================================================ */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  padding: 6px;
  color: var(--text, #374151);
  -webkit-tap-highlight-color: transparent;
}

@media (max-width: 768px) {
  .main > .sidebar,
  .main .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 5000 !important;
    width: 260px !important;
  }

  .main > .sidebar.open,
  .main .sidebar.open { transform: translateX(0); }

  .main { margin-left: 0 !important; }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 4999;
  }

  .sidebar-backdrop.open { display: block; }

  .mobile-menu-btn { display: flex !important; }

  .topbar { padding: 0 14px !important; }
}

/* ============================================================
   TOAST — above bottom nav on mobile
   ============================================================ */
@media (max-width: 768px) {
  .toast {
    bottom: calc(var(--mobile-nav-h) + 16px) !important;
    font-size: 13px !important;
    max-width: 80vw !important;
    white-space: normal !important;
    text-align: center !important;
  }
}

/* ============================================================
   OVERFLOW FIX — clip page to viewport width
   ============================================================ */
@media (max-width: 768px) {
  html {
    overflow-x: clip !important;
  }

  /* Notif dropdown fixed width causes overflow — override */
  .notif-dropdown {
    width: auto !important;
  }
}
@media (max-width: 768px) {
  * { -webkit-tap-highlight-color: rgba(124,58,237,0.08); }
  .desktop-only { display: none !important; }
  .mobile-only  { display: block !important; }

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

  .search-input { width: 100% !important; }
}

.mobile-only { display: none; }

/* ============================================================
   LOGOUT MENU — triggered from bottom nav "More" button
   ============================================================ */
.mobile-more-menu {
  display: none;
  position: fixed;
  bottom: calc(var(--mobile-nav-h) + var(--mobile-safe-bottom) + 8px);
  left: 8px;
  right: 8px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.15);
  z-index: 9998;
  overflow: hidden;
}

.mobile-more-menu.open { display: block; }

.mobile-more-menu a,
.mobile-more-menu button {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px 20px;
  background: none;
  border: none;
  border-bottom: 1px solid #F3F4F6;
  font-size: 15px;
  font-weight: 500;
  color: #374151;
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}

.mobile-more-menu a:last-child,
.mobile-more-menu button:last-child { border-bottom: none; }

.mobile-more-menu .logout-btn { color: #EF4444; }

.mobile-more-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9997;
}

.mobile-more-backdrop.open { display: block; }
