/* VIETPOT_MOBILE_OVERRIDE_ACTIVE_2026
   File này được enqueue SAU vietpot-main (priority 999).
   Tất cả rule đều trong @media max-width.
   KHÔNG ảnh hưởng desktop (>768px).
   Selectors đã audit từ: header.php, front-page.php, footer.php, vietpot.css.
   ─────────────────────────────────────────────────────────────── */

/* ── TEST MARKER — xoá sau khi xác nhận CSS đã load ─────────────────────── */
@media (max-width: 768px) {
  body::after {
    content: "MOBILE CSS ACTIVE";
    position: fixed;
    left: 8px;
    bottom: 8px;
    z-index: 999999;
    background: #0f7a4f;
    color: #fff;
    font-size: 10px;
    font-family: monospace;
    padding: 4px 8px;
    border-radius: 999px;
    pointer-events: none;
    letter-spacing: 0.04em;
  }
}

/* ═══════════════════════════════════════════════════════════════
   1. HEADER MOBILE
   Selector audit: header.php
   .vp-site-header (fixed pill), .vp-mobile-toggle (hamburger),
   .vp-nav-inner (flex row), .vp-nav-scrolled (scroll state class)
   ═══════════════════════════════════════════════════════════════ */

/* Hamburger icon visible on transparent (non-scrolled) header */
@media (max-width: 1120px) {
  .vp-mobile-toggle {
    color: rgba(28, 26, 18, 0.88) !important;
    background: rgba(28, 26, 18, 0.07) !important;
    border-color: rgba(28, 26, 18, 0.18) !important;
  }
  .vp-nav-scrolled .vp-mobile-toggle {
    color: white !important;
    background: rgba(255, 255, 255, 0.12) !important;
    border-color: rgba(255, 255, 255, 0.28) !important;
  }
}

/* Compact header height on small phones */
@media (max-width: 480px) {
  .vp-site-header {
    top: 8px !important;
    width: calc(100vw - 16px) !important;
    height: 52px !important;
  }
  /* Push page content below header */
  .vp-content-shell {
    margin-top: 76px !important;
  }
  .vp-nav-inner {
    padding: 0 10px !important;
    height: 52px !important;
  }
  /* Slightly smaller logo on very small screens */
  .vp-nav-brand img,
  .custom-logo-link img {
    max-height: 34px !important;
    width: auto !important;
  }
}

/* ═══════════════════════════════════════════════════════════════
   2. HERO SECTION MOBILE
   Selector audit: front-page.php + vietpot.css
   .vp-hero-card (section), .vp-hero-content (text area),
   .vp-hero-content h1, .vp-hero-actions (.vp-pill-btn CTA buttons)
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  /* Reduce hero height — existing ≤620px rule sets 570px, still too tall */
  .vp-hero-card {
    min-height: 480px !important;
  }

  /* Move text content up — less bottom offset */
  .vp-hero-content {
    left: 18px !important;
    right: 18px !important;
    bottom: 72px !important;
  }

  /* Smaller headline */
  .vp-hero-content h1 {
    font-size: clamp(36px, 11vw, 52px) !important;
    line-height: 0.96 !important;
    margin-bottom: 12px !important;
    letter-spacing: -0.05em !important;
  }

  /* Shorter description text */
  .vp-hero-content p {
    font-size: 14px !important;
    line-height: 1.5 !important;
    margin-bottom: 18px !important;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  /* Compact CTA buttons */
  .vp-hero-actions .vp-pill-btn {
    min-height: 42px !important;
    padding: 0 18px !important;
    font-size: 13px !important;
  }

  /* Compact kicker label */
  .vp-hero-kicker {
    font-size: 10px !important;
    padding: 5px 10px !important;
    margin-bottom: 10px !important;
    gap: 5px !important;
  }
  .vp-hero-kicker svg {
    width: 13px !important;
    height: 13px !important;
  }
}

@media (max-width: 480px) {
  .vp-hero-card {
    min-height: 420px !important;
  }
  .vp-hero-content {
    bottom: 56px !important;
  }
  .vp-hero-content h1 {
    font-size: clamp(32px, 10vw, 44px) !important;
    margin-bottom: 8px !important;
  }
  .vp-hero-content p {
    font-size: 13px !important;
    -webkit-line-clamp: 2;
  }
}

