/* ========================================================
   Apex Embroidery Designs — Monogram Maker Brand Styling
   Primary brand: #d03970 (Signature Apex Embroidery Pink)
   Accent: #b0285a (Deep Berry), #ee6d9b (Soft Pink)
   Header: #d03970 with header_embroi.29e96a17.svg texture
   ======================================================== */

:root {
  --apex-pink: #d03970;
  --apex-pink-dark: #b0285a;
  --apex-pink-soft: #fdf2f6;
  --apex-pink-border: #f7cad9;
  --apex-pink-ring: rgba(208, 57, 112, 0.18);
  --apex-blue: #4d4dff;
  --apex-blue-dark: #3737e6;
  --text-dark: #212529;
  --text-muted: #6c757d;
  --text-faint: #adb5bd;
  --border-color: #e9ecef;
  --border-focus: #ced4da;
  --bg-page: #f8f9fa;
  --bg-card: #ffffff;
  --topbar-h: 64px;
}

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

body {
  font-family: "Nunito Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-page);
  color: var(--text-dark);
  overflow-x: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ========================================================
   1. BRAND HEADER (Matching apexembdesigns.com)
   ======================================================== */
.afm-topbar {
  height: var(--topbar-h);
  background: #d03970 url("https://apexembdesigns.com/themes/custom/apex/dist/images/header_embroi.29e96a17.svg") no-repeat;
  background-size: cover;
  background-position: center;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
  gap: 16px;
  z-index: 100;
}

.afm-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  flex-shrink: 0;
}

.afm-brand__logo-img {
  height: 38px;
  width: auto;
  display: block;
}

.afm-brand__tag {
  background: rgba(255, 255, 255, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #ffffff;
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 3px 8px;
  border-radius: 9999px;
  white-space: nowrap;
}

/* Header layout tabs (Pill styling matching brand) */
.afm-header-layouts {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 9999px;
  padding: 3px;
  gap: 3px;
  backdrop-filter: blur(4px);
}

.afm-tab-btn {
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.afm-tab-btn:hover {
  background: rgba(255, 255, 255, 0.28);
  color: #ffffff;
}

.afm-tab-btn.is-active {
  background: #ffffff;
  color: var(--apex-pink);
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.afm-topbar__right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

/* Button matching apexembdesigns.com header store link */
.afm-store-btn {
  font-size: 12px;
  font-weight: 800;
  color: var(--apex-pink);
  background: #ffffff;
  text-decoration: none;
  padding: 7px 16px;
  border-radius: 9999px;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.afm-store-btn:hover {
  background: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
}

/* ========================================================
   2. MAIN 3-COLUMN WORKSPACE
   ======================================================== */
.afm-workspace {
  flex: 1;
  display: flex;
  overflow: hidden;
  height: calc(100vh - var(--topbar-h));
}

/* Left Sidebar: Product Catalog Grid */
.afm-sidebar-left {
  width: 380px;
  flex-shrink: 0;
  background: #ffffff;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.afm-sidebar-search {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border-color);
  background: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.afm-search-input {
  width: 100%;
  border: 1px solid var(--border-color);
  background: #fdfafb;
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 13px;
  color: var(--text-dark);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}

.afm-search-input:focus {
  border-color: var(--apex-pink);
  box-shadow: 0 0 0 3px var(--apex-pink-ring);
  background: #ffffff;
}

.afm-catalog-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.afm-catalog-info strong {
  color: var(--apex-pink);
  font-weight: 800;
}

.afm-catalog-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

/* Product Cards Grid: Exactly matching apexembdesigns.com */
.afm-product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.afm-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
  position: relative;
}

.afm-card:hover {
  transform: translateY(-2px);
  border-color: var(--apex-pink);
  box-shadow: 0 4px 16px rgba(208, 57, 112, 0.12);
}

.afm-card.is-selected {
  border-color: var(--apex-pink);
  background: #fff;
  box-shadow: 0 0 0 2px var(--apex-pink), 0 6px 18px rgba(208, 57, 112, 0.2);
}

.afm-card__thumb-wrap {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #f8f9fa;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid #f1f3f5;
}

.afm-card__thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s ease;
}

.afm-card:hover .afm-card__thumb {
  transform: scale(1.04);
}

.afm-card__badge-live {
  position: absolute;
  top: 6px;
  left: 6px;
  background: var(--apex-pink);
  color: #ffffff;
  font-size: 8.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 3px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.afm-card__body {
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex: 1;
}

.afm-card__title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dark);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 6px;
}

.afm-card__footer {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: auto;
}

.afm-card__price {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--apex-pink);
}

.afm-card__type {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* ========================================================
   3. CENTER CANVAS (Emroidery Preview)
   ======================================================== */
.afm-center {
  flex: 1;
  background: #fbf7f9;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.afm-preview-stage {
  width: 100%;
  height: 100%;
  max-width: 900px;
  max-height: 680px;
  background-color: #fdfcfb;
  background-image: 
    radial-gradient(rgba(0, 0, 0, 0.04) 1px, transparent 0),
    radial-gradient(rgba(0, 0, 0, 0.02) 1px, transparent 0);
  background-size: 8px 8px;
  background-position: 0 0, 4px 4px;
  border: 1.5px solid #e5e7eb;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 30px;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.02), 0 4px 20px rgba(0, 0, 0, 0.03);
}

.afm-preview-canvas {
  max-width: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease;
}

.afm-preview-canvas.is-loading {
  opacity: 0.45;
}

.afm-preview-img {
  max-width: 100%;
  max-height: 540px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.1));
}

