/* ============================================================
   ANTHELUS — Mobile Responsive Fixes
   Full Mobile-First Enhancement
   ============================================================ */

/* ── Extra Small (< 400px) ──────────────────────────────── */
@media (max-width: 400px) {
  :root { --nav-h: 60px; }

  .hero-heading { font-size: 1.9rem !important; letter-spacing: -.03em; }
  .section-title { font-size: 1.5rem !important; }

  .btn-primary-custom,
  .btn-outline-custom,
  .btn-ghost {
    padding: 11px 18px !important;
    font-size: .82rem !important;
  }

  .hero-ctas { gap: 10px !important; }
  .hero-ctas > * { width: 100%; justify-content: center; text-align: center; }

  .stat-num { font-size: 1.6rem !important; }
  .card-premium { padding: 18px !important; }

  .product-card-body { padding: 12px !important; }
  .product-title { font-size: .82rem !important; }
  .product-price { font-size: .95rem !important; }

  .hero-stats { gap: 16px !important; }
  .hero-stat-num { font-size: 1.4rem !important; }

  .section-pad { padding: 48px 0 !important; }
  .section-pad-sm { padding: 36px 0 !important; }

  .page-hero { padding: 120px 0 48px !important; }
  .page-hero-title { font-size: 1.6rem !important; }
}