/* ═══════════════════════════════════════════════════════════════
   3. BSC BESTSELLER CAROUSEL MOBILE
   Selector audit: front-page.php + vietpot-home-bestseller-carousel.js
   .vp-bsc-section.vp-shell-padded, .vp-bsc-nav (prev/next arrows),
   .vp-bsc-track .vp-bs-card (each card — JS sets explicit width),
   .vp-bs-media (image), .vp-bs-info, .vp-bs-info h3, .vp-bs-price,
   .vp-bs-cta (CTA), .vp-bs-top-header, .vp-bs-top-label, .vp-bs-rank
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 619px) {

  /* Give carousel more horizontal room — reduce shell margin */
  .vp-bsc-section.vp-shell-padded {
    margin-inline: 6px !important;
  }

  /* Hide prev/next nav buttons — swipe handles navigation */
  .vp-bsc-nav {
    display: none !important;
  }

  /* Override ≤620px existing rule (flex-direction:row) — revert to column
     so 3 compact vertical cards fit side-by-side */
  .vp-bsc-track .vp-bs-card {
    flex-direction: column !important;
    align-items: stretch !important;
    border-radius: 14px !important;
  }

  /* Compact square image — fills card width */
  .vp-bsc-track .vp-bs-media {
    width: auto !important;
    flex-shrink: unset !important;
    margin: 6px 6px 0 !important;
    aspect-ratio: 1 !important;
    border-radius: 10px !important;
  }

  /* Info area: tighter padding */
  .vp-bsc-track .vp-bs-info {
    gap: 3px !important;
    padding: 5px 7px 8px !important;
    justify-content: flex-start !important;
  }

  /* Category micro label */
  .vp-bsc-track .vp-bs-cat {
    font-size: 9px !important;
    letter-spacing: 0.04em;
  }

  /* Product title — 2 lines max */
  .vp-bsc-track .vp-bs-info h3 {
    font-size: 11px !important;
    line-height: 1.3;
    -webkit-line-clamp: 2;
    margin: 0 0 2px !important;
  }

  /* Sales badge */
  .vp-bsc-track .vp-bs-sales {
    padding: 2px 6px !important;
    font-size: 9px !important;
    border-radius: 6px !important;
  }
  .vp-bsc-track .vp-bs-sales strong {
    font-size: 10px !important;
  }

  /* Price */
  .vp-bsc-track .vp-bs-info strong {
    font-size: 12px !important;
  }

  /* Hide elements that don't fit at compact width */
  .vp-bsc-track .vp-bs-cta          { display: none !important; }
  .vp-bsc-track .vp-bs-top-header   { display: none !important; }
  .vp-bsc-track .vp-bs-top-label    { display: none !important; }

  /* Rank badge — smaller */
  .vp-bsc-track .vp-bs-rank {
    font-size: 12px !important;
    width: 22px !important;
    height: 22px !important;
    top: 4px !important;
    left: 4px !important;
  }
}

/* ═══════════════════════════════════════════════════════════════
   4. "THIẾT KẾ ĐỂ CÂY XANH" WHY SECTION MOBILE
   Selector audit: front-page.php + vietpot.css
   .vp-why-section, .vp-why-card-grid (grid), .vp-why-card,
   .vp-why-card-copy (glass overlay), .vp-why-card h3,
   .vp-why-card p (description), .vp-why-card-icon,
   .vp-why-commitments (stats grid below)
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 619px) {

  /* 2-column grid — overrides existing ≤620px 1-column rule */
  .vp-why-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  /* Shorter cards — overrides 330px min-height causing 1320px total */
  .vp-why-card {
    min-height: 200px !important;
    border-radius: 18px !important;
    grid-column: auto !important;
  }

  /* Compact glass overlay */
  .vp-why-card-copy {
    left: 8px !important;
    right: 8px !important;
    bottom: 8px !important;
    padding: 8px 10px !important;
    gap: 8px !important;
    min-height: 0 !important;
    border-radius: 14px !important;
  }

  /* Smaller title */
  .vp-why-card h3 {
    font-size: 12px !important;
    line-height: 1.2;
    min-height: auto !important;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  /* Hide description — no room in 2-col compact layout */
  .vp-why-card p { display: none !important; }

  /* Smaller icon */
  .vp-why-card-icon {
    width: 30px !important;
    height: 30px !important;
    border-radius: 8px !important;
    flex-shrink: 0 !important;
  }
  .vp-why-card-icon svg {
    width: 14px !important;
    height: 14px !important;
  }

  /* Section padding */
  .vp-why-section {
    padding: 24px 14px !important;
    margin-top: 32px !important;
  }

  /* Heading sizes */
  .vp-why-heading h2 {
    font-size: clamp(24px, 7vw, 32px) !important;
  }
  .vp-why-heading p {
    font-size: 13px !important;
    margin-top: 8px;
  }

  /* Commitments stats: 2-column — overrides 1-col ≤620px rule */
  .vp-why-commitments {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
    margin-top: 18px !important;
    padding-top: 18px !important;
  }
  .vp-why-commitment {
    padding: 12px 14px !important;
    border-radius: 14px !important;
  }
  .vp-why-commitment strong {
    font-size: 20px !important;
  }
  .vp-why-commitment span {
    font-size: 11px !important;
    line-height: 1.3;
  }
}

