/* ============================================================
   Smart Order Form — Frontend Styles
   Author: Anis Dzed | anisdzed.com
   ============================================================ */

:root {
  --sof-primary: #e63946;
  --sof-success: #2d6a4f;
  --sof-text: #1a1a2e;
  --sof-muted: #6b7280;
  --sof-border: #e5e7eb;
  --sof-bg: #ffffff;
  --sof-bg-alt: #f9fafb;
  --sof-radius: 12px;
  --sof-radius-sm: 8px;
  --sof-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  --sof-transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

.sof-summary-item {
  margin-bottom: 12px;
}
.sof-summary-item-main {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}
.sof-summary-choice-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.sof-summary-choice-row:first-child {
  border-top: none !important;
  margin-top: 0 !important;
  padding-top: 0 !important;
}
.sof-summary-choice-label {
  font-size: 13px;
  font-weight: 700;
  width: fit-content;
}
.sof-summary-attr-badge {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 11px;
}
.sof-attr-item {
  display: inline-flex;
  align-items: center;
  transition: all 0.3s ease;
}
.sof-attr-name {
  font-weight: 600;
  margin-right: 4px;
}
.sof-attr-val {
  /* Base styles, overridden by Elementor */
}
.sof-attr-sep {
  /* Base styles for delimiters */
}
.sof-summary-product-attrs {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  flex-direction: column; /* Stack choice rows */
}
.sof-card-variations-spacer {
  width: 100%;
  margin-top: 15px;
}
.sof-card-variations-spacer:empty {
  display: none;
}
/* ── Options ────────────────────────────────────────────────────────── */
.sof-form-wrap {
  font-family: inherit;
  color: var(--sof-text);
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.elementor-widget-sof_offers,
.elementor-widget-sof_offers > .elementor-widget-container {
  height: auto !important;
  min-height: 0 !important;
  max-height: fit-content !important;
  width: 100% !important;
  align-self: flex-start !important;
  display: block !important;
}

.sof-section {
  background: var(--sof-bg);
  border-radius: var(--sof-radius);
  padding: 24px;
  box-shadow: var(--sof-shadow);
}

.sof-section-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--sof-muted);
  margin: 0 0 16px;
}

/* ── Radio Cards ─────────────────────────────────────────────────────── */
.sof-radios-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sof-radio-card {
  position: relative;
  border-width: 2px;
  border-style: solid;
  border-color: var(--sof-border);
  border-radius: var(--sof-radius-sm);
  background: var(--sof-bg-alt);
  transition: var(--sof-transition);
  cursor: pointer;
  overflow: visible;
}

.sof-radio-card:hover {
  border-color: var(--sof-primary);
}

.sof-radio-card.is-selected {
  border-color: var(--sof-primary);
  background: #fff8f0;
}

.sof-badge {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ff4757;
  color: #fff;
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 4px;
  z-index: 10;
  pointer-events: none;
  line-height: 1;
  min-width: 20px;
  min-height: 20px;
}
.sof-badge i,
.sof-badge svg {
  display: inline-block;
  margin-right: 4px;
  vertical-align: middle;
  flex-shrink: 0;
}
[dir="rtl"] .sof-badge i,
[dir="rtl"] .sof-badge svg {
  margin-right: 0;
  margin-left: 4px;
}
.sof-badge i,
.sof-badge svg {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 1em !important;
  height: 1em !important;
  min-width: 1em;
  min-height: 1em;
  vertical-align: middle;
  flex-shrink: 0;
  line-height: 1;
  font-size: inherit;
}
.sof-badge i:empty:before {
  content: "\200B"; /* Zero-width space to force dimension if empty */
  display: inline-flex;
}

