/* ═══════════════════════════════════════════════════════════════
   Creator Ctrl Cart Widget — creatorctrl-cart.css
   Uses --bc-* CSS variables with sensible defaults
   ═══════════════════════════════════════════════════════════════ */

/* ─── CSS Variable Defaults ──────────────────────────────────── */
:root {
  --bc-font: inherit;
  --bc-accent: #1f2937;
  --bc-accent-hover: #111827;
  --bc-accent-text: #ffffff;
  --bc-bg: #ffffff;
  --bc-bg-secondary: #f9fafb;
  --bc-text: #111827;
  --bc-text-muted: #6b7280;
  --bc-border: #e5e7eb;
  --bc-radius: 8px;
  --bc-radius-lg: 16px;
  --bc-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  --bc-z-base: 999990;
}

/* ─── Cart Trigger (Floating Button) ─────────────────────────── */
.bc-cart-trigger-wrapper {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--bc-z-base);
}

.bc-cart-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--bc-accent);
  color: var(--bc-accent-text);
  border: none;
  cursor: pointer;
  box-shadow: var(--bc-shadow);
  position: relative;
  transition: transform 0.2s, background 0.2s;
  font-family: var(--bc-font);
}

.bc-cart-trigger:hover {
  background: var(--bc-accent-hover);
  transform: scale(1.05);
}

.bc-cart-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--bc-font);
}

@keyframes bc-pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

.bc-badge-pulse {
  animation: bc-pulse 0.3s ease-in-out;
}

/* ─── Cart Panel ─────────────────────────────────────────────── */
.bc-cart-panel {
  position: fixed;
  inset: 0;
  z-index: var(--bc-z-base);
  pointer-events: none;
  font-family: var(--bc-font);
}

.bc-cart-panel--open {
  pointer-events: all;
}

.bc-cart-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity 0.3s;
}

.bc-cart-panel--open .bc-cart-overlay {
  opacity: 1;
}

.bc-cart-drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 400px;
  max-width: 100vw;
  background: var(--bc-bg);
  box-shadow: var(--bc-shadow);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.bc-cart-panel--open .bc-cart-drawer {
  transform: translateX(0);
}

.bc-cart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--bc-border);
  flex-shrink: 0;
}

.bc-cart-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--bc-text);
  margin: 0;
}

.bc-cart-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
}

.bc-cart-empty {
  text-align: center;
  padding: 48px 0;
  color: var(--bc-text-muted);
}

.bc-cart-empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

/* ─── Cart Items ─────────────────────────────────────────────── */
.bc-cart-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 0;
  border-bottom: 1px solid var(--bc-border);
}

.bc-cart-item-img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: var(--bc-radius);
  flex-shrink: 0;
}

.bc-cart-item-img--placeholder {
  background: var(--bc-bg-secondary);
  border: 1px solid var(--bc-border);
}

.bc-cart-item-info {
  flex: 1;
  min-width: 0;
}

.bc-cart-item-name {
  font-weight: 500;
  color: var(--bc-text);
  font-size: 14px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bc-cart-item-variant {
  font-size: 12px;
  color: var(--bc-text-muted);
  margin-bottom: 4px;
}

.bc-cart-item-price {
  font-size: 14px;
  font-weight: 600;
  color: var(--bc-text);
}

.bc-cart-item-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.bc-qty-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--bc-border);
  background: var(--bc-bg-secondary);
  color: var(--bc-text);
  border-radius: var(--bc-radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background 0.15s;
}

.bc-qty-btn:hover {
  background: var(--bc-border);
}

.bc-qty-value {
  min-width: 24px;
  text-align: center;
  font-size: 14px;
  color: var(--bc-text);
}

