/* ===== GLOBAL MOBILE TAP FIX ===== */
button, .btn, a, input[type="submit"], input[type="button"] {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
/* =============================================
   RESPONSIVE FIX - FULL MOBILE & TABLET
   Appended to style.css via link tag
   ============================================= */

/* === GLOBAL OVERFLOW FIX === */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
}
* { box-sizing: border-box; }

/* === CONTAINER === */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

/* === TOP BAR - always center text on mobile === */
.top-bar {
  font-size: 12px;
  padding: 7px 0;
}
.top-bar .container > div {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  text-align: center;
}

/* === HEADER === */
.header {
  position: sticky;
  top: 0;
  z-index: 1000;
  width: 100%;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  gap: 12px;
  flex-wrap: nowrap;
}
.logo { flex-shrink: 0; }
.logo-text { font-size: 18px; }

/* === SEARCH BAR === */
.header-search {
  flex: 1;
  max-width: 460px;
  min-width: 0;
  position: relative;
}
.header-search input {
  width: 100%;
  min-width: 0;
}

/* === NAV === */
.main-nav {
  width: 100%;
}
.nav-inner {
  display: flex;
  align-items: center;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex-wrap: nowrap;
}
.nav-inner::-webkit-scrollbar { display: none; }
.nav-inner a {
  white-space: nowrap;
  flex-shrink: 0;
}

/* === PRODUCTS GRID - always 2 columns on mobile === */
.products-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

/* === CATEGORY GRID === */
.category-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
}

/* === HERO === */
.hero-slide {
  min-height: 420px;
}
.hero-title { font-size: 36px; }

/* === BLOG GRID === */
.blog-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

/* === FOOTER === */
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 32px;
}

/* === WHY US GRID === */
.why-us-grid {
  grid-template-columns: repeat(3, 1fr) !important;
}

/* =============================================
   TABLET: max-width 1024px
   ============================================= */
@media (max-width: 1024px) {
  .category-grid   { grid-template-columns: repeat(4, 1fr); gap: 12px; }
  .products-grid   { grid-template-columns: repeat(3, 1fr); gap: 16px; }
  .footer-grid     { grid-template-columns: 1fr 1fr; gap: 24px; }
  .why-us-grid     { grid-template-columns: repeat(2, 1fr) !important; }
  .blog-grid       { grid-template-columns: repeat(2, 1fr); }
  .product-detail-grid { grid-template-columns: 1fr 1fr; gap: 28px; }
}

/* =============================================
   MOBILE: max-width 768px
   ============================================= */
