/* =============================================
   E-Commerce PH — Main Stylesheet
   ============================================= */

/* Variables */
:root {
  --primary: #0d6efd;
  --secondary: #6c757d;
  --accent: #ffc107;
  --card-radius: 12px;
  --transition: all 0.2s ease;
}

/* Base */
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: #333;
  background: #fff;
}

a { transition: var(--transition); }

/* Product Cards */
.product-card {
  border-radius: var(--card-radius) !important;
  transition: var(--transition);
}
.product-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0,0,0,.12) !important;
}

.product-img-wrap {
  position: relative;
  border-radius: var(--card-radius) var(--card-radius) 0 0;
  overflow: hidden;
  background: #f8f9fa;
}
.product-img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  transition: transform 0.4s ease;
}
.product-card:hover .product-img {
  transform: scale(1.05);
}
.product-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.35);
  opacity: 0;
  transition: var(--transition);
}
.product-card:hover .product-overlay {
  opacity: 1;
}

/* Category Cards */
.category-card {
  border-radius: var(--card-radius) !important;
  transition: var(--transition);
}
.category-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0,0,0,.1) !important;
  border-color: var(--primary) !important;
}

/* Banner */
.banner-img {
  width: 100%;
  max-height: 500px;
  object-fit: cover;
}

/* Carousel */
.carousel-item {
  min-height: 300px;
}

/* Navbar */
.navbar {
  padding: 12px 0;
}
.navbar-brand {
  font-weight: 700;
  letter-spacing: -0.5px;
}
.nav-link {
  font-weight: 500;
  padding: 8px 14px !important;
}

/* Breadcrumb */
.breadcrumb {
  background: transparent;
  padding: 0;
  font-size: 14px;
}

/* Buttons */
.btn {
  border-radius: 8px;
  font-weight: 500;
  transition: var(--transition);
}
.btn-primary {
  background-color: var(--primary);
  border-color: var(--primary);
}
.btn-primary:hover {
  filter: brightness(0.9);
  background-color: var(--primary);
  border-color: var(--primary);
}

/* Cards */
.card {
  border-radius: var(--card-radius) !important;
}

/* Forms */
.form-control, .form-select {
  border-radius: 8px;
  border-color: #dee2e6;
  transition: var(--transition);
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13,110,253,.12);
}

/* Alerts */
.alert {
  border-radius: 10px;
  border: none;
}

/* Tables */
.table > :not(caption) > * > * {
  padding: 12px 8px;
}

/* Badges */
.badge {
  border-radius: 6px;
  font-weight: 600;
}

/* Cart */
.cart-qty {
  font-size: 15px;
}

