/* ========================================
   RESPONSIVE ENHANCEMENTS - PROFESSIONAL
   ======================================== */

/* Modern CSS Variables for Responsive Spacing */
:root {
  --spacing-xs: 8px;
  --spacing-sm: 12px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  --spacing-2xl: 48px;
  
  --font-xs: 12px;
  --font-sm: 14px;
  --font-base: 16px;
  --font-lg: 18px;
  --font-xl: 20px;
  --font-2xl: 24px;
  --font-3xl: 32px;
  --font-4xl: 40px;
}

/* Fluid Typography - Professional Approach */
html {
  font-size: clamp(14px, 1vw + 0.5rem, 16px);
}

h1 { font-size: clamp(28px, 4vw + 1rem, 48px); }
h2 { font-size: clamp(24px, 3vw + 0.8rem, 38px); }
h3 { font-size: clamp(20px, 2.5vw + 0.6rem, 28px); }
h4 { font-size: clamp(18px, 2vw + 0.5rem, 24px); }

/* Container Responsive */
.container {
  padding-left: clamp(16px, 4vw, 32px);
  padding-right: clamp(16px, 4vw, 32px);
}

/* ========================================
   MOBILE FIRST - 480px and below
   ======================================== */
@media (max-width: 480px) {
  :root {
    --radius: 16px;
    --radius2: 20px;
  }
  
  .hero-title {
    font-size: clamp(24px, 6vw, 32px) !important;
    line-height: 1.2;
  }
  
  .hero-subtitle {
    font-size: 14px !important;
  }
  
  .hero-cta {
    flex-direction: column;
    width: 100%;
  }
  
  .hero-cta .btn {
    width: 100%;
    justify-content: center;
  }
  
  .cards {
    grid-template-columns: 1fr !important;
    gap: 16px;
  }
  
  .mini-card {
    padding: 16px;
  }
  
  .btn {
    padding: 12px 16px;
    font-size: 14px;
  }
  
  .nav-link {
    padding: 12px 16px;
    font-size: 15px;
  }
  
  .footer-grid {
    grid-template-columns: 1fr !important;
    gap: 20px;
  }
  
  .products-grid {
    grid-template-columns: 1fr !important;
  }
  
  .split, .split-reverse {
    grid-template-columns: 1fr !important;
  }
}

/* ========================================
   MOBILE - 640px and below
   ======================================== */
@media (max-width: 640px) {
  .hero-grid {
    grid-template-columns: 1fr !important;
    gap: 24px;
  }
  
  .hero-right {
    order: -1;
    max-width: 100%;
  }
  
  .hero-left {
    text-align: center;
  }
  
  .hero-trust {
    justify-content: center;
  }
  
  .trust-pill {
    font-size: 12px;
    padding: 8px 12px;
  }
  
  .mini-product-media img {
    max-height: 280px;
    object-fit: contain;
  }
  
  .support-grid {
    grid-template-columns: 1fr !important;
  }
  
  .checkout-layout {
    grid-template-columns: 1fr !important;
  }
}

/* ========================================
   TABLET - 768px and below
   ======================================== */
@media (max-width: 768px) {
  .nav-toggle {
    display: inline-flex !important;
  }
  
  .nav-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    display: none;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(226, 232, 240, 0.9);
    box-shadow: 0 20px 60px rgba(2, 6, 23, 0.12);
    padding: 16px;
    flex-direction: column;
    align-items: stretch;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
  }
  
  .nav-menu.open {
    display: flex !important;
  }
  
  .nav-links {
    flex-direction: column;
    gap: 4px;
  }
  
  .nav-link {
    padding: 14px 16px;
    border-radius: 12px;
    transition: background 0.2s ease;
  }
  
  .nav-link:hover {
    background: rgba(245, 158, 11, 0.08);
  }
  
  .cards {
    grid-template-columns: 1fr !important;
  }
  
  .data-table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .data-table th,
  .data-table td {
    white-space: nowrap;
    min-width: 120px;
  }
  
  .profile-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ========================================
   DESKTOP SMALL - 1024px and below
   ======================================== */
@media (max-width: 1024px) {
  .hero-grid {
    grid-template-columns: 1fr 1fr;
    gap: 32px;
  }
  
  .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
  }
  
  .products-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  
  .split {
    grid-template-columns: 1fr !important;
    gap: 28px;
  }
  
  .admin-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-102%);
    transition: transform 0.3s ease;
    z-index: 60;
    width: min(86vw, 320px);
  }
  
  .admin-sidebar.is-open {
    transform: translateX(0);
  }
}

