/*
 * ═══════════════════════════════════════════════════════════════════
 *  NURABILT — MOBILE RESPONSIVENESS FIX  (v2 — complete)
 *  Drop in as LAST stylesheet in index.html, landing.html, info.html
 *  <link rel="stylesheet" href="/static/mobile-fix.css">
 * ═══════════════════════════════════════════════════════════════════
 *
 *  WHAT THIS FIXES (based on full audit of all source files):
 *  1.  Global box-model, overflow-x, text-size-adjust
 *  2.  Sidebar breakpoint gap (901–1023px)
 *  3.  closeSidebar uses ≤900 — patched to 1023 via JS fix
 *  4.  Main layout: full-width below 1023px
 *  5.  Mobile topbar visibility
 *  6.  Chat layout: fixed input, scrollable messages, iOS safe area
 *  7.  Bottom nav: safe area, toast collision fix
 *  8.  Section scroll: non-chat sections have correct max-height
 *  9.  Modals / .nb-overlay: bottom-sheet on small screens
 *  10. .nb-card, .nb-card-sm: responsive padding, no overflow
 *  11. Booking modal, intake modal, manual patient modal
 *  12. Doctor profile form: dp-form-grid stacking
 *  13. Doctor grid (.doctor-grid): single column on mobile
 *  14. Schedule slots builder: wraps on mobile
 *  15. Patient DB table: horizontal scroll
 *  16. My Care section: mc-records-grid responsive
 *  17. All form inputs: font-size 16px (prevents iOS auto-zoom)
 *  18. iOS safe areas (Dynamic Island, notch, home indicator)
 *  19. Android dvh / -webkit-fill-available
 *  20. Landscape phone: compact layout
 *  21. Landing page: hero, nav, sections
 *  22. Toast: hardcoded bottom:90px in directory.js → override
 *  23. Touch targets: 44px minimum
 *  24. Overflow: tables, code blocks, long words
 *  25. Quick tags wrapping
 *  26. Disclaimer + switch bar compact
 * ═══════════════════════════════════════════════════════════════════
 */

/* ──────────────────────────────────────────────────────────────────
   1. GLOBAL FOUNDATION
────────────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: hidden;
  /* Safe area vars used throughout */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
}

