/* Font override */
body,input,button,select,textarea{font-family:'Be Vietnam Pro',-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif!important}

/* ============================================================
   SHIPPERSHOP MOBILE.CSS - Mobile-First Optimization
   Target: Touch screen, 360px-430px phones
   ============================================================ */

/* ========================
   1. BASE MOBILE RESETS
   ======================== */
:root {
  --mobile-nav-h: 60px;
  --header-h: 54px;
  --primary: #7C3AED;
  --primary-dark: #D73211;
  --touch-min: 44px;
}

/* Smooth scrolling everywhere */
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

/* Better tap highlights */
a, button, [onclick] {
  -webkit-tap-highlight-color: transparent;
}

/* Remove hover on touch */
@media (hover: none) {
  a:hover, button:hover { opacity: 1 !important; }
}

/* ========================
   2. RESPONSIVE BREAKPOINTS
   ======================== */
@media (max-width: 768px) {

  /* --- HEADER --- */
  .header-top { display: none !important; } /* Ẩn hotline/email strip */

  .header-main {
    position: sticky;
    top: 0;
    z-index: 500;
    padding: 8px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
  }

  .header-content {
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
  }

  .logo {
    font-size: 18px !important;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .search-bar {
    flex: 1;
    order: 0 !important;
    max-width: none !important;
    margin: 0;
  }

  .search-bar input {
    height: 36px;
    font-size: 14px;
    padding: 0 10px;
    border-radius: 20px;
  }

  .search-bar button {
    width: 36px;
    height: 36px;
    border-radius: 0 20px 20px 0;
  }

  .header-actions {
    flex-wrap: nowrap !important;
    gap: 4px;
    flex-shrink: 0;
  }

  .header-btn span:not(.cart-badge) { display: none !important; }
  .header-btn {
    min-width: var(--touch-min);
    min-height: var(--touch-min);
    padding: 0 8px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    border-radius: 8px;
  }

  /* Cart badge bigger */
  .cart-badge {
    font-size: 10px !important;
    min-width: 18px;
    height: 18px;
    top: 4px !important;
    right: 2px !important;
  }

  /* --- DESKTOP NAV → HIDDEN --- */
  header > nav, .nav-menu { display: none !important; }

  /* --- BOTTOM MOBILE NAV (app-style) --- */
  #mobileBottomNav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--mobile-nav-h);
    background: #fff;
    border-top: 1px solid #e8e8e8;
    display: flex !important;
    align-items: center;
    z-index: 1000;
    box-shadow: 0 -2px 12px rgba(0,0,0,.1);
    padding-bottom: env(safe-area-inset-bottom);
    overflow: visible;
  }

  .mnav-item {
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
    min-width: 0;
    padding: 0 2px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    height: 100%;
    cursor: pointer;
    text-decoration: none;
    color: #999;
    font-size: 9px;
    font-weight: 600;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    transition: color .2s;
    overflow: hidden;
    white-space: nowrap;
    min-width: 0;
    padding: 0 2px;
  }

  .mnav-item i { font-size: 20px; transition: transform .15s; }
  .mnav-item.active { color: var(--primary); }
  .mnav-item.active i { transform: scale(1.1); }
  .mnav-item:active i { transform: scale(0.9); }

  /* Center FAB button */
  .mnav-fab {
    width: 52px;
    height: 52px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 22px;
    box-shadow: 0 4px 12px rgba(238,77,45,.5);
    margin-top: -24px;
    flex-shrink: 0;
  }
  .mnav-fab:active { transform: scale(0.92); }
  .mnav-fab-wrap { overflow: visible !important; }

  /* Badge on nav */
  .mnav-badge {
    position: absolute;
    top: 4px;
    right: 50%;
    transform: translateX(8px);
    background: var(--primary);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
  }

  /* Push content above bottom nav */
  body { padding-bottom: calc(var(--mobile-nav-h) + env(safe-area-inset-bottom)) !important; }
  body.no-bottom-nav { padding-bottom: 0 !important; }

  /* --- HERO → COMPACT --- */
  .hero {
    padding: 24px 16px !important;
    min-height: auto !important;
  }

  .hero h1 { font-size: 22px !important; line-height: 1.3; }
  .hero p { font-size: 14px !important; margin-top: 8px; }

  .hero > div > div { text-align: center; }
  .hero > div > div > div { justify-content: center !important; gap: 10px; flex-wrap: wrap; }

  /* --- CATEGORIES STRIP → HORIZONTAL SCROLL --- */
  .categories-strip, .category-strip, .filter-tabs {
    display: flex !important;
    flex-direction: row !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 8px;
    padding: 10px 12px;
    scroll-snap-type: x mandatory;
  }
  .categories-strip::-webkit-scrollbar { display: none; }

  .category-item, .filter-tab {
    flex-shrink: 0;
    scroll-snap-align: start;
  }

  /* --- PRODUCTS GRID --- */
  .products-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
    padding: 0 10px;
  }

  .product-card {
    border-radius: 10px;
  }

  .product-card img {
    height: 160px !important;
    object-fit: cover;
  }

  .product-info { padding: 8px 10px 10px !important; }
  .product-info h3 { font-size: 13px !important; line-height: 1.3; -webkit-line-clamp: 2; }
  .product-price { font-size: 15px !important; }
  .product-original { font-size: 11px !important; }

  /* Add to cart button on product card - bigger touch target */
  .btn-add-cart, .product-btn, .add-to-cart {
    min-height: var(--touch-min) !important;
    font-size: 13px !important;
    border-radius: 8px !important;
  }

  /* --- SECTION HEADERS --- */
  .section-header {
    padding: 0 12px;
    flex-wrap: wrap;
    gap: 6px;
  }

  .section-title { font-size: 18px !important; }

  /* --- GENERAL CONTAINER --- */
  .container { padding: 0 10px !important; }

  /* --- FLASH SALE STRIP → SCROLL --- */
  .flash-sale-grid {
    display: flex !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 10px;
    padding: 10px 12px;
  }
  .flash-sale-grid::-webkit-scrollbar { display: none; }
  .flash-sale-grid .product-card {
    min-width: 150px;
    flex-shrink: 0;
  }

  /* --- BUTTONS GLOBAL --- */
  .btn {
    min-height: var(--touch-min) !important;
    padding: 10px 20px !important;
    font-size: 14px !important;
    border-radius: 10px !important;
  }

  /* --- FORMS --- */
  input, textarea, select {
    font-size: 16px !important; /* Prevent iOS zoom */
    min-height: var(--touch-min);
  }

  /* --- MODALS → SLIDE UP FROM BOTTOM --- */
  .modal-overlay {
    padding: 0 !important;
    align-items: flex-end !important;
  }

  .modal, .modal-content {
    border-radius: 20px 20px 0 0 !important;
    max-height: 92vh;
    overflow-y: auto;
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Modal drag indicator */
  .modal-head::before, .modal::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: rgba(255,255,255,.4);
    border-radius: 2px;
    margin: 0 auto 8px;
  }

  /* --- CART PAGE --- */
  .cart-container { grid-template-columns: 1fr !important; gap: 16px; }
  .cart-summary { position: static !important; }
  .cart-item { flex-wrap: wrap; gap: 8px; }
  .cart-item img { width: 72px !important; height: 72px !important; }

  /* --- CHECKOUT / FORM PAGES --- */
  .checkout-container, .auth-container {
    padding: 16px !important;
    max-width: 100% !important;
  }

  /* --- PRODUCT DETAIL --- */
  .product-detail { flex-direction: column !important; }
  .product-detail-img { width: 100% !important; }
  .product-detail-info { padding: 16px !important; }

  /* --- FOOTER → COMPACT ON MOBILE --- */
  footer .footer-grid {
    grid-template-columns: 1fr !important;
    gap: 20px;
  }

  footer { padding: 24px 12px !important; }

  /* --- COMMUNITY / POSTS --- */
  .post-card { border-radius: 0 !important; margin-bottom: 8px; }
  .vote-col { width: 36px; }

  /* --- WALLET --- */
  .wallet-card { border-radius: 16px !important; }

  /* --- TABLES → SCROLL --- */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* --- TOAST POSITION MOBILE --- */
  .toast {
    bottom: calc(var(--mobile-nav-h) + 12px) !important;
    left: 12px !important;
    right: 12px !important;
    text-align: center;
  }

  /* --- SEARCH PAGE --- */
  .search-results { padding: 0 10px; }

  /* --- PROFILE --- */
  .profile-header { padding: 20px 12px !important; }
  .profile-container { grid-template-columns: 1fr !important; }
  .profile-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .profile-tab { flex-shrink: 0; }

  /* --- HIDE ON MOBILE --- */
  .desktop-only, .header-top, header > nav { display: none !important; }

  /* --- SHOW ON MOBILE ONLY --- */
  .mobile-only { display: block !important; }

  /* --- SWIPE INDICATOR --- */
  .swipe-hint {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #999;
    padding: 0 12px 6px;
  }

  /* --- PRODUCT IMAGE GALLERY → SWIPE --- */
  .gallery-strip {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .gallery-strip::-webkit-scrollbar { display: none; }
  .gallery-strip img { scroll-snap-align: center; }

  /* --- STICKY BUY BUTTON ON PRODUCT PAGE --- */
  .sticky-buy-bar {
    position: fixed;
    bottom: var(--mobile-nav-h);
    left: 0;
    right: 0;
    padding: 10px 12px;
    background: #fff;
    border-top: 1px solid #eee;
    z-index: 200;
    display: flex;
    gap: 8px;
    box-shadow: 0 -2px 8px rgba(0,0,0,.08);
  }
  .sticky-buy-bar .btn { flex: 1; }

  /* Grid adjustments for product pages */
  .section-actions a, .section-actions button {
    font-size: 13px;
    padding: 8px 14px;
  }

  /* Admin tables */
  .admin-table { font-size: 12px; }
  .admin-table th, .admin-table td { padding: 8px 6px; }
}

