/* ============================================================
   Express COD Checkout — Frontend Styles
   Mobile-first, CSS custom properties, RTL-ready
   ============================================================ */

/* ── Variables & Reset ────────────────────────────────────── */
.ecc-wrapper {
  --ecc-primary:        #e63946;
  --ecc-hover:          #e63946;   /* couleur de survol — configurable depuis les paramètres */
  --ecc-border:         #e0e0e0;
  --ecc-wa:             #25d366;
  --ecc-radius:         12px;
  --ecc-radius-sm:      8px;
  --ecc-shadow:         0 2px 12px rgba(0,0,0,.08);
  --ecc-shadow-hover:   0 4px 20px rgba(0,0,0,.14);
  --ecc-font:           -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --ecc-text:           #1a1a2e;
  --ecc-muted:          #6b7280;
  --ecc-bg:             #ffffff;
  --ecc-bg-alt:         #f9fafb;
  --ecc-active-bg:      color-mix(in srgb, var(--ecc-hover) 12%, white);
  --ecc-active-border:  var(--ecc-hover);
  --ecc-badge-bg:       var(--ecc-primary);
  --ecc-success:        #10b981;
  --ecc-error:          #ef4444;
  --ecc-transition:     .2s ease;

  box-sizing: border-box;
  font-family: var(--ecc-font);
  color: var(--ecc-text);
  background: var(--ecc-bg);
  border: 1px solid var(--ecc-border);
  border-radius: var(--ecc-radius);
  padding: 20px;
  max-width: 520px;
  box-shadow: var(--ecc-shadow);
  width: 100%;
}

.ecc-wrapper *, .ecc-wrapper *::before, .ecc-wrapper *::after {
  box-sizing: border-box;
}

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

/* ── Section ──────────────────────────────────────────────── */
.ecc-section {
  margin-bottom: 20px;
}

.ecc-section-title {
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ecc-muted);
  margin: 0 0 10px;
}

/* ── Card grid ────────────────────────────────────────────── */
.ecc-card-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ── Card base (variants + qty) ───────────────────────────── */
.ecc-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex: 1 1 auto;
  min-width: 80px;
  padding: 12px 10px;
  background: var(--ecc-bg-alt);
  border: 2px solid var(--ecc-border);
  border-radius: var(--ecc-radius-sm);
  cursor: pointer;
  text-align: center;
  font-family: var(--ecc-font);
  transition:
    border-color var(--ecc-transition),
    background   var(--ecc-transition),
    box-shadow   var(--ecc-transition),
    transform    var(--ecc-transition);
  outline: none;
  line-height: 1.3;
  overflow: visible;
}

.ecc-card:hover:not(.is-disabled) {
  border-color: var(--ecc-hover);
  background: color-mix(in srgb, var(--ecc-hover) 6%, white);
  box-shadow: var(--ecc-shadow-hover);
  transform: translateY(-2px);
}

.ecc-card.is-active {
  background: var(--ecc-active-bg);
  border-color: var(--ecc-active-border);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ecc-hover) 25%, transparent);
}

.ecc-card.is-active .ecc-card-name,
.ecc-card.is-active .ecc-qty-num {
  color: var(--ecc-hover);
}

.ecc-card.is-disabled {
  opacity: .45;
  cursor: not-allowed;
  pointer-events: none;
}

/* Active checkmark */
.ecc-card.is-active::after {
  content: '✓';
  position: absolute;
  top: -8px;
  right: -8px;
  width: 20px;
  height: 20px;
  background: var(--ecc-hover);
  color: #fff;
  font-size: .65rem;
  font-weight: 900;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 20px;
}

.ecc-rtl .ecc-card.is-active::after {
  right: auto;
  left: -8px;
}

/* ── Variant image ────────────────────────────────────────── */
.ecc-card-img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
  pointer-events: none;
  transition: transform var(--ecc-transition), opacity var(--ecc-transition);
}

.ecc-card:hover:not(.is-disabled) .ecc-card-img {
  transform: scale(1.06);
}

.ecc-card.is-disabled .ecc-card-img {
  opacity: .4;
  filter: grayscale(1);
}

/* ── Variant card ─────────────────────────────────────────── */
.ecc-card-name {
  font-size: .875rem;
  font-weight: 600;
  color: var(--ecc-text);
  transition: color var(--ecc-transition);
}

.ecc-card-price {
  font-size: .78rem;
  color: var(--ecc-muted);
  font-weight: 500;
}

/* ── Quantity card ────────────────────────────────────────── */
.ecc-qty-num {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--ecc-text);
  line-height: 1;
  transition: color var(--ecc-transition);
}