body {
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

img, video, canvas, svg {
  max-width: 100%;
  height: auto;
}


/* ──────────────────────────────────────────────────────────────────
   2. SIDEBAR + LAYOUT (≤1023px)
   Fixes: 901-1023px gap, closeSidebar breakpoint,
          main-content full width, mobile-topbar
────────────────────────────────────────────────────────────────── */
@media (max-width: 1023px) {

  /* Sidebar: always a hidden drawer */
  #sidebar,
  .sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    height: 100vh !important;
    height: 100dvh !important;
    transform: translateX(-100%) !important;
    transition: transform 0.28s cubic-bezier(0.4,0,0.2,1) !important;
    z-index: 300 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  #sidebar.open,
  .sidebar.open {
    transform: translateX(0) !important;
    box-shadow: 4px 0 40px rgba(0,0,0,0.35) !important;
  }

  .sidebar-close {
    display: block !important;
  }

  .hamburger,
  .menu-toggle {
    display: flex !important;
  }

  /* Overlay */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 250;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }
  .sidebar-overlay.open {
    display: block;
  }

  /* Main content: full width */
  .main-content {
    margin-left: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    padding-left: 0 !important;
  }

  /* Desktop header hidden — mobile topbar visible */
  .top-header {
    display: none !important;
  }

  .mobile-topbar {
    display: flex !important;
    position: sticky;
    top: 0;
    z-index: 150;
    flex-shrink: 0;
    width: 100%;
    height: 56px;
    padding: 0 16px;
    padding-left: max(16px, var(--safe-l));
    padding-right: max(16px, var(--safe-r));
    padding-top: var(--safe-t);
    align-items: center;
    justify-content: space-between;
    background: var(--bg-2, #fff);
    border-bottom: 1px solid var(--border, #e2e8f0);
    box-shadow: 0 1px 0 var(--border, #e2e8f0);
  }
}


/* ──────────────────────────────────────────────────────────────────
   3. BOTTOM NAV (exists in DOM — injected by server or patches)
────────────────────────────────────────────────────────────────── */
@media (max-width: 1023px) {
  .bottom-nav {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    /* Safe area for home indicator */
    padding-bottom: max(6px, var(--safe-b)) !important;
    padding-left: var(--safe-l) !important;
    padding-right: var(--safe-r) !important;
    z-index: 190 !important;
  }

  .bottom-nav-btn,
  .bnav-item {
    min-height: 44px !important;
    min-width: 44px !important;
  }
}


/* ──────────────────────────────────────────────────────────────────
   4. TOAST — override hardcoded bottom:90px in directory.js
   The JS creates: toast.style.cssText = '...bottom:90px...'
   We use !important to override inline style
────────────────────────────────────────────────────────────────── */
@media (max-width: 1023px) {
  #nurabilt-toast,
  #medai-toast,
  .nb-toast {
    bottom: calc(var(--bnav-h, 62px) + var(--safe-b, 0px) + 12px) !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    max-width: calc(100vw - 32px) !important;
    white-space: normal !important;
    text-align: center !important;
  }
}


/* ──────────────────────────────────────────────────────────────────
   5. SECTION LAYOUT
   Non-chat sections: scrollable, padded for bottom nav + safe area
   Chat section: fixed-height flex column
────────────────────────────────────────────────────────────────── */
@media (max-width: 1023px) {

  .section {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
    /* Bottom padding accounts for bottom nav */
    padding-bottom: calc(var(--bnav-h, 62px) + var(--safe-b, 0px) + 20px) !important;
  }

  /* Chat section is different — uses flex column */
  #section-chat.section {
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    padding: 0 !important;
    height: calc(100dvh - 56px) !important;
    height: calc(var(--vh, 1vh) * 100 - 56px) !important;
  }

  .chat-container {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  .chat-messages,
  #chat-messages {
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    min-height: 0 !important;
    /* JS will set paddingBottom dynamically */
  }

  /* Chat bottom area: glued to the bottom as flex-shrink children of chat-container.
     Do NOT use position:sticky on both — they must stack together naturally. */
  .chat-bottom-wrapper {
    flex-shrink: 0 !important;
    position: static !important;   /* part of the flex-column flow */
    background: var(--bg-2, #fff) !important;
    border-top: 1px solid var(--border, #e2e8f0) !important;
    padding: 3px max(8px, var(--safe-l)) 0 max(8px, var(--safe-l)) !important;
    z-index: 50 !important;
    /* Compact height — only as tall as the chips need */
    min-height: 0 !important;
  }

  .chat-input-area {
    flex-shrink: 0 !important;
    position: static !important;   /* part of the flex-column flow */
    background: var(--bg-2, #fff) !important;
    border-top: 1px solid var(--border, #e2e8f0) !important;
    padding-top: 4px !important;
    padding-bottom: max(8px, var(--safe-b)) !important;
    padding-left: max(12px, var(--safe-l)) !important;
    padding-right: max(12px, var(--safe-r)) !important;
    z-index: 50 !important;
  }

  /* Disclaimer bar above input */
  .disclaimer-bar {
    font-size: 11px !important;
    padding: 5px 12px !important;
    flex-shrink: 0;
  }
}


/* ──────────────────────────────────────────────────────────────────
   6. FORMS — prevent iOS auto-zoom (font-size must be ≥ 16px)
────────────────────────────────────────────────────────────────── */
@media (max-width: 1023px) {
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="tel"],
  input[type="url"],
  input[type="search"],
  input[type="date"],
  input[type="time"],
  textarea,
  select {
    font-size: 16px !important;
  }

  /* Allow smaller font in read-only display elements, not form controls */
  .chat-input-row #chat-input {
    font-size: 16px !important;
  }
}


/* ──────────────────────────────────────────────────────────────────
   7. MODALS — .nb-overlay + .nb-card bottom-sheet on small screens
   These are dynamically created by features.js, directory.js, etc.
────────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {

  /* Overlay: align to bottom */
  .nb-overlay {
    align-items: flex-end !important;
    padding: 0 !important;
  }

  /* Card becomes bottom sheet */
  .nb-card,
  .nb-card-sm,
  .nbdpm-card {
    border-radius: 24px 24px 0 0 !important;
    max-width: 100vw !important;
    width: 100vw !important;
    max-height: 90dvh !important;
    max-height: calc(var(--vh, 1vh) * 90) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    margin: 0 !important;
    padding: 28px 20px !important;
    padding-bottom: max(28px, var(--safe-b)) !important;
  }

  /* Auth modal */
  .auth-modal {
    border-radius: 20px 20px 0 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    margin: 0 !important;
    padding: 28px 20px !important;
    padding-bottom: max(24px, var(--safe-b)) !important;
  }

  /* Booking and intake modals in index.html */
  #booking-modal > div,
  #intake-modal > div,
  #nb-doctor-profile-modal .nbdpm-card,
  #nb-write-review-modal .nb-card,
  #nb-appt-detail-modal .nb-card,
  #nb-meeting-modal .nb-card,
  #nb-record-view-modal .nb-card,
  #nb-addcol-modal .nb-card,
  #nb-dbpw-modal .nb-card,
  #nb-apikey-modal .nb-card,
  #reset-pw-overlay > div,
  #manual-patient-modal > div {
    border-radius: 24px 24px 0 0 !important;
    max-width: 100vw !important;
    width: 100vw !important;
    max-height: 92dvh !important;
    overflow-y: auto !important;
    margin: 0 !important;
    padding-bottom: max(24px, var(--safe-b)) !important;
  }

  /* Overlay that wraps the above: align bottom */
  #booking-modal,
  #intake-modal,
  #nb-doctor-profile-modal,
  #nb-write-review-modal,
  #nb-appt-detail-modal,
  #nb-meeting-modal,
  #nb-record-view-modal,
  #nb-addcol-modal,
  #nb-dbpw-modal,
  #reset-pw-overlay,
  #manual-patient-modal {
    align-items: flex-end !important;
    padding: 0 !important;
  }

  /* manual-patient-modal inner grid: single column */
  #manual-patient-modal [style*="grid-template-columns: 1fr 1fr"],
  #manual-patient-modal [style*="grid-template-columns:1fr 1fr"],
  #booking-modal [style*="grid-template-columns: 1fr 1fr"],
  #booking-modal [style*="grid-template-columns:1fr 1fr"] {
    display: flex !important;
    flex-direction: column !important;
  }

  /* Fix booking modal specifically */
  #booking-modal > div {
    border-radius: 24px 24px 0 0 !important;
    margin: 0 !important;
    padding: 24px 20px !important;
    padding-bottom: max(24px, var(--safe-b)) !important;
    width: 100% !important;
    max-width: 100dvw !important;
  }

  /* Action buttons in booking modal */
  #booking-modal [style*="display:flex;gap:10px"] {
    flex-direction: column-reverse !important;
    gap: 8px !important;
  }
  #booking-modal [style*="display:flex;gap:10px"] button {
    width: 100% !important;
    padding: 14px !important;
  }
}


