/* ==========================================================
   Sri Krishna Fireworks - UI Polish Layer
   Loaded AFTER style.css / animations.css to refine spacing,
   touch targets, and layout behaviour on real mobile & desktop
   viewports without disturbing the existing design tokens.
   ========================================================== */

/* ---- Global safe-area & tap target baseline ---- */
:root {
  --polish-radius: 14px;
}

* , *::before, *::after { -webkit-tap-highlight-color: transparent; }

html, body { overflow-x: hidden; }

a, button, .btn, .nav-item, .mobile-links-list a {
  -webkit-user-select: none;
}

/* Every interactive control gets a comfortable minimum touch target on touch devices */
@media (pointer: coarse) {
  .btn, button, .nav-item, .mobile-menu-toggle, .theme-toggle-btn,
  .form-control, .form-select, select, input[type="text"], input[type="tel"],
  input[type="email"], input[type="number"] {
    min-height: 44px;
  }
}

/* ---- Top utility bar: stop it wrapping badly on small phones ---- */
.top-utility-bar {
  overflow-x: auto;
  scrollbar-width: none;
}
.top-utility-bar::-webkit-scrollbar { display: none; }

@media (max-width: 768px) {
  .top-utility-bar .container-nav {
    flex-wrap: nowrap;
    gap: 0.75rem;
    justify-content: flex-start;
  }
  .utility-left, .utility-right {
    flex-shrink: 0;
    white-space: nowrap;
  }
}

@media (max-width: 480px) {
  .top-utility-bar { font-size: 0.72rem; padding: 0.4rem 0; }
  .sale-badge { display: none; } /* keep the bar from overflowing on very small phones */
}

/* ---- Header: tighten on mobile, keep logo/brand legible ---- */
@media (max-width: 991px) {
  .main-site-header .header-inner { padding-top: 0.5rem; padding-bottom: 0.5rem; }
  .brand-title { font-size: 1.05rem; }
  .brand-sub { font-size: 0.68rem; }
  .btn-cta-calculate span { display: none; } /* icon-only CTA on small screens to save space */
  .btn-cta-calculate { padding: 0.6rem 0.8rem; }
}

@media (max-width: 400px) {
  .logo-icon { display: none; }
}

/* ---- Mobile nav drawer: ensure it's above everything and scrollable ---- */
.mobile-nav-drawer {
  max-width: 82vw;
  overflow-y: auto;
  padding-bottom: 2rem;
}
.mobile-links-list a {
  padding: 0.9rem 1rem;
  display: block;
  border-radius: 10px;
}

/* ---- Container fluid breathing room on small screens ---- */
@media (max-width: 480px) {
  .container, .container-nav { padding-left: 1rem; padding-right: 1rem; }
}

/* ---- Cards & grids: fluid columns instead of fixed widths ---- */
.category-grid, .product-grid, .cracker-grid, .cards-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}
@media (max-width: 480px) {
  .category-grid, .product-grid, .cracker-grid, .cards-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }
}

/* ---- Any wide table (pricelist etc.) becomes horizontally scrollable
       inside its own box instead of breaking page layout ---- */
.table-responsive, .pricelist-table-wrap, table.pricelist-table {
  -webkit-overflow-scrolling: touch;
}
table {
  max-width: 100%;
}

/* ---- Forms: full-width, comfortably spaced fields on phones ---- */
@media (max-width: 576px) {
  .form-label { font-size: 0.85rem; }
  .form-control, .form-select, input, textarea, select {
    font-size: 1rem !important; /* prevents iOS Safari auto-zoom on focus */
  }
  .row.g-3 > *, .row.g-4 > * { margin-bottom: 0.25rem; }
}

/* ---- Buttons stack cleanly on small screens instead of overflowing ---- */
@media (max-width: 480px) {
  .btn-group-responsive, .d-flex.gap-2:not(.utility-left):not(.utility-right) {
    flex-wrap: wrap;
  }
}

/* ---- Sticky/fixed elements respect device safe areas (notches, home bar) ---- */
.main-site-header {
  padding-top: env(safe-area-inset-top, 0px);
}
.mobile-nav-drawer {
  padding-top: calc(1rem + env(safe-area-inset-top, 0px));
  padding-bottom: calc(2rem + env(safe-area-inset-bottom, 0px));
}

/* ---- Footer: keep columns readable and centered on mobile ---- */
@media (max-width: 768px) {
  footer .container, footer .container-nav {
    text-align: center;
  }
  footer .row > * { margin-bottom: 1.25rem; }
}

/* ---- Desktop refinement: cap hero/content width so ultra-wide screens
       don't stretch text into unreadable full-bleed lines ---- */
@media (min-width: 1400px) {
  .container, .container-nav { max-width: 1320px; }
}

/* ---- Images: avoid layout shift / oversized banners ---- */
.hero-banner img, .banner-slide img, .promo-banner img {
  width: 100%;
  height: auto;
  object-fit: cover;
}

/* ---- Focus visibility for accessibility & keyboard users ---- */
a:focus-visible, button:focus-visible, .btn:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--gold-primary, #f59e0b);
  outline-offset: 2px;
}

