/* ==========================================================================
   BTS SHOP — MOBILE STOREFRONT REDESIGN
   Feature: Compact mobile layout matching professional mobile shopping UX
   Branch: feature/mobile-storefront-redesign
   Breakpoints: 320px | 375px | 390px | 430px | 640px
   Desktop design is 100% preserved — all rules scoped to max-width: 768px
   ========================================================================== */

/* ==========================================================================
   1. MOBILE ELEMENTS — DESKTOP HIDING GUARDS (>768px)
   All mobile-only elements MUST be strictly hidden on desktop screens so
   the desktop storefront remains completely untouched and clean.
   ========================================================================== */

.mobile-header,
.mobile-ship-to-bar,
.mobile-nav-overlay,
.mobile-nav-drawer,
.mobile-country-sheet-overlay,
.mobile-country-sheet {
  display: none !important;
}

/* Guard dimensions for mobile SVG icons */
.drawer-pin-icon {
  width: 17px !important;
  height: 17px !important;
  flex-shrink: 0;
}

.mobile-ship-to-left svg {
  width: 15px !important;
  height: 15px !important;
  flex-shrink: 0;
}

.mobile-cart-btn svg,
.mobile-hamburger-btn svg {
  width: 24px !important;
  height: 24px !important;
}

.mobile-drawer-close svg {
  width: 20px !important;
  height: 20px !important;
}