/* ──────────────────────────────────────────────────────────────────
   8. DOCTOR PROFILE EDITOR (features.js)
────────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .dp-form-grid {
    grid-template-columns: 1fr !important;
  }

  .dp-row2,
  .dp-row3 {
    grid-template-columns: 1fr !important;
  }

  .dp-radio-row {
    flex-wrap: wrap;
    gap: 8px;
  }

  .dp-hero {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .dp-save-row {
    flex-direction: column;
    gap: 10px;
  }

  .dp-save-btn {
    width: 100%;
  }

  .dp-toggles {
    gap: 12px;
  }
}


/* ──────────────────────────────────────────────────────────────────
   9. DOCTOR DIRECTORY GRID (features.js + directory.js)
────────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .doctor-grid {
    grid-template-columns: 1fr !important;
    gap: 16px;
  }
}

@media (min-width: 600px) and (max-width: 900px) {
  .doctor-grid {
    grid-template-columns: 1fr 1fr !important;
  }
}

@media (max-width: 900px) {
  .doctor-grid-card {
    width: 100% !important;
  }

  .dgc-top {
    flex-wrap: wrap;
    gap: 10px;
  }

  .dgc-actions {
    flex-direction: column;
    gap: 8px;
  }

  .dgc-book-btn,
  .dgc-view-btn {
    width: 100%;
    min-height: 44px;
  }

  .dgc-slots {
    flex-wrap: wrap;
    gap: 6px;
  }
}

/* Doctor directory search/filter bar */
@media (max-width: 640px) {
  .doctor-directory-filters,
  .directory-search-bar,
  .dir-filters {
    flex-direction: column !important;
    gap: 8px !important;
  }

  .dir-filter-row {
    grid-template-columns: 1fr !important;
  }
}