/* ── Small (< 576px) ────────────────────────────────────── */
@media (max-width: 575px) {
  :root { --nav-h: 62px; }

  /* ── Navbar ── */
  #navbar { height: var(--nav-h); padding: 0 16px; }
  .nav-logo { font-size: 1.25rem; }

  /* ── Hero ── */
  #hero { min-height: 100svh; }
  #hero .container { padding: 0 16px; }
  #hero > .container > .row { padding: 100px 0 48px !important; }

  .hero-heading { font-size: 2rem !important; line-height: 1.1 !important; margin-bottom: 16px !important; }
  .hero-sub { font-size: .95rem !important; margin-bottom: 28px !important; }
  .hero-badge { font-size: .72rem; padding: 6px 14px; margin-bottom: 18px; }

  .hero-ctas {
    flex-direction: column !important;
    gap: 10px !important;
    margin-bottom: 36px !important;
  }
  .hero-ctas > * {
    width: 100%;
    justify-content: center;
    text-align: center;
    padding: 13px 20px !important;
  }

  .hero-stats {
    flex-wrap: wrap;
    gap: 16px 28px !important;
    padding-top: 24px !important;
  }
  .hero-stat { min-width: calc(50% - 14px); }
  .hero-stat-num { font-size: 1.5rem; }

  /* ── Section Padding ── */
  .section-pad { padding: 52px 0 !important; }
  .section-pad-sm { padding: 36px 0 !important; }

  /* ── Section Labels & Titles ── */
  .section-label { font-size: .68rem; padding: 5px 12px; margin-bottom: 14px; }
  .section-title { font-size: 1.6rem !important; }
  .section-subtitle { font-size: .875rem !important; }

  /* ── Cards ── */
  .card-premium { padding: 20px !important; border-radius: var(--radius) !important; }
  .card-icon { width: 52px !important; height: 52px !important; font-size: 1.3rem !important; margin-bottom: 16px !important; }

  /* ── Project Cards ── */
  .project-card-img { height: 180px !important; }
  .project-card-body { padding: 18px !important; }
  .project-card-title { font-size: .95rem !important; }
  .project-card-text { font-size: .82rem !important; }

  /* ── Flow Steps (vertical) ── */
  .flow-steps {
    flex-direction: column !important;
    gap: 0 !important;
    padding-left: 48px;
    position: relative;
  }
  .flow-steps::before {
    left: 20px !important;
    top: 0 !important; bottom: 0 !important;
    width: 2px !important; height: auto !important;
    right: auto !important;
    background: linear-gradient(to bottom, var(--primary), var(--accent)) !important;
  }
  .flow-step {
    flex-direction: row !important;
    text-align: left !important;
    align-items: flex-start !important;
    padding: 12px 0 24px 20px !important;
    gap: 16px;
  }
  .flow-node {
    width: 44px !important; height: 44px !important;
    flex-shrink: 0;
    margin-bottom: 0 !important;
    font-size: 1rem !important;
  }
  .flow-step > div:last-child { padding-top: 4px; }

  /* ── Stats ── */
  .stat-card { padding: 24px 12px !important; }
  .stat-num { font-size: 2rem !important; }
  .stat-label { font-size: .75rem !important; }

  /* ── Innovation Grid ── */
  .innovation-grid { grid-template-columns: 1fr !important; gap: 16px !important; }
  .innovation-card { padding: 22px !important; border-radius: var(--radius) !important; }

  /* ── Product Cards ── */
  .product-card-img { height: 180px !important; }
  .product-card-body { padding: 14px !important; }
  .product-title { font-size: .85rem !important; }
  .product-price { font-size: 1rem !important; }
  .product-rating { font-size: .72rem !important; }

  /* ── Filter Bar ── */
  .filter-bar {
    flex-direction: column !important;
    gap: 12px !important;
    padding: 16px !important;
  }
  .filter-bar > * { width: 100%; }

  /* ── Forms ── */
  .form-control-custom { padding: 12px 14px !important; font-size: .875rem !important; }
  .form-label { font-size: .72rem !important; margin-bottom: 6px !important; }

  /* ── Newsletter ── */
  .newsletter-form { flex-direction: column !important; gap: 10px !important; }
  .newsletter-input { border-radius: 12px !important; padding: 13px 16px !important; }
  .newsletter-form button { border-radius: 12px !important; width: 100%; justify-content: center; }

  /* ── Footer ── */
  #footer { padding: 52px 0 24px !important; }
  .footer-logo { font-size: 1.4rem !important; }
  .footer-desc { font-size: .82rem !important; }
  .footer-heading { margin-bottom: 12px !important; }
  .footer-links a { font-size: .82rem !important; }
  .social-links { gap: 8px !important; flex-wrap: wrap; }

  /* ── Timeline ── */
  .timeline::before { left: 14px !important; }
  .timeline-item,
  .timeline-item:nth-child(even) {
    padding: 0 0 0 44px !important;
    justify-content: flex-start !important;
  }
  .timeline-dot { left: 14px !important; width: 16px !important; height: 16px !important; }
  .timeline-card { padding: 18px 20px !important; max-width: 100% !important; }
  .timeline-year { font-size: .75rem !important; }

  /* ── Page Hero ── */
  .page-hero { padding: 120px 0 48px !important; }
  .page-hero-title { font-size: 1.75rem !important; }
  .page-hero-sub { font-size: .9rem !important; }
  .breadcrumb-custom { font-size: .78rem !important; }

  /* ── Testimonials ── */
  .testimonial-card { padding: 24px 20px !important; }

  /* ── Hero floating badges — hide on mobile ── */
  .floating-badge { display: none !important; }

  /* ── Buttons ── */
  .btn-primary-custom,
  .btn-outline-custom {
    font-size: .85rem !important;
    padding: 12px 20px !important;
  }

  /* ── Scroll top ── */
  #scroll-top { bottom: 16px !important; right: 16px !important; width: 42px !important; height: 42px !important; }

  /* ── FAQ ── */
  .accordion-button { font-size: .875rem !important; padding: 14px 16px !important; }
  .accordion-body { font-size: .875rem !important; padding: 12px 16px !important; }
}

/* ── Medium Mobile (576px – 767px) ─────────────────────── */
@media (min-width: 576px) and (max-width: 767px) {
  .hero-heading { font-size: 2.4rem !important; }
  .section-title { font-size: 1.85rem !important; }
  .section-pad { padding: 64px 0 !important; }

  .hero-ctas { flex-wrap: wrap; gap: 12px; }
  .hero-ctas > * { flex: 1 1 calc(50% - 6px); justify-content: center; text-align: center; }

  .innovation-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .product-card-img { height: 200px !important; }
}