/* Order status */
.status-pending    { color: #856404; background: #fff3cd; }
.status-confirmed  { color: #0c5460; background: #d1ecf1; }
.status-processing { color: #004085; background: #cce5ff; }
.status-shipped    { color: #155724; background: #d4edda; }
.status-delivered  { color: #155724; background: #d4edda; }
.status-cancelled  { color: #721c24; background: #f8d7da; }

/* Footer */
footer a:hover { color: #fff !important; }

/* Loading spinner overlay */
.page-loader {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

/* Sticky cart summary */
@media (min-width: 992px) {
  .sticky-top { top: 20px; }
}

/* Responsive product grid */
@media (max-width: 576px) {
  .product-img { height: 160px; }
  .card-title { font-size: 13px !important; }
}

/* Admin overrides (for public pages only) */
.hover-light:hover { color: #fff !important; }

/* Delivery / payment option cards */
.delivery-option:hover,
.payment-option:hover {
  border-color: var(--primary) !important;
  cursor: pointer;
}

/* Price display */
.price-tag {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
}

/* Trust badges section */
.trust-icon {
  font-size: 2.5rem;
  opacity: .85;
}

/* Product description */
.product-description {
  line-height: 1.8;
  color: #555;
}
.product-description p { margin-bottom: 12px; }

/* Scrollable order items list at checkout */
.order-items-list::-webkit-scrollbar { width: 4px; }
.order-items-list::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 4px; }
.order-items-list::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }

/* Search bar */
.navbar .input-group .form-control {
  border-radius: 8px 0 0 8px;
}
.navbar .input-group .btn {
  border-radius: 0 8px 8px 0;
}

/* Thumb navigation for product gallery */
.thumb-nav:hover {
  border-color: var(--primary) !important;
  opacity: .85;
}

/* Toast customization */
#cartToast {
  min-width: 240px;
  border-radius: 12px;
}

/* Pagination */
.pagination .page-link {
  border-radius: 8px !important;
  margin: 0 2px;
  border: 1px solid #dee2e6;
  color: var(--primary);
}
.pagination .page-item.active .page-link {
  background: var(--primary);
  border-color: var(--primary);
}

/* Maintenance mode banner */
.maintenance-banner {
  background: #fff3cd;
  border-bottom: 2px solid #ffc107;
  padding: 8px;
  text-align: center;
  font-weight: 600;
  font-size: 14px;
}

/* Trust badges */
.trust-badge {
  transition: var(--transition);
  border: 1px solid transparent;
}
.trust-badge:hover {
  background: #f8f9fa;
  border-color: #dee2e6;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,.08);
}

/* ═══════════════════════════════════════════════════════
   MOBILE RESPONSIVE — Public Site
   These rules override Bootstrap defaults for small screens
   without touching the desktop layout.
═══════════════════════════════════════════════════════ */

/* ── Collapsed navbar (hamburger open) ── */
@media (max-width: 991.98px) {
  /* Give the collapsed area an explicit background so text is always readable */
  .navbar-collapse {
    background-color: var(--navbar-bg, #0d6efd);
    border-top: 1px solid rgba(255,255,255,.12);
    border-radius: 0 0 12px 12px;
    padding: 10px 8px 14px;
    margin-top: 6px;
  }

  /* Nav links inside collapsed area */
  .navbar-collapse .nav-link {
    color: var(--navbar-text, #ffffff) !important;
    padding: 10px 16px !important;
    border-radius: 8px;
    margin: 1px 4px;
    opacity: 1 !important;
  }
  .navbar-collapse .nav-link:hover,
  .navbar-collapse .nav-link:focus {
    background: rgba(255,255,255,.12) !important;
  }

  /* Dropdown menu inside collapsed navbar — show inline, not floating */
  .navbar-collapse .dropdown-menu {
    position: static !important;
    float: none !important;
    background: rgba(0,0,0,.18) !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 8px !important;
    padding: 4px 0 4px 12px !important;
    margin: 4px 8px 4px 20px !important;
  }
  .navbar-collapse .dropdown-item {
    color: var(--navbar-text, #fff) !important;
    padding: 8px 14px !important;
    border-radius: 6px !important;
    background: transparent !important;
    white-space: normal;
  }
  .navbar-collapse .dropdown-item:hover,
  .navbar-collapse .dropdown-item:focus {
    background: rgba(255,255,255,.12) !important;
    color: #fff !important;
  }
  .navbar-collapse hr.dropdown-divider {
    border-color: rgba(255,255,255,.15);
  }

  /* Search form — full width on mobile */
  .navbar-collapse form.d-flex {
    max-width: 100% !important;
    width: 100% !important;
    margin-bottom: 8px !important;
  }
  .navbar-collapse .input-group {
    width: 100%;
  }

  /* Cart button in navbar — don't get too small */
  .navbar .btn-outline-light {
    min-width: 44px;
    min-height: 38px;
  }

  /* Top bar hidden on mobile — already d-none d-md-block, but reinforce */
  .bg-dark.py-1.d-none.d-md-block { display: none !important; }
}

/* ── Product grid mobile ── */
@media (max-width: 575.98px) {
  .product-img { height: 170px !important; }
  .card-title, .fw-semibold { font-size: 13px; }

  /* Full-width checkout steps */
  .checkout-step { padding: 16px 12px; }

  /* Tighter cart table */
  .cart-qty input { width: 55px !important; }

  /* Trust badges — 2×2 grid on very small screens */
  section.py-4 .col-6 { padding: 4px; }
  .trust-badge { padding: 10px 6px; }

  /* Order summary sticky not needed on small screens */
  .sticky-top { position: relative !important; top: auto !important; }
}

/* ── Cart & Checkout mobile ── */
@media (max-width: 767.98px) {
  /* Cart table — horizontal scroll */
  .table-responsive { -webkit-overflow-scrolling: touch; }

  /* Checkout buttons stack */
  .btn-group-gate { flex-direction: column; }

  /* Coupon + delivery feedback */
  #couponFeedback, #presetNote { font-size: 13px; }
}

/* ── Footer mobile ── */
@media (max-width: 767.98px) {
  footer .row.g-4 > div { margin-bottom: 20px; }
}

/* ═══════════════════════════════════════════════════════
   MOBILE RESPONSIVE — Admin Panel
═══════════════════════════════════════════════════════ */

/* Sidebar overlay (injected by JS) */
#sidebarOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 1039;
  /* Use opacity+pointer-events so transitions work AND clicks are blocked when hidden */
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  cursor: pointer;
}
#sidebarOverlay.active {
  opacity: 1;
  pointer-events: auto;  /* overlay captures ALL clicks outside sidebar */
}

@media (max-width: 991.98px) {
  /* Admin tables — horizontal scroll with touch support */
  .table-responsive {
    -webkit-overflow-scrolling: touch;
    overflow-x: auto;
  }

  /* Admin topbar text shortening */
  #topbar h5 { font-size: 15px; }
  #topbar .d-none.d-md-block { display: none !important; }

  /* Admin content padding */
  #mainContent .p-4 { padding: 12px !important; }

  /* Stat cards stack */
  .stat-card { margin-bottom: 0; }

  /* Forms in admin — full width selects */
  .admin-form-row { flex-direction: column; }
  .admin-form-row .col-md-6,
  .admin-form-row .col-md-4 { width: 100%; }

  /* Sidebar toggle button — larger tap target */
  #sidebarToggle {
    width: 40px;
    height: 40px;
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 8px;
    border: 1px solid rgba(0,0,0,.15);
    background: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,.1);
    flex-shrink: 0;
  }
  #sidebarToggle i { font-size: 20px; color: #333; }

  /* Prevent sidebar from being behind overlay */
  #sidebar { z-index: 1040; }

  /* Push notification bar below topbar on mobile */
  .maintenance-banner { font-size: 12px; }
}

@media (max-width: 575.98px) {
  /* Admin cards — reduce padding */
  .card-body.p-4 { padding: 16px !important; }

  /* Admin forms — compact */
  .row.g-4 { --bs-gutter-x: 12px; --bs-gutter-y: 12px; }

  /* Hide non-essential table columns on very small screens */
  .table td:last-child, .table th:last-child { min-width: 80px; }
}

/* ── Print styles ── */
@media print {
  .navbar, footer, .btn, .alert { display: none !important; }
  #sidebar, #topbar { display: none !important; }
  #mainContent { margin-left: 0 !important; }
}
