/* ============================================
   Codflow COD Form — Production Styles
   ============================================ */

:root {
  --codflow-primary: #000000;
  --codflow-primary-hover: #222222;
  --codflow-bg: #ffffff;
  --codflow-surface: #f8f9fa;
  --codflow-border: #e2e6ea;
  --codflow-text: #1a1a2e;
  --codflow-text-muted: #6c757d;
  --codflow-error: #dc3545;
  --codflow-success: #00c896;
  --codflow-radius: 8px;
  --codflow-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

/* ============= FORM CONTAINER ============= */
.codflow-form {
  font-family: var(--codflow-font);
  max-width: 480px;
  margin: 0 auto;
  padding: 24px;
  background: var(--codflow-bg);
  border: 1px solid var(--codflow-border);
  border-radius: calc(var(--codflow-radius) + 4px);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.03);
}

/* Inside popup — no extra border/shadow */
.codflow-form--popup {
  border: none;
  box-shadow: none;
  border-radius: 0;
  max-width: none;
  padding: 0 20px 20px;
}

/* ============= TOP BAR ============= */
.codflow-form__topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 0;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--codflow-border);
  font-size: 15px;
  font-weight: 700;
  color: var(--codflow-text);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  position: relative;
}

.codflow-form--popup .codflow-form__topbar {
  padding: 20px 40px 16px 0;
}

/* ============= PRODUCT ============= */
.codflow-form__product {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  margin-bottom: 14px;
  background: var(--codflow-surface);
  border: 1px solid var(--codflow-border);
  border-radius: var(--codflow-radius);
}

.codflow-form__product-img-wrap {
  position: relative;
  flex-shrink: 0;
}

.codflow-form__product-img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: var(--codflow-radius);
  border: 1px solid var(--codflow-border);
}

.codflow-form__product-info {
  flex: 1;
  min-width: 0;
}

.codflow-form__product-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--codflow-text);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.codflow-form__product-price {
  font-size: 16px;
  font-weight: 700;
  color: var(--codflow-text);
  margin-top: 4px;
}

/* ============= TITLE ============= */
.codflow-form__title {
  font-size: 17px;
  font-weight: 700;
  color: var(--codflow-text);
  margin: 0 0 18px 0;
  text-align: center;
  letter-spacing: -0.01em;
}

/* ============= FIELDS ============= */
.codflow-form__fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.codflow-form__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.codflow-form__field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ============= LABEL ============= */
.codflow-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--codflow-text);
  letter-spacing: 0.01em;
}

/* ============= INPUTS ============= */
.codflow-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 15px;
  font-family: var(--codflow-font);
  color: var(--codflow-text);
  background: var(--codflow-surface);
  border: 1.5px solid var(--codflow-border);
  border-radius: var(--codflow-radius);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
  -webkit-appearance: none;
}

