/* ================================================================
   NEOLIFE WELLNESS — Additional Mobile Enhancements
   Advanced Media Queries & Responsive Patterns
   ================================================================ */

/* Global logo sizing for polished branding across all pages */
.logo img,
.nl-logo img,
.site-logo img,
.lp-logo img,
.topbar-logo img,
.navbar-brand img,
.brand img,
.header-logo img,
.logo-mark,
img[alt*="logo"] {
  width: 32px !important;
  height: 32px !important;
  max-width: 32px !important;
  object-fit: contain !important;
  display: inline-block !important;
}

.nl-logo,
.logo,
.site-logo,
.lp-logo,
.topbar-logo,
.navbar-brand,
.brand,
.header-logo {
  gap: 0.65rem !important;
  align-items: center !important;
}

.nl-logo-text strong,
.nl-logo-text small,
.site-logo-text,
.lp-logo-text {
  font-size: 0.95rem !important;
}

/* Extra Small Devices (320px - 375px) */
@media (max-width: 375px) {
  html {
    font-size: 14px;
  }
  
  body {
    overflow-x: hidden;
  }
  
  h1 {
    font-size: 1.5rem !important;
  }
  
  h2 {
    font-size: 1.25rem !important;
  }
  
  h3 {
    font-size: 1rem !important;
  }
  
  .container, .container-sm, .page, .wrap {
    padding: 0.75rem !important;
  }
  
  button, .btn, .button, [class*="btn"] {
    width: 100% !important;
    font-size: 0.8rem !important;
  }
  
  .grid, .grid-2, .grid-3, .grid-4 {
    gap: 0.5rem !important;
  }
}

/* Small Devices (376px - 576px) */
@media (max-width: 576px) {
  .site-header-nav,
  .navbar-nav,
  .nav-menu {
    display: none !important;
  }
  
  .hdr-hamburger,
  .mobile-menu-toggle,
  [class*="hamburger"] {
    display: flex !important;
  }
  
  /* Flexible Grid */
  .grid, .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }
  
  .page-grid, [class*="grid-"] {
    grid-template-columns: 1fr !important;
  }
  
  /* Typography */
  h1 { font-size: clamp(1.25rem, 4vw, 2rem) !important; }
  h2 { font-size: clamp(1.1rem, 3vw, 1.75rem) !important; }
  h3 { font-size: clamp(0.95rem, 2.5vw, 1.25rem) !important; }
  
  /* Spacing */
  section, .section {
    padding: 1.5rem 1rem !important;
  }
  
  /* Forms */
  .form-grid {
    grid-template-columns: 1fr !important;
  }
  
  /* Flexbox Stack */
  .flex-row {
    flex-direction: column !important;
  }
  
  .flex-between {
    justify-content: flex-start !important;
    flex-direction: column !important;
  }
  
  /* Modal */
  .modal, .dialog, .popup {
    width: 95vw !important;
  }
  
  /* Remove desktop spacing */
  .hide-mobile {
    display: none !important;
  }
}