@media (max-width: 768px) {

  /* Hide the full desktop header on mobile */
  .weverse-top-header {
    display: none !important;
  }

  /* Hide the top announcement bar on mobile (too long for small screens) */
  .top-announcement-bar {
    display: none !important;
  }

  /* Show mobile header */
  .mobile-header {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    height: 52px;
    padding: 0 14px;
    background: #ffffff;
    border-bottom: 1px solid #ede9fe;
    position: sticky;
    top: 0;
    z-index: 1200;
    box-shadow: 0 1px 4px rgba(121, 82, 222, 0.07);
  }

  .mobile-header-logo {
    display: flex;
    align-items: center;
    gap: 2px;
    text-decoration: none;
    flex-shrink: 0;
  }

  .mobile-header-logo .logo-bts {
    font-size: 22px;
    font-weight: 900;
    color: #7952de !important;
    letter-spacing: -0.5px;
  }

  .mobile-header-logo .logo-shop {
    font-size: 22px;
    font-weight: 800;
    color: #111827 !important;
  }

  .mobile-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
  }

  /* Cart Button in mobile header */
  .mobile-cart-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 8px;
    color: #1e293b;
    transition: background 0.15s;
  }

  .mobile-cart-btn:hover,
  .mobile-cart-btn:active {
    background: #f1f5f9;
  }

  .mobile-cart-btn svg {
    width: 24px;
    height: 24px;
    stroke: #1e293b;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .mobile-cart-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 17px;
    height: 17px;
    background: #7952de;
    color: #ffffff;
    font-size: 10px;
    font-weight: 800;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
    pointer-events: none;
  }

  .mobile-cart-badge[data-count="0"] {
    display: none;
  }

  /* Hamburger menu button */
  .mobile-hamburger-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 8px;
    transition: background 0.15s;
  }

  .mobile-hamburger-btn:hover,
  .mobile-hamburger-btn:active {
    background: #f1f5f9;
  }

  .mobile-hamburger-btn svg {
    width: 24px;
    height: 24px;
    stroke: #1e293b;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
  }

  /* ==========================================================================
     2. MOBILE NAV DRAWER — Slide in from right (Minimalist Weverse Layout)
     ========================================================================== */

  .mobile-nav-overlay {
    display: block !important;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }

  .mobile-nav-overlay.open {
    opacity: 1;
    pointer-events: all;
  }

  .mobile-nav-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(320px, 84vw);
    background: #ffffff;
    z-index: 2100;
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.33, 1, 0.68, 1);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.08);
    display: flex !important;
    flex-direction: column;
    padding-top: max(8px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }

  .mobile-nav-drawer.open {
    transform: translateX(0);
  }

  /* Drawer header: Minimal black "MENU" + crisp "✕" icon */
  .mobile-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px 24px 16px 24px;
    background: #ffffff;
    flex-shrink: 0;
  }

  .mobile-drawer-header .menu-label {
    font-size: 16px;
    font-weight: 700;
    color: #000000;
    margin: 0;
    letter-spacing: -0.2px;
    text-transform: uppercase;
    font-family: inherit;
  }

  .mobile-drawer-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    margin-right: -6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000000;
    border-radius: 4px;
    transition: opacity 0.15s;
    line-height: 1;
    outline: none !important;
  }

  .mobile-drawer-close:focus,
  .mobile-drawer-close:focus-visible {
    outline: none !important;
  }

  .mobile-drawer-close:hover,
  .mobile-drawer-close:active {
    opacity: 0.6;
  }

  .mobile-drawer-close svg {
    width: 20px;
    height: 20px;
    stroke: #000000;
    stroke-width: 1.8;
  }

  /* Drawer scrollable body */
  .mobile-drawer-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 4px 24px 28px 24px;
    display: flex;
    flex-direction: column;
  }

  /* Section containers */
  .drawer-section {
    display: flex;
    flex-direction: column;
  }

  /* Clean minimal dividers matching reference */
  .drawer-divider {
    height: 1px;
    background: #f1f3f5;
    margin: 18px 0;
    border: none;
    flex-shrink: 0;
  }

  /* Interactive Row Items (Country, Language, Currency) */
  .drawer-row-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: none;
    border: none;
    padding: 10px 0;
    font-size: 14.5px;
    color: #000000;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    transition: opacity 0.15s;
    min-height: 42px;
  }

  .drawer-row-item:hover,
  .drawer-row-item:active {
    opacity: 0.65;
  }

  .drawer-row-left {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #000000;
    font-size: 14.5px;
    font-weight: 500;
  }

  .drawer-pin-icon {
    width: 17px;
    height: 17px;
    stroke: #000000;
    stroke-width: 1.8;
    fill: none;
    flex-shrink: 0;
  }

  .drawer-pref-label {
    color: #000000;
    font-size: 14.5px;
    font-weight: 500;
  }

  /* Teal value accent — exact reference screenshot styling */
  .drawer-val-teal {
    font-size: 14px;
    font-weight: 600;
    color: #00c7be;
    letter-spacing: -0.2px;
    text-align: right;
  }

  /* Standard navigation menu links (Black text, no emojis, clean vertical rhythm) */
  .drawer-link {
    display: block;
    font-size: 14.5px;
    font-weight: 500;
    color: #111111;
    text-decoration: none;
    padding: 10px 0;
    line-height: 1.4;
    cursor: pointer;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
    transition: opacity 0.15s;
  }

  .drawer-link:hover,
  .drawer-link:active {
    opacity: 0.65;
  }

  .drawer-logout-link {
    color: #dc2626 !important;
  }

  /* Logged-in user identity (minimalist) */
  .drawer-user-meta {
    padding: 2px 0 10px 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .drawer-user-name {
    font-size: 14px;
    font-weight: 700;
    color: #000000;
  }

  .drawer-user-email {
    font-size: 12px;
    color: #64748b;
  }

  /* ==========================================================================
     3. SHIP-TO BAR — Below mobile header, above category nav
     ========================================================================== */

  .mobile-ship-to-bar {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    padding: 7px 14px;
    background: #faf8ff;
    border-bottom: 1px solid #ede9fe;
    font-size: 12.5px;
  }

  .mobile-ship-to-left {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #334155;
    font-weight: 500;
  }

  .mobile-ship-to-left svg {
    width: 13px;
    height: 13px;
    stroke: #7952de;
    fill: none;
    stroke-width: 2;
    flex-shrink: 0;
  }

  .mobile-ship-to-country {
    font-weight: 700;
    color: #0f172a;
  }

  .mobile-ship-to-change {
    font-size: 12px;
    font-weight: 700;
    color: #7952de;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    min-height: 30px;
    font-family: inherit;
  }

  .mobile-ship-to-change:hover {
    background: #f3f0fd;
  }

  /* ==========================================================================
     4. COUNTRY PICKER BOTTOM SHEET
     ========================================================================== */

  .mobile-country-sheet-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 2500;
  }

  .mobile-country-sheet-overlay.open {
    display: block !important;
  }

  .mobile-country-sheet {
    display: block !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #ffffff;
    border-radius: 20px 20px 0 0;
    padding: 0 0 env(safe-area-inset-bottom, 16px);
    z-index: 2600;
    max-height: 70vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .mobile-country-sheet-overlay.open .mobile-country-sheet {
    transform: translateY(0);
  }

  .country-sheet-handle {
    width: 36px;
    height: 4px;
    background: #cbd5e1;
    border-radius: 2px;
    margin: 10px auto 0;
  }

  .country-sheet-title {
    font-size: 15px;
    font-weight: 800;
    color: #0f172a;
    padding: 14px 18px 10px;
    border-bottom: 1px solid #f1f5f9;
  }

  .country-sheet-list {
    padding: 8px 0;
  }

  .country-sheet-search {
    display: block;
    width: calc(100% - 32px);
    margin: 12px 16px 4px;
    padding: 11px 12px;
    border: 1px solid #d7dce5;
    border-radius: 10px;
    font: inherit;
  }

  .country-sheet-empty {
    padding: 16px;
    color: #64748b;
    text-align: center;
  }

  .country-sheet-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 18px;
    font-size: 14px;
    font-weight: 500;
    color: #1e293b;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    min-height: 48px;
    font-family: inherit;
    transition: background 0.1s;
  }

  .country-sheet-item:hover,
  .country-sheet-item:active {
    background: #f8fafc;
  }

  .country-sheet-item.selected {
    background: #f3f0fd;
    color: #7952de;
    font-weight: 700;
  }

  .country-sheet-item .country-check {
    color: #7952de;
    font-size: 16px;
    opacity: 0;
  }

  .country-sheet-item.selected .country-check {
    opacity: 1;
  }

  /* ==========================================================================
     5. CATEGORY BAR — Horizontal scroll, mobile-tuned
     ========================================================================== */

  /* The destination bar scrolls away; the category bar stays below the header. */
  .weverse-category-bar {
    position: sticky !important;
    top: 52px !important;
    z-index: 1100 !important;
  }

  .category-bar-inner {
    padding: 0 10px !important;
    gap: 2px !important;
  }

  .cat-nav-item {
    padding: 10px 11px !important;
    font-size: 12.5px !important;
    min-height: 40px !important;
    white-space: nowrap;
  }

  /* ==========================================================================
     6. HERO BANNER — Hidden on mobile (products shown immediately)
     ========================================================================== */

  .bts-hero-showcase,
  #bts-hero-banner {
    display: none !important;
  }

  /* ==========================================================================
     7. FILTER STRIP — Compact mobile layout
     ========================================================================== */

  .weverse-filter-strip {
    flex-direction: column !important;
    gap: 8px !important;
    padding: 10px 0 8px !important;
  }

  .storefront-filter-left {
    width: 100% !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 10px !important;
  }

  .storefront-filter-right {
    width: 100% !important;
    gap: 8px !important;
  }

  /* Search bar full width on mobile */
  .mini-search-wrapper {
    flex: 1 !important;
  }

  .mini-search-wrapper input {
    width: 100% !important;
    font-size: 13px !important;
  }

  .mini-search-wrapper input:focus {
    width: 100% !important;
  }

  /* Sort select compact */
  .storefront-sort-wrapper {
    flex-shrink: 0;
  }

  .storefront-sort-wrapper label {
    display: none !important; /* "Sort by:" label hidden on mobile, implied */
  }

  .storefront-sort-select {
    font-size: 12px !important;
    padding: 6px 24px 6px 8px !important;
    min-height: 36px !important;
    max-width: 130px;
  }

  /* ==========================================================================
     8. PRODUCT GRID — 2-column, square images
     ========================================================================== */

  .weverse-product-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px 8px !important;
    padding: 2px 0 !important;
    margin-top: 6px !important;
  }

  /* Square product image */
  .wv-product-card .wv-card-img-wrap {
    aspect-ratio: 1 / 1;
    overflow: hidden;
  }

  .wv-product-card .wv-card-img-wrap img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
  }

  /* Card info area */
  .wv-card-info {
    padding: 8px 9px 10px !important;
  }

  .wv-card-title {
    font-size: 12px !important;
    line-height: 1.35 !important;
    height: auto !important;
    min-height: 30px !important;
    max-height: 42px !important;
    overflow: hidden !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
  }

  .wv-price-val {
    font-size: 13.5px !important;
    font-weight: 800 !important;
  }

  .wv-tax-label {
    font-size: 10px !important;
  }

  /* Ships from KR badge on product card */
  .mobile-ship-kr-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 9.5px;
    font-weight: 600;
    color: #475569;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 3px;
    padding: 2px 5px;
    margin-top: 4px;
    white-space: nowrap;
  }

  /* Add to cart / wishlist buttons on card — touch-friendly */
  .wv-btn-add-cart,
  .wv-btn-wishlist {
    min-height: 36px !important;
    font-size: 11.5px !important;
  }

  /* ==========================================================================
     9. COOKIE BANNER — Compact mobile layout
     ========================================================================== */

  .weverse-cookie-banner {
    padding: 10px 12px !important;
    font-size: 12px !important;
  }

  .weverse-cookie-banner .cookie-container {
    flex-direction: row !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    gap: 8px !important;
  }

  .weverse-cookie-banner .cookie-container p {
    font-size: 11px !important;
    line-height: 1.35 !important;
    flex: 1;
    margin: 0;
  }

  .weverse-cookie-banner .cookie-actions {
    display: flex !important;
    flex-direction: row !important;
    flex-shrink: 0 !important;
    gap: 5px !important;
    flex-wrap: nowrap !important;
    width: auto !important;
  }

  .weverse-cookie-banner .cookie-actions button {
    min-height: 34px !important;
    font-size: 10.5px !important;
    padding: 5px 8px !important;
    white-space: nowrap;
    flex: none !important;
  }

  /* Hide the "Refuse and continue" button on tiny screens to save space */
  .weverse-cookie-banner .cookie-btn-refuse {
    display: none;
  }

  /* ==========================================================================
     10. GENERAL MOBILE FIXES — Overflow, spacing, touch targets
     ========================================================================== */

  /* Prevent horizontal overflow on all elements */
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  body {
    overflow-x: hidden !important;
  }

  /* Main content container: remove excessive top padding */
  .weverse-main-content {
    padding-top: 0 !important;
  }

  .weverse-container {
    padding-left: 10px !important;
    padding-right: 10px !important;
  }

  /* Auth modal mobile */
  .bts-auth-modal {
    width: calc(100vw - 20px) !important;
    max-width: calc(100vw - 20px) !important;
    padding: 18px 16px !important;
    max-height: calc(100dvh - 40px) !important;
  }

  /* Cart / wishlist drawers: full width on mobile */
  .cart-drawer {
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Product modal mobile */
  .product-detail-modal {
    width: 98% !important;
    max-height: calc(100dvh - 20px) !important;
    padding: 16px !important;
    border-radius: 16px !important;
  }

  .modal-grid {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }

  .modal-title {
    font-size: 17px !important;
  }

  /* Checkout modal */
  .checkout-flow-modal {
    width: 98% !important;
    max-height: calc(100dvh - 10px) !important;
    padding: 16px !important;
  }

  .checkout-grid {
    grid-template-columns: 1fr !important;
  }

  /* Trust badges strip — single column on mobile */
  .trust-badges-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  /* Footer — single column */
  .footer-top-row {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }

  /* Empty state spacing */
  .empty-state {
    padding: 40px 20px !important;
  }

  /* Toast notifications positioning on mobile */
  .toast-container {
    bottom: 20px !important;
    left: 12px !important;
    right: 12px !important;
    top: auto !important;
    width: auto !important;
  }

  /* Sold-out overlay badge on card */
  .sold-out-overlay {
    font-size: 10px !important;
    padding: 3px 6px !important;
  }

} /* END @media (max-width: 768px) */

