/*
 * Embroidery Customizer – Frontend Styles
 * FIGS-inspired premium product page UI
 */

/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --ec-bg:          #ffffff;
  --ec-sidebar-bg:  #f8f7f5;
  --ec-border:      #e5e5e5;
  --ec-text:        #1a1a1a;
  --ec-text-muted:  #6b6b6b;
  --ec-accent:      #c8102e;        /* FIGS red */
  --ec-accent-dark: #a00d26;
  --ec-overlay-bg:  rgba(0,0,0,0.45);
  --ec-radius:      4px;
  --ec-radius-lg:   8px;
  --ec-transition:  0.22s ease;
  --ec-font:        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --ec-sidebar-w:   360px;
  --ec-z:           99999;
}

/* ── Trigger button ────────────────────────────────────────────────────────── */
.ec-trigger-wrap { margin: 12px 0 8px; }

.ec-trigger-btn {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 14px 18px;
  background: #fff;
  border: 1.5px solid var(--ec-border);
  border-radius: var(--ec-radius);
  cursor: pointer;
  font-family: var(--ec-font);
  font-size: 14px;
  font-weight: 500;
  color: var(--ec-text);
  text-align: left;
  transition: border-color var(--ec-transition), box-shadow var(--ec-transition);
  gap: 8px;
}

.ec-trigger-btn:hover {
  border-color: #aaa;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.ec-trigger-icon { font-size: 16px; color: var(--ec-accent); }

.ec-trigger-price {
  margin-left: auto;
  font-size: 13px;
  color: var(--ec-text-muted);
}

.ec-trigger-arrow {
  font-size: 20px;
  color: var(--ec-text-muted);
  margin-left: 4px;
}

/* Cart meta */
.ec-cart-meta {
  display: block;
  font-size: 12px;
  color: var(--ec-text-muted);
  margin-top: 2px;
}

/* ── Panel overlay (full-screen) ───────────────────────────────────────────── */
.ec-panel {
  position: fixed;
  inset: 0;
  z-index: var(--ec-z);
  display: flex;
  flex-direction: column;
  background: var(--ec-bg);
  overflow: hidden;
  animation: ecFadeIn 0.25s ease;
}

@keyframes ecFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Panel header ──────────────────────────────────────────────────────────── */
.ec-panel__header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--ec-border);
  flex-shrink: 0;
  background: #fff;
  z-index: 2;
}

.ec-panel__close {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--ec-text);
  letter-spacing: 0.04em;
  padding: 0;
  text-transform: uppercase;
}

.ec-panel__close:hover { color: var(--ec-accent); }

.ec-panel__title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0;
  flex: 1;
  text-align: center;
}

/* ── Panel body ────────────────────────────────────────────────────────────── */
.ec-panel__body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Preview area ──────────────────────────────────────────────────────────── */
.ec-preview-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #f2f0ed;
  position: relative;
  overflow: hidden;
}

.ec-preview-container {
  position: relative;
  display: inline-block;
  max-width: 100%;
}

.ec-preview-img {
  display: block;
  max-height: calc(100vh - 160px);
  max-width: 100%;
  object-fit: contain;
  border-radius: var(--ec-radius-lg);
  user-select: none;
}

/* ── Embroidery overlays ───────────────────────────────────────────────────── */
.ec-overlay {
  position: absolute;
  pointer-events: none;
  transition: left var(--ec-transition), top var(--ec-transition);
}

.ec-text-overlay {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.3;
  white-space: nowrap;
  /* default position set via JS */
}

.ec-overlay__line1,
.ec-overlay__line2 {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.ec-logo-overlay img {
  display: block;
  max-width: 80px;
  max-height: 60px;
  object-fit: contain;
}

/* ── Image navigation ──────────────────────────────────────────────────────── */
.ec-preview-dots {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  justify-content: center;
}

.ec-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ccc;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: background var(--ec-transition);
}

.ec-dot.is-active { background: var(--ec-text); }

.ec-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.85);
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  transition: background var(--ec-transition);
  z-index: 2;
}