/* ── Tablet (768px – 991px) ─────────────────────────────── */
@media (min-width: 768px) and (max-width: 991px) {
  .hero-heading { font-size: 3rem !important; }
  .section-title { font-size: 2.1rem !important; }
  .section-pad { padding: 72px 0 !important; }

  .hero-ctas { gap: 12px; flex-wrap: wrap; }

  .innovation-grid { grid-template-columns: repeat(2, 1fr) !important; }

  /* Admin sidebar on tablet */
  #admin-sidebar { width: 220px; }
  #admin-main { margin-left: 220px; }
}

/* ── Touch Device Hover Removal ─────────────────────────── */
@media (hover: none) {
  .card-premium:hover { transform: none; box-shadow: none; }
  .project-card:hover { transform: none; box-shadow: none; }
  .product-card:hover { transform: none; box-shadow: none; }
  .innovation-card:hover::after { opacity: 0; }
  .btn-primary-custom:hover { transform: none; }
  .btn-outline-custom:hover { transform: none; }
  .social-link:hover { transform: none; }
  .flow-step:hover .flow-node { transform: none; }
  .footer-links a:hover { color: rgba(255,255,255,.6); }
}

/* ── Safe Area (iPhone notch) ───────────────────────────── */
@supports (padding: max(0px)) {
  #navbar { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  #footer { padding-bottom: max(24px, env(safe-area-inset-bottom)); }
}

/* ── Mobile Nav Improvements ────────────────────────────── */
@media (max-width: 991px) {
  .offcanvas { width: min(300px, 85vw) !important; }
  .offcanvas-body .nav-link { font-size: .95rem !important; padding: 12px 16px !important; border-radius: 10px; margin-bottom: 2px; }
  .offcanvas-body .btn-primary-custom { margin-top: 8px; padding: 14px 20px; font-size: .9rem; }

  /* Navbar bg always visible on mobile */
  #navbar {
    background: rgba(255,255,255,.97) !important;
    backdrop-filter: blur(20px) !important;
    box-shadow: 0 2px 20px rgba(0,0,0,.08) !important;
  }

  /* Hamburger icon color fix */
  #navbar .bi-list { color: var(--primary-dark) !important; }
}

/* ── Freepko Mobile ─────────────────────────────────────── */
@media (max-width: 575px) {
  /* Product grid — 2 columns on mobile */
  #products-grid { --bs-gutter-x: 12px !important; }

  .product-actions { opacity: 1 !important; } /* Always show on touch */

  /* Freepko hero search bar */
  #hero-search { font-size: .85rem !important; }

  /* Sell page steps */
  .col-lg-3 .card-premium { flex-direction: row !important; text-align: left !important; gap: 16px; }
}

/* ── Admin Panel Mobile ──────────────────────────────────── */
@media (max-width: 991px) {
  #admin-sidebar {
    transform: translateX(-100%);
    transition: transform .3s ease;
    z-index: 1050;
    box-shadow: 4px 0 24px rgba(0,0,0,.3);
  }
  #admin-sidebar.open { transform: translateX(0); }
  #admin-main { margin-left: 0 !important; }

  .admin-content { padding: 16px !important; }
  #admin-topbar { padding: 0 16px !important; }
  .topbar-title { font-size: .875rem !important; }

  .stat-widget { padding: 16px !important; }
  .stat-num { font-size: 1.4rem !important; }
  .stat-icon { width: 44px !important; height: 44px !important; font-size: 1.1rem !important; }

  .admin-card-header { padding: 14px 16px !important; font-size: .85rem !important; }
  .admin-card-body { padding: 16px !important; }

  .admin-table th, .admin-table td { padding: 10px 12px !important; font-size: .78rem !important; white-space: nowrap; }

  /* Overlay when sidebar open */
  #admin-sidebar.open::after {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: -1;
  }
}

@media (max-width: 400px) {
  .admin-content { padding: 12px !important; }
  .stat-widget { flex-direction: column; gap: 8px; padding: 14px !important; }
  .stat-num { font-size: 1.2rem !important; }
}