/* ---- Reduce motion for users who prefer it (fireworks canvas etc.) ---- */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* ---- Prevent horizontal scroll from oversized fixed-width elements ---- */
.fireworks-canvas, #fireworks {
  max-width: 100vw;
}

/* ---- WhatsApp / floating action buttons: keep clear of iOS home indicator ---- */
.whatsapp-float, .floating-cta, .fab-whatsapp {
  bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
  right: 1.25rem;
}

/* ==========================================================
   Storefront Specific Polish & Contrast Enforcement
   ========================================================== */

/* Category Tabs Toolbar */
.pricelist-toolbar {
  position: sticky;
  top: 72px;
  z-index: 100;
  background-color: rgba(7, 11, 20, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  padding: 0.85rem 0;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

.toolbar-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.category-tabs-wrapper {
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-top: 0.5rem;
}
.category-tabs-wrapper::-webkit-scrollbar { display: none; }

.category-tabs {
  display: flex;
  gap: 0.5rem;
  padding-bottom: 4px;
}

.tab-btn {
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-pill);
  padding: 0.45rem 1.1rem;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  color: #ffffff;
  border-color: var(--primary-accent);
  background: var(--bg-elevated);
}

.tab-btn.active {
  background: var(--primary-accent) !important;
  color: #070b14 !important;
  border-color: var(--primary-accent) !important;
  font-weight: 700;
}

/* Products Grid & Product Cards */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

@media (max-width: 600px) {
  .products-grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }
}

.product-row {
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.product-row:hover {
  border-color: rgba(245, 158, 11, 0.4);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.product-left {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  margin-bottom: 0.85rem;
}

.product-thumb {
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #000;
  position: relative;
  cursor: pointer;
}

.product-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb-zoom-icon {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.7);
  color: #fbbf24;
  font-size: 0.62rem;
  text-align: center;
  padding: 2px 0;
}

.product-info {
  flex: 1;
  min-width: 0;
}

.product-code {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--primary-accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.product-title {
  font-size: 0.98rem !important;
  font-weight: 700;
  color: var(--text-primary) !important;
  margin: 0.15rem 0 0.35rem 0;
  line-height: 1.3;
}

.product-pack {
  font-size: 0.8rem;
  color: var(--text-muted) !important;
}

.product-pricing {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}

.price-actual {
  font-size: 0.85rem;
  color: #94a3b8;
  text-decoration: line-through;
}

.price-discount {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-gold-highlight) !important;
}

.product-actions-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-color);
}

.product-qty-ctrl {
  display: inline-flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.qty-btn {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: none;
  width: 34px;
  height: 34px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.qty-btn:hover {
  background: var(--primary-accent);
  color: #070b14;
}

.qty-input {
  width: 44px !important;
  height: 34px !important;
  text-align: center;
  background: transparent !important;
  border: none !important;
  color: var(--text-primary) !important;
  font-weight: 700;
  padding: 0 !important;
}

.product-subtotal-box {
  text-align: right;
}

.product-subtotal-val {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Sticky Calculation Dock (Bottom Bar) */
.sticky-calc-dock {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1040;
  background: rgba(7, 11, 20, 0.95);
  backdrop-filter: blur(16px);
  border-top: 1px solid rgba(245, 158, 11, 0.4);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.7);
  padding: 0.85rem 0 calc(0.85rem + env(safe-area-inset-bottom, 0px));
}

.calc-dock-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.calc-metrics {
  display: flex;
  align-items: center;
  gap: clamp(0.75rem, 2vw, 2rem);
  flex-wrap: wrap;
}

.calc-metric-item {
  display: flex;
  flex-direction: column;
}

.calc-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted) !important;
  font-weight: 600;
}

.calc-value {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
  font-family: var(--font-heading);
}

.calc-value.savings {
  color: #10b981 !important;
}

.calc-value.net-amount {
  color: var(--text-gold-highlight) !important;
  font-size: 1.3rem;
}

[data-theme="light"] .sticky-calc-dock {
  background: rgba(255, 255, 255, 0.96) !important;
  border-top: 1px solid rgba(217, 119, 6, 0.4) !important;
  box-shadow: 0 -8px 25px rgba(0, 0, 0, 0.1) !important;
}

@media (max-width: 680px) {
  .calc-dock-flex {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }
  
  .calc-metrics {
    justify-content: space-between;
  }

  .calc-metric-item:nth-child(2) {
    display: none; /* Hide Total MRP on tiny screens to preserve Net & Savings */
  }

  .sticky-calc-dock .btn {
    width: 100%;
    padding: 0.85rem !important;
  }
}

/* Order Review Modal Styling */
.order-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 13, 0.85);
  backdrop-filter: blur(8px);
  z-index: 1060;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.order-modal-dialog {
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-modal);
}

.order-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-color);
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}

.order-modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-summary-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  background: var(--bg-input);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin: 1rem 0;
  font-size: 0.9rem;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

@media (max-width: 520px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}