/* ──────────────────────────────────────────────────────────────────
   10. SCHEDULE SLOTS BUILDER (directory.js _renderSlots)
   Inline grid: 1.4fr 1fr 1fr auto auto → wraps on mobile
────────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  /* The slot rows use inline style grid — we override with flex */
  #slots-builder > div {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
  }

  #slots-builder select,
  #slots-builder input[type="time"] {
    flex: 1 1 auto !important;
    min-width: 100px !important;
  }
}


/* ──────────────────────────────────────────────────────────────────
   11. PATIENT DATABASE TABLE (directory.js)
────────────────────────────────────────────────────────────────── */
@media (max-width: 1023px) {
  .patient-db-table-wrap,
  #patient-db-wrap {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    width: 100% !important;
  }

  .patient-db-table {
    min-width: 900px !important;
    font-size: 12px !important;
  }

  /* DB toolbar */
  .db-toolbar,
  .patient-db-toolbar {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  #db-unlock-btn,
  #db-add-btn {
    min-height: 44px;
  }

  #patient-db-search {
    font-size: 16px !important;
    min-height: 44px;
  }
}


/* ──────────────────────────────────────────────────────────────────
   12. MY CARE SECTION (features.js _renderMyCare)
────────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .mc-records-grid {
    grid-template-columns: 1fr !important;
  }

  .mc-appt-card,
  .mc-appt-top {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  .mc-appt-dt {
    font-size: 11px !important;
    margin-left: 0 !important;
    width: 100%;
  }

  .mc-join-btn {
    width: 100%;
    text-align: center;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .mc-section-header {
    font-size: 14px !important;
    flex-wrap: wrap;
    gap: 6px;
  }

  .mc-find-btn {
    width: 100%;
    min-height: 44px;
    margin-top: 8px;
  }
}


/* ──────────────────────────────────────────────────────────────────
   13. APPOINTMENT CARDS (general)
────────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .appt-card,
  .pa-card {
    flex-direction: column !important;
    gap: 10px !important;
  }

  .pa-card-top {
    flex-wrap: wrap;
    gap: 8px;
  }

  .pa-actions {
    flex-direction: column;
    gap: 8px;
  }

  .pa-accept-btn,
  .pa-reject-btn,
  .pa-view-btn {
    width: 100%;
    min-height: 44px;
  }
}


/* ──────────────────────────────────────────────────────────────────
   14. DOCTOR PROFILE MODAL (features.js _renderDoctorProfileModal)
────────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .nbdpm-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
  }

  .nbdpm-book-btn {
    width: 100%;
    min-height: 44px;
  }

  .nbdpm-details-grid {
    grid-template-columns: 1fr !important;
  }

  .nbdpm-chips {
    flex-wrap: wrap;
    gap: 6px;
  }

  .nbdpm-hinfo h2 {
    font-size: 18px !important;
  }

  .nbdpm-rev-top {
    flex-wrap: wrap;
    gap: 8px;
  }

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

  .nbdpm-write-review-btn {
    width: 100%;
    min-height: 44px;
  }
}


/* ──────────────────────────────────────────────────────────────────
   15. CARDS + GRIDS (general page content)
────────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .page-card {
    padding: 20px 16px !important;
    border-radius: 14px !important;
  }

  .two-col-layout,
  .three-col-layout,
  .stats-grid,
  .features-grid,
  .about-grid,
  .dashboard-grid,
  .rc-stats-grid {
    grid-template-columns: 1fr !important;
  }

  .right-panel {
    position: static !important;
  }
}

@media (max-width: 600px) {
  .page-card {
    padding: 16px 14px !important;
    border-radius: 12px !important;
  }

  .rc-stats-grid {
    grid-template-columns: 1fr 1fr !important;
  }
}


/* ──────────────────────────────────────────────────────────────────
   16. HISTORY CARDS
────────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .history-card {
    padding: 14px 14px !important;
  }

  .h-card-header {
    flex-wrap: wrap;
    gap: 6px;
  }

  .h-card-time {
    font-size: 11px !important;
  }
}


/* ──────────────────────────────────────────────────────────────────
   17. CHAT MESSAGES
────────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .message-content {
    max-width: 96%;
    font-size: 14px !important;
  }

  .bot-message .message-content,
  .assistant-message .message-content {
    max-width: 95% !important;
    width: 95% !important;
  }

  .chat-messages,
  #chat-messages {
    padding: 12px 12px 0 !important;
  }

  /* Suggestion chips */
  .quick-tags,
  .suggestion-chips {
    flex-wrap: wrap !important;
    gap: 6px !important;
  }

  .quick-tags button,
  .suggestion-chips button,
  .hs-card {
    font-size: 12px !important;
    padding: 6px 12px !important;
    min-height: 36px !important;
  }
}