/* ==========================================================================
   11. NARROW SCREEN TWEAKS: 430px and below
   ========================================================================== */

@media (max-width: 430px) {

  .mobile-header {
    height: 50px;
    padding: 0 12px;
  }

  .mobile-header-logo .logo-bts,
  .mobile-header-logo .logo-shop {
    font-size: 20px;
  }

  .weverse-category-bar {
    top: 50px !important;
  }

  .weverse-product-grid {
    gap: 8px 6px !important;
  }

  .wv-card-info {
    padding: 7px 8px 9px !important;
  }

  .wv-card-title {
    font-size: 11.5px !important;
  }

  .wv-price-val {
    font-size: 13px !important;
  }

}

/* ==========================================================================
   12. NARROW SCREEN TWEAKS: 390px (iPhone 15 Pro)
   ========================================================================== */

@media (max-width: 390px) {

  .mobile-header-logo .logo-bts,
  .mobile-header-logo .logo-shop {
    font-size: 19px;
  }

  .weverse-product-grid {
    gap: 7px 5px !important;
  }

}

/* ==========================================================================
   13. NARROW SCREEN TWEAKS: 375px (iPhone SE 2nd/3rd gen, iPhone 14)
   ========================================================================== */

@media (max-width: 375px) {

  .mobile-header-logo .logo-bts,
  .mobile-header-logo .logo-shop {
    font-size: 18px;
  }

  .cat-nav-item {
    padding: 10px 9px !important;
    font-size: 12px !important;
  }

  .wv-card-title {
    font-size: 11px !important;
  }

  .mobile-nav-drawer {
    width: 84vw;
    max-width: 315px;
  }

}

/* ==========================================================================
   14. NARROW SCREEN TWEAKS: 320px (iPhone SE 1st gen)
   ========================================================================== */

@media (max-width: 320px) {

  .mobile-header {
    padding: 0 10px;
  }

  .mobile-header-logo .logo-bts,
  .mobile-header-logo .logo-shop {
    font-size: 16px;
  }

  .mobile-cart-btn,
  .mobile-hamburger-btn {
    min-width: 38px;
    min-height: 38px;
  }

  .mobile-cart-btn svg,
  .mobile-hamburger-btn svg {
    width: 20px;
    height: 20px;
  }

  .cat-nav-item {
    padding: 10px 8px !important;
    font-size: 11.5px !important;
  }

  .weverse-product-grid {
    gap: 6px 4px !important;
  }

  .wv-card-title {
    font-size: 10.5px !important;
    min-height: 26px !important;
  }

  .wv-price-val {
    font-size: 12px !important;
  }

  .mobile-nav-drawer {
    width: 85vw;
    max-width: 275px;
  }

  .mobile-drawer-header,
  .mobile-drawer-body {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }

  .country-sheet-item {
    padding: 11px 14px;
    font-size: 13px;
  }

}