/* Tablet Landscape (577px - 768px) */
@media (max-width: 768px) and (min-width: 577px) {
  .site-header-nav {
    display: none !important;
  }
  
  .hdr-hamburger {
    display: flex !important;
  }
  
  .grid-4 {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  
  .page-grid {
    grid-template-columns: 1fr !important;
  }
  
  /* Sidebar */
  .sidebar,
  .aside,
  [class*="sidebar"] {
    position: static !important;
    width: 100% !important;
    margin-top: 2rem !important;
  }
}

/* Large Tablet / Small Desktop (769px - 1024px) */
@media (max-width: 1024px) {
  .site-header-nav a {
    padding: 6px 10px !important;
    font-size: 0.75rem !important;
  }
  
  .grid-3 {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  
  .grid-4 {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  
  .quick-link-card {
    grid-column: span 2 !important;
  }
  
  .appointment-shell {
    grid-template-columns: 1fr !important;
  }
}

/* Desktop (1025px and up) */
@media (min-width: 1025px) {
  .hdr-hamburger {
    display: none !important;
  }
  
  .site-header-nav {
    display: flex !important;
  }
}

/* Responsive Images & Media */
@media (max-width: 768px) {
  img {
    width: 100% !important;
    height: auto !important;
  }
  
  video {
    width: 100% !important;
    height: auto !important;
  }
  
  iframe {
    width: 100% !important;
  }
}

/* Tablet Portrait Specific */
@media (max-width: 768px) and (orientation: portrait) {
  body {
    font-size: 15px;
  }
  
  .container {
    padding: 1rem !important;
  }
}

/* Landscape Mode Adjustments */
@media (max-height: 500px) {
  .hero, .page-hero, .page-banner {
    padding: 1.5rem 1rem !important;
    min-height: auto !important;
  }
  
  section {
    padding: 1rem !important;
  }
  
  h1 {
    font-size: 1.25rem !important;
  }
}

/* Touch Device Optimization */
@media (hover: none) and (pointer: coarse) {
  /* Increase touch target size */
  button, a, input[type="button"], input[type="submit"], [role="button"] {
    min-height: 48px !important;
    min-width: 48px !important;
  }
  
  /* Remove hover effects on touch devices */
  .card:hover { transform: none !important; }
  .btn:hover { background: inherit !important; }
  .link:hover { color: inherit !important; }
  
  /* Add active state instead */
  .btn:active { opacity: 0.8; }
}

/* Non-Touch Device Optimization */
@media (hover: hover) and (pointer: fine) {
  button:hover, .btn:hover, a:hover {
    transition: all 0.2s ease;
  }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Print Styles */
@media print {
  body {
    background: white;
    color: black;
  }
  
  .no-print,
  nav,
  header,
  footer,
  .mobile-menu {
    display: none !important;
  }
  
  a {
    text-decoration: underline;
  }
}

/* Responsive Tables */
@media (max-width: 768px) {
  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    border-collapse: collapse;
  }
  
  table thead {
    display: none;
  }
  
  table, table tbody, table tr, table td {
    display: block;
    width: 100%;
  }
  
  table tr {
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-light, #ddd);
  }
  
  table td {
    text-align: right;
    padding-left: 50%;
    position: relative;
    padding: 0.75rem;
  }
  
  table td::before {
    content: attr(data-label);
    position: absolute;
    left: 0;
    width: 50%;
    font-weight: bold;
    text-align: left;
    padding: 0.75rem;
  }
}

/* Responsive Video Container */
.video-container,
.video-wrapper {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 ratio */
  height: 0;
  overflow: hidden;
}

.video-container iframe,
.video-wrapper iframe,
.video-container video,
.video-wrapper video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* Responsive Cards - Mobile Optimized */
.card {
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
}

@media (max-width: 768px) {
  .card {
    margin-bottom: 1rem;
  }
  
  .card img {
    max-height: 200px;
    object-fit: cover;
  }
}

/* Responsive Navigation */
.nav-brand {
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .nav-items {
    position: fixed;
    left: -100%;
    top: 56px;
    flex-direction: column;
    background-color: white;
    width: 100%;
    text-align: center;
    transition: 0.3s;
    box-shadow: 0 10px 27px rgba(0, 0, 0, 0.05);
    z-index: 100;
  }
  
  .nav-items.active {
    left: 0;
  }
}

/* Responsive Buttons - Stack on Mobile */
.button-group,
.btn-group {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

@media (max-width: 768px) {
  .button-group,
  .btn-group {
    flex-direction: column;
  }
  
  .button-group .btn,
  .btn-group .btn {
    width: 100%;
  }
}

/* Responsive Alerts */
.alert,
.notification,
[role="alert"] {
  padding: 1rem;
  margin-bottom: 1rem;
  border-radius: 0.5rem;
  width: 100%;
}

@media (max-width: 768px) {
  .alert,
  .notification {
    font-size: 0.9rem;
    padding: 0.75rem;
  }
}

/* Responsive Breadcrumb */
.breadcrumb,
[role="navigation"][aria-label="Breadcrumb"] {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: clamp(0.75rem, 1vw, 0.9rem);
}

/* Responsive Pagination */
.pagination,
.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.pagination a,
.pagination button {
  min-width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 480px) {
  .pagination a,
  .pagination button {
    min-width: 32px;
    height: 32px;
    font-size: 0.8rem;
  }
}

/* Responsive Form Layout */
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
}

@media (max-width: 768px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

/* Responsive Checkboxes and Radios */
input[type="checkbox"],
input[type="radio"] {
  min-width: 18px;
  min-height: 18px;
  cursor: pointer;
}

label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

@media (max-width: 768px) {
  input[type="checkbox"],
  input[type="radio"] {
    min-width: 20px;
    min-height: 20px;
  }
}

/* Responsive Footer */
footer {
  width: 100%;
  padding: 2rem 1rem;
}

@media (max-width: 768px) {
  footer {
    padding: 1.5rem 1rem;
  }
  
  .footer-grid {
    grid-template-columns: 1fr !important;
  }
}

/* Safe Area Insets for Notch Display */
@supports (padding: max(0px)) {
  body {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }
  
  .container,
  .container-sm {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }
}

/* Accessible Focus States */
:focus-visible {
  outline: 2px solid var(--primary, #0f8a4b);
  outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--primary, #0f8a4b);
  outline-offset: 2px;
}

/* Visible on Mobile Classes */
@media (min-width: 769px) {
  .show-mobile,
  .d-block-mobile {
    display: none !important;
  }
}

@media (max-width: 768px) {
  .hide-mobile,
  .d-none-mobile {
    display: none !important;
  }
  
  .show-mobile,
  .d-block-mobile {
    display: block !important;
  }
}

/* ---------------------------------------------------------------
   Emergency mobile fixes: prevent pages showing only white text
   and reduce oversized logos on small screens.
   Applied conservatively to avoid breaking desktop styles.
   --------------------------------------------------------------- */
@media (max-width: 1024px) {
  /* Prefer a mobile-friendly page background and text color */
  body,
  html {
    background-color: #f7fff6 !important;
    color: #083b20 !important;
    overflow-x: hidden !important;
  }

  main,
  .main,
  .page,
  .wrap,
  .page-grid,
  .content,
  .page-content,
  section {
    background-color: transparent !important;
  }

  /* Reduce logo / brand image sizes on mobile */
  .site-logo img,
  .logo img,
  .lp-logo img,
  .topbar-logo img,
  .nl-logo img,
  .hero-brand img,
  .auth-brand img,
  .navbar-brand img,
  .brand img,
  .header-logo img,
  .logo-mark,
  img.logo,
  img[alt*="logo"] {
    width: 24px !important;
    height: 24px !important;
    min-width: 24px !important;
    max-width: 24px !important;
    object-fit: cover !important;
    display: inline-block !important;
  }

  .site-logo,
  .logo,
  .lp-logo,
  .nl-logo,
  .topbar-logo,
  .navbar-brand,
  .brand,
  .header-logo {
    gap: 0.5rem !important;
    align-items: center !important;
  }

  .site-logo-text,
  .lp-logo-text,
  .nl-logo-text {
    font-size: 0.9rem !important;
  }

  /* Ensure hero/background areas remain visible (don't get overridden by white) */
  .hero,
  .page-hero,
  .therapy-marquee-shell,
  .quick-links,
  .therapy-cards-section {
    background-color: transparent !important;
    background-image: unset !important;
  }

  /* Keep cards readable but not hide other elements */
  .info-card,
  .card,
  .auth-card,
  .quick-link-card {
    background: var(--card, #ffffff) !important;
    box-shadow: var(--shadow-sm, 0 3px 12px rgba(0,0,0,0.06)) !important;
  }

  /* Ensure images are shown and scale correctly */
  img { display: block !important; max-width: 100% !important; height: auto !important; }

  /* Reduce oversized hero title spacing on small screens */
  .hero-title { font-size: clamp(1.6rem, 6vw, 2.4rem) !important; }
}
