/* ═══════════════════════════════════════════════════════════
   MK Pokkisham — Complete Mobile App-Shell CSS
   Full Android/iOS app experience on mobile devices
   ═══════════════════════════════════════════════════════════ */

/* ── Base mobile variables ── */
:root {
  --tab-bar-h: 62px;
  --app-radius: 16px;
  --app-gold: #c9a227;
}

/* ════════════════════════════════════════════════════
   MOBILE APP SHELL — activates on ≤768px
   ════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* App body — room for bottom tab bar */
  html {
    overflow-x: hidden;  /* prevent any element wider than viewport causing scroll */
    max-width: 100vw;
  }
  body {
    padding-bottom: calc(var(--tab-bar-h) + env(safe-area-inset-bottom, 0px));
    background: #f0ebe0;
    overscroll-behavior-x: none;
    overflow-x: hidden;
    max-width: 100vw;
    width: 100%;
  }

  /* ── App-style header (compact, sticky) ── */
  .site-header {
    position: sticky; top: 0; z-index: 500;
    padding-top: env(safe-area-inset-top, 0);
  }
  .header-inner {
    height: 54px;
    padding: 0 14px;
  }
  .logo { font-size: 1.15rem; }
  .logo-icon { font-size: 1.4rem; }
  .logo span { display: none; } /* hide tagline on mobile */

  /* ── Mobile Sidebar Nav ── */
  .site-nav {
    display: block !important;
    position: fixed !important;
    top: 0; left: 0; bottom: 0; width: 300px;
    transform: translateX(-100%);
    background: var(--navy);
    z-index: 2001;
    transition: transform .35s cubic-bezier(.4,0,.2,1);
    box-shadow: 4px 0 40px rgba(0,0,0,.3);
    padding-top: calc(env(safe-area-inset-top, 0) + 20px);
    border-right: 1px solid rgba(201,162,39,.2);
  }
  .site-nav.open { transform: translateX(0) !important; }
  .nav-inner {
    flex-direction: column;
    align-items: flex-start;
    padding: 20px;
    gap: 8px;
    overflow-y: auto;
    height: 100%;
  }
  .nav-link {
    width: 100%;
    font-size: 1.05rem;
    padding: 12px 16px;
    border-radius: var(--app-radius);
    margin-bottom: 4px;
  }
  
  /* Add overlay for nav */
  .nav-overlay {
    display: none;
    position: fixed; inset: 0; background: rgba(0,0,0,.6);
    z-index: 2000; transition: var(--transition);
  }
  .nav-overlay.open { display: block; }

  /* ── Hide desktop search bar — replaced by inline search ── */
  .header-search { display: none !important; }

  /* ── Header actions compact ── */
  .header-actions { gap: 2px; }
  .hbtn { padding: 6px 8px; }
  .hbtn .badge { width: 14px; height: 14px; font-size: .6rem; }
  .d-none-sm { display: none !important; }
  
  /* Hide redundant header buttons (already in bottom tab bar) */
  .header-actions .hbtn[title="Wishlist"],
  .header-actions .hbtn[title="My Account"],
  .header-actions a.hbtn[href*="login.php"],
  .header-actions #cart-btn {
    display: none !important;
  }

  /* ── Mobile search bar (full-width below header) ── */
  .mobile-search-bar {
    background: var(--navy-mid);
    padding: 8px 12px 10px;
    display: block;
  }
  .mobile-search-form {
    display: flex; align-items: center;
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(201,162,39,.3);
    border-radius: 50px; overflow: hidden;
  }
  .mobile-search-form input {
    flex: 1; background: none; border: none; outline: none;
    color: #fff; padding: 9px 14px; font-size: .9rem;
  }
  .mobile-search-form input::placeholder { color: rgba(255,255,255,.45); }
  .mobile-search-form button {
    background: var(--gold); border: none; padding: 9px 14px;
    color: var(--navy); font-size: .95rem; cursor: pointer;
  }

  /* ── Bottom Tab Bar ── */
  .mobile-tab-bar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    width: 100%;                             /* never wider than viewport */
    box-sizing: border-box;
    height: var(--tab-bar-h);
    background: var(--navy);
    border-top: 1.5px solid rgba(201,162,39,.35);
    display: grid;
    grid-template-columns: repeat(5, 1fr);   /* exactly 5 equal columns */
    align-items: stretch;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    z-index: 900;
    box-shadow: 0 -4px 20px rgba(0,0,0,.3);
    overflow: hidden;                         /* clip anything that bleeds out */
  }
  .mtb-item {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 3px; padding: 6px 2px;              /* tighter padding so 5 items fit */
    color: rgba(255,255,255,.45); font-size: .58rem;
    font-weight: 600; text-decoration: none;
    transition: color .15s; position: relative;
    min-width: 0;                             /* allow shrinking below min-content */
    overflow: hidden;
    background: none; border: none; cursor: pointer; /* reset for <button> */
  }
  .mtb-item.active { color: var(--app-gold); }
  .mtb-item .mtb-icon { font-size: 1.25rem; line-height: 1; flex-shrink: 0; }
  .mtb-badge {
    position: absolute; top: 2px; right: calc(50% - 18px);
    background: #ef4444; color: #fff; font-size: .56rem;
    font-weight: 700; min-width: 14px; height: 14px;
    border-radius: 7px; display: flex; align-items: center;
    justify-content: center; padding: 0 3px;
    pointer-events: none;
  }
  /* FAB cart button */
  .mtb-fab-wrap { position: relative; }
  .mtb-fab {
    width: 46px; height: 46px; border-radius: 50%;
    background: linear-gradient(135deg, var(--app-gold), #e8c45a);
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 14px rgba(201,162,39,.5);
    margin-top: -12px; font-size: 1.4rem;
    flex-shrink: 0;
  }
  .mtb-fab .mtb-label { display: none; }
  .mtb-label {
    font-size: .56rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    text-align: center;
  }

  /* ── App-style product cards (2-col grid) ── */
  .products-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
    padding: 0 10px;
  }
  .product-card {
    border-radius: var(--app-radius) !important;
    box-shadow: 0 2px 12px rgba(0,0,0,.08) !important;
    border: none !important;
    overflow: hidden;
  }
  .product-img-wrap { border-radius: 0; }
  .product-img-wrap img { height: 140px !important; }
  .product-placeholder { height: 140px !important; font-size: 2.5rem !important; }
  .product-body { padding: 10px 11px 12px !important; }
  .product-name { font-size: .88rem !important; }
  .price-current { font-size: 1rem !important; }
  .product-meta { font-size: .72rem !important; }

  /* ── Category chips (horizontal scroll) ── */
  .categories-grid {
    display: flex !important;
    flex-direction: row !important;
    overflow-x: auto !important;
    gap: 10px !important;
    padding: 4px 12px 12px !important;
    grid-template-columns: unset !important;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }
  .categories-grid::-webkit-scrollbar { display: none; }
  .cat-card {
    flex: 0 0 90px !important;
    scroll-snap-align: start;
    border-radius: 14px !important;
    padding: 14px 8px !important;
    text-align: center;
    border: none !important;
    box-shadow: 0 2px 8px rgba(0,0,0,.07) !important;
  }
  .cat-icon { font-size: 1.8rem !important; margin-bottom: 6px !important; }
  .cat-name { font-size: .72rem !important; font-weight: 600; }
  .cat-count, .cat-desc { display: none !important; }

  /* ── Section headings — app style ── */
  .section-header {
    text-align: left !important;
    margin-bottom: 14px !important;
    padding: 0 12px;
  }
  .section-header h2 { font-size: 1.2rem !important; }
  .section-header p { font-size: .82rem !important; }
  .section-header .gold-line { margin: 6px 0 0 !important; }

  .section { padding: 24px 0 !important; }
  .container {
    padding: 0 10px !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
  }

  /* ── Hero — full-bleed app banner ── */
  .hero {
    padding: 40px 16px 36px !important;
    min-height: 280px !important;
    border-radius: 0 0 24px 24px;
    margin-bottom: 6px;
  }
  .hero h1 { font-size: 1.8rem !important; }
  .hero p  { font-size: .9rem !important; }
  .hero-badge { font-size: .75rem !important; padding: 4px 12px !important; }
  .hero-btns { gap: 8px !important; }
  .btn { padding: 10px 20px !important; font-size: .88rem !important; }
  .btn-sm { padding: 7px 14px !important; font-size: .8rem !important; }

  /* ── Cart sidebar — full-screen drawer ── */
  .cart-sidebar {
    width: 100% !important;
    right: -100% !important;
    border-radius: 20px 20px 0 0 !important;
    top: auto !important; bottom: 0 !important;
    height: 90vh !important;
    max-height: 90vh !important;
  }
  .cart-sidebar.open { right: 0 !important; }

  /* ── Footer — compact on mobile ── */
  .site-footer { display: none !important; }  /* replaced by tab bar */
  .toast-wrap { bottom: calc(var(--tab-bar-h) + 12px) !important; right: 12px !important; }

  /* ── PWA banner ── */
  .pwa-banner { display: none !important; }

  /* ── Forms mobile ── */
  .form-row { grid-template-columns: 1fr !important; gap: 12px !important; }
  .form-control { font-size: 16px !important; } /* prevent iOS zoom */

  /* ── Breadcrumb ── */
  .breadcrumb { padding: 10px 12px !important; font-size: .78rem !important; }

  /* ── Utility ── */
  .d-none-mobile { display: none !important; }
  .mobile-px { padding-left: 12px !important; padding-right: 12px !important; }

  /* ── Shop Responsive Layout ── */
  .shop-layout {
    display: block !important;
  }
  .shop-sidebar {
    display: none;
    margin-bottom: 20px;
  }
  .shop-sidebar.open {
    display: block !important;
  }
  .shop-sidebar .card {
    position: static !important;
  }
  #toggle-filters-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--navy) !important;
    color: var(--app-gold) !important;
    border: 1px solid rgba(201,162,39,.3) !important;
    border-radius: var(--app-radius) !important;
    font-weight: 600;
    width: 100%;
    padding: 12px !important;
    margin-bottom: 14px;
  }
  .filter-bar {
    padding: 12px 14px !important;
    margin-bottom: 14px !important;
    font-size: .85rem !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
  }
  .filter-bar > div {
    font-size: .8rem !important;
  }
  .filter-group {
    gap: 4px !important;
  }
  .filter-select {
    padding: 5px 8px !important;
    font-size: .8rem !important;
  }
}

/* Show tab bar only on mobile */
.mobile-tab-bar { display: none; }
.mobile-search-bar { display: none; }
@media (max-width: 768px) {
  .mobile-tab-bar { display: grid; }
  .mobile-search-bar { display: block; }
}

/* ── Smooth transitions for app feel ── */
@media (max-width: 768px) {
  a, button { -webkit-tap-highlight-color: transparent; }
  * { -webkit-font-smoothing: antialiased; }
}

/* ── Extra-small phones (≤380px) ── */
@media (max-width: 380px) {
  .mtb-item { font-size: .52rem; padding: 6px 1px; }
  .mtb-item .mtb-icon { font-size: 1.15rem; }
  .mtb-fab { width: 42px; height: 42px; font-size: 1.25rem; margin-top: -10px; }
  .products-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 8px !important; padding: 0 8px; }
}