/* ── Contact Page Mobile ─────────────────────────────────── */
@media (max-width: 575px) {
  .contact-info-item { flex-direction: column; gap: 8px; }
}

/* ── Vision Page Pillar Cards Mobile ─────────────────────── */
@media (max-width: 575px) {
  [style*="border-radius:var(--radius-xl)"] {
    padding: 32px 24px !important;
    min-height: auto !important;
  }
}

/* ── Image Overflow Fix ──────────────────────────────────── */
img { max-width: 100%; height: auto; }
.hero-visual img { border-radius: var(--radius-lg); }

/* ── Text Overflow Fix ───────────────────────────────────── */
h1, h2, h3, h4, h5, h6, p {
  overflow-wrap: break-word;
  word-break: break-word;
}

/* ── Horizontal Scroll Fix ───────────────────────────────── */
body { overflow-x: hidden !important; }
.container { padding-left: max(16px, calc((100vw - 1200px) / 2)) !important; padding-right: max(16px, calc((100vw - 1200px) / 2)) !important; }
@media (max-width: 575px) {
  .container { padding-left: 16px !important; padding-right: 16px !important; }
}

/* ── Table Responsive Wrapper ────────────────────────────── */
@media (max-width: 767px) {
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* ── Button Group Mobile ─────────────────────────────────── */
@media (max-width: 575px) {
  .d-flex.gap-3.flex-wrap { gap: 10px !important; }
  .d-flex.gap-3.flex-wrap > a,
  .d-flex.gap-3.flex-wrap > button {
    flex: 1 1 calc(50% - 5px);
    justify-content: center;
    text-align: center;
    min-width: 120px;
  }
}

/* ── Swiper Testimonials Mobile ──────────────────────────── */
@media (max-width: 575px) {
  .swiper-pagination { margin-top: 20px !important; }
  .testimonial-card { padding: 20px !important; min-height: auto !important; }
  .testimonial-card::before { font-size: 3.5rem !important; }
}

/* ── Smooth Scroll on iOS ────────────────────────────────── */
html { -webkit-overflow-scrolling: touch; }

/* ── Better tap targets ──────────────────────────────────── */
@media (max-width: 767px) {
  a, button { min-height: 44px; }
  .nav-link { min-height: 44px; display: flex; align-items: center; }
  .social-link { width: 44px !important; height: 44px !important; }
  .footer-links a { min-height: 36px; display: flex; align-items: center; }
}

/* ── Loader Mobile ───────────────────────────────────────── */
@media (max-width: 575px) {
  .loader-logo { font-size: 2rem !important; }
  .loader-bar { width: 160px !important; }
}

/* ── Stats section mobile columns ───────────────────────── */
@media (max-width: 400px) {
  #stats-section .col-6 { flex: 0 0 50% !important; max-width: 50% !important; }
}

/* ── Hero section min-height fix for mobile browsers ─────── */
@media (max-width: 767px) {
  #hero { min-height: 100svh; /* dynamic viewport height for iOS Safari */ }
  #hero .container > .row { min-height: auto !important; }
}

/* ── Fix inline styles on mobile ─────────────────────────── */
@media (max-width: 575px) {
  [style*="min-height:100vh"] { min-height: 100svh !important; }
  [style*="padding:160px"] { padding: 100px 0 48px !important; }
  [style*="padding:120px"] { padding: 90px 0 40px !important; }
  [style*="height:520px"] { height: auto !important; min-height: 280px; }
  [style*="height:480px"] { height: auto !important; min-height: 240px; }
  [style*="height:320px"] { height: auto !important; min-height: 180px; }
  [style*="height:200px"] { height: 160px !important; }
  [style*="font-size:5rem"] { font-size: 3rem !important; }
  [style*="font-size:4rem"] { font-size: 2.5rem !important; }
  [style*="font-size:3rem"] { font-size: 2rem !important; }
  [style*="padding:48px"] { padding: 24px !important; }
  [style*="padding:60px"] { padding: 28px !important; }
  [style*="max-width:520px"], [style*="max-width:560px"], [style*="max-width:480px"] { max-width: 100% !important; }
}