@media (max-width: 768px) {
  /* TOP BAR */
  .top-bar .top-bar-right { display: none !important; }
  .top-bar .container > div { justify-content: center; text-align: center; font-size: 11px; }

  /* HEADER */
  .header-search { display: none; }
  .header-inner { padding: 10px 0; gap: 8px; }
  .logo-text { font-size: 16px; }
  .logo-sub { display: none; }
  .menu-toggle { display: flex !important; }

  /* MOBILE SEARCH BAR below header */
  .mobile-search-bar {
    display: block;
    padding: 8px 16px;
    background: white;
    border-bottom: 1px solid #e5e7eb;
  }
  .mobile-search-bar input {
    width: 100%;
    padding: 10px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 50px;
    font-family: var(--font);
    font-size: 13px;
  }

  /* NAVIGATION */
  .main-nav { display: none; }
  .main-nav.open {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    width: 85vw;
    max-width: 300px;
    height: 100vh;
    background: #0f1f0f;
    z-index: 9999;
    overflow-y: auto;
    box-shadow: 4px 0 20px rgba(0,0,0,.4);
  }
  .main-nav.open .nav-inner {
    flex-direction: column;
    flex-wrap: nowrap;
    overflow-x: visible;
  }
  .main-nav.open .nav-inner a {
    padding: 14px 20px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    color: rgba(255,255,255,.85);
    font-size: 14px;
  }
  .nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 9998;
  }
  .nav-overlay.show { display: block; }

  /* HERO */
  .hero-slide   { min-height: 260px; }
  .hero-title   { font-size: 22px; line-height: 1.3; }
  .hero-subtitle { font-size: 14px; }
  .hero-content { max-width: 100%; }
  .hero-actions { gap: 8px; }
  .hero-actions .btn { padding: 10px 18px; font-size: 13px; }
  .slider-arrow { width: 34px; height: 34px; font-size: 15px; }

  /* SECTION */
  .section { padding: 28px 0; }
  .section-title { font-size: 20px; }
  .section-header { margin-bottom: 20px; }

  /* CATEGORIES */
  .category-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
  .category-card { padding: 14px 8px; }
  .category-icon { width: 50px; height: 50px; font-size: 22px; }
  .category-name { font-size: 11px; }

  /* PRODUCTS - ALWAYS 2 COLUMNS */
  .products-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px;
  }
  .product-body { padding: 10px; }
  .product-name { font-size: 12px; }
  .price-current { font-size: 14px; }
  .product-footer { padding: 0 8px 10px; gap: 5px; }
  .product-footer .btn { font-size: 11px; padding: 7px 6px; }
  .quick-add-btn { font-size: 11px; padding: 9px; }
  .badge { font-size: 9px; padding: 2px 6px; }

  /* PRODUCT DETAIL */
  .product-detail-grid { grid-template-columns: 1fr !important; gap: 20px; }
  .product-gallery { position: static !important; }
  .product-title { font-size: 20px; }
  .product-btn-row .btn { padding: 12px 16px; font-size: 14px; }

  /* CART SIDEBAR */
  .cart-sidebar { max-width: 100%; right: -100%; }
  .cart-sidebar.open { right: 0; }

  /* CHECKOUT MODAL - bottom sheet */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .checkout-modal {
    border-radius: 20px 20px 0 0;
    max-height: 92vh;
    width: 100%;
    max-width: 100%;
  }

  /* FLASH SALE */
  .countdown { gap: 8px; }
  .countdown-item { padding: 10px 12px; min-width: 54px; }
  .countdown-num { font-size: 22px; }

  /* BLOG */
  .blog-grid { grid-template-columns: 1fr !important; gap: 16px; }

  /* WHY US */
  .why-us-grid { grid-template-columns: 1fr !important; gap: 14px; }

  /* FOOTER */
  .footer-grid { grid-template-columns: 1fr !important; gap: 20px; }
  .footer { padding: 32px 0 20px; }
  .footer-bottom { flex-direction: column; align-items: center; text-align: center; gap: 10px; }

  /* TRUST BADGES */
  .trust-badges { gap: 10px; flex-wrap: wrap; }
  .trust-badge { font-size: 11px; }

  /* TOP TRUST BAR */
  .top-trust-bar > .container > div { justify-content: center; gap: 16px; }

  /* TRACKING */
  .tracking-step { gap: 10px; }

  /* CHAT WIDGET */
  .chat-window { width: calc(100vw - 32px); bottom: 70px; right: 0; }
  .chat-widget { right: 12px; bottom: 16px; }

  /* WHATSAPP FLOAT */
  .wa-float { width: 46px; height: 46px; font-size: 22px; bottom: 80px; right: 12px; }

  /* PAGINATION */
  .pagination { gap: 5px; }
  .page-btn { width: 34px; height: 34px; font-size: 12px; }

  /* PRODUCTS PAGE SIDEBAR */
  .products-sidebar-layout {
    grid-template-columns: 1fr !important;
  }
  .products-sidebar-layout aside { display: none; }
  .filter-toggle-btn { display: flex !important; }

  /* HEADINGS */
  h1 { font-size: 20px !important; }
  h2 { font-size: 18px !important; }

  /* TABLES */
  .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* =============================================
   VERY SMALL: max-width 400px
   ============================================= */
@media (max-width: 400px) {
  .products-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px;
  }
  .category-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .container { padding: 0 10px; }
  .hero-title { font-size: 18px; }
  .hero-slide { min-height: 220px; }
  .product-body { padding: 8px; }
  .product-name { font-size: 11px; }
  .price-current { font-size: 13px; }
  .product-footer .btn { font-size: 10px; padding: 6px 4px; border-radius: 6px; }
}

/* =============================================
   ADMIN PANEL RESPONSIVE
   ============================================= */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid  { grid-template-columns: 1fr; }
  .form-grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 260px; }
  .sidebar {
    position: fixed;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 1050;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 1049;
  }
  .sidebar-overlay.show { display: block; }
  .main-content { margin-left: 0 !important; }
  #sidebarToggle { display: flex !important; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 20px; }
  .topbar { padding: 0 14px; }
  .topbar-right .admin-name, .topbar-right .admin-role { display: none; }
  .page-content { padding: 14px; }
  .card-body { padding: 14px; }
  .filters-bar { gap: 6px; }
  .search-input, .filter-select { min-width: 120px; }

  /* Admin table horizontal scroll */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 600px; }

  /* Chat admin */
  .chat-wrap { grid-template-columns: 1fr !important; height: auto !important; }
  .sess-list { max-height: 200px; }
  .cmain { height: 400px; }

  /* Form grids */
  .form-grid, .form-grid-3 { grid-template-columns: 1fr !important; }
  .form-full { grid-column: 1 !important; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 12px; }
  .stat-value { font-size: 18px; }
  .stat-icon { width: 42px; height: 42px; font-size: 20px; }
  .btn-lg { padding: 10px 18px; font-size: 14px; }
}