@keyframes sofBadgePop {
  from {
    transform: scale(0.6);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* ── Variation Presets ────────────────────────────────────────── */
.sof-variation-list {
  display: grid;
  gap: 15px;
  margin-top: 15px;
}

/* Default / Grid Style */
.sof-preset-grid .sof-variation-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
}
.sof-preset-grid .sof-var-opt {
  flex-direction: column;
  text-align: center;
  padding: 12px;
  border: 2px solid var(--sof-border);
  border-radius: var(--sof-radius-sm);
  background: #fff;
  transition: var(--sof-transition);
}

/* Cards (Stack) Style */
.sof-preset-cards .sof-variation-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.sof-preset-cards .sof-var-opt {
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  text-align: left;
  padding: 12px 16px;
  border: 2px solid var(--sof-border);
  border-radius: var(--sof-radius-sm);
  background: #fff;
  gap: 15px;
}
[dir="rtl"] .sof-preset-cards .sof-var-opt {
  text-align: right;
}
.sof-preset-cards .sof-var-img {
  width: 50px;
  height: 50px;
  border-radius: 6px;
}

/* Buttons / Badges Style */
.sof-preset-btns .sof-variation-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.sof-preset-btns .sof-var-opt {
  width: auto;
  min-width: 80px;
  padding: 8px 16px;
  border-radius: 30px;
  border: 1.5px solid var(--sof-border);
  background: #fff;
  text-align: center;
  justify-content: center;
}
.sof-preset-btns .sof-var-img {
  display: none;
}

/* Swatches / Dots Style */
.sof-preset-dot .sof-variation-options {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
}
.sof-preset-dot .sof-var-opt {
  width: 45px;
  height: 45px;
  padding: 0;
  overflow: hidden;
  border-radius: 50%;
  position: relative;
  border: 2px solid var(--sof-border);
  background: #fff;
}
.sof-preset-dot .sof-var-text {
  display: none;
}
.sof-preset-dot .sof-var-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.sof-preset-dot .sof-var-opt.is-selected {
  box-shadow: 0 0 0 3px var(--sof-primary);
}

/* ── Selected Tick / Indicator ─────────────────────────────────── */
.sof-var-opt {
  position: relative;
}
.sof-var-opt.is-selected::after {
  content: "\2713"; /* Unicode checkmark */
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  background: #4caf50;
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  z-index: 5;
}
[dir="rtl"] .sof-var-opt.is-selected::after {
  right: auto;
  left: -6px;
}

/* ── Animations ─────────────────────────────────────────────── */
@keyframes sof-pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.03);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes sof-glow-loop {
  0% {
    box-shadow: 0 0 5px rgba(var(--sof-primary-rgb), 0.2);
  }
  50% {
    box-shadow: 0 0 20px rgba(var(--sof-primary-rgb), 0.6);
  }
  100% {
    box-shadow: 0 0 5px rgba(var(--sof-primary-rgb), 0.2);
  }
}

@keyframes sof-float-loop {
  0% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
  100% {
    transform: translateY(0);
  }
}

/* Loop animations for Total Value specifically */
.sof-total-loop-pulse .sof-total-val {
  animation: sof-pulse 2s infinite ease-in-out;
}
.sof-total-loop-glow .sof-total-val {
  animation: sof-glow-loop 2s infinite ease-in-out;
}
.sof-total-loop-float .sof-total-val {
  animation: sof-float-loop 3s infinite ease-in-out;
}
.sof-total-loop-scale .sof-total-val {
  animation: sof-total-scale 2s infinite ease-in-out;
}

@keyframes sof-pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes sof-glow-loop {
  0%,
  100% {
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
  }
  50% {
    box-shadow: 0 0 20px rgba(var(--sof-primary-rgb, 79, 70, 229), 0.4);
  }
}

/* Field Alignment fixes */
[dir="rtl"] .sof-input,
[dir="rtl"] .sof-select,
[dir="rtl"] .sof-textarea {
  text-align: right;
}
[dir="rtl"] .sof-input[type="tel"] {
  direction: ltr;
  text-align: right;
}
@keyframes sof-bounce {
  0%,
  20%,
  50%,
  80%,
  100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-5px);
  }
  60% {
    transform: translateY(-3px);
  }
}
@keyframes sof-pop {
  0% {
    transform: scale(0.95);
    opacity: 0.8;
  }
  50% {
    transform: scale(1.05);
    opacity: 1;
  }
  100% {
    transform: scale(1);
  }
}
@keyframes sof-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}