/* ═══════════════════════════════════════════════════════════════
   5. "GỢI Ý XANH CHO TỪNG GÓC NHÀ" SPACE SECTION MOBILE
   Selector audit: front-page.php + vietpot.css
   .vp-space-grid (grid), .vp-space-card (each card),
   .vp-space-label (bottom label), .vp-space-name (room name),
   .vp-space-large/.vp-space-wide (large span cards → reset to auto)
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 619px) {

  /* 2-column grid — overrides ≤620px 1-column rule */
  .vp-space-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  /* Square cards, no fixed min-height */
  .vp-space-card {
    min-height: 0 !important;
    aspect-ratio: 1 / 1 !important;
    border-radius: 16px !important;
  }

  /* Reset large/wide card spans to normal */
  .vp-space-large,
  .vp-space-wide {
    grid-column: auto !important;
    grid-row: auto !important;
  }

  /* Compact bottom label */
  .vp-space-label {
    left: 8px !important;
    right: 8px !important;
    bottom: 8px !important;
    padding: 6px 8px 6px 10px !important;
    border-radius: 10px !important;
    gap: 4px !important;
  }

  .vp-space-name {
    font-size: 12px !important;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* ═══════════════════════════════════════════════════════════════
   6. FLOATING SOCIAL BUTTONS MOBILE
   Selector audit: footer.php
   .vp-social-float (container), .vp-sf-btn (base class),
   .vp-sf-facebook, .vp-sf-messenger, .vp-sf-zalo (specific buttons)
   DOM confirmed: Zalo + Facebook + Messenger ALL present in HTML.
   Root cause: existing rule @media(max-width:479px) sets display:none
   for .vp-sf-facebook and .vp-sf-messenger — this hides them on ALL
   iPhones (375–430px). Override below restores them.
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 479px) {
  /* Restore Facebook + Messenger — DOM has them, CSS was hiding them */
  .vp-sf-facebook,
  .vp-sf-messenger {
    display: flex !important;
  }

  /* Slightly smaller buttons + tighter stack on small screen */
  .vp-social-float {
    bottom: 88px !important;
    right: 12px !important;
    gap: 7px !important;
  }

  .vp-sf-btn {
    width: 46px !important;
    height: 46px !important;
    min-width: 46px !important;
  }

  .vp-sf-btn svg {
    width: 20px !important;
    height: 20px !important;
    flex-shrink: 0;
  }
}

/* ═══════════════════════════════════════════════════════════════
   7. CHATBOT PANEL MOBILE
   Selector audit: footer.php + vietpot.css
   .chatbot-window (panel — React-rendered), .chatbot-bubble (trigger),
   #vp-chat-placeholder (PHP placeholder button, has inline style)
   Issue: calc(100vh - 120px) on 667px Safari → panel top at 16px,
   behind the 56px fixed header. Use 100dvh + larger offset.
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 619px) {
  .chatbot-window {
    width: min(370px, calc(100vw - 24px)) !important;
    /* vh fallback for browsers without dvh support */
    max-height: min(520px, calc(100vh - 180px)) !important;
    /* dvh = dynamic viewport height (excludes iOS Safari chrome) */
    max-height: min(520px, calc(100dvh - 180px)) !important;
  }

  .chatbot-bubble {
    bottom: max(20px, env(safe-area-inset-bottom, 20px)) !important;
    right: 16px !important;
  }
}

/* Chat placeholder: safe area on iPhone notch/home bar.
   Note: has inline style — using !important to override. */
