/* ================================================================
   NEOLIFE WELLNESS — Mobile Responsive Fixes
   Enhanced Mobile Support for All Pages
   ================================================================ */

/* Ensure proper viewport and box-sizing on all devices */
html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}

* {
  box-sizing: border-box;
}

/* Prevent horizontal scroll */
html, body {
  overflow-x: hidden;
  width: 100%;
  max-width: 100%;
}

/* ── Responsive Images ── */
img {
  display: block;
  max-width: 100%;
  height: auto;
  object-fit: cover;
}

/* ── Responsive Tables ── */
table {
  width: 100%;
  border-collapse: collapse;
}

@media (max-width: 768px) {
  table {
    font-size: 0.875rem;
  }
  
  table td, table th {
    padding: 0.5rem;
  }
}

/* ── Responsive Typography ── */
h1 {
  font-size: clamp(1.5rem, 5vw, 3rem);
  margin-bottom: clamp(0.75rem, 2vw, 1.5rem);
}

h2 {
  font-size: clamp(1.25rem, 4vw, 2.25rem);
  margin-bottom: clamp(0.5rem, 1.5vw, 1rem);
}

h3 {
  font-size: clamp(1.1rem, 3vw, 1.5rem);
  margin-bottom: clamp(0.5rem, 1vw, 0.75rem);
}

h4, h5, h6 {
  font-size: clamp(0.95rem, 2vw, 1.2rem);
  margin-bottom: 0.5rem;
}

@media (max-width: 640px) {
  body {
    font-size: 15px;
    line-height: 1.5;
  }
  
  p {
    margin-bottom: 1rem;
  }
}

/* ── Responsive Containers ── */
.container,
.container-sm,
.page,
.wrap {
  width: 100%;
  max-width: 100%;
  padding: clamp(1rem, 5vw, 2rem);
  margin: 0 auto;
  overflow: hidden;
}

@media (max-width: 1280px) {
  .container {
    padding: clamp(1rem, 4vw, 1.75rem);
  }
}

@media (max-width: 768px) {
  .container,
  .container-sm,
  .page,
  .wrap {
    padding: clamp(1rem, 3vw, 1.5rem);
  }
}

@media (max-width: 640px) {
  .container,
  .container-sm,
  .page,
  .wrap {
    padding: 1rem;
  }
}

@media (max-width: 480px) {
  .container,
  .container-sm,
  .page,
  .wrap {
    padding: 0.75rem;
  }
}

/* ── Responsive Grid Systems ── */
.grid,
.grid-2,
.grid-3,
.grid-4,
[class*="grid-"],
[class*="col-"] {
  display: grid;
  gap: clamp(1rem, 3vw, 2rem);
  width: 100%;
  overflow: hidden;
}

@media (max-width: 1024px) {
  .grid-3,
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }
  
  .grid {
    gap: 1rem;
  }
}