.codflow-input:focus {
  border-color: var(--codflow-primary, #000);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--codflow-primary, #000) 10%, transparent);
  background: var(--codflow-bg);
}

.codflow-input::placeholder {
  color: var(--codflow-text-muted);
}

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

/* ============= INPUT GROUP (phone prefix) ============= */
.codflow-input-group {
  display: flex;
  align-items: stretch;
  border: 1.5px solid var(--codflow-border);
  border-radius: var(--codflow-radius);
  background: var(--codflow-surface);
  position: relative;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.codflow-input-group:focus-within {
  border-color: var(--codflow-primary, #000);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--codflow-primary, #000) 10%, transparent);
  background: var(--codflow-bg);
}

.codflow-input-prefix {
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-size: 15px;
  font-weight: 500;
  color: var(--codflow-text-muted);
  background: rgba(0, 0, 0, 0.03);
  border-right: 1px solid var(--codflow-border);
  white-space: nowrap;
}

/* Phone prefix dropdown button */
button.codflow-input-prefix {
  border: none;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}
button.codflow-input-prefix:hover {
  background: rgba(0, 0, 0, 0.06);
}

/* Ensure rounded corners on group edges */
.codflow-input-group > :first-child {
  border-radius: calc(var(--codflow-radius) - 1px) 0 0 calc(var(--codflow-radius) - 1px);
}
.codflow-input-group > :last-child {
  border-radius: 0 calc(var(--codflow-radius) - 1px) calc(var(--codflow-radius) - 1px) 0;
}

.codflow-prefix-select {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  background: #f8f9fa;
  border-right: 1px solid var(--codflow-border);
  padding: 0 12px;
  font-size: 14px;
  font-family: var(--codflow-font);
  min-width: 80px;
  cursor: pointer;
  border-radius: 8px 0 0 8px;
  color: var(--codflow-text);
  outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%236c757d' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  padding-right: 20px;
}

.codflow-prefix-select:focus {
  background: #eef0f3;
}

.codflow-input--prefixed {
  border: none;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
}

.codflow-input--prefixed:focus {
  border: none;
  box-shadow: none;
}

/* ============= TEXTAREA ============= */
.codflow-textarea {
  resize: vertical;
  min-height: 48px;
}

/* ============= BUTTONS ============= */
.codflow-btn {
  display: block;
  width: 100%;
  padding: 13px 20px;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--codflow-font);
  border: none;
  border-radius: var(--codflow-radius);
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
  letter-spacing: 0.01em;
  text-align: center;
  line-height: 1.3;
}

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

.codflow-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.codflow-btn--primary {
  background: var(--codflow-primary, #000);
  color: #ffffff;
  margin-top: 16px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.codflow-btn--primary:hover:not(:disabled) {
  opacity: 0.9;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}

.codflow-btn--secondary {
  background: var(--codflow-surface);
  color: var(--codflow-text);
  border: 1.5px solid var(--codflow-border);
  margin-top: 8px;
}

.codflow-btn--secondary:hover:not(:disabled) {
  background: var(--codflow-border);
}

/* ============= ERROR & MESSAGES ============= */
.codflow-form__error {
  background: #fff5f5;
  color: var(--codflow-error);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 14px;
  border-radius: var(--codflow-radius);
  border: 1px solid #fecdd3;
  margin-top: 12px;
  text-align: center;
}

.codflow-form__msg {
  font-size: 13px;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: var(--codflow-radius);
  margin-top: 8px;
  text-align: center;
}

.codflow-form__msg--success {
  background: #f0fdf9;
  color: var(--codflow-success);
  border: 1px solid #bbf7d0;
}

.codflow-form__msg--error {
  background: #fff5f5;
  color: var(--codflow-error);
  border: 1px solid #fecdd3;
}

/* ============= URGENCY ============= */
.codflow-urgency {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  background: #FEF3C7;
  border: 1px solid #FDE68A;
  border-radius: var(--codflow-radius);
  margin-bottom: 12px;
  font-size: 12px;
  color: #92400E;
}

.codflow-urgency__timer {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 500;
}

.codflow-urgency__timer strong {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.codflow-urgency__social {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 500;
  font-size: 11px;
}

.codflow-urgency__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #00C896;
  animation: codflow-pulse 2s ease-in-out infinite;
}

@keyframes codflow-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

/* ============= TRUST BADGES ============= */
.codflow-trust {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 12px 0;
  margin-top: 12px;
  border-top: 1px solid var(--codflow-border);
}

.codflow-trust__item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--codflow-text-muted);
}

/* ============= FOOTER ============= */
.codflow-form__footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--codflow-text-muted);
  opacity: 0.5;
}

/* ============= THANK YOU ============= */
.codflow-thankyou {
  text-align: center;
  padding: 32px 20px;
}

.codflow-thankyou__icon {
  margin-bottom: 16px;
}

.codflow-thankyou__title {
  font-size: 22px;
  font-weight: 700;
  color: var(--codflow-text);
  margin: 0 0 8px 0;
}

.codflow-thankyou__msg {
  font-size: 15px;
  color: var(--codflow-text-muted);
  margin: 0 0 12px 0;
  line-height: 1.5;
}

.codflow-thankyou__order {
  font-size: 14px;
  color: var(--codflow-text);
  margin: 0;
}

/* ============= UPSELL ============= */
.codflow-upsell {
  margin-top: 20px;
  padding: 20px;
  background: linear-gradient(135deg, #fef9e7 0%, #fef3c7 100%);
  border: 1px solid #fde68a;
  border-radius: calc(var(--codflow-radius) + 2px);
  text-align: center;
}

.codflow-upsell__title {
  font-size: 17px;
  font-weight: 700;
  color: var(--codflow-text);
  margin: 0 0 6px 0;
}

.codflow-upsell__desc {
  font-size: 14px;
  color: var(--codflow-text-muted);
  margin: 0 0 12px 0;
}

.codflow-upsell__discount {
  display: inline-block;
  background: var(--codflow-error);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 14px;
}

.codflow-upsell__success {
  font-size: 15px;
  font-weight: 600;
  color: var(--codflow-success);
  padding: 12px 0;
  margin: 0;
}

/* ============= POPUP OVERLAY ============= */
.codflow-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: codflow-fadeIn 0.2s ease;
  overflow-y: auto;
}

.codflow-popup {
  position: relative;
  background: var(--codflow-bg);
  border-radius: calc(var(--codflow-radius) + 6px);
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.05);
  animation: codflow-slideUp 0.3s ease;
  padding: 0;
}

.codflow-popup__close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--codflow-surface);
  border: 1px solid var(--codflow-border);
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  color: var(--codflow-text);
  cursor: pointer;
  transition: background 0.15s ease;
}

.codflow-popup__close:hover {
  background: var(--codflow-border);
  color: var(--codflow-text);
}

/* ============= FLOATING ACTION BUTTON ============= */
.codflow-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 22px;
  background: var(--codflow-primary);
  color: #ffffff;
  font-family: var(--codflow-font);
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2), 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  animation: codflow-fadeIn 0.4s ease;
}

.codflow-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25), 0 2px 8px rgba(0, 0, 0, 0.12);
}