@keyframes sof-error-blink {
  0%,
  100% {
    border-color: var(--sof-border);
    box-shadow: none;
  }
  50% {
    border-color: #dc2626;
    box-shadow: 0 0 10px rgba(220, 38, 38, 0.4);
    background-color: rgba(220, 38, 38, 0.05);
  }
}

.sof-error-blink {
  animation: sof-error-blink 0.8s ease-in-out 2;
}

.sof-anim-pulse {
  animation: sof-pulse 0.4s ease-in-out;
}
.sof-anim-bounce {
  animation: sof-bounce 0.4s ease-in-out;
}
.sof-anim-pop {
  animation: sof-pop 0.4s ease-in-out;
}
.sof-anim-shake {
  animation: sof-shake 0.4s ease-in-out;
}

/* ── Order Button Active State ── */
.sof-btn-order.is-complete {
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
  cursor: pointer;
}

/* Animations for updating values */
.is-updating.sof-anim-pulse {
  animation: sof-pulse-lite 0.4s ease;
}
.is-updating.sof-anim-bounce {
  animation: sof-bounce-lite 0.4s ease;
}
.is-updating.sof-anim-flash {
  animation: sof-flash-lite 0.4s ease;
}

@keyframes sof-pulse-lite {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}
@keyframes sof-bounce-lite {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}
@keyframes sof-flash-lite {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@keyframes sof-total-scale {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.15);
  }
  100% {
    transform: scale(1);
  }
}

.sof-total-animating {
  display: inline-block;
  animation: sof-total-scale 0.3s ease-out;
}

.sof-radio-label {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  cursor: pointer;
  width: 100%;
  user-select: none;
}

.sof-radio-input {
  display: none;
}

.sof-radio-indicator {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border-width: 2px;
  border-style: solid;
  border-color: var(--sof-border);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--sof-transition);
  background: #fff;
}

.sof-radio-card.is-selected .sof-radio-indicator {
  border-color: var(--sof-primary);
  background: var(--sof-primary);
}

.sof-radio-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  transform: scale(0);
  transition: transform 0.18s ease;
}

.sof-radio-card.is-selected .sof-radio-dot {
  transform: scale(1);
}

.sof-radio-content {
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  /* Allow Elementor controls to override */
  flex-direction: inherit;
  align-items: inherit;
  gap: inherit;
}

.sof-rtl .sof-radio-content {
  align-items: flex-start; /* Default for RTL, but now controllable */
}

.sof-radio-title {
  font-weight: 600;
  font-size: 1rem;
}

.sof-radio-pricing {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sof-promo-price {
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--sof-primary);
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}

.sof-orig-price {
  font-size: 0.85rem;
  color: #aaa;
  text-decoration: line-through;
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}

.sof-price-sep {
  display: none; /* Just a spacer for PHP, gap handles it here */
}

/* Ensure numbers always look consistent in RTL */
.sof-price-amount {
  direction: ltr;
  unicode-bidi: isolate;
}

/* ── Price Display ───────────────────────────────────────────────────── */
.sof-price-display {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #fff5f6 0%, #fff 100%);
  border: 1px solid #ffd0d4;
  border-radius: var(--sof-radius-sm);
}

.sof-price-label {
  font-size: 0.85rem;
  color: var(--sof-muted);
  font-weight: 600;
}

.sof-price-value {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--sof-primary);
  transition: var(--sof-transition);
}

/* ── Fields ──────────────────────────────────────────────────────────── */
.sof-fields-section {
  display: flex;
  flex-direction: column;
  gap: 15px; /* Default gap, controllable by Elementor */
}

.sof-field-group {
  margin-bottom: 0; /* Use gap instead */
}

.sof-field-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--sof-text);
  margin-bottom: 7px;
}

.sof-required {
  color: var(--sof-primary);
  margin-left: 3px;
}