/* ========================
   3. EXTRA SMALL (< 360px)
   ======================== */
@media (max-width: 360px) {
  .products-grid { gap: 8px !important; }
  .product-card img { height: 130px !important; }
  .header-btn { min-width: 36px; padding: 0 6px !important; }
  .mnav-item { font-size: 9px; }
  .mnav-item i { font-size: 22px; }
}

/* ========================
   4. LANDSCAPE PHONE
   ======================== */
@media (max-width: 768px) and (orientation: landscape) {
  .hero { padding: 16px !important; }
  .hero h1 { font-size: 18px !important; }
  #mobileBottomNav { height: 50px; }
  body { padding-bottom: 50px !important; }
}

/* ========================
   5. TABLET (769-1024px)
   ======================== */
@media (min-width: 769px) and (max-width: 1024px) {
  .products-grid { grid-template-columns: repeat(3, 1fr) !important; }
  .container { padding: 0 16px !important; }
  #mobileBottomNav { display: none !important; }
  .mobile-only { display: none !important; }
}

/* ========================
   6. DESKTOP
   ======================== */
@media (min-width: 1025px) {
  #mobileBottomNav, #backToTop { display: none !important; }
  .mobile-only { display: none !important; }
}

/* ========================
   7. PWA / SAFE AREAS
   ======================== */