.codflow-fab:active {
  transform: translateY(0);
}

/* ============= ANIMATIONS ============= */
@keyframes codflow-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes codflow-fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes codflow-slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============= RESPONSIVE ============= */
@media (max-width: 600px) {
  .codflow-form {
    padding: 18px 16px;
    border-radius: var(--codflow-radius);
  }

  .codflow-form__row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .codflow-form__product-img {
    width: 52px;
    height: 52px;
  }

  .codflow-form__title {
    font-size: 15px;
  }

  .codflow-input {
    font-size: 16px; /* Prevent iOS zoom */
    padding: 11px 12px;
  }

  .codflow-prefix-select {
    font-size: 16px; /* Prevent iOS zoom */
    min-width: 76px;
  }

  .codflow-btn {
    font-size: 15px;
    padding: 14px 16px;
  }

  .codflow-popup {
    max-height: 95vh;
    border-radius: var(--codflow-radius);
    margin: 8px;
    padding: 4px;
  }

  .codflow-popup-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .codflow-fab {
    bottom: 16px;
    right: 16px;
    padding: 12px 18px;
    font-size: 13px;
  }

  .codflow-thankyou {
    padding: 24px 16px;
  }

  .codflow-thankyou__title {
    font-size: 19px;
  }
}

/* ============= ORDER SUMMARY ============= */
.codflow-summary {
  padding: 14px 16px;
  background: var(--codflow-surface);
  border: 1px solid var(--codflow-border);
  border-radius: var(--codflow-radius);
  margin-bottom: 16px;
}

.codflow-summary__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--codflow-text-muted);
  padding: 3px 0;
}

.codflow-summary__discount {
  color: #00C896;
}

.codflow-summary__total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 16px;
  font-weight: 700;
  color: var(--codflow-text);
  padding-top: 8px;
  margin-top: 8px;
  border-top: 1px solid var(--codflow-border);
}

/* ============= SECTION LABELS ============= */
.codflow-section-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--codflow-text);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--codflow-border);
}

/* ============= SHIPPING METHOD ============= */
.codflow-shipping-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1.5px solid var(--codflow-border);
  border-radius: var(--codflow-radius);
  margin-bottom: 14px;
  background: var(--codflow-bg);
}

.codflow-shipping-option--active {
  border-color: var(--codflow-primary, #000);
}

.codflow-shipping-option__radio {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--codflow-primary, #000);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}

.codflow-shipping-option--active .codflow-shipping-option__radio::after {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--codflow-primary, #000);
}

.codflow-shipping-option__info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.codflow-shipping-option__name {
  font-size: 14px;
  font-weight: 600;
  color: var(--codflow-text);
}

.codflow-shipping-option__desc {
  font-size: 12px;
  color: var(--codflow-text-muted);
}

.codflow-shipping-option__price {
  font-size: 14px;
  font-weight: 600;
  color: var(--codflow-text);
  white-space: nowrap;
}

/* ============= SHIPPING BLOCKED ============= */
.codflow-shipping--blocked {
  background: #fff5f5;
  color: var(--codflow-error);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 14px;
  border-radius: var(--codflow-radius);
  border: 1px solid #fecdd3;
  text-align: center;
  margin-bottom: 12px;
}

/* ============= FORM INLINE CLOSE ============= */
.codflow-form__close {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--codflow-text);
  border: none;
  font-size: 18px;
  color: #fff;
  cursor: pointer;
  border-radius: 50%;
  transition: opacity 0.15s;
  line-height: 1;
}

.codflow-form__close:hover {
  opacity: 0.8;
}

/* ============= PROVINCE SEARCHABLE DROPDOWN ============= */
.codflow-province-wrap {
  position: relative;
}

.codflow-province-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 100;
  max-height: 200px;
  overflow-y: auto;
  background: var(--codflow-bg);
  border: 1.5px solid var(--codflow-primary, #000);
  border-top: none;
  border-radius: 0 0 var(--codflow-radius) var(--codflow-radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.codflow-province-item {
  padding: 9px 12px;
  font-size: 14px;
  color: var(--codflow-text);
  cursor: pointer;
  transition: background 0.1s;
}

.codflow-province-item:hover {
  background: var(--codflow-surface);
}

/* Quantity/Bundle Offers */
.codflow-offers { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.codflow-offer { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border: 2px solid rgba(0,0,0,0.08); border-radius: 10px; cursor: pointer; transition: all 0.2s; background: #fff; }
.codflow-offer:hover { border-color: rgba(0,0,0,0.15); }
.codflow-offer input[type="radio"] { width: 18px; height: 18px; flex-shrink: 0; }
.codflow-offer__info { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.codflow-offer__title { font-size: 13px; font-weight: 700; color: #08071E; }
.codflow-offer__price { font-size: 13px; color: #08071E; }
.codflow-offer__badge { font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; padding: 3px 8px; border-radius: 6px; color: #fff; white-space: nowrap; flex-shrink: 0; }