.sof-input {
  width: 100%;
  padding: 11px 15px;
  border: 1.5px solid var(--sof-border);
  border-radius: var(--sof-radius-sm);
  font-size: 0.95rem;
  color: var(--sof-text);
  background: var(--sof-bg);
  transition: var(--sof-transition);
  box-sizing: border-box;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  text-align: inherit; /* Allow Elementor alignment to pass through */
}

select.sof-input {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 40px;
}

.sof-rtl select.sof-input {
  background-position: left 12px center;
  padding-right: 15px;
  padding-left: 40px;
  text-align: right;
}

.sof-rtl input[type="tel"].sof-input,
.sof-rtl input[type="text"].sof-input,
.sof-rtl textarea.sof-input {
  text-align: right;
}

.sof-input:focus {
  border-color: var(--sof-primary);
  box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.12);
}

.sof-input.has-error {
  border-color: #dc2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.sof-field-error {
  display: block;
  font-size: 0.78rem;
  color: #dc2626;
  margin-top: 5px;
  min-height: 1em;
}

textarea.sof-input {
  resize: vertical;
  min-height: 80px;
}

/* ── Shipping Toggle ─────────────────────────────────────────────────── */
.sof-shipping-options {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.sof-shipping-opt {
  flex: 1;
  min-width: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border: 2px solid var(--sof-border);
  border-radius: var(--sof-radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  transition: var(--sof-transition);
  background: var(--sof-bg);
  user-select: none;
  position: relative;
}

.sof-shipping-opt::before,
.sof-radio-indicator {
  content: "";
  width: 16px;
  height: 16px;
  border: 2px solid var(--sof-border);
  border-radius: 50%;
  display: inline-block;
  background: #fff;
  transition: var(--sof-transition);
  flex-shrink: 0;
}

.sof-summary-row.sof-shipping-opt::before {
  display: none !important;
}

.sof-shipping-opt.is-selected {
  border-color: var(--sof-primary);
  background: #fff8f0;
  color: var(--sof-primary);
}

.sof-shipping-opt.is-selected::before,
label.sof-summary-row:has(input:checked) .sof-radio-indicator {
  border-color: var(--sof-primary);
  background: var(--sof-primary);
  box-shadow: inset 0 0 0 3px #fff;
}

.sof-shipping-radio {
  display: none;
}

/* ── Summary ─────────────────────────────────────────────────────────── */
.sof-summary {
  background: var(--sof-bg-alt);
  border-radius: var(--sof-radius-sm);
  overflow: hidden;
}

.sof-summary-product {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--sof-border);
}

.sof-product-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--sof-border);
}

.sof-product-name {
  font-weight: 700;
  font-size: 1rem;
}

.sof-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  font-size: 0.95rem;
  cursor: default;
  gap: 12px;
  transition: var(--sof-transition);
}

.sof-summary-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sof-summary-label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sof-summary-value {
  font-weight: 700;
}

/* ── Order Total ─────────────────────────────────────────────────────── */
.sof-total-section {
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.sof-total-container {
  display: flex;
  flex-direction: column;
  padding: 24px;
  background: var(--sof-bg);
  border-radius: var(--sof-radius);
  transition: var(--sof-transition);
}

.sof-total-row {
  display: flex;
  align-items: center;
  gap: 15px;
  /* Justify is controlled by Elementor */
}

.sof-total-label {
  font-size: 1.1rem;
  font-weight: 700;
}

.sof-total-value {
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--sof-primary);
  line-height: 1.2;
}

.sof-total-before,
.sof-total-after {
  font-size: 0.95rem;
  color: var(--sof-muted);
}

/* ── Submit Button ───────────────────────────────────────────────────── */
.sof-submit-section {
  padding: 16px 0;
  background: transparent;
  box-shadow: none;
}

