/* ─────────────────────────────────────────
   MODALS — Base styles & all modal variants
   ───────────────────────────────────────── */

/* Overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}
.modal-overlay.side-right {
  align-items: stretch;
  justify-content: flex-end;
  padding: 0;
}
.modal-overlay.side-right .modal {
  width: 420px;
  max-width: 100%;
  height: 100%;
  border-radius: 0;
  border-right: none;
  transform: translateX(60px);
}
.modal-overlay.side-right.open .modal {
  transform: translateX(0);
}

/* Base modal */
.modal {
  background: var(--surface);
  border: 1px solid var(--border-md);
  border-radius: var(--r-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  transform: translateY(24px) scale(0.98);
  transition: transform 0.3s var(--ease-out);
  scrollbar-width: thin;
  scrollbar-color: var(--surface-2) transparent;
}
.modal-overlay.open .modal {
  transform: translateY(0) scale(1);
}
.modal-lg { max-width: 760px; }
.modal-xl { max-width: 980px; }

/* Modal header */
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 5;
}
.modal-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}
.modal-close {
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: none;
  transition: all 0.15s;
  flex-shrink: 0;
}
.modal-close:hover { color: var(--text); background: var(--surface-2); border-color: var(--border-md); }
.modal-close svg { width: 14px; height: 14px; }

/* Modal body */
.modal-body {
  padding: 24px 28px;
}

/* Modal footer */
.modal-footer {
  padding: 16px 28px 24px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
  background: var(--surface);
}

/* ── AUTH MODAL ── */
#modal-auth .modal { max-width: 420px; }
.auth-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg);
  border-radius: var(--r-sm);
  padding: 4px;
  margin-bottom: 28px;
}
.auth-tab {
  flex: 1;
  padding: 8px;
  text-align: center;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: none;
  background: none;
  border: none;
  transition: all 0.2s;
}
.auth-tab.active {
  background: var(--surface-2);
  color: var(--text);
}
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-divider {
  display: flex; align-items: center; gap: 12px;
  font-size: 0.75rem; color: var(--text-muted);
  margin: 4px 0;
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}
.auth-social-btn {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border-md);
  color: var(--text-dim);
  padding: 10px;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 0.875rem; font-weight: 600;
  cursor: none;
  transition: all 0.2s;
}
.auth-social-btn:hover { border-color: var(--border-hover); color: var(--green); }
.auth-social-btn svg { width: 18px; height: 18px; }
.auth-footnote {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 4px;
}
.auth-footnote a { color: var(--green); }

/* ── CART MODAL ── */
#modal-cart .modal {
  width: 420px;
  height: 100%;
  display: flex;
  flex-direction: column;
}
#modal-cart .modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
}
.cart-item {
  display: flex;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.cart-item:last-child { border-bottom: none; }
.cart-item-thumb {
  width: 64px; height: 48px;
  border-radius: var(--r-sm);
  object-fit: cover;
  background: var(--surface-2);
  flex-shrink: 0;
}
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cart-item-cat {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.cart-item-price {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text);
  font-family: var(--font-mono);
}
.cart-item-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: none;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.15s;
  flex-shrink: 0;
}
.cart-item-remove:hover { color: var(--red); }
.cart-item-remove svg { width: 14px; height: 14px; }
.cart-summary {
  padding: 16px 0 0;
}
.cart-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 0.85rem;
}
.cart-summary-row.total {
  font-size: 1rem;
  font-weight: 800;
  padding-top: 12px;
  margin-top: 8px;
  border-top: 1px solid var(--border);
}
.cart-summary-row span:last-child {
  font-family: var(--font-mono);
  font-weight: 700;
}
.cart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 16px;
  text-align: center;
}
.cart-empty-icon {
  width: 60px; height: 60px;
  background: var(--surface-2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
}
.cart-empty-icon svg { width: 28px; height: 28px; }
.cart-empty h3 { font-size: 1rem; font-weight: 700; color: var(--text); }
.cart-empty p { font-size: 0.85rem; color: var(--text-muted); }

/* ── PRODUCT QUICK VIEW MODAL ── */
#modal-product .modal-xl {
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.product-modal-gallery {
  background: var(--bg);
  border-radius: var(--r-xl) 0 0 var(--r-xl);
  overflow: hidden;
  position: relative;
}
.product-modal-gallery img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.product-modal-body {
  padding: 32px;
  overflow-y: auto;
  max-height: 90vh;
}
.product-modal-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  margin: 12px 0;
  line-height: 1.2;
}
.product-modal-price {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text);
  font-family: var(--font-mono);
  margin: 20px 0;
  letter-spacing: -0.04em;
}
.product-modal-price sub {
  font-size: 1rem;
  vertical-align: super;
  color: var(--text-dim);
}
.product-modal-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1px;
  background: var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  margin: 20px 0;
}
.product-modal-stat {
  background: var(--surface-2);
  padding: 14px;
  text-align: center;
}
.product-modal-stat-val {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text);
  font-family: var(--font-mono);
  display: block;
}
.product-modal-stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
  display: block;
}
.product-modal-desc {
  font-size: 0.875rem;
  color: var(--text-dim);
  line-height: 1.7;
  margin: 20px 0;
}
.product-modal-features {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}
.product-modal-feature {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--text-dim);
}
.feature-check {
  width: 18px; height: 18px;
  background: var(--green-glow);
  border: 1px solid rgba(74, 222, 128, 0.2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.feature-check svg { width: 10px; height: 10px; color: var(--green); }
.product-modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}
.product-modal-actions .btn { flex: 1; }

/* ── SEARCH MODAL ── */
#modal-search .modal {
  max-width: 640px;
  background: var(--bg-2);
  border-color: var(--border-md);
}
#modal-search .modal-body {
  padding: 20px;
}
.search-modal-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border-md);
  border-radius: var(--r-md);
  padding: 0 16px;
  margin-bottom: 20px;
  transition: border-color 0.2s;
}
.search-modal-bar:focus-within { border-color: rgba(74, 222, 128, 0.4); }
.search-modal-bar svg { color: var(--text-muted); flex-shrink: 0; }
.search-modal-bar input {
  flex: 1; background: none; border: none;
  outline: none; padding: 14px 0;
  font-family: var(--font-display);
  font-size: 0.95rem; color: var(--text);
}
.search-modal-bar input::placeholder { color: var(--text-muted); }
.search-results-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.search-result-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  cursor: none;
  transition: background 0.15s;
}
.search-result-item:hover { background: var(--surface); }
.search-result-thumb {
  width: 44px; height: 44px;
  border-radius: var(--r-sm);
  object-fit: cover;
  background: var(--surface-2);
  flex-shrink: 0;
}
.search-result-info { flex: 1; min-width: 0; }
.search-result-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-result-cat {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.search-result-price {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--text);
  flex-shrink: 0;
}

@media (max-width: 700px) {
  #modal-product .modal-xl {
    grid-template-columns: 1fr;
  }
  .product-modal-gallery { height: 200px; border-radius: var(--r-xl) var(--r-xl) 0 0; }
  .modal-overlay.side-right .modal { width: 100%; }
}