.bc-remove-btn {
  background: none;
  border: none;
  color: var(--bc-text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 4px;
  border-radius: var(--bc-radius);
  transition: color 0.15s;
  margin-left: 4px;
}

.bc-remove-btn:hover {
  color: #ef4444;
}

/* ─── Cart Footer ────────────────────────────────────────────── */
.bc-cart-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--bc-border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bc-discount-row {
  display: flex;
  gap: 8px;
}

.bc-discount-msg {
  font-size: 13px;
  padding: 4px 0;
}

.bc-discount-msg--success { color: #16a34a; }
.bc-discount-msg--error { color: #dc2626; }

.bc-cart-totals {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 0;
  border-top: 1px solid var(--bc-border);
  border-bottom: 1px solid var(--bc-border);
}

.bc-total-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: var(--bc-text-muted);
}

.bc-total-final {
  font-weight: 700;
  font-size: 16px;
  color: var(--bc-text);
  margin-top: 4px;
}

.bc-discount-value {
  color: #16a34a;
}

/* ─── Buttons ────────────────────────────────────────────────── */
.bc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--bc-radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.2s, opacity 0.2s;
  text-decoration: none;
  font-family: var(--bc-font);
  line-height: 1.4;
}

.bc-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.bc-btn-primary {
  background: var(--bc-accent);
  color: var(--bc-accent-text);
}

.bc-btn-primary:hover:not(:disabled) {
  background: var(--bc-accent-hover);
}

.bc-btn-secondary {
  background: var(--bc-bg-secondary);
  color: var(--bc-text);
  border: 1px solid var(--bc-border);
}

.bc-btn-secondary:hover:not(:disabled) {
  background: var(--bc-border);
}

.bc-btn-ghost {
  background: transparent;
  color: var(--bc-text-muted);
}

.bc-btn-ghost:hover:not(:disabled) {
  color: var(--bc-text);
  background: var(--bc-bg-secondary);
}

.bc-btn-full {
  width: 100%;
}

.bc-btn-sm {
  padding: 7px 14px;
  font-size: 13px;
}

/* ─── Checkout Overlay ───────────────────────────────────────── */
.bc-checkout-overlay {
  position: fixed;
  inset: 0;
  z-index: calc(var(--bc-z-base) + 1);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  font-family: var(--bc-font);
}

.bc-checkout-overlay--open {
  pointer-events: all;
}

.bc-checkout-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.3s;
}

.bc-checkout-overlay--open .bc-checkout-backdrop {
  opacity: 1;
}

.bc-checkout-modal {
  position: relative;
  background: var(--bc-bg);
  border-radius: var(--bc-radius-lg);
  box-shadow: var(--bc-shadow);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  transform: translateY(20px) scale(0.97);
  opacity: 0;
  transition: transform 0.3s, opacity 0.3s;
  margin: 16px;
}

.bc-checkout-overlay--open .bc-checkout-modal {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.bc-checkout-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--bc-border);
  flex-shrink: 0;
}

.bc-checkout-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--bc-text);
  margin: 0;
}

.bc-checkout-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.bc-checkout-section {
  padding: 20px 24px;
  border-bottom: 1px solid var(--bc-border);
}

.bc-checkout-section:last-child {
  border-bottom: none;
}

.bc-section-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--bc-text-muted);
  margin: 0 0 14px;
}

.bc-checkout-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--bc-border);
  flex-shrink: 0;
}

/* ─── Form Elements ──────────────────────────────────────────── */
.bc-field-group {
  margin-bottom: 12px;
}

.bc-field-row {
  display: flex;
  gap: 12px;
}

.bc-field-grow { flex: 1; }
.bc-field-sm { width: 100px; flex-shrink: 0; }

.bc-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--bc-text);
  margin-bottom: 5px;
}

.bc-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--bc-border);
  border-radius: var(--bc-radius);
  font-size: 14px;
  color: var(--bc-text);
  background: var(--bc-bg);
  font-family: var(--bc-font);
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.bc-input:focus {
  outline: none;
  border-color: var(--bc-accent);
}

.bc-input::placeholder {
  color: var(--bc-text-muted);
}

.bc-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
  cursor: pointer;
}

.bc-textarea {
  resize: vertical;
  min-height: 100px;
}

/* ─── Order Summary ──────────────────────────────────────────── */
.bc-order-item {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: var(--bc-text);
  padding: 4px 0;
}

.bc-order-totals {
  border-top: 1px solid var(--bc-border);
  margin-top: 12px;
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bc-order-total {
  font-weight: 700;
  font-size: 16px;
  color: var(--bc-text);
}

/* ─── Stripe Element ─────────────────────────────────────────── */
.bc-stripe-element {
  border: 1px solid var(--bc-border);
  border-radius: var(--bc-radius);
  padding: 10px 12px;
  background: var(--bc-bg);
}

/* ─── Close Button ───────────────────────────────────────────── */
.bc-close-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--bc-text-muted);
  font-size: 18px;
  padding: 4px 8px;
  border-radius: var(--bc-radius);
  transition: color 0.15s, background 0.15s;
  line-height: 1;
}

.bc-close-btn:hover {
  color: var(--bc-text);
  background: var(--bc-bg-secondary);
}

/* ─── Spinner ────────────────────────────────────────────────── */
.bc-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: bc-spin 0.7s linear infinite;
  display: inline-block;
}

.bc-spinner-sm {
  width: 14px;
  height: 14px;
}

@keyframes bc-spin {
  to { transform: rotate(360deg); }
}