.ec-arrow:hover { background: #fff; }
.ec-arrow--prev { left: 8px; }
.ec-arrow--next { right: 8px; }

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.ec-sidebar {
  width: var(--ec-sidebar-w);
  flex-shrink: 0;
  background: var(--ec-sidebar-bg);
  border-left: 1px solid var(--ec-border);
  overflow-y: auto;
  position: relative;
}

.ec-screen { padding: 24px; }

.ec-sidebar__heading {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 6px;
}

.ec-sidebar__sub {
  font-size: 13px;
  color: var(--ec-text-muted);
  margin: 0 0 20px;
}

/* ── Menu list ─────────────────────────────────────────────────────────────── */
.ec-menu-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ec-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 16px 14px;
  background: #fff;
  border: 1px solid var(--ec-border);
  border-radius: var(--ec-radius);
  cursor: pointer;
  font-family: var(--ec-font);
  text-align: left;
  transition: border-color var(--ec-transition), box-shadow var(--ec-transition);
}

.ec-menu-item:hover {
  border-color: #aaa;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.ec-menu-item__label { flex: 1; }

.ec-menu-item__title {
  display: block;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.ec-menu-item__sub {
  display: block;
  font-size: 12px;
  color: var(--ec-text-muted);
  margin-top: 2px;
}

.ec-menu-item__price {
  font-size: 13px;
  font-weight: 600;
  color: var(--ec-text-muted);
}

.ec-menu-item__arrow {
  font-size: 18px;
  color: #aaa;
}

/* applied state */
.ec-menu-item.is-applied { border-color: #2e7d32; }
.ec-menu-item.is-applied .ec-menu-item__price { color: #2e7d32; }

/* ── Price summary ─────────────────────────────────────────────────────────── */
.ec-price-summary {
  margin: 20px 0;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid var(--ec-border);
  border-radius: var(--ec-radius);
}

.ec-price-summary__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.ec-price-summary__total { font-size: 16px; }

/* ── Screen header (back bar) ──────────────────────────────────────────────── */
.ec-screen-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--ec-border);
}

.ec-back-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--ec-text);
  padding: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.ec-back-btn:hover { color: var(--ec-accent); }

.ec-screen-header__title {
  flex: 1;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-align: center;
}

.ec-screen-header__price {
  font-size: 13px;
  font-weight: 600;
  color: var(--ec-text-muted);
}

/* ── Form elements ─────────────────────────────────────────────────────────── */
.ec-form { display: flex; flex-direction: column; gap: 18px; }

.ec-form-group { display: flex; flex-direction: column; gap: 8px; }

.ec-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ec-text);
  display: flex;
  align-items: center;
  gap: 6px;
}

.ec-optional {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ec-text-muted);
  font-size: 11px;
}

.ec-selected-label {
  font-weight: 600;
  font-size: 11px;
  color: var(--ec-text);
  letter-spacing: 0;
}

.ec-input-wrap { position: relative; }

.ec-input {
  width: 100%;
  padding: 10px 48px 10px 12px;
  border: 1.5px solid var(--ec-border);
  border-radius: var(--ec-radius);
  font-size: 14px;
  font-family: var(--ec-font);
  color: var(--ec-text);
  background: #fff;
  box-sizing: border-box;
  transition: border-color var(--ec-transition);
}

.ec-input:focus {
  outline: none;
  border-color: var(--ec-text);
}

.ec-char-count {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--ec-text-muted);
  pointer-events: none;
}

/* ── Button group (position / font choice) ─────────────────────────────────── */
.ec-btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ec-choice-btn {
  padding: 9px 16px;
  border: 1.5px solid var(--ec-border);
  border-radius: var(--ec-radius);
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  font-family: var(--ec-font);
  color: var(--ec-text);
  font-weight: 500;
  transition: border-color var(--ec-transition), background var(--ec-transition), color var(--ec-transition);
}

.ec-choice-btn:hover { border-color: #aaa; }

.ec-choice-btn.is-active {
  border-color: var(--ec-text);
  background: var(--ec-text);
  color: #fff;
}

/* ── Color swatches ────────────────────────────────────────────────────────── */
.ec-color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ec-swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  position: relative;
  transition: transform var(--ec-transition), box-shadow var(--ec-transition);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.ec-swatch:hover { transform: scale(1.12); }

.ec-swatch.is-active {
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--ec-text);
}