@supports (padding: max(0px)) {
  #mobileBottomNav {
    padding-bottom: max(env(safe-area-inset-bottom), 0px);
    height: calc(var(--mobile-nav-h) + env(safe-area-inset-bottom));
  }
  body { padding-bottom: calc(var(--mobile-nav-h) + env(safe-area-inset-bottom)) !important; }
}

/* ========================
   8. TOUCH INTERACTION STATES
   ======================== */
.product-card:active { transform: scale(0.97); }
.btn:active { transform: scale(0.97); }
.mnav-item:active { background: rgba(0,0,0,.04); }

/* ========================
   9. LOADING SKELETON
   ======================== */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 8px;
}

/* ========================
   10. TYPOGRAPHY MOBILE
   ======================== */
@media (max-width: 768px) {
  h1 { font-size: 22px !important; }
  h2 { font-size: 18px !important; }
  h3 { font-size: 16px !important; }
  p { font-size: 14px; line-height: 1.6; }
  body { font-size: 14px; }
}

/* FIX FORCE NÚT ĐĂNG BÀI */
@media (max-width: 768px) {
    .modal-footer {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        background: white !important;
        z-index: 99999 !important;
        padding: 15px !important;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.2) !important;
    }
    .modal-body {
        padding-bottom: 100px !important;
    }
}



