/* ===== EasyBG Comprehensive Responsive Adaptation =====
   Supports: All desktops, tablets (iPad), phones (Android 320px+, iPhone SE to Pro Max)
   ===== */

/* ===== BASE FIXES ===== */
html, body {
  overflow-x: hidden !important;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
}

/* iOS safe areas */
@supports (padding: env(safe-area-inset-top)) {
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
  .site-footer {
    padding-bottom: calc(24px + env(safe-area-inset-bottom)) !important;
  }
}

html {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* Prevent zoom on input focus on iOS (font-size must be >= 16px) */
@media screen and (max-width: 767px) {
  input, select, textarea {
    font-size: 16px !important;
  }
}

/* ===== VERY SMALL PHONES (max 359px) - iPhone SE, old Androids ===== */
@media screen and (max-width: 359px) {
  .max-w-4xl.mx-auto, .max-w-3xl.mx-auto {
    padding-left: 0.25rem !important;
    padding-right: 0.25rem !important;
  }
  .text-lg { font-size: 1rem !important; }
  .text-xl { font-size: 1.125rem !important; }
  .text-2xl { font-size: 1.25rem !important; }
  .bg-white.rounded-xl.shadow-sm.border {
    border-radius: 0.625rem !important;
  }
  .max-w-md { max-width: calc(100vw - 16px) !important; }
  .mx-4 { margin-left: 0.5rem !important; margin-right: 0.5rem !important; }
  .site-footer { padding: 20px 8px 16px !important; }
  .site-footer .footer-disclaimer { font-size: 10px !important; }
  .site-footer .footer-brand { font-size: 12px !important; }
  .flex.gap-1.flex-wrap button {
    padding: 0.375rem 0.5rem !important;
    font-size: 11px !important;
  }
  .uppercase.tracking-wider {
    font-size: 10px !important;
    letter-spacing: 0.03em !important;
  }
}

/* ===== SMALL PHONES (max 413px) ===== */
@media screen and (max-width: 413px) {
  .max-w-4xl.mx-auto, .max-w-3xl.mx-auto {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
  }
  .bg-white.rounded-xl.shadow-sm.border.p-3 {
    padding: 0.75rem !important;
  }
  input[type="date"] {
    max-width: 100% !important;
  }
  .fixed.bottom-4.left-4.right-4 {
    left: 0.5rem !important;
    right: 0.5rem !important;
    bottom: 0.5rem !important;
  }
}

/* ===== ALL PHONES (max 639px) ===== */
@media screen and (max-width: 639px) {
  .max-w-4xl { max-width: 100% !important; }
  .max-w-3xl { max-width: 100% !important; }
  .font-medium.truncate,
  .font-semibold.truncate {
    max-width: calc(100vw - 160px) !important;
  }
  .w-\[90px\] { width: 80px !important; }
  .w-full.table-fixed {
    table-layout: auto !important;
  }
  .bg-blue-50.border.border-blue-200.rounded-xl.p-4 {
    padding: 0.75rem !important;
  }
  .grid.grid-cols-2.md\:grid-cols-4 {
    grid-template-columns: 1fr 1fr !important;
    gap: 0.5rem !important;
  }
  .bg-white.rounded-xl.shadow-sm.border.overflow-hidden {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  .bg-white.rounded-2xl.shadow-2xl.w-full.max-w-md {
    max-width: calc(100vw - 2rem) !important;
    margin: 1rem !important;
    max-height: calc(100vh - 2rem) !important;
    overflow-y: auto !important;
  }
  .mt-6.flex.justify-center.gap-3 {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.5rem !important;
    padding: 0 1rem !important;
  }
  .mt-6.flex.justify-center.gap-3 a,
  .mt-6.flex.justify-center.gap-3 button {
    width: 100% !important;
    justify-content: center !important;
    display: inline-flex !important;
  }
  .grid.grid-cols-1.md\:grid-cols-3 {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }
  .site-footer {
    padding: 24px 12px 20px !important;
  }
  .site-footer .footer-disclaimer {
    font-size: 10.5px !important;
    line-height: 1.7 !important;
    padding: 0 4px !important;
  }
  .fixed.bottom-4.left-4.right-4.md\:left-auto.md\:right-4.md\:w-96 {
    left: 0.5rem !important;
    right: 0.5rem !important;
    bottom: 0.5rem !important;
    width: auto !important;
    max-width: none !important;
  }
  .flex.flex-wrap.items-center.gap-2 {
    gap: 0.375rem !important;
  }
}

/* ===== TABLETS (640px - 1023px) ===== */
@media screen and (min-width: 640px) and (max-width: 1023px) {
  .max-w-4xl { max-width: 95% !important; }
  .max-w-3xl { max-width: 90% !important; }
  .grid.grid-cols-1.md\:grid-cols-3 {
    grid-template-columns: 1fr 1fr !important;
  }
  .grid.grid-cols-2.md\:grid-cols-4 {
    grid-template-columns: repeat(4, 1fr) !important;
  }
}

/* ===== LARGE TABLETS (1024px - 1279px) ===== */
@media screen and (min-width: 1024px) and (max-width: 1279px) {
  .max-w-4xl { max-width: 960px !important; }
  .max-w-3xl { max-width: 860px !important; }
}

/* ===== LARGE DESKTOPS (1920px+) ===== */
@media screen and (min-width: 1920px) {
  .max-w-4xl { max-width: 64rem !important; }
  .max-w-3xl { max-width: 56rem !important; }
}

/* ===== LANDSCAPE PHONE ===== */
@media screen and (max-height: 500px) and (orientation: landscape) {
  .sticky.top-0.z-50 .h-14 {
    height: 2.75rem !important;
  }
  .fixed.inset-0.z-50 .bg-white.rounded-2xl {
    max-height: 95vh !important;
    overflow-y: auto !important;
  }
}

/* ===== PRINT ===== */
@media print {
  .sticky { position: relative !important; }
  .fixed { display: none !important; }
  .shadow-sm, .shadow-lg, .shadow-xl, .shadow-2xl { box-shadow: none !important; }
  .site-footer { break-inside: avoid; }
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ===== TOUCH DEVICES ===== */
@media (hover: none) and (pointer: coarse) {
  button:active, a:active, [role="button"]:active {
    opacity: 0.7 !important;
    transition: all 0.1s ease !important;
  }
}

/* ===== DROPDOWN FIXES ===== */
.absolute.left-0.right-0.bg-white.border {
  max-height: 200px !important;
  overflow-y: auto !important;
  z-index: 100 !important;
}
.absolute.top-full.right-0 {
  z-index: 100 !important;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; border-radius: 3px; }
::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #64748b; }

#root { min-height: 100vh; }

/* ===== HEADER NAV FIX - center items, no scroll ===== */
header .h-14 {
  overflow: visible !important;
  flex-wrap: nowrap !important;
  position: relative !important;
}

/* Mobile: ensure desktop nav stays hidden */
@media screen and (max-width: 767px) {
  header .h-14 > nav.hidden {
    display: none !important;
  }
}

/* Desktop: nav absolutely centered in header */
@media screen and (min-width: 768px) {
  header .h-14 > nav {
    position: absolute !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow: visible !important;
    align-items: center !important;
    gap: 0.25rem !important;
    z-index: 1 !important;
  }
  header .h-14 > div:last-child {
    margin-left: auto !important;
    z-index: 2 !important;
  }
}
