/* ============================================
   GLOBAL MOBILE RESPONSIVE — ALL PAGES
   Serena Health Platform
   ============================================
   Included on every HTML page to ensure baseline
   mobile responsiveness across the entire platform.
   ============================================ */

/* Base responsive — fallback for pages without reset.css */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

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

/* Prevent iOS zoom on focused inputs (font-size < 16px triggers zoom) */
@media screen and (max-width: 768px) {
  input, select, textarea {
    font-size: 16px !important;
  }
}

/* Touch-friendly buttons — 44px minimum (Apple HIG / Material) */
button,
.btn,
[type="submit"],
[type="button"],
.btn-primary,
.btn-secondary {
  min-height: 44px;
  cursor: pointer;
}

/* Table responsive wrapper */
.table-responsive,
.table-container,
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ============================================
   MOBILE BREAKPOINT: 768px and below
   ============================================ */
@media screen and (max-width: 768px) {

  /* Full-width form elements */
  input:not([type="checkbox"]):not([type="radio"]),
  select,
  textarea,
  .form-control {
    width: 100%;
    max-width: 100%;
  }

  /* Modal sizing — fit within mobile viewport */
  .modal-content,
  .modal-dialog,
  .modal-body,
  .modal > div,
  [class*="modal"] > div:not(.modal-overlay) {
    width: 95% !important;
    max-width: 95vw !important;
    margin-left: auto !important;
    margin-right: auto !important;
    max-height: 90vh;
    overflow-y: auto;
  }

  /* Stats cards — 2 columns on tablets */
  .stats-grid,
  .stat-cards,
  .stats-container,
  .summary-stats {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }

  /* Pipeline/kanban — horizontal scroll */
  .pipeline-container,
  .kanban-container,
  .pipeline {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap !important;
    padding-bottom: 12px;
  }

  /* Table overflow — wrap all tables in scroll context */
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }

  thead, tbody, tr, th, td {
    white-space: normal;
  }

  /* Typography scaling */
  h1 { font-size: clamp(22px, 5vw, 36px) !important; }
  h2 { font-size: clamp(19px, 4vw, 28px) !important; }
  h3 { font-size: clamp(17px, 3.5vw, 22px) !important; }

  /* Prevent horizontal overflow on body */
  body {
    overflow-x: hidden;
  }

  /* Container padding */
  .container,
  .content,
  main,
  .main-content {
    padding-left: 12px;
    padding-right: 12px;
  }

  /* Side-by-side button groups stack */
  .btn-group,
  .button-group,
  .modal-actions,
  .form-actions {
    flex-direction: column;
    gap: 8px;
  }

  .btn-group > *,
  .button-group > *,
  .modal-actions > button,
  .form-actions > button {
    width: 100%;
    text-align: center;
  }

  /* Sidebar layouts — collapse */
  .sidebar {
    position: fixed;
    left: -260px;
    top: 0;
    width: 240px;
    height: 100%;
    z-index: 1000;
    transition: left 0.3s ease;
  }

  .sidebar.open {
    left: 0;
  }

  /* Two-column grids → single column */
  .grid-2col,
  .two-column {
    grid-template-columns: 1fr !important;
  }

  /* Admin nav tabs — horizontal scroll */
  .tabs,
  .tab-nav,
  .nav-tabs,
  [role="tablist"] {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap !important;
    white-space: nowrap;
    -ms-overflow-style: none;
    scrollbar-width: none;
  }

  .tabs::-webkit-scrollbar,
  .tab-nav::-webkit-scrollbar,
  .nav-tabs::-webkit-scrollbar,
  [role="tablist"]::-webkit-scrollbar {
    display: none;
  }
}

/* ============================================
   SMALL MOBILE: 480px and below
   ============================================ */
@media screen and (max-width: 480px) {

  /* Stats — single column */
  .stats-grid,
  .stat-cards,
  .stats-container,
  .summary-stats {
    grid-template-columns: 1fr !important;
  }

  /* Tighter container padding */
  .container,
  .content,
  main,
  .main-content {
    padding-left: 8px;
    padding-right: 8px;
  }

  /* Reduce card padding */
  .card,
  .patient-card,
  .modal-content {
    padding: 16px !important;
  }

  /* Full-width buttons */
  button:not(.actions-btn):not(.close-btn),
  .btn,
  [type="submit"],
  [type="button"] {
    width: 100%;
    text-align: center;
  }
}

/* ============================================
   STOREFRONT HERO & COMPARISON TABLE
   ============================================ */
@media screen and (max-width: 768px) {
  .product-hero,
  .hero-section {
    padding-top: 24px !important;
    padding-bottom: 24px !important;
  }

  .comparison-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .comparison-table table {
    min-width: 600px;
  }
}

@media screen and (max-width: 480px) {
  .product-hero,
  .hero-section {
    padding-top: 16px !important;
    padding-bottom: 16px !important;
  }
}