/* ──────────────────────────────────────────────────────────────────
   18. HEADER + BADGE (top bar elements on desktop → hidden mobile)
────────────────────────────────────────────────────────────────── */
@media (max-width: 1023px) {
  .header-badge .badge-text,
  #llm-badge-text {
    max-width: 100px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }
}

@media (max-width: 480px) {
  .header-badge .badge-text,
  #llm-badge-text {
    display: none !important;
  }
}


/* ──────────────────────────────────────────────────────────────────
   19. DRUG INFO TABS + MEDICAL CALCULATORS TABS
────────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .drug-tabs,
  .calc-tabs,
  .history-tabs,
  .section-tabs {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap !important;
    scrollbar-width: none;
  }

  .drug-tabs::-webkit-scrollbar,
  .calc-tabs::-webkit-scrollbar {
    display: none;
  }

  .drug-tab,
  .calc-tab {
    flex-shrink: 0;
    white-space: nowrap;
  }

  /* Icon only on smallest screens */
  .drug-tab span:not(.tab-icon),
  .drug-tab-text {
    display: none;
  }
}


/* ──────────────────────────────────────────────────────────────────
   20. RESULT CARDS (nutrition, BMI, drug)
────────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .result-card,
  .nutrition-result,
  .drug-result,
  .bmi-result {
    padding: 16px 14px !important;
    border-radius: 12px !important;
  }

  .nutrition-grid,
  .macro-grid,
  .bmi-grid {
    grid-template-columns: 1fr 1fr !important;
  }

  .ai-table {
    font-size: 12px !important;
  }

  .ai-table td {
    padding: 8px 10px !important;
  }
}


/* ──────────────────────────────────────────────────────────────────
   21. PORTAL SWITCH BAR + DISCLAIMER
────────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  #nurabilt-switch-bar {
    padding: 6px 12px !important;
  }

  .nsb-wrap {
    flex-wrap: wrap !important;
    gap: 6px !important;
    justify-content: center;
  }

  .nsb-btn {
    flex: 1;
    min-width: 120px;
    min-height: 40px;
    font-size: 12px !important;
    text-align: center;
  }
}


/* ──────────────────────────────────────────────────────────────────
   22. LLM PROVIDER SECTION (apikeys)
────────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .llm-providers-grid,
  .provider-cards-grid {
    grid-template-columns: 1fr !important;
  }

  .llm-provider-card,
  .llm-card {
    padding: 16px !important;
  }

  .llm-connect-row,
  .llm-input-row {
    flex-direction: column !important;
    gap: 8px !important;
  }

  .llm-connect-btn,
  #llm-btn-groq,
  #llm-btn-openai,
  #llm-btn-anthropic,
  #llm-btn-gemini {
    width: 100% !important;
    min-height: 44px !important;
  }
}


/* ──────────────────────────────────────────────────────────────────
   23. STAT CARDS (dashboard)
────────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .doc-stats-row,
  .stats-row {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
  }

  .stat-card,
  .doc-stat {
    padding: 14px 12px !important;
  }
}


/* ──────────────────────────────────────────────────────────────────
   24. OVERFLOW FIXES — tables, code, long text
────────────────────────────────────────────────────────────────── */
@media (max-width: 1023px) {
  /* All tables: scroll horizontally */
  table:not(.patient-db-table) {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
  }

  /* Code blocks */
  pre, code {
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    max-width: 100%;
  }

  /* Long word breaking */
  .ai-response,
  .message-content,
  .result-card,
  .page-card {
    word-break: break-word;
    overflow-wrap: break-word;
  }

  /* Horizontal scroll containers */
  .rc-countries,
  .provider-scroll,
  .horizontal-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .rc-countries::-webkit-scrollbar,
  .horizontal-scroll::-webkit-scrollbar {
    display: none;
  }
}