.afm-preview-placeholder {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 600;
  text-align: center;
  line-height: 1.5;
}

.afm-watermark-pill {
  position: absolute;
  bottom: 12px;
  right: 14px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-faint);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border-color);
  padding: 3px 8px;
  border-radius: 4px;
  pointer-events: none;
  z-index: 5;
}

/* ========================================================
   4. RIGHT PANEL (Customise & Order CTA)
   ======================================================== */
.afm-sidebar-right {
  width: 330px;
  flex-shrink: 0;
  background: #ffffff;
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 18px;
  gap: 18px;
  overflow-y: auto;
}

.afm-panel-heading {
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--apex-pink);
  border-bottom: 2px solid var(--apex-pink-border);
  padding-bottom: 8px;
}

.afm-field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.afm-field-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-dark);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* Monogram letter inputs */
.afm-letter-inputs-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.afm-letter-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.afm-letter-tag {
  font-size: 9.5px;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.afm-letter-input {
  width: 100%;
  height: 48px;
  border: 1.5px solid var(--border-color);
  background: #fdfafb;
  border-radius: 6px;
  font-size: 20px;
  font-weight: 800;
  text-align: center;
  color: var(--apex-pink);
  text-transform: uppercase;
  outline: none;
  transition: all 0.15s ease;
}

.afm-letter-input:focus {
  border-color: var(--apex-pink);
  background: #ffffff;
  box-shadow: 0 0 0 3px var(--apex-pink-ring);
}

.afm-letter-input.is-center {
  border-color: var(--apex-pink-border);
  background: #ffffff;
}

/* Thread Color Swatches */
.afm-swatches-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.afm-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--border-color);
  transition: transform 0.12s, box-shadow 0.12s;
}

.afm-swatch:hover {
  transform: scale(1.15);
}

.afm-swatch.is-active {
  box-shadow: 0 0 0 2.5px var(--apex-pink);
  transform: scale(1.1);
}

.afm-palette-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  padding: 10px;
  background: var(--bg-page);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  max-height: 180px;
  overflow-y: auto;
}

.afm-palette-grid .afm-swatch {
  width: 22px;
  height: 22px;
}

.afm-custom-color-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

/* Range Slider */
.afm-range-control {
  width: 100%;
  accent-color: var(--apex-pink);
  cursor: pointer;
}

/* Buy & Download Card (Branded to match Apex theme) */
.afm-checkout-box {
  margin-top: auto;
  background: var(--apex-pink-soft);
  border: 1px solid var(--apex-pink-border);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.afm-checkout-header {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.afm-checkout-name {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text-dark);
  line-height: 1.3;
}

.afm-checkout-meta {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}

.afm-checkout-price-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.afm-checkout-price {
  font-size: 19px;
  font-weight: 900;
  color: var(--apex-pink);
}

.afm-buy-btn {
  display: block;
  text-align: center;
  background: var(--apex-pink);
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  padding: 11px 16px;
  border-radius: 6px;
  transition: all 0.15s ease;
  box-shadow: 0 4px 12px rgba(208, 57, 112, 0.25);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.afm-buy-btn:hover {
  background: var(--apex-pink-dark);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(208, 57, 112, 0.35);
}

/* Responsive */
@media (max-width: 1024px) {
  .afm-sidebar-left { width: 320px; }
  .afm-sidebar-right { width: 280px; }
  .afm-product-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .afm-workspace { flex-direction: column; height: auto; }
  .afm-sidebar-left, .afm-sidebar-right { width: 100%; height: 360px; }
  .afm-center { min-height: 420px; }
}