/* ========================================
   DESKTOP - 1280px and below
   ======================================== */
@media (max-width: 1280px) {
  .container {
    max-width: 1140px;
  }
  
  .hero-grid {
    gap: 40px;
  }
}

/* ========================================
   LARGE DESKTOP - 1440px and above
   ======================================== */
@media (min-width: 1440px) {
  .container {
    max-width: 1320px;
  }
  
  .hero-grid {
    gap: 60px;
  }
}

/* ========================================
   TOUCH DEVICES OPTIMIZATION
   ======================================== */
@media (hover: none) and (pointer: coarse) {
  .btn,
  .nav-link,
  a,
  button {
    min-height: 44px;
    min-width: 44px;
  }
  
  .btn {
    padding: 14px 24px;
  }
  
  input,
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* ========================================
   LANDSCAPE MOBILE OPTIMIZATION
   ======================================== */
@media (max-height: 500px) and (orientation: landscape) {
  .hero {
    min-height: auto;
    padding: 40px 0;
  }
  
  .hero-grid {
    grid-template-columns: 1fr 1fr;
    gap: 24px;
  }
  
  .nav-menu {
    max-height: calc(100vh - 60px);
  }
}

/* ========================================
   HIGH DPI SCREENS (RETINA)
   ======================================== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {
  .nav,
  .footer,
  .wa-fab,
  .support-fab,
  .a11y-fab,
  .hero-bg,
  .admin-sidebar,
  .admin-topbar {
    display: none !important;
  }
  
  body {
    background: white;
    color: black;
  }
  
  .container {
    max-width: 100%;
  }
  
  a[href]:after {
    content: " (" attr(href) ")";
  }
}

/* ========================================
   REDUCED MOTION (ACCESSIBILITY)
   ======================================== */
@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;
  }
}

/* ========================================
   DARK MODE SUPPORT (FUTURE READY)
   ======================================== */
@media (prefers-color-scheme: dark) {
  :root:not(.light-mode) {
    --bg: #0f172a;
    --text: #f1f5f9;
    --card: #1e293b;
    --soft: #334155;
    --line: #475569;
  }
}

/* ========================================
   RTL RESPONSIVE FIXES
   ======================================== */
body.rtl .hero-cta {
  flex-direction: row-reverse;
}

@media (max-width: 768px) {
  body.rtl .nav-menu {
    left: auto;
    right: 0;
  }
  
  body.rtl .admin-sidebar {
    left: auto;
    right: 0;
    transform: translateX(102%);
  }
  
  body.rtl .admin-sidebar.is-open {
    transform: translateX(0);
  }
}

/* ========================================
   SAFE AREA INSETS (iPhone X+)
   ======================================== */
@supports (padding: max(0px)) {
  body {
    padding-left: max(0px, env(safe-area-inset-left));
    padding-right: max(0px, env(safe-area-inset-right));
  }
  
  .nav,
  .footer {
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
  }
  
  .wa-fab,
  .support-fab,
  .a11y-fab {
    bottom: max(16px, env(safe-area-inset-bottom));
  }
}

/* ========================================
   SMOOTH SCROLLING FOR ALL DEVICES
   ======================================== */
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

/* ========================================
   IMAGE OPTIMIZATION
   ======================================== */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

picture {
  display: block;
}

/* Lazy Loading Optimization */
img[loading="lazy"] {
  opacity: 0;
  transition: opacity 0.3s ease;
}

img[loading="lazy"].loaded,
img[loading="lazy"]:not([src*="data:image"]) {
  opacity: 1;
}

/* ========================================
   FORM ELEMENTS RESPONSIVE
   ======================================== */
@media (max-width: 640px) {
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="password"],
  select,
  textarea {
    font-size: 16px;
    padding: 12px 14px;
  }
  
  .field label {
    font-size: 14px;
  }
}

/* ========================================
   PERFORMANCE OPTIMIZATIONS
   ======================================== */
* {
  -webkit-tap-highlight-color: transparent;
}

button,
a {
  touch-action: manipulation;
}

/* GPU Acceleration for Smooth Animations */
.nav-menu,
.admin-sidebar,
.support-panel,
.a11y-panel {
  will-change: transform;
  transform: translateZ(0);
  backface-visibility: hidden;
}