.sof-btn-order {
  width: auto;
  padding: 16px 24px;
  border: none;
  border-radius: var(--sof-radius-sm);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: var(--sof-transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  position: relative;
  overflow: hidden;
  margin-left: auto;
  margin-right: auto;
}

/* Width Helpers */
.sof-btn-width-block .sof-btn-order {
  width: 100%;
}
.sof-btn-width-auto .sof-btn-order {
  width: auto;
}

/* Alignment Helpers (applied to container) */
.sof-btn-align-left .sof-submit-section {
  text-align: left;
}
.sof-btn-align-center .sof-submit-section {
  text-align: center;
}
.sof-btn-align-right .sof-submit-section {
  text-align: right;
}
.sof-btn-align-justify .sof-submit-section {
  text-align: justify;
}

.sof-btn-align-left .sof-btn-order {
  margin-left: 0;
  margin-right: auto;
}
.sof-btn-align-center .sof-btn-order {
  margin-left: auto;
  margin-right: auto;
}
.sof-btn-align-right .sof-btn-order {
  margin-left: auto;
  margin-right: 0;
}
.sof-btn-align-justify .sof-btn-order {
  margin: 0;
  width: 100%;
}

/* Animations */
.sof-btn-anim-pulse .sof-btn-order {
  animation: sof-pulse 2s infinite;
}
.sof-btn-anim-grow .sof-btn-order {
  animation: sof-grow 1.5s infinite alternate;
}
.sof-btn-anim-shrink .sof-btn-order {
  animation: sof-shrink 1.5s infinite alternate;
}
.sof-btn-anim-bounce .sof-btn-order {
  animation: sof-bounce 0.8s ease infinite alternate;
}
.sof-btn-anim-flash .sof-btn-order {
  animation: sof-flash 2s infinite;
}
.sof-btn-anim-wobble .sof-btn-order {
  animation: sof-wobble 2s infinite;
}

@keyframes sof-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(230, 57, 70, 0.4);
  }
  70% {
    box-shadow: 0 0 0 15px rgba(230, 57, 70, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(230, 57, 70, 0);
  }
}

@keyframes sof-grow {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(1.05);
  }
}

@keyframes sof-shrink {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(0.95);
  }
}

@keyframes sof-bounce {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-8px);
  }
}

@keyframes sof-flash {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

@keyframes sof-wobble {
  0%,
  100% {
    transform: translateX(0%);
  }
  15% {
    transform: translateX(-5%) rotate(-5deg);
  }
  30% {
    transform: translateX(4%) rotate(3deg);
  }
  45% {
    transform: translateX(-3%) rotate(-3deg);
  }
  60% {
    transform: translateX(2%) rotate(2deg);
  }
  75% {
    transform: translateX(-1%) rotate(-1deg);
  }
}

.sof-btn-order:hover {
  filter: brightness(1.05);
}

.sof-btn-order:active {
  transform: scale(0.98);
}

.sof-btn-order:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
  animation: none !important;
}

.sof-btn-spinner {
  display: inline-block;
  animation: sofSpin 0.7s linear infinite;
  font-style: normal;
}

.sof-form-message.is-success {
  display: block;
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #6ee7b7;
}

.sof-form-message.is-error {
  display: block;
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

/* ── Custom content ──────────────────────────────────────────────────── */
.sof-custom-content {
  margin-bottom: 20px;
  padding: 14px 16px;
  background: #fffbeb;
  border-left: 4px solid #f59e0b;
  border-radius: 0 var(--sof-radius-sm) var(--sof-radius-sm) 0;
  font-size: 0.9rem;
  line-height: 1.6;
}

/* ── Variation modal ─────────────────────────────────────────────────── */
.sof-variation-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: sofFadeIn 0.2s ease;
  transition: opacity 0.2s ease;
}

@keyframes sofFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.sof-variation-modal {
  background: #fff;
  border-radius: var(--sof-radius);
  padding: 28px;
  max-width: 480px;
  width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  animation: sofSlideUp 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}

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

.sof-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: #f3f4f6;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--sof-transition);
}

.sof-modal-close:hover {
  background: #e5e7eb;
}

.sof-modal-title {
  margin: 0 0 6px;
  font-size: 1.2rem;
  font-weight: 800;
}

.sof-modal-subtitle {
  font-size: 0.85rem;
  color: var(--sof-muted);
  margin: 0 0 18px;
}

.sof-variation-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
  overflow-y: auto;
  flex: 1;
}

.sof-variation-slot {
  border: 1px solid var(--sof-border);
  border-radius: var(--sof-radius-sm);
  padding: 12px;
}