.ecc-qty-unit {
  font-size: .72rem;
  color: var(--ecc-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.ecc-qty-sublabel {
  font-size: .7rem;
  color: var(--ecc-primary);
  font-weight: 600;
}

/* ── Promo badge ──────────────────────────────────────────── */
.ecc-promo-badge {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ecc-badge-bg);
  color: #fff;
  font-size: .62rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
  line-height: 1.6;
}

/* ── Save tag ─────────────────────────────────────────────── */
.ecc-save-tag {
  font-size: .72rem;
  font-weight: 700;
  color: var(--ecc-primary);
  background: color-mix(in srgb, var(--ecc-primary) 10%, white);
  border-radius: 4px;
  padding: 1px 5px;
}

/* ── Form fields ──────────────────────────────────────────── */
.ecc-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ecc-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ecc-label {
  font-size: .825rem;
  font-weight: 600;
  color: var(--ecc-text);
}

.ecc-req {
  color: var(--ecc-primary);
  margin-inline-start: 2px;
}

.ecc-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--ecc-border);
  border-radius: var(--ecc-radius-sm);
  font-size: .9rem;
  font-family: var(--ecc-font);
  color: var(--ecc-text);
  background: var(--ecc-bg);
  transition: border-color var(--ecc-transition), box-shadow var(--ecc-transition);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.ecc-input:focus {
  border-color: var(--ecc-hover);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ecc-hover) 20%, transparent);
}

.ecc-input::placeholder {
  color: #b0b5c0;
}

/* RTL input direction for arabic */
.ecc-rtl .ecc-input {
  text-align: right;
}

/* ── Price summary ────────────────────────────────────────── */
.ecc-summary {
  background: var(--ecc-bg-alt);
  border: 1px solid var(--ecc-border);
  border-radius: var(--ecc-radius-sm);
  padding: 14px 16px;
  margin-bottom: 18px;
}

.ecc-summary-row,
.ecc-savings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ecc-savings-row {
  margin-top: 6px;
}

.ecc-summary-label {
  font-size: .82rem;
  color: var(--ecc-muted);
  font-weight: 500;
}

.ecc-savings-label {
  color: var(--ecc-success);
}

.ecc-total-display {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--ecc-primary);
  letter-spacing: -.02em;
}

.ecc-savings-display {
  font-size: .875rem;
  font-weight: 700;
  color: var(--ecc-success);
}

/* ── Action buttons ───────────────────────────────────────── */
.ecc-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ecc-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 20px;
  border: none;
  border-radius: var(--ecc-radius-sm);
  font-size: .95rem;
  font-weight: 700;
  font-family: var(--ecc-font);
  cursor: pointer;
  transition:
    background     var(--ecc-transition),
    transform      var(--ecc-transition),
    box-shadow     var(--ecc-transition),
    opacity        var(--ecc-transition);
  outline: none;
  position: relative;
  overflow: hidden;
  letter-spacing: .01em;
}

.ecc-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.12);
  opacity: 0;
  transition: opacity var(--ecc-transition);
}

.ecc-btn:hover::before {
  opacity: 1;
}

.ecc-btn:active {
  transform: scale(.97);
}

.ecc-btn:disabled {
  opacity: .7;
  cursor: not-allowed;
  transform: none;
}

.ecc-btn-order {
  background: var(--ecc-primary);
  color: #fff;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--ecc-primary) 45%, transparent);
}

.ecc-btn-order:hover:not(:disabled) {
  box-shadow: 0 6px 20px color-mix(in srgb, var(--ecc-primary) 55%, transparent);
  transform: translateY(-1px);
}

.ecc-btn-whatsapp {
  background: var(--ecc-wa);
  color: #fff;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--ecc-wa) 40%, transparent);
}

.ecc-btn-whatsapp:hover:not(:disabled) {
  box-shadow: 0 6px 20px color-mix(in srgb, var(--ecc-wa) 50%, transparent);
  transform: translateY(-1px);
}

.ecc-btn-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.ecc-btn-label {
  flex: 1;
  text-align: center;
}

/* ── Spinner ──────────────────────────────────────────────── */
.ecc-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: ecc-spin .65s linear infinite;
}

@keyframes ecc-spin {
  to { transform: rotate(360deg); }
}

/* ── Alert message ────────────────────────────────────────── */
.ecc-alert {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: var(--ecc-radius-sm);
  font-size: .875rem;
  font-weight: 600;
  text-align: center;
  animation: ecc-fadein .25s ease;
}

.ecc-alert.is-success {
  background: color-mix(in srgb, var(--ecc-success) 12%, white);
  color: var(--ecc-success);
  border: 1px solid color-mix(in srgb, var(--ecc-success) 30%, white);
}

.ecc-alert.is-error {
  background: color-mix(in srgb, var(--ecc-error) 10%, white);
  color: var(--ecc-error);
  border: 1px solid color-mix(in srgb, var(--ecc-error) 25%, white);
}

@keyframes ecc-fadein {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Card click animation ─────────────────────────────────── */
@keyframes ecc-pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ecc-primary) 50%, transparent); }
  60%  { box-shadow: 0 0 0 8px color-mix(in srgb, var(--ecc-primary) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.ecc-card.is-active {
  animation: ecc-pulse .35s ease;
}

/* ── Honeypot — complètement hors écran, invisible ───────── */
.ecc-hp-wrap {
  position: absolute;
  left: -9999px;
  top: -9999px;
  width: 0;
  height: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  tab-index: -1;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 400px) {
  .ecc-wrapper { padding: 14px; }
  .ecc-total-display { font-size: 1.2rem; }
  .ecc-qty-num { font-size: 1.3rem; }
  .ecc-btn { padding: 12px 16px; font-size: .88rem; }
}