/* ──────────────────────────────────────────────────────────────────
   25. TOUCH TARGETS — minimum 44×44px
────────────────────────────────────────────────────────────────── */
@media (max-width: 1023px) {
  button,
  [role="button"],
  a.btn,
  .nav-btn,
  .dgc-book-btn,
  .dgc-view-btn,
  .mc-join-btn,
  .mc-review-btn,
  .mc-find-btn,
  .pa-accept-btn,
  .pa-reject-btn,
  .pa-view-btn,
  .nbdpm-book-btn,
  .slot-select-btn {
    min-height: 44px;
    min-width: 44px;
  }

  /* Sidebar nav items */
  .nav-btn {
    min-height: 46px !important;
    padding: 0 14px !important;
  }
}


/* ──────────────────────────────────────────────────────────────────
   26. PROFILE SECTION
────────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .profile-grid,
  .profile-form {
    grid-template-columns: 1fr !important;
  }

  .profile-pic-section {
    text-align: center;
    margin-bottom: 16px;
  }
}


/* ──────────────────────────────────────────────────────────────────
   27. SHARE SECTION
────────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .share-options-grid {
    grid-template-columns: 1fr !important;
  }

  .share-preview-card {
    padding: 14px !important;
  }

  #share-link-box {
    flex-direction: column !important;
    gap: 8px !important;
  }

  .copy-link-btn {
    width: 100%;
  }
}


/* ──────────────────────────────────────────────────────────────────
   28. FORGOT PASSWORD / AUTH OVERLAYS
────────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  #forgot-pw-overlay {
    align-items: flex-end !important;
    padding: 0 !important;
  }

  #forgot-pw-overlay > div {
    border-radius: 24px 24px 0 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    padding-bottom: max(24px, var(--safe-b)) !important;
  }
}


/* ──────────────────────────────────────────────────────────────────
   29. INTAKE FORMS LIST (doctor view)
────────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .intake-form-card {
    padding: 14px !important;
  }

  .ifc-header {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  .ifc-body {
    grid-template-columns: 1fr !important;
  }
}


/* ──────────────────────────────────────────────────────────────────
   30. LANDING PAGE (landing.html)
────────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Nav links hidden → only logo + CTA */
  .landing-nav .nav-links,
  .landing-nav ul,
  .landing-header nav ul {
    display: none !important;
  }

  .landing-hero,
  .hero-section {
    flex-direction: column !important;
    padding: 48px 20px 40px !important;
    text-align: center;
  }

  .hero-title,
  .landing-hero h1 {
    font-size: clamp(28px, 7vw, 44px) !important;
  }

  .hero-subtitle,
  .landing-hero p {
    font-size: 15px !important;
  }

  .hero-actions,
  .hero-cta {
    flex-direction: column !important;
    gap: 12px !important;
    align-items: stretch !important;
  }

  .hero-actions a,
  .hero-cta a,
  .hero-actions button {
    text-align: center !important;
    min-height: 50px !important;
  }

  .features-grid,
  .landing-features {
    grid-template-columns: 1fr !important;
  }

  .landing-section {
    padding: 40px 20px !important;
  }

  .landing-section h2 {
    font-size: clamp(22px, 6vw, 36px) !important;
  }
}


