/**
 * style.css
 * -----------------------------------------------------------------------
 * Storefront styling. Uses CSS custom properties for the accent color so
 * the admin panel can retheme the app instantly without a rebuild.
 * -----------------------------------------------------------------------
 */

:root {
  --accent-color: #FFB800;
  --accent-color-dark: #d99a00;
  --bg-primary: #0f0f12;
  --bg-secondary: #17171c;
  --bg-card: #1e1e24;
  --text-primary: #f5f5f7;
  --text-secondary: #9a9aa4;
  --border-color: #2a2a32;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 8px;
  --shadow-elevated: 0 8px 24px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  padding-bottom: 90px;
}

a { color: inherit; text-decoration: none; }

/* ---------- App Shell / Top Bar ---------- */
.app-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: rgba(15, 15, 18, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
}

.store-name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.install-btn {
  display: none;
  align-items: center;
  gap: 6px;
  background: var(--accent-color);
  color: #101010;
  border: none;
  font-weight: 600;
  font-size: 13px;
  padding: 9px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.install-btn.visible {
  display: inline-flex;
}

.install-btn:active {
  transform: scale(0.96);
}

.cart-btn {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
}

.cart-count {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--accent-color);
  color: #101010;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* ---------- Hero ---------- */
.hero {
  padding: 28px 20px 8px;
}

.hero h1 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
}

.hero p {
  color: var(--text-secondary);
  font-size: 14px;
}

/* ---------- Product Grid ---------- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  padding: 20px;
}

@media (min-width: 640px) {
  .product-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 960px) {
  .product-grid { grid-template-columns: repeat(4, 1fr); }
}

.product-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.product-card .image-wrap {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--bg-secondary);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.product-card .no-image {
  font-size: 34px;
  color: var(--text-secondary);
}

.product-info {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.product-name {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
}

.product-price {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent-color);
}

.add-to-cart-btn {
  margin-top: auto;
  background: var(--accent-color);
  color: #101010;
  border: none;
  font-weight: 700;
  font-size: 13px;
  padding: 9px 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform 0.12s ease;
}

.add-to-cart-btn:active {
  transform: scale(0.97);
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

/* ---------- Cart Drawer ---------- */
.cart-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.cart-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.cart-drawer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 70;
  background: var(--bg-secondary);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  max-height: 85vh;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-elevated);
}

.cart-drawer.open {
  transform: translateY(0);
}

.drawer-handle {
  width: 40px;
  height: 4px;
  background: var(--border-color);
  border-radius: 999px;
  margin: 12px auto 4px;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px 16px;
  border-bottom: 1px solid var(--border-color);
}

.drawer-header h2 {
  font-size: 17px;
  font-weight: 700;
}

.drawer-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 22px;
  cursor: pointer;
}

.cart-items {
  overflow-y: auto;
  padding: 12px 20px;
  flex: 1;
}

.cart-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
}

.cart-item .thumb {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  object-fit: cover;
  flex-shrink: 0;
}

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

.cart-item-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cart-item-price {
  font-size: 13px;
  color: var(--accent-color);
  margin-top: 2px;
}

.qty-control {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border-radius: 999px;
  padding: 4px 8px;
}

.qty-control button {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: var(--border-color);
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qty-control span {
  min-width: 18px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
}

.empty-cart {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

.drawer-footer {
  padding: 16px 20px 22px;
  border-top: 1px solid var(--border-color);
}

.subtotal-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 14px;
  font-size: 15px;
}

.subtotal-row strong {
  font-size: 17px;
  color: var(--accent-color);
}

.checkout-btn {
  width: 100%;
  background: var(--accent-color);
  color: #101010;
  border: none;
  font-weight: 700;
  font-size: 15px;
  padding: 14px 0;
  border-radius: 999px;
  cursor: pointer;
}

.checkout-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- Checkout Form ---------- */
.checkout-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 0 16px;
}

.checkout-form input, .checkout-form textarea {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
}

.checkout-form input:focus, .checkout-form textarea:focus {
  outline: 2px solid var(--accent-color);
}

.checkout-form label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  display: block;
}

.back-link {
  background: none;
  border: none;
  color: var(--accent-color);
  font-size: 13px;
  cursor: pointer;
  margin-bottom: 10px;
  text-align: left;
}

.whatsapp-btn {
  width: 100%;
  background: #25d366;
  color: #ffffff;
  border: none;
  font-weight: 700;
  font-size: 15px;
  padding: 14px 0;
  border-radius: 999px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  box-shadow: var(--shadow-elevated);
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(-6px);
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