@media (max-width: 767px) {
  #vp-chat-placeholder {
    bottom: max(20px, calc(env(safe-area-inset-bottom, 0px) + 12px)) !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   VIETPOT_VISUAL_UX_FIX_PHASE_2026 — Mobile-only overrides
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── A. Space grid: slightly taller cards for better image visibility ────────
   Current: aspect-ratio 1:1 from previous fix. Increase to 1/1.1 = taller.
   Also reduce outer section padding to give cards more horizontal room. */
@media (max-width: 619px) {
  .vp-space-grid {
    gap: 12px !important;
    padding: 0 2px !important;
  }

  .vp-space-card {
    aspect-ratio: 1 / 1.1 !important;
    border-radius: 18px !important;
  }

  /* Ensure the label overlay doesn't cover too much image */
  .vp-space-label {
    left: 6px !important;
    right: 6px !important;
    bottom: 6px !important;
    padding: 6px 8px 6px 10px !important;
    border-radius: 10px !important;
  }

  .vp-space-name {
    font-size: 12px !important;
    font-weight: 700;
  }
}

/* ── B. VIETPOT_MOBILE_GREEN_MOMENTS_MARQUEE_2026 ────────────────────────────
   Restore 2-row horizontal marquee on mobile.
   Reverses the static 3-column grid override that broke the animation.
   Selector audit: .vp-motion-gallery-row, .vp-motion-gallery-track,
   .vp-motion-gallery-card, .vp-motion-gallery-card[aria-hidden=true] */
@media (max-width: 767px) {

  /* Restore flex track — undo display:grid and animation:none */
  .vp-mg-row--ltr .vp-motion-gallery-track,
  .vp-mg-row--rtl .vp-motion-gallery-track {
    animation-play-state: running !important;
    display: flex !important;
    width: max-content !important;
    gap: 0 !important;
    flex-wrap: nowrap !important;
  }

  /* Clip the scrolling track — undo overflow:visible */
  .vp-motion-gallery-row {
    overflow: hidden !important;
    margin-bottom: 12px !important;
  }

  /* Compact fixed-size cards — undo aspect-ratio:1/1 and auto sizing */
  .vp-motion-gallery-card {
    width: 210px !important;
    height: 158px !important;
    aspect-ratio: unset !important;
    margin-right: 12px !important;
    border-radius: 14px !important;
    flex-shrink: 0 !important;
  }

  /* Show duplicate cards — required for seamless marquee loop */
  .vp-motion-gallery-card[aria-hidden="true"] {
    display: block !important;
  }

  /* Restore edge fade masks */
  .vp-motion-gallery-marquee::before,
  .vp-motion-gallery-marquee::after {
    display: block !important;
    width: 40px !important;
  }

  .vp-home-motion-gallery {
    padding: 44px 0 52px !important;
  }

  .vp-mg-header-wrap {
    padding: 0 14px !important;
    margin-bottom: 24px !important;
  }
}

/* ── C. Floating buttons: stable positions, prevent overlap with chatbot ─────
   Root cause: .vp-social-float bottom:92px at ≤640px. Chatbot top edge at
   28+60=88px. Only 4px gap. Entrance animation translateY(12px) briefly
   overlaps. Fix: increase bottom, disable entrance animation on mobile,
   hide scroll-to-top on mobile (simplifies the stack). */
@media (max-width: 768px) {

  /* Disable entrance animation bounce — prevents temporary overlap */
  .vp-sf-btn {
    animation: none !important;
  }

  /* Hide scroll-to-top on mobile: it adds height and can cause overlap
     on small screens. User can use natural scroll instead. */
  .vp-scroll-top {
    display: none !important;
  }

  /* Social float: move up from chatbot with clear gap.
     Chatbot placeholder: bottom:20px, height:60px → top at 80px.
     Social float bottom set to 96px gives 16px breathing room. */
  .vp-social-float {
    bottom: 96px !important;
    right: 14px !important;
    gap: 8px !important;
    position: fixed !important;
  }
}

@media (max-width: 479px) {
  /* On very small phones: show all 3 buttons (override the display:none rule),
     keep the comfortable position above chatbot */
  .vp-sf-facebook,
  .vp-sf-messenger {
    display: flex !important;
  }

  .vp-social-float {
    bottom: 96px !important;
    right: 10px !important;
    gap: 7px !important;
  }

  .vp-sf-btn {
    width: 46px !important;
    height: 46px !important;
    min-width: 46px !important;
  }

  .vp-sf-btn svg {
    width: 20px !important;
    height: 20px !important;
  }
}

/* ── D. Hero CTA buttons mobile: side by side, large enough to tap ──────────
   Two buttons at ≤480px: gap reduced to stay on one line. */
@media (max-width: 480px) {
  .vp-hero-actions {
    flex-wrap: nowrap !important;
    gap: 8px !important;
  }

  .vp-hero-actions .vp-pill-btn {
    min-height: 44px !important;
    padding: 0 14px !important;
    font-size: 13px !important;
    flex: 1 !important;
    text-align: center !important;
    justify-content: center !important;
  }
}

/* ── E. Why section: text legibility on mobile ─────────────────────────────
   The glass overlay (.vp-why-card-copy) may not provide enough contrast
   on all device renders. Strengthen here. */
@media (max-width: 767px) {
  .vp-why-section .vp-why-card h3 {
    font-size: 12px !important;
    color: white !important;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.32) !important;
  }

  .vp-why-section .vp-why-card-copy {
    background:
      linear-gradient(135deg, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0.03)),
      rgba(8, 30, 20, 0.52) !important;
  }
}