@media (max-width: 640px) {
  .grid,
  .grid-2,
  .grid-3,
  .grid-4,
  [class*="grid-"] {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
}

/* ── Responsive Flexbox ── */
.flex,
.flex-row,
.flex-col,
[class*="flex-"] {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(0.75rem, 2vw, 1.5rem);
  overflow-x: hidden;
}

@media (max-width: 768px) {
  .flex-row {
    flex-direction: column;
  }
  
  .flex {
    gap: 1rem;
  }
}

@media (max-width: 640px) {
  .flex,
  .flex-row,
  .flex-col {
    gap: 0.75rem;
  }
}

/* ── Button Responsive ── */
button,
.btn,
.button,
a[class*="btn"],
a[class*="button"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: clamp(0.5rem, 2vw, 0.75rem) clamp(1rem, 3vw, 1.5rem);
  min-height: 44px;
  font-size: clamp(0.875rem, 2vw, 1rem);
  border-radius: clamp(0.5rem, 1vw, 0.75rem);
  white-space: nowrap;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  font-weight: 600;
  width: 100%;
  max-width: 100%;
}

@media (min-width: 640px) {
  button,
  .btn,
  .button,
  a[class*="btn"],
  a[class*="button"] {
    width: auto;
  }
}

@media (max-width: 640px) {
  button,
  .btn,
  .button,
  a[class*="btn"],
  a[class*="button"] {
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
  }
}

/* ── Form Elements ── */
input,
textarea,
select,
.form-control,
.input-field {
  width: 100%;
  max-width: 100%;
  padding: clamp(0.5rem, 2vw, 0.75rem);
  font-size: 16px; /* Prevents zoom on iOS */
  border-radius: clamp(0.375rem, 1vw, 0.625rem);
  border: 1.5px solid;
  font-family: inherit;
  transition: border-color 0.2s ease;
  outline: none;
}

textarea {
  min-height: clamp(80px, 20vw, 120px);
  resize: vertical;
}

@media (max-width: 640px) {
  input,
  textarea,
  select,
  .form-control,
  .input-field {
    font-size: 16px;
    padding: 0.625rem;
  }
  
  input:focus,
  textarea:focus,
  select:focus {
    font-size: 16px;
  }
}

/* ── Navigation Mobile-Friendly ── */
.navbar,
.navigation,
.nav,
header,
nav {
  position: sticky;
  top: 0;
  width: 100%;
  z-index: 100;
  overflow-x: hidden;
}

.nav-menu,
.navbar-menu,
.menu,
[class*="nav-menu"] {
  display: flex;
  gap: clamp(0.5rem, 2vw, 1.5rem);
  flex-wrap: wrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
  .nav-menu,
  .navbar-menu,
  .menu,
  .site-header-nav {
    flex-direction: column;
    gap: 0.5rem;
  }
}

@media (max-width: 640px) {
  .nav-menu,
  .navbar-menu,
  .menu {
    gap: 0.25rem;
  }
}

/* ── Card Components ── */
.card,
.card-item,
.box,
[class*="card"] {
  width: 100%;
  max-width: 100%;
  padding: clamp(1rem, 3vw, 1.5rem);
  border-radius: clamp(0.75rem, 2vw, 1.25rem);
  overflow: hidden;
}

@media (max-width: 640px) {
  .card,
  .card-item,
  .box,
  [class*="card"] {
    padding: 1rem;
  }
}

/* ── Modal & Dialog ── */
.modal,
.dialog,
.popup,
[role="dialog"] {
  width: 90vw;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: clamp(0.75rem, 2vw, 1.25rem);
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 640px) {
  .modal,
  .dialog,
  .popup {
    width: 95vw;
    max-width: 100%;
  }
}

/* ── Touch-Friendly Spacing ── */
@media (max-width: 768px) {
  /* Ensure minimum touch target size (44x44px) */
  a, button, input[type="button"], input[type="submit"] {
    min-height: 44px;
    min-width: 44px;
  }
}

/* ── Responsive Padding/Margin ── */
.p-0 { padding: 0; }
.p-1 { padding: clamp(0.5rem, 1vw, 0.75rem); }
.p-2 { padding: clamp(1rem, 2vw, 1.5rem); }
.p-3 { padding: clamp(1.5rem, 3vw, 2rem); }
.p-4 { padding: clamp(2rem, 4vw, 3rem); }

.m-0 { margin: 0; }
.m-1 { margin: clamp(0.5rem, 1vw, 0.75rem); }
.m-2 { margin: clamp(1rem, 2vw, 1.5rem); }
.m-3 { margin: clamp(1.5rem, 3vw, 2rem); }
.m-4 { margin: clamp(2rem, 4vw, 3rem); }

@media (max-width: 640px) {
  .p-md { padding: 1rem; }
  .p-lg { padding: 1.5rem; }
  .m-md { margin: 1rem; }
  .m-lg { margin: 1.5rem; }
}

/* ── Responsive Sections ── */
section {
  width: 100%;
  padding: clamp(2rem, 5vw, 4rem) clamp(1rem, 5vw, 2rem);
  overflow-x: hidden;
}

@media (max-width: 768px) {
  section {
    padding: clamp(1.5rem, 4vw, 2.5rem) clamp(1rem, 3vw, 1.5rem);
  }
}

@media (max-width: 640px) {
  section {
    padding: 1.5rem 1rem;
  }
}

/* ── Aspect Ratio (for images/videos) ── */
.aspect-square { aspect-ratio: 1 / 1; }
.aspect-video { aspect-ratio: 16 / 9; }
.aspect-4-3 { aspect-ratio: 4 / 3; }
.aspect-3-2 { aspect-ratio: 3 / 2; }

/* ── Prevent Text Overflow ── */
.text-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.text-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Line Height & Letter Spacing ── */
@media (max-width: 768px) {
  body {
    line-height: 1.6;
    letter-spacing: 0;
  }
  
  h1, h2, h3, h4, h5, h6 {
    letter-spacing: 0;
  }
}

/* ── Hide/Show on Mobile ── */
@media (max-width: 768px) {
  .hide-mobile,
  .d-none-mobile {
    display: none !important;
  }
}

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

/* ── Safe Area (notch support) ── */
body {
  padding-left: max(env(safe-area-inset-left), 0);
  padding-right: max(env(safe-area-inset-right), 0);
  padding-top: max(env(safe-area-inset-top), 0);
  padding-bottom: max(env(safe-area-inset-bottom), 0);
}

/* ── Viewport Height ── */
.vh-100 { height: 100vh; }
.min-vh-100 { min-height: 100vh; }

@media (max-width: 768px) {
  .min-vh-100 {
    min-height: auto;
  }
}

/* ── Prevent Zoom on Input Focus (iOS) ── */
input, select, textarea, button {
  font-size: 16px;
}

/* ── Scrollbar Styling ── */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

/* ── Selection Color ── */
::selection {
  background: rgba(15, 138, 75, 0.3);
  color: inherit;
}

::-moz-selection {
  background: rgba(15, 138, 75, 0.3);
  color: inherit;
}

/* ── Print Styles ── */
@media print {
  * {
    background: transparent !important;
    box-shadow: none !important;
  }
  
  body {
    padding: 0;
    margin: 0;
  }
  
  .no-print {
    display: none !important;
  }
}

/* ── Landscape Orientation ── */
@media (orientation: landscape) and (max-height: 500px) {
  body {
    padding-top: 0;
  }
  
  section {
    padding: 1rem;
  }
  
  h1 {
    font-size: 1.5rem;
  }
}

/* ── Ultra-Small Screens ── */
@media (max-width: 320px) {
  * {
    font-size: 14px;
  }
  
  .container,
  .container-sm {
    padding: 0.5rem;
  }
  
  button,
  .btn,
  .button {
    font-size: 13px;
    padding: 0.5rem 0.75rem;
  }
}
