:root {
  --brand-color: #7b2d8e;
  --brand-dark: #4a1a55;
  --brand-light: #f3e6f5;
}

body {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: #faf7fb;
  color: #2b2b2b;
}

a { text-decoration: none; }

.btn-brand {
  background-color: var(--brand-color);
  border-color: var(--brand-color);
  color: #fff;
}
.btn-brand:hover, .btn-brand:focus {
  background-color: var(--brand-dark);
  border-color: var(--brand-dark);
  color: #fff;
}
.btn-outline-brand {
  color: var(--brand-color);
  border-color: var(--brand-color);
}
.btn-outline-brand:hover {
  background-color: var(--brand-color);
  color: #fff;
}
.text-brand { color: var(--brand-color); }
.bg-brand { background-color: var(--brand-color); }
.bg-brand-light { background-color: var(--brand-light); }

.brand-logo { height: 40px; width: auto; object-fit: contain; border-radius: 6px; }
.navbar .nav-link { font-weight: 500; color: #333; }
.navbar .nav-link.active { color: var(--brand-color); }
.cart-count-badge { font-size: 0.65rem; position: relative; top: -8px; left: -4px; }
.cart-count-badge-mobile {
  position: absolute;
  top: -4px;
  right: -6px;
  left: auto;
  font-size: 0.6rem;
  min-width: 16px;
  height: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* ---------- Hero ---------- */
.hero-section {
  background: linear-gradient(135deg, var(--brand-dark), var(--brand-color));
  color: #fff;
  border-radius: 0 0 40px 40px;
  padding: 70px 0 90px;
}
.hero-section h1 { font-weight: 700; }

/* ---------- Product Cards ---------- */
.product-card {
  border: none;
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  transition: transform .2s ease, box-shadow .2s ease;
  height: 100%;
}
.product-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 10px 24px rgba(0,0,0,0.12);
}
.product-card .product-img-wrap {
  aspect-ratio: 1/1;
  overflow: hidden;
  background: var(--brand-light);
  position: relative;
}
.product-card .product-img-wrap img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform .3s;
}
.product-card:hover .product-img-wrap img { transform: scale(1.06); }
.product-badges { position: absolute; top: 10px; left: 10px; display: flex; flex-direction: column; gap: 4px; z-index: 2;}
.product-badges .badge { font-size: 0.65rem; }
.price-old { text-decoration: line-through; color: #999; font-size: .85rem; }
.price-new { color: var(--brand-color); font-weight: 700; font-size: 1.05rem; }

.section-title {
  font-weight: 700;
  position: relative;
  padding-bottom: 10px;
  margin-bottom: 1.5rem;
}
.section-title::after {
  content: '';
  position: absolute;
  left: 0; bottom: 0;
  width: 60px; height: 4px;
  background: var(--brand-color);
  border-radius: 2px;
}

/* ---------- Footer ---------- */
.footer-brand { background: var(--brand-dark); color: #eee; }
.footer-link { color: #cbb8ce; }
.footer-link:hover { color: #fff; }

/* ---------- Cards / Forms ---------- */
.card-soft { border: none; border-radius: 16px; box-shadow: 0 2px 12px rgba(0,0,0,0.06); }
.form-control:focus, .form-select:focus { border-color: var(--brand-color); box-shadow: 0 0 0 0.2rem rgba(123,45,142,0.15); }

/* ---------- Offline banner ---------- */
.offline-banner {
  background: #ffc107; color: #333; text-align: center; padding: 8px; font-size: .9rem; position: sticky; top: 0; z-index: 1100;
}

/* ---------- PWA install button ---------- */
.pwa-install-btn { position: fixed; bottom: 20px; right: 20px; z-index: 1200; }

/* ---------- Admin Layout ---------- */
.admin-sidebar {
  min-height: 100vh;
  background: var(--brand-dark);
  color: #fff;
  width: 240px;
}
.admin-sidebar .nav-link { color: #ddd; padding: 10px 18px; border-radius: 8px; margin: 2px 8px; }
.admin-sidebar .nav-link.active, .admin-sidebar .nav-link:hover { background: rgba(255,255,255,0.12); color: #fff; }
.admin-content { flex: 1; background: var(--brand-light); min-height: 100vh; }
.stat-card { border-radius: 16px; border: none; box-shadow: 0 2px 12px rgba(0,0,0,0.06); }
.stat-card .stat-icon { width: 52px; height: 52px; border-radius: 12px; display:flex; align-items:center; justify-content:center; font-size:1.4rem; }

.thumb-60 { width: 60px; height: 60px; object-fit: cover; border-radius: 8px; }
.img-preview-box { width: 90px; height: 90px; border: 2px dashed #ccc; border-radius: 10px; display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; background: #fafafa; }
.img-preview-box img { width: 100%; height: 100%; object-fit: cover; }
.img-preview-box .remove-img { position: absolute; top: 2px; right: 2px; background: #dc3545; color: #fff; border-radius: 50%; width: 20px; height: 20px; font-size: 12px; display: flex; align-items: center; justify-content: center; cursor: pointer; }

/* ---------- Star Rating ---------- */
.star-rating i { color: #ffc107; }
.rating-input i { cursor: pointer; color: #ddd; font-size: 1.4rem; }
.rating-input i.active { color: #ffc107; }

/* ---------- Responsive tweaks ---------- */
@media (max-width: 991px) {
  .admin-sidebar { position: fixed; left: -240px; top: 0; z-index: 1050; transition: left .25s ease; }
  .admin-sidebar.show { left: 0; }
}
@media (max-width: 576px) {
  .hero-section { padding: 40px 0 60px; border-radius: 0 0 24px 24px; }
  .brand-text { font-size: 1rem; }
}

.toast-container { z-index: 2000; }

/* The number field between the -/+ buttons was being squeezed to almost
   zero width because Bootstrap's input-group makes it flex-shrinkable by
   default, and the old fixed 110px on the whole group left barely any
   room for it once the two buttons took their share. Giving the input a
   guaranteed, non-shrinking width fixes that so the quantity is always
   fully visible (up to 3 digits) no matter how the group is laid out. */
.qty-box { width: auto; display: inline-flex; flex-wrap: nowrap; flex-shrink: 0; }
.qty-box input[type="number"] {
  flex: 0 0 56px;
  width: 56px;
  min-width: 56px;
  text-align: center;
}
.qty-box .btn { flex: 0 0 auto; }

/* The name/price column needs min-width:0 so it can actually shrink inside
   the flex row on narrow screens, instead of forcing everything else
   (including the qty-box) to be squeezed until it wraps. */
.cart-row .flex-grow-1 { min-width: 0; }

@media (max-width: 576px) {
  /* On phone widths there isn't room for image + name + qty box + total +
     delete all on one line. Instead of letting the qty-box get squeezed
     (which is what caused the -/number/+ to stack), wrap the row onto two
     clean lines: image+name on top, controls (qty, total, delete) below.
     The ::after acts as an invisible full-width "line break" so the two
     groups land on separate lines instead of splitting unpredictably. */
  .cart-row { flex-wrap: wrap; row-gap: 10px; }
  .cart-row::after { content: ""; flex-basis: 100%; width: 0; order: 2; }
  .cart-row .qty-box { order: 3; }
  .cart-row .line-total { order: 4; margin-left: auto; min-width: 0 !important; }
  .cart-row .btn-remove-cart { order: 5; }
}

.checkout-summary { position: sticky; top: 90px; }

.gcash-card { border: 2px dashed var(--brand-color); border-radius: 16px; background: var(--brand-light); }

.empty-state { padding: 60px 20px; text-align: center; color: #888; }
.empty-state i { font-size: 3rem; margin-bottom: 1rem; opacity: .5; }

/* Long forms (e.g. Add/Edit Product) can be taller than the viewport.
   Bootstrap's own "modal-dialog-scrollable" class relies on 100vh math
   that behaves inconsistently across browsers/zoom levels/DevTools, so
   instead we force an explicit, guaranteed scroll area here: the header
   and footer always stay pinned in place, and only the body between them
   scrolls, no matter how tall the browser window is.
   Only applies at md and up — below that the modal is full-screen
   (modal-fullscreen-md-down in the markup) and already fills the
   viewport correctly on its own, so this must not interfere there. */
@media (min-width: 768px) {
  .modal-dialog-scrollable .modal-content {
    max-height: 80vh;
  }
  .modal-dialog-scrollable .modal-body {
    overflow-y: auto;
    max-height: calc(80vh - 65px); /* ~header height only, since the Save/Cancel buttons now live inside the scrollable body itself, not a separate footer */
  }
}
.modal-dialog-scrollable .modal-body {
  background:
    linear-gradient(#fff 30%, rgba(255,255,255,0)),
    linear-gradient(rgba(255,255,255,0), #fff 70%) 0 100%,
    radial-gradient(farthest-side at 50% 0, rgba(0,0,0,.12), rgba(0,0,0,0)),
    radial-gradient(farthest-side at 50% 100%, rgba(0,0,0,.12), rgba(0,0,0,0)) 0 100%;
  background-repeat: no-repeat;
  background-size: 100% 40px, 100% 40px, 100% 14px, 100% 14px;
  background-attachment: local, local, scroll, scroll;
  padding: 1rem 1.25rem;
}
.modal-dialog-scrollable .modal-footer {
  box-shadow: 0 -2px 6px rgba(0,0,0,.06);
  padding: .85rem 1.25rem;
}