/* ══════════════════════════════════════════════════════════════
   VIETPOT_MOBILE_TRUST_GRID_2026
   Trust strip: 2×2 grid on mobile.
   Overrides the ≤600px rule in vietpot.css that collapses to 1-col.
   Selectors: .vp-home-trust-strip, .vp-home-trust-inner, .vp-home-trust-item
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 767px) {
  .vp-home-trust-strip {
    padding: 0 10px !important;
  }

  .vp-home-trust-inner {
    grid-template-columns: repeat(2, 1fr) !important;
    width: 100% !important;
    border-radius: 18px !important;
  }

  .vp-home-trust-item {
    border-right: none !important;
    border-bottom: 1px solid rgba(196, 182, 158, 0.28) !important;
    padding: 16px 14px !important;
  }

  /* Odd items get right divider */
  .vp-home-trust-item:nth-child(odd) {
    border-right: 1px solid rgba(196, 182, 158, 0.28) !important;
  }

  /* Last two items: no bottom border */
  .vp-home-trust-item:nth-last-child(-n+2) {
    border-bottom: none !important;
  }
}

/* ══════════════════════════════════════════════════════════════
   VIETPOT_MOBILE_HOME_REORDER_2026
   After vietpot-mobile-ux.js moves .vp-bsc-section before .vp-home-trust-strip,
   reset the -28px hero-overlap margin so trust strip sits normally below BSC.
   body.vp-mobile-reordered is added by the JS after the DOM move.
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 767px) {
  body.vp-mobile-reordered .vp-home-trust-strip {
    margin-top: 16px !important;
  }
}

/* ══════════════════════════════════════════════════════════════
   VIETPOT_MOBILE_SHOP_FILTER_COLLAPSE_2026
   Filter bar row: .vp-mobile-filter-btn (left) + .vp-mobile-search-input (right).
   .vp-mobile-filter-bar wrapper is injected by vietpot-mobile-ux.js.
   Sidebar collapse is already handled by vietpot.css ≤980px rule.
   Original .vp-shop-search-sticky-wrap is hidden — replaced by mini search.
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 767px) {
  .vp-mobile-filter-bar {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 10px 0 14px !important;
  }

  .vp-mobile-filter-bar .vp-mobile-filter-btn {
    flex-shrink: 0 !important;
  }

  .vp-mobile-search-input {
    flex: 1 !important;
    height: 38px !important;
    padding: 0 12px !important;
    border: 1.5px solid rgba(0, 0, 0, 0.14) !important;
    border-radius: 999px !important;
    font-size: 13px !important;
    background: #f8f8f6 !important;
    color: #1c1a12 !important;
    outline: none !important;
    min-width: 0 !important;
    transition: border-color 0.15s !important;
    -webkit-appearance: none !important;
  }

  .vp-mobile-search-input:focus {
    border-color: #2a7a4e !important;
    background: #fff !important;
  }

  /* Hide original sticky search on mobile — replaced by mini search in filter bar */
  .vp-shop-search-sticky-wrap {
    display: none !important;
  }
}