.sof-variation-slot-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--sof-muted);
  margin-bottom: 10px;
}

.sof-variation-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}

.sof-var-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1.5px solid var(--sof-border);
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  transition: var(--sof-transition);
  background: var(--sof-bg);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.sof-var-opt:hover {
  border-color: var(--sof-primary);
  background: var(--sof-bg-alt);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.sof-var-opt.is-selected {
  border-color: var(--sof-primary);
  background: #fff8f0;
  color: var(--sof-primary);
  box-shadow: 0 4px 12px rgba(230, 57, 70, 0.12);
}

.sof-var-opt.is-selected::after {
  content: "✓";
  position: absolute;
  top: 5px;
  right: 5px;
  background: var(--sof-primary);
  color: #fff;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sof-rtl .sof-var-opt.is-selected::after {
  right: auto;
  left: 5px;
}

.sof-var-opt.is-disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(1);
}

.sof-var-img {
  width: 100%;
  aspect-ratio: 1/1;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--sof-border);
}

.sof-var-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sof-var-stock {
  font-size: 0.75rem;
  color: #f59e0b;
  font-weight: 700;
}

/* ── Variation Presets ── */

/* 1. Horizontal Cards */
.sof-preset-cards .sof-var-opt {
  flex-direction: row;
  text-align: left;
}
.sof-rtl .sof-preset-cards .sof-var-opt {
  text-align: right;
}
.sof-preset-cards .sof-var-img {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}

/* 2. Buttons / Badges */
.sof-preset-btns .sof-var-opt {
  padding: 8px 16px;
  border-radius: 50px;
  flex-direction: row;
  justify-content: center;
  min-width: 80px;
}
.sof-preset-btns .sof-var-img {
  display: none;
}

/* 3. Swatches / Dots */
.sof-preset-dot .sof-variation-options {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.sof-preset-dot .sof-var-opt {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  justify-content: center;
  overflow: visible;
}
.sof-preset-dot .sof-var-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}
.sof-preset-dot .sof-var-text {
  display: none;
}
.sof-preset-dot .sof-var-opt.is-selected::after {
  top: -5px;
  right: -5px;
  width: 20px;
  height: 20px;
}

.sof-preset-btns .sof-var-img {
  width: 24px;
  height: 24px;
  margin-right: 8px;
}
.sof-rtl .sof-preset-btns .sof-var-img {
  margin-right: 0;
  margin-left: 8px;
}

/* 3. Swatches (Dots) */
.sof-preset-dot .sof-variation-options {
  display: flex !important;
  flex-wrap: wrap;
}
.sof-preset-dot .sof-var-opt {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  padding: 0;
  justify-content: center;
}
.sof-preset-dot .sof-var-text {
  display: none;
}
.sof-preset-dot .sof-var-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: none;
}
.sof-preset-dot .sof-var-opt.is-selected::after {
  top: auto;
  bottom: 0;
  right: -5px;
}
.sof-rtl .sof-preset-dot .sof-var-opt.is-selected::after {
  left: -5px;
  right: auto;
}

.sof-btn-confirm-variations {
  width: 100%;
  padding: 13px;
  background: var(--sof-primary);
  color: #fff;
  border: none;
  border-radius: var(--sof-radius-sm);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--sof-transition);
}

.sof-btn-confirm-variations:hover {
  filter: brightness(1.08);
}

/* ── Integrated Variations ───────────────────────────────────────────── */
.sof-integrated-variations {
  display: block;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px dashed var(--sof-border);
  animation: sofFadeDown 0.4s ease-out;
}

.sof-integrated-variations .sof-variation-slot {
  background: var(--sof-bg-alt);
  padding: 15px;
  border-radius: 12px;
  margin-bottom: 20px;
  border: 1px solid var(--sof-border);
}