/* =============================================
   PRODUCTS PAGE FILTER LAYOUT FIX
   ============================================= */
.products-sidebar-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 24px;
  align-items: start;
}

.filter-toggle-btn {
  display: none;
  margin-bottom: 12px;
}

@media (max-width: 768px) {
  .products-sidebar-layout {
    grid-template-columns: 1fr;
  }
  .products-sidebar-layout aside {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 85vw;
    max-width: 300px;
    height: 100vh;
    background: white;
    z-index: 9999;
    overflow-y: auto;
    padding: 20px;
    box-shadow: 4px 0 20px rgba(0,0,0,.2);
  }
  .products-sidebar-layout aside.open { display: block; }
  .filter-toggle-btn { display: flex; }
}

/* =============================================
   MISC FIXES
   ============================================= */

/* Prevent images from breaking layout */
img { max-width: 100%; height: auto; }

/* Fix select overflow */
select { max-width: 100%; }

/* Input fix */
input, textarea, select {
  max-width: 100%;
}

/* Fix admin product form grid on small screens */
@media (max-width: 900px) {
  .admin-product-form-grid {
    grid-template-columns: 1fr !important;
  }
}

/* Mobile nav close button */
.mobile-nav-close {
  display: none;
  color: white;
  background: rgba(255,255,255,.1);
  border: none;
  padding: 12px 20px;
  width: 100%;
  text-align: left;
  font-size: 16px;
  cursor: pointer;
}
.main-nav.open .mobile-nav-close { display: block; }

/* =============================================
   TRUST BAR - 2x2 grid on mobile, 4-col desktop
   ============================================= */
.trust-bar-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  align-items: center;
}
@media (max-width: 768px) {
  .trust-bar-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
}
@media (max-width: 400px) {
  .trust-bar-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .trust-bar-grid > div { font-size: 12px; }
  .trust-bar-grid span { font-size: 20px !important; }
}

/* =============================================
   CHAT WIDGET FIXES
   ============================================= */
/* Remove "লাইভ চ্যাট" text label from toggle button */
.chat-toggle-label { display: none; }

/* Chat toggle button - clean circle */
.chat-toggle-btn {
  width: 56px !important;
  height: 56px !important;
  border-radius: 50% !important;
}

/* Chat window - cleaner */
.chat-window {
  bottom: 70px !important;
}
@media (max-width: 768px) {
  .chat-window {
    width: calc(100vw - 24px) !important;
    right: 0 !important;
  }
  .chat-widget { right: 12px !important; bottom: 14px !important; }
  .wa-float { bottom: 78px !important; right: 12px !important; }
}

/* =============================================
   HERO SLIDER - show image properly as background
   ============================================= */