/* ──────────────────────────────────────────────────────────────────
   31. INFO PAGE (info.html)
────────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .info-grid,
  .info-section-grid {
    grid-template-columns: 1fr !important;
  }

  .info-hero {
    padding: 40px 20px !important;
    text-align: center;
  }
}


/* ──────────────────────────────────────────────────────────────────
   32. iOS SAFE AREAS (Dynamic Island, notch, home indicator)
────────────────────────────────────────────────────────────────── */
@supports (padding-top: env(safe-area-inset-top)) {

  .mobile-topbar {
    padding-top: env(safe-area-inset-top) !important;
    height: calc(56px + env(safe-area-inset-top)) !important;
  }

  .bottom-nav {
    padding-bottom: env(safe-area-inset-bottom) !important;
  }

  /* Only apply safe-area bottom to the actual input area, not the suggestions row */
  .chat-input-area {
    padding-bottom: max(10px, env(safe-area-inset-bottom)) !important;
  }

  /* Toast position accounts for safe area */
  #nurabilt-toast,
  #medai-toast {
    bottom: calc(var(--bnav-h, 62px) + env(safe-area-inset-bottom) + 12px) !important;
  }
}


/* ──────────────────────────────────────────────────────────────────
   33. ANDROID — dynamic viewport height
────────────────────────────────────────────────────────────────── */
@media (max-width: 1023px) {
  .main-content {
    /* Fallback for browsers not supporting dvh */
    min-height: -webkit-fill-available;
    min-height: 100dvh;
  }

  #section-chat.section {
    height: 100dvh !important;
  }
}

/* Ensure body fills viewport on mobile */
@media (max-width: 1023px) {
  html, body {
    min-height: 100%;
    min-height: -webkit-fill-available;
  }
}


/* ──────────────────────────────────────────────────────────────────
   34. LANDSCAPE PHONES (short + narrow)
────────────────────────────────────────────────────────────────── */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {

  .mobile-topbar {
    height: 44px !important;
  }

  #section-chat.section {
    height: calc(100dvh - 44px) !important;
  }

  .disclaimer-bar {
    display: none !important;
  }

  .quick-tags,
  .suggestion-chips {
    display: none !important;
  }

  .chat-input-area,
  .chat-bottom-wrapper {
    padding-top: 6px !important;
    padding-bottom: 6px !important;
  }

  .bottom-nav {
    --bnav-h: 46px !important;
  }

  .section {
    padding-bottom: calc(46px + 8px) !important;
  }
}


/* ──────────────────────────────────────────────────────────────────
   35. DISABLE HOVER EFFECTS ON TOUCH DEVICES
    Prevents sticky hover states on mobile
────────────────────────────────────────────────────────────────── */
@media (hover: none) and (pointer: coarse) {
  button:hover,
  a:hover,
  .nav-btn:hover,
  .dgc-book-btn:hover,
  .dgc-view-btn:hover {
    /* Reset hover styles — let :active handle feedback */
    opacity: 1 !important;
    transform: none !important;
  }
}


/* ──────────────────────────────────────────────────────────────────
   36. VERY SMALL PHONES (≤380px — Galaxy A series, older iPhones)
────────────────────────────────────────────────────────────────── */
@media (max-width: 380px) {

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

  .nb-card,
  .nb-card-sm {
    padding: 22px 16px !important;
  }

  .chat-messages,
  #chat-messages {
    padding: 8px !important;
  }

  .message-content {
    font-size: 13px !important;
  }

  .mobile-logo {
    font-size: 14px !important;
  }

  .nsb-btn {
    font-size: 11px !important;
    padding: 6px 10px !important;
  }
}
/* Logo container background fix */
.auth-logo-icon,
.brand-logo,
.nav-logo-icon {
  background: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
  border: none !important;
  padding: 0 !important;
}

/* Logo container background fix */
.auth-logo-icon,
.brand-logo,
.nav-logo-icon {
  background: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
  border: none !important;
  padding: 0 !important;
}


/* Force transparent logo containers everywhere */
.auth-logo-icon,
.brand-logo,
.nav-logo-icon,
.mobile-logo img,
#mobile-topbar .mobile-logo,
.sidebar .brand-logo {
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
  border: none !important;
  padding: 0 !important;
  border-radius: 0 !important;
}