.ec-swatch__check {
  font-size: 13px;
  color: var(--ec-text);
  position: absolute;
}

/* ── Upload area ───────────────────────────────────────────────────────────── */
.ec-upload-area {
  border: 2px dashed var(--ec-border);
  border-radius: var(--ec-radius-lg);
  background: #fff;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: border-color var(--ec-transition);
  padding: 16px;
  text-align: center;
}

.ec-upload-area.is-dragover { border-color: var(--ec-accent); background: #fff5f6; }

.ec-upload-area__inner { display: flex; flex-direction: column; align-items: center; gap: 8px; }

.ec-upload-area__icon { font-size: 36px; color: #aaa; line-height: 1; }

.ec-upload-area__text { font-size: 13px; color: var(--ec-text-muted); margin: 0; }

.ec-upload-area__btn { cursor: pointer; }

.ec-upload-area__hint { font-size: 11px; color: var(--ec-text-muted); margin: 0; }

#ec-upload-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

#ec-logo-preview-img {
  max-width: 120px;
  max-height: 100px;
  object-fit: contain;
  border-radius: var(--ec-radius);
  background: repeating-conic-gradient(#ddd 0% 25%, #fff 0% 50%) 0 0 / 10px 10px;
}

.ec-upload-area__remove {
  background: none;
  border: 1px solid var(--ec-border);
  border-radius: var(--ec-radius);
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  color: var(--ec-text-muted);
}

.ec-upload-area__remove:hover { color: var(--ec-accent); border-color: var(--ec-accent); }

/* ── Spinner ───────────────────────────────────────────────────────────────── */
.ec-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--ec-border);
  border-top-color: var(--ec-text);
  border-radius: 50%;
  animation: ecSpin 0.7s linear infinite;
  margin: 0 auto 6px;
}

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

/* ── Error message ─────────────────────────────────────────────────────────── */
.ec-error-msg {
  color: var(--ec-accent);
  font-size: 13px;
  padding: 8px 12px;
  background: #fff5f6;
  border-radius: var(--ec-radius);
  border: 1px solid #f5c2c7;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.ec-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  border-radius: var(--ec-radius);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-family: var(--ec-font);
  cursor: pointer;
  border: 2px solid transparent;
  transition: background var(--ec-transition), color var(--ec-transition), border-color var(--ec-transition), opacity var(--ec-transition);
}

.ec-btn--primary {
  background: var(--ec-text);
  color: #fff;
  border-color: var(--ec-text);
}

.ec-btn--primary:hover { background: #333; border-color: #333; }

.ec-btn--outline {
  background: #fff;
  color: var(--ec-text);
  border-color: var(--ec-border);
}

.ec-btn--outline:hover { border-color: var(--ec-text); }

.ec-btn--full { width: 100%; }

.ec-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.ec-form-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.ec-form-actions .ec-btn { flex: 1; }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --ec-sidebar-w: 100%; }

  .ec-panel__body { flex-direction: column; }

  .ec-preview-area {
    max-height: 40vh;
    padding: 12px;
  }

  .ec-preview-img { max-height: calc(40vh - 40px); }

  .ec-sidebar {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--ec-border);
    flex: 1;
  }

  .ec-screen { padding: 16px; }
}

@media (max-width: 480px) {
  .ec-panel__title { font-size: 13px; }
  .ec-sidebar__heading { font-size: 16px; }
}
/* Force square preview container for consistent zone placement */
#ec-preview-container {
    aspect-ratio: 1 / 1;
}
#ec-base-img {
    object-fit: contain;
    width: 100%;
    height: 100%;
}
/* Mobile embroidery preview fix */
@media (max-width: 768px) {

    .ec-overlay__line1,
    .ec-overlay__line2 {
        font-size: 8px !important;
        line-height: 1.1 !important;
    }

    .ec-text-overlay {
        transform: scale(0.8);
        transform-origin: center center;
    }

}