.hero-slide {
  background-size: cover !important;
  background-position: center center !important;
  background-repeat: no-repeat !important;
}
.hero-slide.no-image {
  background: linear-gradient(135deg, #0f1f0f 0%, #2d5a1b 100%) !important;
}

/* =============================================
   SITE SETTINGS - color preview update live
   ============================================= */

/* =============================================
   TOP BAR - PROPER RESPONSIVE
   ============================================= */
.top-bar { font-size: 12px; padding: 7px 0; }
.top-bar-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.top-bar-left { font-size: 12px; }
.top-bar-right {
  display: flex;
  gap: 16px;
  font-size: 12px;
}
.top-bar-right a { color: var(--accent, #fbbf24) !important; }

@media (max-width: 768px) {
  .top-bar-inner {
    justify-content: center;
    text-align: center;
  }
  .top-bar-right { display: none; }
  .top-bar-left { font-size: 11px; text-align: center; width: 100%; }
}

/* =============================================
   HERO SLIDER - proper background image display
   ============================================= */
.hero-slider { position: relative; overflow: hidden; }
.hero-slide {
  display: none;
  min-height: 420px;
  background-size: cover !important;
  background-position: center center !important;
  background-repeat: no-repeat !important;
  align-items: center;
  position: relative;
}
.hero-slide[style*="display:flex"],
.hero-slide[style*="display: flex"] { display: flex !important; }

@media (max-width: 768px) {
  .hero-slide { min-height: 280px; }
  .hero-title { font-size: 22px !important; }
  .hero-subtitle { font-size: 13px !important; }
  .hero-actions .btn { padding: 10px 16px !important; font-size: 13px !important; }
}
@media (max-width: 480px) {
  .hero-slide { min-height: 240px; }
  .hero-title { font-size: 18px !important; }
}

/* =============================================
   ORDERS PAGE - no horizontal overflow on page body
   ============================================= */
.orders-page-wrap { overflow-x: hidden; }
.filters-bar form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
}
@media (max-width: 768px) {
  .filters-bar form { flex-direction: column; align-items: stretch; }
  .filters-bar input,
  .filters-bar select { width: 100% !important; }
}

/* =============================================
   PRODUCT CARD MOBILE FIXES
   ============================================= */
@media (max-width: 480px) {
  .product-footer { flex-direction: column; gap: 5px; }
  .product-footer .btn { width: 100%; justify-content: center; touch-action: manipulation; }
  .product-body { padding: 8px; }
  .product-name { font-size: 12px; -webkit-line-clamp: 2; }
  .price-current { font-size: 14px; }
}

/* =============================================
   ADMIN ORDER TABLE - horizontal scroll inside card only
   ============================================= */
.admin-wrapper { overflow-x: hidden; }
.main-content { overflow-x: hidden; }
.page-content { overflow-x: hidden; }
.card { overflow: hidden; }
/* Only the table wrapper scrolls horizontally */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}
.table-wrap::-webkit-scrollbar { height: 4px; }
.table-wrap::-webkit-scrollbar-track { background: #f1f1f1; }
.table-wrap::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 2px; }

/* =============================================
   SETTINGS PAGE - color picker inline
   ============================================= */
input[type="color"] {
  -webkit-appearance: none;
  border: none;
  width: 40px;
  height: 36px;
  padding: 2px;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid var(--border, #e5e7eb);
}


/* =============================================
   CHECKOUT MODAL - MOBILE SCROLL FIX
   ============================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 1100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.modal-overlay.show { display: flex; }

.checkout-modal {
  background: white;
  border-radius: 20px;
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 8px 40px rgba(0,0,0,.2);
  position: relative;
  margin: auto;
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from { opacity:0; transform:translateY(30px) scale(0.97); }
  to   { opacity:1; transform:translateY(0)  scale(1); }
}

.modal-header {
  text-align: center;
  padding: 20px 20px 14px;
  border-bottom: 2px solid #e5e7eb;
  position: sticky;
  top: 0;
  background: white;
  z-index: 1;
}
.modal-header h3 { font-size: 17px; font-weight: 700; }
.modal-close-btn {
  position: absolute;
  top: 12px; right: 12px;
  background: #f3f4f6;
  border: none;
  border-radius: 50%;
  width: 30px; height: 30px;
  font-size: 17px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.modal-close-btn:hover { background: #ef4444; color: white; }
.modal-body { padding: 18px 20px; }

@media (max-width: 768px) {
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }
  .checkout-modal {
    border-radius: 20px 20px 0 0;
    max-height: 95vh;
    max-width: 100%;
    width: 100%;
    margin: 0;
  }
  .modal-body { padding: 14px 16px 30px; }
  .modal-header { padding: 16px 16px 12px; }
  .modal-header h3 { font-size: 15px; }
  /* Ensure confirm button visible */
  .confirm-order-btn { font-size: 15px !important; padding: 14px !important; touch-action: manipulation; }
}

@media (max-width: 400px) {
  .checkout-modal { border-radius: 16px 16px 0 0; }
  .modal-body { padding: 12px 14px 28px; }
  .shipping-option { padding: 11px 12px; }
  .shipping-option-label { font-size: 13px; }
}

/* =============================================
   CONFIRM ORDER BUTTON - always visible
   ============================================= */
.confirm-order-btn {
  background: linear-gradient(135deg, #f97316, #fb923c) !important;
  color: white !important;
  border: none !important;
  width: 100% !important;
  padding: 15px !important;
  border-radius: 10px !important;
  font-family: var(--font) !important;
  font-size: 15px !important;
  font-weight: 700 !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 10px !important;
  margin-bottom: 10px !important;
  box-shadow: 0 4px 18px rgba(249,115,22,.4) !important;
}

.order-confirm-note {
  text-align: center;
  color: #2d8a4e;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
}

/* =============================================
   CART SIDEBAR MOBILE
   ============================================= */
@media (max-width: 768px) {
  .cart-sidebar {
    max-width: 100% !important;
    width: 100% !important;
    right: -100% !important;
  }
  .cart-sidebar.open { right: 0 !important; }
  .cart-footer { position: sticky; bottom: 0; z-index: 2; }
  .cart-footer .btn { font-size: 14px !important; padding: 13px !important; touch-action: manipulation; }
}