.sof-integrated-variations.is-loading,
.sof-variation-popup-content.is-loading {
  opacity: 0.5;
  pointer-events: none;
  min-height: 120px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sof-loader {
  width: 40px;
  height: 40px;
  border: 4px solid var(--sof-border);
  border-top: 4px solid var(--sof-primary);
  border-radius: 50%;
  animation: sofSpinner 1s linear infinite;
}

@keyframes sofSpinner {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.sof-var-text {
  display: block; /* Default, overridden by Elementor selectors */
  flex-wrap: wrap;
}

/* ── Attribute Naming ────────────────────────────────────────────────── */
.sof-attr-key {
  font-weight: 600;
  color: var(--sof-muted);
  margin-right: 4px;
}
[dir="rtl"] .sof-attr-key {
  margin-right: 0;
  margin-left: 4px;
}
.sof-attr-val {
  font-weight: 700;
  color: var(--sof-text);
}

@keyframes sofFadeDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Checkbox label ──────────────────────────────────────────────────── */
.sof-checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  cursor: pointer;
}

.sof-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--sof-primary);
}

/* ── Progress Bar ────────────────────────────────────────────────────── */
.sof-progress {
  height: 6px;
  background: #f3f4f6;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 24px;
}

.sof-progress-bar {
  height: 100%;
  background: var(--sof-primary);
  width: 0%;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 10px rgba(230, 57, 70, 0.4);
}

/* ── Multi-Step ──────────────────────────────────────────────────────── */
.sof-step {
  display: none;
  animation: sofStepFade 0.3s ease-out;
}

.sof-step.is-active {
  display: block;
}

