/* Creet Product Configurator — Frontend Styles */
/* All brand colors use CSS custom properties: --creet-cfg-primary, --creet-cfg-secondary */

:root {
  /* Inherit the active site's theme colors. Falls back to Creet brand only if the
     site hasn't set a theme. The site root sets --creet-primary-color via store-design. */
  --creet-cfg-primary:   var(--creet-primary-color, #1a1a2e);
  --creet-cfg-secondary: var(--creet-secondary-color, #ffffff);
  --creet-cfg-accent:    var(--creet-primary-color, #C3FD73);
  --creet-cfg-radius:    8px;
  --creet-cfg-font:      inherit;
}

.creet-cfg {
  font-family: var(--creet-cfg-font);
  direction: rtl;
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
  position: relative;
}

/* ── Layout ───────────────────────────────────────────────────────────────── */
.creet-cfg-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.creet-cfg-sidebar {
  width: 180px;
  flex-shrink: 0;
}

.creet-cfg-panels {
  flex: 1;
  min-width: 0;
}

/* ── Sidebar steps ────────────────────────────────────────────────────────── */
.creet-cfg-steps { display: flex; flex-direction: column; gap: 4px; }

.creet-cfg-step {
  padding: 10px 14px;
  border-radius: var(--creet-cfg-radius);
  cursor: pointer;
  color: #64748b;
  font-size: 13px;
  transition: background .15s, color .15s;
  border: 1px solid transparent;
  white-space: nowrap;
}
.creet-cfg-step:hover { background: #f1f5f9; color: #111; }
.creet-cfg-step.active {
  background: var(--creet-cfg-primary);
  color: var(--creet-cfg-secondary);
  border-color: var(--creet-cfg-primary);
  font-weight: 600;
}

/* ── Panels ───────────────────────────────────────────────────────────────── */
.creet-cfg-panel {
  display: none;
  animation: creet-fade-in .2s ease;
  min-height: 300px;
}
.creet-cfg-panel.active { display: block !important; visibility: visible !important; opacity: 1 !important; }
@keyframes creet-fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.creet-cfg-panel h3 {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 16px;
  color: #111;
}

/* ── Preset grid (step 0) ─────────────────────────────────────────────────── */
.creet-cfg-grid { display: grid; gap: 12px; }
.creet-cfg-presets { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }

.creet-cfg-cat {
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: var(--creet-cfg-radius);
  padding: 20px 12px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.creet-cfg-cat:hover  { border-color: var(--creet-cfg-primary); background: #fff; }
.creet-cfg-cat.active { border-color: var(--creet-cfg-primary); background: var(--creet-cfg-primary); color: var(--creet-cfg-secondary); }

.creet-cfg-cat-icon  { width: 36px; height: 36px; }
.creet-cfg-cat-label { font-size: 13px; font-weight: 600; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.creet-cfg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--creet-cfg-radius);
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: background .15s, color .15s;
  text-decoration: none;
}
.creet-cfg-btn-primary {
  background: var(--creet-cfg-primary);
  color: var(--creet-cfg-secondary);
  border-color: var(--creet-cfg-primary);
}
.creet-cfg-btn-primary:hover { opacity: .88; }
.creet-cfg-btn-whatsapp {
  background: #25d366;
  color: #fff;
  border-color: #25d366;
}
.creet-cfg-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* ── Upload (step 1) ──────────────────────────────────────────────────────── */
.creet-cfg-upload-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.creet-cfg-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid #cbd5e1;
  border-top-color: var(--creet-cfg-primary);
  border-radius: 50%;
  animation: creet-spin .7s linear infinite;
  vertical-align: middle;
}
@keyframes creet-spin { to { transform: rotate(360deg); } }

.creet-cfg-thumbs { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.creet-cfg-thumb  { position: relative; width: 90px; height: 90px; }
.creet-cfg-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; border: 1px solid #e2e8f0; display: block; }
.creet-cfg-remove-img {
  position: absolute;
  top: -6px;
  left: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ef4444;
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Dimensions (step 2) ──────────────────────────────────────────────────── */
.creet-cfg-dims { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.creet-cfg-dims label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.creet-cfg-dims input,
.creet-cfg-qty-wrap input {
  padding: 8px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 15px;
  width: 100%;
  box-sizing: border-box;
}

.creet-cfg-qty-wrap { display: flex; align-items: center; gap: 0; border: 1px solid #e2e8f0; border-radius: 6px; overflow: hidden; width: fit-content; }
.creet-cfg-qty-wrap input { border: none; width: 60px; text-align: center; }
.creet-cfg-qty-btn { padding: 8px 14px; border: none; background: #f1f5f9; cursor: pointer; font-size: 16px; font-weight: 700; }
.creet-cfg-qty-btn:hover { background: #e2e8f0; }

#creet-cfg-dims-summary { color: #64748b; font-size: 13px; }

/* ── Materials (step 3) ───────────────────────────────────────────────────── */
.creet-cfg-finish-note {
  background: #f0f9ff;
  border-radius: 6px;
  padding: 10px 14px;
  color: #333;
  font-size: 13px;
  margin-bottom: 16px;
}

.creet-cfg-material-section { margin-bottom: 20px; }
.creet-cfg-material-label   { font-weight: 700; margin-bottom: 12px; color: #0f172a; font-size: 14px; }
.creet-cfg-material-grid    { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }

/* Material chip — same edge-to-edge image card as the custom-step options */
.creet-cfg-chip {
  position: relative !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  gap: 0 !important;
  padding: 0 !important;
  background: #fff !important;
  color: #0f172a !important;
  border: 2px solid #e2e8f0 !important;
  border-radius: 12px !important;
  cursor: pointer !important;
  overflow: hidden !important;
  transition: border-color .15s, box-shadow .15s, transform .15s !important;
  box-shadow: none !important;
  text-shadow: none !important;
  width: 100% !important;
  box-sizing: border-box !important;
  min-height: 0 !important;
}
.creet-cfg-chip:hover {
  border-color: var(--creet-cfg-primary) !important;
  background: #fff !important;
  transform: translateY(-1px);
}
.creet-cfg-chip.active {
  border-color: var(--creet-cfg-primary) !important;
  border-width: 3px !important;
  background: #fff !important;
  box-shadow: 0 0 0 4px rgba(0,0,0,.05) !important;
}
.creet-cfg-chip.active::after {
  content: "" !important;
  position: absolute !important;
  top: 8px !important;
  inset-inline-end: 8px !important;
  width: 22px !important; height: 22px !important;
  border-radius: 50% !important;
  background-color: var(--creet-cfg-primary) !important;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><path d='M5 13l4 4L19 7'/></svg>") !important;
  background-size: 14px !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
  z-index: 2 !important;
  box-shadow: 0 1px 4px rgba(0,0,0,.18) !important;
}
.creet-cfg-swatch {
  display: block !important;
  width: 100% !important;
  height: auto !important;
  aspect-ratio: 1 / 1 !important;
  border: none !important;
  border-radius: 0 !important;
  background-size: cover !important;
  background-position: center !important;
  background-color: #f1f5f9 !important;
  background-repeat: no-repeat !important;
  margin: 0 !important;
  padding: 0 !important;
  flex-shrink: 0 !important;
}
.creet-cfg-chip-label {
  display: block !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  color: #0f172a !important;
  background: #fff !important;
  text-align: center !important;
  padding: 9px 6px !important;
  border-top: 1px solid #f1f5f9 !important;
  margin: 0 !important;
}

.creet-cfg-other-label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; margin-top: 12px; }
.creet-cfg-other-label input {
  padding: 8px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 14px;
  max-width: 360px;
}

/* Collapsible grid */
.creet-cfg-material-grid.creet-cfg-collapsed .creet-cfg-chip:nth-child(n+7) { display: none; }
.creet-cfg-show-more {
  background: none;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 13px;
  color: #64748b;
  margin-top: 8px;
  display: block;
}
.creet-cfg-show-more:hover { background: #f1f5f9; }

/* ── Add-ons (step 4) ─────────────────────────────────────────────────────── */
.creet-cfg-addons { display: flex; flex-wrap: wrap; gap: 8px; }
.creet-cfg-addon {
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid #e2e8f0;
  cursor: pointer;
  font-size: 13px;
  transition: background .15s, border-color .15s;
}
.creet-cfg-addon:hover  { border-color: var(--creet-cfg-primary); }
.creet-cfg-addon.active { background: var(--creet-cfg-primary); color: var(--creet-cfg-secondary); border-color: var(--creet-cfg-primary); }
.creet-cfg-addon.active .creet-cfg-addon-price { color: var(--creet-cfg-secondary); opacity: .85; }

/* ── Custom step option grid (image cards) ──────────────────────────────────
   Storefront themes can heavily restyle <button> (full-color fills, padding).
   Use !important so the configurator's neutral card look wins on every theme. */
.creet-cfg-cs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.creet-cfg-cs-opt {
  position: relative !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  gap: 0 !important;
  padding: 0 !important;
  background: #fff !important;
  color: #0f172a !important;
  border: 2px solid #e2e8f0 !important;
  border-radius: 12px !important;
  cursor: pointer !important;
  overflow: hidden !important;
  font-family: inherit !important;
  font-weight: 500 !important;
  text-align: center !important;
  transition: border-color .15s, box-shadow .15s, transform .15s !important;
  box-shadow: none !important;
  width: 100% !important;
  min-height: 0 !important;
  line-height: normal !important;
  text-shadow: none !important;
}
.creet-cfg-cs-opt:hover {
  border-color: var(--creet-cfg-primary) !important;
  background: #fff !important;
  color: #0f172a !important;
  transform: translateY(-1px);
}
.creet-cfg-cs-opt.active {
  border-color: var(--creet-cfg-primary) !important;
  border-width: 3px !important;
  background: #fff !important;
  color: #0f172a !important;
  box-shadow: 0 0 0 4px rgba(0,0,0,.06) !important;
}
.creet-cfg-cs-opt.active::after {
  content: "" !important;
  position: absolute !important;
  top: 8px !important;
  inset-inline-end: 8px !important;
  width: 22px !important; height: 22px !important;
  border-radius: 50% !important;
  background-color: var(--creet-cfg-primary) !important;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><path d='M5 13l4 4L19 7'/></svg>") !important;
  background-size: 14px !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
  z-index: 2 !important;
  box-shadow: 0 1px 4px rgba(0,0,0,.18) !important;
}
.creet-cfg-cs-opt-img {
  display: block !important;
  width: 100% !important;
  aspect-ratio: 1 / 1 !important;
  background-color: #f1f5f9 !important;
  background-size: cover !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  border: none !important;
  border-radius: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
}
.creet-cfg-cs-opt-img.placeholder { background-color: #f1f5f9 !important; }
.creet-cfg-cs-opt-text {
  display: block !important;
  font-size: 13px !important;
  color: #0f172a !important;
  background: #fff !important;
  text-align: center !important;
  padding: 9px 6px !important;
  font-weight: 600 !important;
  border-top: 1px solid #f1f5f9 !important;
  margin: 0 !important;
}

/* ── Notes (step 5) ───────────────────────────────────────────────────────── */
#creet-cfg-notes {
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 12px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  min-height: 100px;
  box-sizing: border-box;
}

/* ── Summary (step 6) ─────────────────────────────────────────────────────── */
.creet-cfg-summary-card {
  border: 1px solid #e2e8f0;
  border-radius: var(--creet-cfg-radius);
  padding: 20px;
  background: #fafafa;
  display: flex;
  flex-direction: column;
  gap: 10px;
  line-height: 1.6;
}
.creet-cfg-summary-card strong { color: #111; }

/* ── Nav arrows ───────────────────────────────────────────────────────────── */
.creet-cfg-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
}
.creet-cfg-prev,
.creet-cfg-next {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
.creet-cfg-prev:hover,
.creet-cfg-next:hover { background: #e2e8f0; }

/* ── Steps toggle (mobile) ────────────────────────────────────────────────── */
.creet-cfg-steps-toggle {
  display: none;
  width: 100%;
  padding: 10px 16px;
  background: var(--creet-cfg-primary);
  color: var(--creet-cfg-secondary);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  margin-bottom: 12px;
  text-align: start;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .creet-cfg-steps-toggle { display: block; }
  .creet-cfg-sidebar { display: none; }
  .creet-cfg.creet-cfg-steps-open .creet-cfg-sidebar {
    display: block;
    position: absolute;
    z-index: 100;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px;
    top: 48px;
    inset-inline-end: 16px;
    width: 220px;
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
  }
  .creet-cfg.creet-cfg-steps-open .creet-cfg-sidebar .creet-cfg-steps { display: flex; flex-direction: column; gap: 6px; }
  .creet-cfg-layout { display: block; position: relative; }
}

@media (max-width: 640px) {
  .creet-cfg-dims { grid-template-columns: 1fr; }
  .creet-cfg-presets { grid-template-columns: repeat(2, 1fr); }
  .creet-cfg-material-grid { grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); }
}

/* ── Cart / order page spec block ────────────────────────────────────────── */
.woocommerce-cart table.cart td.product-name,
.woocommerce-checkout table.shop_table td.product-name {
  vertical-align: top;
  padding-top: 12px;
}
td.product-name .creet-cfg-spec {
  max-width: 100%;
  box-sizing: border-box;
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.5;
}
td.product-name .creet-cfg-spec a img {
  width: 60px;
  height: 60px;
}
@media (max-width: 782px) {
  .woocommerce-cart .woocommerce,
  .woocommerce-cart form.woocommerce-cart-form { overflow-x: auto; }
  td.product-name .creet-cfg-spec { font-size: 11px; }
}