.bc-payment-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--bc-text-muted);
  font-size: 14px;
  padding: 16px 0;
}

.bc-payment-loading .bc-spinner {
  border-color: var(--bc-border);
  border-top-color: var(--bc-accent);
}

/* ─── Messages ───────────────────────────────────────────────── */
.bc-error-msg {
  color: #dc2626;
  font-size: 13px;
  padding: 8px 12px;
  background: #fef2f2;
  border-radius: var(--bc-radius);
  margin-top: 8px;
}

.bc-success-msg {
  color: #16a34a;
  font-size: 13px;
  padding: 8px 12px;
  background: #f0fdf4;
  border-radius: var(--bc-radius);
  margin-top: 8px;
}

.bc-checkout-error {
  margin: 0 24px 8px;
}

/* ─── Success Screen ─────────────────────────────────────────── */
.bc-success-screen {
  text-align: center;
  padding: 48px 24px;
}

.bc-success-icon {
  width: 64px;
  height: 64px;
  background: #16a34a;
  color: #fff;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-bottom: 20px;
}

.bc-success-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--bc-text);
  margin: 0 0 8px;
}

.bc-success-order {
  font-size: 14px;
  color: var(--bc-text-muted);
  margin: 0 0 4px;
}

.bc-success-email {
  font-size: 14px;
  color: var(--bc-text-muted);
  margin: 0 0 20px;
}

.bc-success-message {
  font-size: 15px;
  color: var(--bc-text);
  font-style: italic;
  margin: 20px 0;
  padding: 16px;
  background: var(--bc-bg-secondary);
  border-radius: var(--bc-radius);
}

/* ─── Contact / Waitlist Modal ───────────────────────────────── */
.bc-contact-overlay,
.bc-waitlist-overlay,
.bc-variant-overlay {
  position: fixed;
  inset: 0;
  z-index: calc(var(--bc-z-base) + 2);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  font-family: var(--bc-font);
}

.bc-contact-overlay.bc-overlay--open,
.bc-waitlist-overlay.bc-overlay--open,
.bc-variant-overlay.bc-overlay--open {
  pointer-events: all;
}

.bc-contact-modal,
.bc-variant-modal {
  position: relative;
  background: var(--bc-bg);
  border-radius: var(--bc-radius-lg);
  box-shadow: var(--bc-shadow);
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  transform: scale(0.95);
  opacity: 0;
  transition: transform 0.25s, opacity 0.25s;
  margin: 16px;
  max-height: 90vh;
}

.bc-overlay--open .bc-contact-modal,
.bc-overlay--open .bc-variant-modal {
  transform: scale(1);
  opacity: 1;
}

.bc-contact-overlay .bc-checkout-backdrop,
.bc-waitlist-overlay .bc-checkout-backdrop,
.bc-variant-overlay .bc-checkout-backdrop {
  opacity: 0;
  transition: opacity 0.25s;
}

.bc-overlay--open .bc-checkout-backdrop {
  opacity: 1;
}

.bc-waitlist-desc {
  font-size: 14px;
  color: var(--bc-text-muted);
  margin: 0 0 16px;
}

/* ─── Variant Picker ─────────────────────────────────────────── */
.bc-variant-group {
  margin-bottom: 16px;
}

.bc-variant-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.bc-variant-opt {
  padding: 7px 14px;
  border: 1px solid var(--bc-border);
  border-radius: var(--bc-radius);
  background: var(--bc-bg-secondary);
  color: var(--bc-text);
  cursor: pointer;
  font-size: 13px;
  transition: border-color 0.15s, background 0.15s;
  font-family: var(--bc-font);
}

.bc-variant-opt:hover {
  border-color: var(--bc-accent);
}

.bc-variant-opt--selected {
  border-color: var(--bc-accent);
  background: var(--bc-accent);
  color: var(--bc-accent-text);
}

.bc-variant-price {
  font-size: 20px;
  font-weight: 700;
  color: var(--bc-text);
  margin: 0 0 20px;
}

.bc-qty-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bc-qty-input {
  width: 60px;
  text-align: center;
  padding: 8px;
}

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 480px) {
  .bc-cart-drawer {
    width: 100vw;
  }

  .bc-checkout-modal {
    border-radius: 0;
    max-height: 100vh;
    margin: 0;
    height: 100%;
    max-width: 100vw;
  }

  .bc-cart-trigger-wrapper {
    bottom: 16px;
    right: 16px;
  }

  .bc-field-row {
    flex-direction: column;
  }

  .bc-field-sm {
    width: 100%;
  }
}