/* === SMOOTH PAGE TRANSITIONS === */
body{opacity:1;transition:opacity .15s ease;}
body.page-exit{opacity:0;transition:opacity .12s ease;}
body.page-enter{animation:pageIn .2s ease forwards;}
@keyframes pageIn{from{opacity:0;transform:translateY(6px);}to{opacity:1;transform:translateY(0);}}
#mobileBottomNav{transition:none!important;transform:none!important;}
#mobileBottomNav .mnav-item{-webkit-tap-highlight-color:transparent;}


/* ============================================
   DESKTOP LAYOUT (min-width: 769px)
   Centers all pages, constrains widths
   ============================================ */
@media (min-width: 769px) {
  /* Hide ALL mobile bottom navs on desktop */
  #mobileBottomNav, .mk-bnav, .map-bnav, .mk-fab, .map-fab, .ask-fab, .map-locate,
  #backToTop, .mnav-fab-wrap, .fab-center, .fab-space { display: none !important; }

  /* Global body - centered bg */
  body { background: #e4e6eb !important; }

  /* Post detail page */
  .header { max-width: 680px; margin: 0 auto; left: 50% !important; transform: translateX(-50%); border-radius: 0 0 12px 12px; }
  .post-wrap, #cmtSection, .cmt-input { max-width: 680px; margin-left: auto; margin-right: auto; }
  .cmt-input { border-radius: 0; left: 50% !important; transform: translateX(-50%); }

  /* User page */
  .back-nav, .profile-section, .tabs, #tabContent, .cover { max-width: 680px; margin-left: auto; margin-right: auto; }

  /* Groups page */
  .page-header, .search-bar, .cats, .groups-list { max-width: 680px; margin-left: auto; margin-right: auto; }

  /* Marketplace page */
  .mk-header, .mk-cats, .mk-grid { max-width: 900px; margin-left: auto; margin-right: auto; }
  .mk-grid { grid-template-columns: repeat(3, 1fr) !important; }

  /* Messages page */
  .list-view, .chat-view { max-width: 700px; margin-left: auto; margin-right: auto; }

  /* Listing detail */
  .carousel, .price-section, .variants-section, .seller-section, .section,
  .similar-section, .reviews-section, .bottom-bar, .hd { max-width: 680px; margin-left: auto; margin-right: auto; }
  .hd { left: 50% !important; transform: translateX(-50%); }
  .bottom-bar { left: 50% !important; transform: translateX(-50%); max-width: 680px; }

  /* Profile settings page */
  .container { max-width: 680px !important; margin-left: auto !important; margin-right: auto !important; }

  /* Map - keep full width */

  /* Post cards on desktop - add shadow + round corners */
  .post-card { border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.1); margin-bottom: 12px; }

  /* Modal overlay - center properly */
  .modal-overlay, .pd-cmt-overlay, .spm-overlay, .post-sheet-overlay,
  .cmt-modal-overlay, .ask-overlay { padding: 20px; }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
  .mk-grid { grid-template-columns: repeat(2, 1fr) !important; }
}