@keyframes sofStepFade {
  from {
    opacity: 0;
    transform: translateX(10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.sof-step-nav {
  display: flex;
  justify-content: flex-end;
  margin-top: 20px;
}

.sof-btn-next,
.sof-btn-prev {
  padding: 12px 24px;
  border-radius: var(--sof-radius-sm);
  font-weight: 700;
  cursor: pointer;
  transition: var(--sof-transition);
}

.sof-btn-next {
  background: var(--sof-primary);
  color: #fff;
  border: none;
  box-shadow: 0 4px 12px rgba(230, 57, 70, 0.25);
}

.sof-btn-prev {
  background: #f3f4f6;
  color: var(--sof-muted);
  border: 1px solid var(--sof-border);
  margin-right: auto;
}

.sof-btn-next:hover {
  background: #d62839;
}
.sof-btn-prev:hover {
  background: #e5e7eb;
}

/* Adjust submit section for multi-step */
.is-multi-step .sof-submit-section {
  display: flex;
  gap: 12px;
}

.is-multi-step .sof-btn-prev {
  flex-shrink: 0;
  width: auto;
}

.is-multi-step .sof-btn-order {
  flex: 1;
}

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .sof-section {
    padding: 16px;
  }
  .sof-radio-content {
    flex-direction: column;
    align-items: flex-start;
  }
  .sof-shipping-options {
    flex-direction: column;
  }
  .sof-total-value {
    font-size: 1.25rem;
  }
  .sof-step-nav {
    flex-direction: column;
    gap: 10px;
  }
  .sof-btn-next,
  .sof-btn-prev {
    width: 100%;
    text-align: center;
  }
}

/* ── RTL Support ─────────────────────────────────────────────────────── */
.sof-rtl {
  direction: rtl;
  text-align: right;
}

.sof-rtl .sof-badge {
  left: auto;
  /* Right is handled by inline style, but let's ensure it's correct */
}

.sof-rtl .sof-required {
  margin-left: 0;
  margin-right: 3px;
}

.sof-rtl .sof-custom-content {
  border-left: none;
  border-right: 4px solid #f59e0b;
  border-radius: var(--sof-radius-sm) 0 0 var(--sof-radius-sm);
}

.sof-rtl .sof-modal-close {
  right: auto;
  left: 16px;
}

.sof-rtl .sof-var-opt {
  text-align: right;
}

.sof-rtl .sof-btn-prev {
  margin-right: 0;
  margin-left: auto;
}

.sof-rtl .sof-step-nav {
  justify-content: flex-start;
}

.sof-rtl .sof-step-nav .sof-btn-next {
  margin-right: auto;
  margin-left: 0;
}

@media (max-width: 480px) {
  .sof-rtl .sof-radio-content {
    align-items: flex-start; /* Ensure mobile doesn't force end-alignment */
  }
}

/* ── Editor placeholder ──────────────────────────────────────────────── */
.sof-placeholder {
  border: 2px dashed #ddd;
  border-radius: 12px;
  padding: 40px;
  text-align: center;
  color: #999;
  font-size: 1rem;
}

/* ── Custom Containers ────────────────────────────────────────────────── */
.sof-custom-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  box-sizing: border-box;
}

.sof-custom-container-header {
  margin: 0 0 15px 0;
  font-weight: 700;
  font-size: 1.1rem;
}

/* Ensure blocks inside containers stay consistent */
.sof-custom-container .sof-block-wrap {
  width: 100%;
}

/* ── Loaders ── */
.sof-spinner {
  margin: 30px auto;
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-left-color: var(--sof-primary, #e63946);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  animation: sof-spin 1s linear infinite;
}

@keyframes sof-spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* ── Inline Field Validation Errors ── */
.sof-field-error,
.sof-inline-error {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  color: #dc2626;
  margin-top: 5px;
  min-height: 0;
  line-height: 1.4;
  animation: sof-error-slide-in 0.2s ease forwards;
}

@keyframes sof-error-slide-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Populated .sof-field-error spans are hidden by default, shown by JS */
.sof-field-error:empty {
  display: none;
}

/* Red border on errored inputs */
.sof-input.has-error {
  border-color: #dc2626 !important;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12) !important;
}

/* Inline errors injected below offer cards / shipping options */
.sof-offers-error-msg,
.sof-shipping-error-msg {
  font-size: 0.82rem;
  font-weight: 500;
  color: #dc2626;
  margin: 6px 0 0 4px;
  padding: 0;
  animation: sof-error-slide-in 0.2s ease forwards;
}

/* ── Scroll-to-error blink animation ── */
@keyframes sof-error-blink-kf {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(220, 38, 38, 0);
  }
  40% {
    box-shadow: 0 0 0 6px rgba(220, 38, 38, 0.25);
  }
}

.sof-error-blink {
  animation: sof-error-blink-kf 0.7s ease 2;
}

/* ── Field Icons ─────────────────────────────────────────────────────── */
.sof-input-container {
  display: flex !important;
  flex-direction: row;
  flex-wrap: nowrap !important;
  align-items: stretch;
  border: 1px solid var(--sof-border, #d1d5db);
  border-radius: var(--sof-radius-sm, 8px);
  overflow: hidden;
  transition: var(--sof-transition, all 0.2s ease);
}

.sof-input-container:focus-within {
  border-color: var(--sof-primary, #e63946);
  box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.08);
}

.sof-input-container .sof-input {
  border: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  flex: 1 1 0% !important;
  width: auto !important;
  min-width: 0 !important;
  margin: 0 !important;
}

.sof-input-container .sof-input:focus {
  border: none !important;
  box-shadow: none !important;
}

.sof-input-icon {
  display: flex !important;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  min-width: 42px;
  background-color: #f6f6f7;
  color: #21374f;
  flex-shrink: 0 !important;
  flex-grow: 0 !important;
}

.sof-input-icon svg,
.sof-input-icon i {
  width: 20px;
  height: 20px;
  font-size: 20px;
  fill: currentColor;
}

/* Icon position: row = icon-left, row-reverse = icon-right */
.sof-input-container.sof-icon-left {
  flex-direction: row !important;
}

.sof-input-container.sof-icon-right {
  flex-direction: row-reverse !important;
}

/* RTL adjustments: In RTL, naturally row-reverse puts first child on left. 
   We want icon on RIGHT for icon-right, so first child (icon) on right = row.
*/
.sof-rtl .sof-input-container.sof-icon-left {
  flex-direction: row-reverse !important;
}

.sof-rtl .sof-input-container.sof-icon-right {
  flex-direction: row !important;
}

/* Error state on the container */
.sof-input-container.has-error {
  border-color: #dc2626 !important;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12) !important;
}