/* ── LOGO CONTAINER FIX ── */
.auth-logo-icon {
  background: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  width: auto !important;
  height: auto !important;
}
.brand-logo {
  background: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  width: 32px !important;
  height: 32px !important;
}
.brand-logo img,
.auth-logo-icon img {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
}


/* ── LOGO FIX v3 ── */
.auth-logo-icon {
  background: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  width: 40px !important;
  height: 40px !important;
}
.auth-logo-icon img {
  width: 40px !important;
  height: 40px !important;
  object-fit: contain !important;
}
.brand-logo {
  background: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  width: 28px !important;
  height: 28px !important;
}
.brand-logo img {
  width: 28px !important;
  height: 28px !important;
  object-fit: contain !important;
}

/* ── SUGGESTION BAR MOBILE FIX — compact & tightly attached to input ── */
@media (max-width: 1023px) {
  /* Suggestions bar: compact height, no extra gaps */
  .chat-bottom-wrapper {
    gap: 4px !important;
    padding: 3px 8px 2px !important;
    align-items: center !important;
    min-height: 0 !important;
  }

  /* hs-widget: remove vertical margins, single-line scroll */
  #hs-widget {
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
  }

  #hs-track {
    padding: 2px 0 2px !important;
    gap: 6px !important;
  }

  /* Chips: smaller height on mobile */
  .hs-card {
    padding: 5px 10px !important;
    border-radius: 8px !important;
    min-height: 30px !important;
    height: 30px !important;
    line-height: 1 !important;
  }

  .hs-icon {
    font-size: 13px !important;
  }

  .hs-text {
    font-size: 12px !important;
  }

  #hs-toggle-btn {
    width: 28px !important;
    height: 28px !important;
    min-height: 28px !important;
    padding: 0 !important;
    flex-shrink: 0 !important;
    border-radius: 7px !important;
  }

  #hs-toggle-icon {
    font-size: 12px !important;
  }

  /* Clear/chat-controls button */
  #chat-controls {
    flex-shrink: 0 !important;
  }
}

/* ──────────────────────────────────────────────────────────────────
   22. AUTH MODAL CENTERING FIX
   Ensures the login/portal card is always centered on mobile
────────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  #auth-overlay {
    align-items: center !important;
    justify-content: center !important;
    position: fixed !important;
    inset: 0 !important;
    width: 100dvw !important;
    height: 100dvh !important;
    padding: 12px !important;
    z-index: 10000 !important;
    overflow: hidden !important;
  }
}

@media (max-width: 768px) {
  .auth-modal {
    margin: auto !important;
    width: 100% !important;
    max-width: 380px !important; /* Fits well on all phones */
    position: relative !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    bottom: auto !important;
    transform: none !important;
    flex-direction: column !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: rgba(255, 255, 255, 0.98) !important;
  }
}

/* On very small devices, ensure it doesn't touch edges too harshly */
@media (max-width: 360px) {
  .auth-modal {
    max-width: calc(100vw - 20px) !important;
  }
}

/* ──────────────────────────────────────────────────────────────────
   23. CONSULTATION HEADER MOBILE FIX
   Fixes character-by-character wrapping and cramped layout
────────────────────────────────────────────────────────────────── */
#my-care-reply-header {
  flex-wrap: wrap !important;
  height: auto !important;
  min-height: 64px !important;
  gap: 12px 6px !important;
  padding: 12px 14px !important;
}

#my-care-reply-header > div:first-child {
  flex: 1 1 180px !important; /* Allow it to take full width if needed */
  min-width: 0 !important;
}

#my-care-reply-header .ifc-presence-dot {
  bottom: 1px !important;
  right: 1px !important;
}

@media (max-width: 380px) {
  #my-care-reply-header {
    padding: 10px !important;
  }
  #pat-reply-video-btn {
    padding: 6px 10px !important;
    font-size: 11px !important;
  }
}

/* Make auth back button more accessible on mobile */
.back-to-portal {
  padding: 10px 14px !important;
  margin-left: -8px !important;
  margin-top: -8px !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  color: var(--primary) !important;
  border-radius: 8px !important;
  background: rgba(14, 165, 233, 0.08) !important;
  width: fit-content !important;
}

.back-to-portal:active {
  background: rgba(14, 165, 233, 0.15) !important;
  transform: scale(0.98) !important;
}
