/* ============================================================
   RESPONSIVE.CSS — Complete Mobile/Tablet Responsiveness
   Covers: index, categories, about, contact, product-detail,
           cart, checkout, products, admin, user pages
   Breakpoints:
     lg  : max-width 1024px
     md  : max-width 768px
     sm  : max-width 640px
     xs  : max-width 480px
   ============================================================ */

/* ── Global overflow guard ── */
html, body {
  overflow-x: hidden;
  max-width: 100%;
}
img { max-width: 100%; height: auto; }
table { max-width: 100%; }

/* ── Mobile Menu Toggle Button (hamburger) ── */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 10px;
  color: var(--secondary, #0F172A);
  font-size: 1.4rem;
  transition: background 0.2s;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
}
.mobile-menu-btn:hover {
  background: var(--primary-light, #DBEAFE);
  color: var(--primary, #2563EB);
}

/* ── Mobile Nav Drawer ── */
.mobile-nav-drawer {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
}
.mobile-nav-drawer.open { display: block; }
.mobile-nav-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.mobile-nav-panel {
  position: absolute;
  top: 0; right: 0;
  width: min(320px, 85vw);
  height: 100%;
  background: #fff;
  box-shadow: -8px 0 40px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.mobile-nav-drawer.open .mobile-nav-panel { transform: translateX(0); }
.mobile-nav-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid #E2E8F0;
}
.mobile-nav-head .logo-text strong { font-size: 1.1rem; }
.mobile-nav-close {
  background: #F8FAFC;
  border: none;
  border-radius: 50%;
  width: 40px; height: 40px;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--text-muted, #64748B);
  transition: 0.2s;
  display: flex; align-items: center; justify-content: center;
}
.mobile-nav-close:hover { background: #FEE2E2; color: #EF4444; }
.mobile-nav-links { list-style: none; padding: 16px 0; flex: 1; }
.mobile-nav-links li a {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 24px;
  font-size: 1rem; font-weight: 600;
  color: var(--text-main, #334155);
  border-bottom: 1px solid #F1F5F9;
  transition: 0.2s;
}
.mobile-nav-links li a:hover,
.mobile-nav-links li a.active {
  background: var(--primary-light, #DBEAFE);
  color: var(--primary, #2563EB);
}
.mobile-nav-links li a i { width: 20px; text-align: center; color: var(--primary, #2563EB); }
.mobile-nav-footer { padding: 20px 24px; border-top: 1px solid #E2E8F0; }
.mobile-cart-btn {
  width: 100%;
  background: var(--secondary, #0F172A);
  color: #fff; border: none; border-radius: 14px;
  padding: 14px; font-weight: 700; font-size: 1rem;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 10px;
  transition: 0.3s;
}
.mobile-cart-btn:hover { background: var(--primary, #2563EB); }

/* ============================================================
   ADMIN MOBILE TOGGLE
   ============================================================ */
.admin-mobile-toggle {
  display: none;
  background: var(--primary-light, #DBEAFE);
  color: var(--primary-dark, #1D4ED8);
  border: none; border-radius: 10px;
  padding: 8px 14px; font-size: 1.1rem;
  cursor: pointer; align-items: center; gap: 8px;
  font-weight: 600; transition: 0.2s;
}
.admin-mobile-toggle:hover { background: var(--primary, #2563EB); color: #fff; }
.admin-sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 499;
}
.admin-sidebar-overlay.open { display: block; }

/* ============================================================
   LARGE TABLET / SMALL LAPTOP  (≤ 1024px)
   ============================================================ */
@media (max-width: 1024px) {
  .site-header { margin: 0 12px; top: 10px; }
  .header-inner { padding: 0 20px; height: 72px; }
  .nav-links { gap: 1.5rem; margin-right: 1.5rem; }
  .nav-links a { font-size: 0.9rem; }
  .about-inner { gap: 3rem; }

  /* Admin */
  .admin-sidebar { width: 240px; }
  .admin-content { margin-left: 240px !important; padding: 28px; }

  /* Products page sidebar */
  .products-grid { grid-template-columns: 200px 1fr; }
}

/* ============================================================
   TABLET  (≤ 768px)
   ============================================================ */
@media (max-width: 768px) {

  /* ── RX Bar ── */
  .rx-bar {
    gap: 0.8rem; font-size: 0.7rem; padding: 8px 12px;
  }
  .rx-bar span:nth-child(n+4) { display: none; }

  /* ── Header ── */
  .site-header { margin: 0 8px; top: 6px; }
  .header-inner { padding: 0 16px; height: 64px; border-radius: 16px; }
  .logo-text strong { font-size: 1.1rem; }
  .logo-text small { font-size: 0.65rem; }
  .logo-wrap img { height: 42px; width: 42px; }
  .nav-links { display: none; }
  .btn-cart { display: none; }
  .mobile-menu-btn { display: flex; }

  /* ── Hero (index) ── */
  .hero {
    min-height: 60vh; margin-top: 12px;
    padding: 60px 16px 80px;
  }
  .hero h1 { font-size: clamp(1.8rem, 7vw, 2.8rem); margin-bottom: 16px; }
  .hero p { font-size: clamp(0.95rem, 3vw, 1.15rem); margin-bottom: 24px; }
  .hero-badges { gap: 10px; margin-bottom: 28px; }
  .hero-badge { padding: 8px 16px; font-size: 0.85rem; }
  .hero-cta { padding: 14px 28px; font-size: 1rem; }

  /* ── Trust Strip ── */
  .trust-strip {
    grid-template-columns: 1fr 1fr !important;
    margin: -30px 12px 48px !important;
    gap: 12px !important; padding: 8px !important;
  }
  .trust-item { padding: 16px; gap: 12px; }
  .trust-item:not(:last-child)::after { display: none; }
  .trust-icon { width: 44px; height: 44px; font-size: 1.1rem; border-radius: 10px; flex-shrink: 0; }
  .trust-text p { font-size: 0.9rem; }
  .trust-text small { font-size: 0.75rem; }

  /* ── Sections ── */
  .section { padding: 60px 16px; }
  .section-head { margin-bottom: 2.5rem; }
  .section-head h2 { font-size: clamp(1.6rem, 5vw, 2.2rem); }
  .section-head p { font-size: 1rem; }

  /* ── Search ── */
  .search-wrapper { margin-bottom: 2rem; }
  .search-wrapper input { padding: 14px 20px 14px 48px; font-size: 0.95rem; }
  .search-wrapper button { padding: 0 20px; font-size: 0.9rem; }

  /* ── Category Tabs (index) ── */
  .cat-tabs {
    gap: 0.6rem; margin-bottom: 2.5rem;
    justify-content: flex-start;
    overflow-x: auto; flex-wrap: nowrap;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .cat-tabs::-webkit-scrollbar { display: none; }
  .cat-tab { padding: 10px 18px; font-size: 0.85rem; white-space: nowrap; flex-shrink: 0; }

  /* ── Product Grid (index) ── */
  .product-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 16px !important;
  }
  .product-body { padding: 16px; }
  .product-name { font-size: 0.95rem; }
  .price-main { font-size: 1.2rem; }
  .btn-add { padding: 12px; font-size: 0.9rem; }

  /* ── About Section (index) ── */
  .about-inner {
    grid-template-columns: 1fr !important;
    gap: 2rem !important;
  }
  .about-img-wrap { order: -1; max-width: 320px; }
  .about-content h2 { font-size: clamp(1.6rem, 5vw, 2.2rem); }
  .about-stats { gap: 1.5rem; flex-wrap: wrap; }
  .stat-item strong { font-size: 2rem; }

  /* ── Contact section (index) ── */
  #contact .section-inner > div {
    flex-direction: column; align-items: center; gap: 1rem;
  }
  #contact .section-inner > div > div { width: 100%; max-width: 320px; }

  /* ── Footer ── */
  .site-footer { padding: 40px 16px 20px !important; }
  .site-footer > div > div:first-child {
    grid-template-columns: 1fr 1fr !important;
    gap: 24px !important;
  }

  /* ── Cart Panel ── */
  .cart-panel { width: 100vw; }

  /* ── Checkout ── */
  .checkout-wrap { margin: 30px auto; padding: 0 12px; }
  .checkout-form-box, .order-summary-box { padding: 20px; border-radius: 16px; }
  .checkout-grid { grid-template-columns: 1fr !important; gap: 2rem !important; }
  .form-row { grid-template-columns: 1fr !important; gap: 1rem !important; }

  /* ── Admin ── */
  .admin-sidebar {
    position: fixed !important;
    left: -280px !important;
    width: 280px !important;
    transition: left 0.3s ease !important;
    z-index: 500 !important;
  }
  .admin-sidebar.open { left: 0 !important; }
  .admin-content { margin-left: 0 !important; padding: 20px 16px !important; }
  .admin-topbar { flex-wrap: wrap; gap: 12px; margin-bottom: 24px; }
  .admin-topbar h1 { font-size: 1.4rem; }
  .admin-mobile-toggle { display: flex !important; }
  .stat-cards { grid-template-columns: repeat(2, 1fr); gap: 16px; }
  .stat-card { padding: 16px; gap: 12px; }
  .stat-val { font-size: 1.4rem; }
  .admin-card { padding: 20px; border-radius: 16px; }

  /* ── Data Tables ── */
  .data-table-wrap, .overflow-x-auto, .table-card,
  [style*="overflow-x:auto"], [style*="overflow-x: auto"] {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  .data-table { min-width: 600px; }
  .data-table th, .data-table td { padding: 12px; font-size: 0.85rem; }

  /* ── User pages ── */
  .user-layout { flex-direction: column !important; }
  .user-sidebar { width: 100% !important; position: static !important; height: auto !important; }

  /* ── CATEGORIES PAGE ── */
  .page-hero { padding: 70px 16px 50px !important; margin-top: 12px !important; }
  .page-hero h1 { font-size: clamp(1.8rem, 7vw, 2.8rem) !important; }
  .page-hero p { font-size: clamp(0.95rem, 3vw, 1.1rem) !important; }
  .hero-stats { gap: 20px !important; }
  .hero-stat-number { font-size: 2rem !important; }

  /* Categories grid — 2 equal columns */
  .categories-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 16px !important;
  }
  /* Equal-height cards */
  .category-card {
    max-width: none !important;
    margin: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
  }
  .category-image { height: 160px !important; }
  .category-image i { font-size: 3.5rem !important; }
  .category-content {
    padding: 16px !important;
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
  }
  .category-name { font-size: 1.1rem !important; margin-bottom: 8px !important; }
  .category-description { font-size: 0.85rem !important; margin-bottom: 12px !important; }
  .category-meta { padding-top: 12px !important; margin-top: auto !important; }
  .view-btn { padding: 8px 14px !important; font-size: 0.8rem !important; }
  .category-badge { padding: 5px 10px !important; font-size: 0.75rem !important; }

  /* Categories section padding */
  .categories-section { padding: 48px 16px !important; }
  .section-header { margin-bottom: 32px !important; }
  .section-title { font-size: clamp(1.6rem, 5vw, 2.2rem) !important; }
  .section-description { font-size: 0.95rem !important; }

  /* CTA section */
  .cta-section { padding: 48px 16px !important; }
  .cta-content h2 { font-size: clamp(1.6rem, 5vw, 2.2rem) !important; }
  .cta-content p { font-size: 1rem !important; }
  .cta-buttons { gap: 12px !important; }
  .cta-btn { padding: 12px 20px !important; font-size: 0.9rem !important; }

  /* ── ABOUT PAGE ── */
  .about-grid { grid-template-columns: 1fr !important; gap: 32px !important; }
  .about-image { max-width: 320px; margin: 0 auto; }
  .about-content h2 { font-size: clamp(1.6rem, 5vw, 2.2rem) !important; }
  .stats-row { grid-template-columns: repeat(3, 1fr) !important; gap: 12px !important; }
  .stat-box { padding: 20px 12px !important; }
  .stat-box .number { font-size: 2rem !important; }
  .values-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 16px !important; }
  .value-card { padding: 24px 16px !important; }
  .doctor-card { grid-template-columns: 1fr !important; }
  .doctor-info { padding: 24px !important; }
  .doctor-info h3 { font-size: 1.5rem !important; }
  .about-section { padding: 48px 16px !important; }
  .team-section { padding: 48px 16px !important; }

  /* ── CONTACT PAGE ── */
  .contact-hero { padding: 60px 16px 32px !important; margin-top: 12px !important; }
  .contact-hero h1 { font-size: clamp(1.8rem, 7vw, 2.8rem) !important; }
  .contact-wrapper {
    grid-template-columns: 1fr !important;
    gap: 24px !important;
    margin: 24px auto 48px !important;
    padding: 0 16px !important;
  }
  .contact-info-box { padding: 24px !important; }
  .contact-form-box { padding: 24px !important; }

  /* ── PRODUCT DETAIL PAGE ── */
  .product-detail-wrapper { margin: 24px auto 40px !important; padding: 0 12px !important; }
  .product-detail-grid {
    grid-template-columns: 1fr !important;
    gap: 24px !important;
    padding: 20px !important;
  }
  .product-info h1 { font-size: 1.6rem !important; }
  .price-main-lg { font-size: 1.8rem !important; }
  .action-block { flex-direction: column !important; align-items: stretch !important; }
  .btn-add-lg { height: 48px !important; font-size: 1rem !important; }
  .related-section { margin-top: 48px !important; }
  .related-section h3 { font-size: 1.5rem !important; }

  /* ── CART PAGE ── */
  .cart-grid { grid-template-columns: 1fr !important; gap: 2rem !important; }
  .cart-summary { position: relative !important; top: 0 !important; }
  .cart-item { grid-template-columns: 80px 1fr !important; gap: 1rem !important; }
  .cart-item-image { width: 80px !important; height: 80px !important; }
  .cart-item-actions {
    grid-column: 1 / -1 !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    margin-top: 0.75rem !important;
  }
  .cart-container { padding: 0 16px !important; }
  .page-title { font-size: 1.8rem !important; }

  /* ── PRODUCTS PAGE ── */
  .products-grid { grid-template-columns: 1fr !important; gap: 1.5rem !important; }
  .filters-sidebar { position: relative !important; top: 0 !important; }
  .products-list { grid-template-columns: repeat(2, 1fr) !important; gap: 1rem !important; }
  .products-container { padding: 0 16px !important; }

  /* ── INCLUDES/HEADER.PHP nav ── */
  #desktopNav { display: none !important; }
  .md\:hidden { display: block !important; }
  .md\:hidden.fixed.bottom-4.right-4 {
    bottom: auto !important; top: 12px !important;
    right: 12px !important; z-index: 9998 !important;
  }
  #mobileMenu { z-index: 9997; }
}

/* ============================================================
   PHONE  (≤ 640px)
   ============================================================ */
@media (max-width: 640px) {

  /* ── RX Bar ── */
  .rx-bar { gap: 0.6rem; font-size: 0.68rem; }
  .rx-bar span:nth-child(n+3) { display: none; }

  /* ── Header ── */
  .header-inner { height: 58px; padding: 0 12px; border-radius: 14px; }
  .logo-wrap { gap: 10px; }
  .logo-wrap img { height: 36px; width: 36px; }
  .logo-text strong { font-size: 1rem; }

  /* ── Hero ── */
  .hero { min-height: 55vh; padding: 50px 12px 70px; }
  .hero h1 { font-size: clamp(1.6rem, 8vw, 2.4rem); }
  .hero-badges { gap: 8px; }
  .hero-badge { padding: 7px 12px; font-size: 0.8rem; }

  /* ── Trust Strip ── */
  .trust-strip { grid-template-columns: 1fr !important; margin: -20px 8px 40px !important; }

  /* ── Product Grid ── */
  .product-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 12px !important; }
  .product-body { padding: 12px; }
  .product-name { font-size: 0.88rem; margin-bottom: 8px; }
  .price-main { font-size: 1.1rem; }
  .price-old { font-size: 0.85rem; }
  .btn-add { padding: 10px; font-size: 0.85rem; gap: 6px; }
  .product-cat { font-size: 0.7rem; }

  /* ── About stats ── */
  .about-stats { gap: 1rem; }
  .stat-item strong { font-size: 1.8rem; }

  /* ── Footer ── */
  .site-footer > div > div:first-child { grid-template-columns: 1fr !important; }

  /* ── Admin stat cards ── */
  .stat-cards { grid-template-columns: 1fr 1fr !important; }
  .admin-content { padding: 16px 12px !important; }
  .admin-topbar h1 { font-size: 1.2rem; }

  /* ── Forms ── */
  .form-group input, .form-group textarea, .form-group select {
    padding: 12px 14px; font-size: 0.95rem;
  }

  /* ── CATEGORIES PAGE ── */
  .categories-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
  }
  .category-image { height: 130px !important; }
  .category-image i { font-size: 3rem !important; }
  .category-content { padding: 12px !important; }
  .category-name { font-size: 1rem !important; }
  .category-description { font-size: 0.8rem !important; -webkit-line-clamp: 2 !important; }
  .product-count span { font-size: 0.8rem; }

  /* ── ABOUT PAGE ── */
  .stats-row { grid-template-columns: repeat(3, 1fr) !important; gap: 8px !important; }
  .stat-box { padding: 16px 8px !important; }
  .stat-box .number { font-size: 1.6rem !important; min-height: 2.5rem !important; }
  .stat-box .label { font-size: 0.8rem !important; }
  .values-grid { grid-template-columns: 1fr !important; gap: 12px !important; }
  .value-card { padding: 20px !important; }

  /* ── PRODUCTS PAGE ── */
  .products-list { grid-template-columns: repeat(2, 1fr) !important; gap: 0.75rem !important; }
  .product-image { height: 180px !important; }
  .product-info { padding: 0.75rem !important; }
  .product-title { font-size: 0.85rem !important; }
  .product-actions { flex-direction: column !important; gap: 0.5rem !important; }
  .btn-view, .btn-add-cart, .btn-wishlist { padding: 0.5rem !important; font-size: 0.75rem !important; }
}

/* ============================================================
   SMALL PHONE  (≤ 480px)
   ============================================================ */
@media (max-width: 480px) {

  /* ── RX Bar ── */
  .rx-bar { font-size: 0.65rem; padding: 6px 10px; gap: 0.5rem; }
  .rx-bar span:nth-child(n+2) { display: none; }

  /* ── Header ── */
  .site-header { margin: 0 6px; top: 4px; }
  .header-inner { height: 54px; padding: 0 10px; border-radius: 12px; }
  .logo-text small { display: none; }

  /* ── Hero ── */
  .hero { min-height: 50vh; padding: 40px 10px 60px; margin-top: 8px; }
  .hero h1 { font-size: clamp(1.4rem, 9vw, 2rem); }
  .hero p { font-size: 0.9rem; }
  .hero-badges { display: none; }
  .hero-cta { padding: 12px 24px; font-size: 0.95rem; }

  /* ── Trust Strip ── */
  .trust-strip { margin: -16px 6px 32px !important; gap: 8px !important; padding: 6px !important; }
  .trust-item { padding: 14px; }

  /* ── Section ── */
  .section { padding: 48px 12px; }

  /* ── CATEGORIES PAGE ── */
  /* Keep 2 columns even on very small screens for better density */
  .categories-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }
  .category-image { height: 110px !important; }
  .category-image i { font-size: 2.5rem !important; }
  .category-content { padding: 10px !important; }
  .category-name { font-size: 0.9rem !important; margin-bottom: 6px !important; }
  .category-description { display: none !important; } /* hide desc on tiny screens */
  .category-meta { padding-top: 8px !important; }
  .product-count { font-size: 0.75rem !important; }
  .view-btn { padding: 6px 10px !important; font-size: 0.75rem !important; }

  /* ── Admin ── */
  .stat-cards { grid-template-columns: 1fr !important; }
  .admin-content { padding: 16px 12px !important; }
  .admin-topbar h1 { font-size: 1.2rem; }

  /* ── ABOUT PAGE ── */
  .stats-row { grid-template-columns: 1fr !important; gap: 8px !important; }
  .stat-box { padding: 16px !important; }

  /* ── PRODUCTS PAGE ── */
  .products-list { grid-template-columns: 1fr !important; }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
  .site-header, .rx-bar, .admin-sidebar, .cart-overlay,
  .mobile-nav-drawer, .admin-mobile-toggle { display: none !important; }
  .admin-content { margin-left: 0 !important; }
}
