/* =========================================
   CLEA FX WIDGET — COMPLETE STYLESHEET (v2.1.4)
   Original widget CSS adapted from #fx-widget (ID) scoping to
   .fx-widget (class) so multiple widgets per page work, with the
   multi-currency picker additions merged at the end.
   ORDER MATTERS: picker rules override base .fx-right constraints.
========================================= */

/* ====== Base / Layout ====== */
.fx-widget.fx-card {
  max-width: 500px;
  margin: auto;
  background: #fff;
  border: 1px solid #eee;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 4px 10px rgba(0,0,0,.08);
  overflow-x: hidden;
  box-sizing: border-box;
}

/* Override global form input styles inside the widget */
.fx-widget .fx-field input {
  border: none !important;
  outline: none;
  box-shadow: none;
  background: transparent;
}

.fx-widget .fx-stack {
  display: grid;
  gap: 16px;
  min-width: 0;
}
.fx-widget .fx-center { text-align: center; }
.fx-widget .fx-muted { color: #1f2937; opacity: .9; }

/* ====== Inputs row ====== */
.fx-widget .fx-field {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  min-width: 0;
  box-sizing: border-box;
}

.fx-widget .fx-field input {
  width: 100%;
  border: 0;
  outline: none;
  padding: 12px 16px;
  font-size: 25px;
  background: transparent;
  line-height: 1.2;
  min-width: 0;
  box-sizing: border-box;
}

/* hide number spinners if type=number ever used */
.fx-widget .fx-field input::-webkit-outer-spin-button,
.fx-widget .fx-field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.fx-widget .fx-field input[type=number] { -moz-appearance: textfield; }

/* Right cluster (flag + code, crisp) */
.fx-widget .fx-right {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-left: 1px solid #e5e7eb;
  flex: 0 0 auto;
  white-space: nowrap;
  min-width: 0;
  max-width: 120px;
}

.fx-widget .fx-flag {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  object-fit: cover;
}

.fx-widget .fx-code {
  font-size: 16px;
  color: #111827;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ====== CTA ====== */
.fx-widget .fx-cta {
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 16px;
  color: #fff;
  background: #0b5cff;
  cursor: pointer;
  box-sizing: border-box;
  min-width: 0;
}

/* No hover effect for CTA */
.fx-widget .fx-cta:hover { background: #0b5cff; color: #fff; }

/* ====== Divider title ====== */
.fx-widget .fx-divider {
  position: relative;
  text-align: center;
  margin: 6px 0 0;
  color: #9ca3af;
  font-size: 13px;
  letter-spacing: .4px;
  text-transform: uppercase;
  overflow: hidden;
  width: 100%;
  box-sizing: border-box;
}
.fx-widget .fx-divider span {
  background: #fff;
  padding: 0 12px;
  position: relative;
  z-index: 1;
  display: inline-block;
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fx-widget .fx-divider::before {
  content: "";
  position: absolute;
  left: 0; right: 0;
  top: 50%;
  height: 1px;
  background: #e5e7eb;
  z-index: 0;
}

/* ====== Savings text ====== */
.fx-widget .fx-save {
  margin-top: 4px;
  font-size: 15px;
  overflow-wrap: break-word;
  word-wrap: break-word;
}
.fx-widget .fx-save strong { font-weight: 700; color: #1865FF; }

/* ====== Compare row ====== */
.fx-widget .fx-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: center;
  min-width: 0;
}
.fx-widget .fx-item {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  align-items: center;
  min-width: 0;
}
.fx-widget .fx-icon { width: 28px; height: 28px; object-fit: contain; flex-shrink: 0; }
.fx-widget .fx-name {
  font-size: 14px;
  color: #111827;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fx-widget .fx-amount {
  font-size: 14px;
  color: #111827;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ====== Note ====== */
.fx-widget .fx-note {
  font-size: 13px;
  color: #6b7280;
  margin-top: 4px;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

/* Group wrapper for label + field */
.fx-widget .fx-group {
  display: grid;
  gap: 6px;
  min-width: 0;
}

/* Field labels */
.fx-widget .fx-label {
  font-size: 14px;
}

/* Match input look for <select> */
.fx-widget .fx-field select {
  width: 100%;
  border: 0;
  outline: none;
  padding: 17px 16px;
  font-size: 18px;
  background: transparent;
  appearance: none;
  -moz-appearance: none;
  -webkit-appearance: none;
  line-height: 1.2;
  min-width: 0;
  box-sizing: border-box;
}

/* Chevron in select cluster */
.fx-widget .fx-field select + .fx-right svg {
  width: 20px;
  height: 20px;
  stroke: #111827;
  flex-shrink: 0;
}

/* Prevent global button/select styles from leaking */
.fx-widget select { box-shadow: none; }

/* ====== Fee card ====== */
.fx-widget .fx-fee-card {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
  padding: 14px 16px;
  display: grid;
  gap: 10px;
  min-width: 0;
  box-sizing: border-box;
  overflow: hidden;
}

.fx-widget .fx-fee-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  font-size: 14px;
  color: #111827;
  min-width: 0;
}

.fx-widget .fx-fee-row-total {
  padding-top: 5px;
  font-weight: 500;
}

.fx-widget .fx-fee-label {
  opacity: .9;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.fx-widget .fx-fee-amt {
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 0;
}

.fx-widget .fx-total-amount {
  font-weight: 700;
}

/* Inline L2 savings (compact upsell) */
.fx-widget .fx-upsell {
  margin: 8px 0 0;
  font-size: 13px;
  color: #065f46;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  padding: 8px 10px;
  border-radius: 8px;
  overflow-wrap: break-word;
  word-wrap: break-word;
  box-sizing: border-box;
}
.fx-widget .fx-upsell strong { font-weight: 700; }

/* Make the select the clickable layer */
.fx-widget .fx-field select { position: relative; z-index: 2; }
/* Let taps pass through the chevron container */
.fx-widget .fx-field .fx-right,
.fx-widget .fx-field .fx-right svg { pointer-events: none; }

/* ====== Responsive tweaks ====== */
@media (max-width: 768px) {
  .fx-widget.fx-card {
    padding: 16px;
    margin: 8px;
    max-width: calc(100vw - 16px);
  }

  .fx-widget .fx-field input,
  .fx-widget .fx-field select {
    font-size: 18px;
    padding: 10px 12px;
  }

  .fx-widget .fx-right {
    padding: 10px 12px;
    gap: 8px;
    max-width: 100px;
  }

  .fx-widget .fx-code {
    font-size: 14px;
  }

  /* Prevent iOS auto-zoom/auto-scaling */
  .fx-widget { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

  .fx-widget .fx-field select {
    font-size: 16px !important;
    padding: 10px 12px;
    line-height: 1.2;
  }

  .fx-widget .fx-field select option,
  .fx-widget .fx-field select optgroup {
    font-size: 16px !important;
    line-height: 1.2 !important;
  }
}

/* Even tighter on very small screens if needed */
@media (max-width: 420px) {
  .fx-widget.fx-card {
    padding: 12px;
    margin: 4px;
  }

  .fx-widget .fx-field select {
    font-size: 16px !important;
    padding: 10px 12px;
  }
  .fx-widget .fx-field select option,
  .fx-widget .fx-field select optgroup {
    font-size: 16px !important;
  }

  .fx-widget .fx-right {
    max-width: 80px;
    padding: 8px 10px;
  }
}

/* =========================================
   MULTI-CURRENCY PICKER — must come AFTER the base rules above.
   The .fx-field .fx-right.fx-ccy compound out-specifies the base
   .fx-right constraints (pointer-events: none, max-width, ellipsis).
========================================= */

.fx-widget .fx-field .fx-right.fx-ccy {
  position: relative;
  pointer-events: auto;   /* re-enable clicks (base sets none for the chevron) */
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  white-space: nowrap;
  max-width: none;        /* undo base 120px/100px/80px caps */
  overflow: visible;
}

.fx-widget .fx-field .fx-right.fx-ccy svg {
  pointer-events: none;   /* caret stays decorative */
}

.fx-widget .fx-field .fx-right.fx-ccy .fx-flag {
  flex: 0 0 20px;
}

.fx-widget .fx-field .fx-right.fx-ccy .fx-code {
  max-width: none;
  overflow: visible;
  text-overflow: clip;    /* kills the "U..." ellipsis on mobile */
}

.fx-widget .fx-field .fx-right.fx-ccy .fx-ccy-caret {
  flex: 0 0 auto;
}

.fx-widget .fx-field .fx-right.fx-ccy .fx-ccy-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  border: 0;
  margin: 0;
  padding: 0;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  pointer-events: auto;
  font-size: 16px;        /* prevents iOS auto-zoom when tapped */
  z-index: 3;             /* above the base select z-index: 2 */
}

/* Keep the picker cluster width caps lifted at all breakpoints */
@media (max-width: 768px) {
  .fx-widget .fx-field .fx-right.fx-ccy {
    max-width: none;
  }
}
@media (max-width: 420px) {
  .fx-widget .fx-field .fx-right.fx-ccy {
    max-width: none;
  }
}

/* Single-currency corridor pages: picker locked, reads as a static label */
.fx-widget .fx-field .fx-right.fx-ccy.fx-ccy-locked {
  cursor: default;
  pointer-events: none;
}

.fx-widget .fx-field .fx-right.fx-ccy.fx-ccy-locked .fx-ccy-caret,
.fx-widget .fx-field .fx-right.fx-ccy.fx-ccy-locked .fx-ccy-overlay {
  display: none;
}

/* Single-method corridor pages: JS disables the select; keep it readable */
.fx-widget .fx-field select.fx-method:disabled {
  opacity: 1;
  -webkit-text-fill-color: currentColor;
  color: #111827;
  cursor: default;
}

.fx-widget .fx-field select.fx-method:disabled + .fx-right {
  display: none;
}

/* =========================================
   CUSTOM CURRENCY DROPDOWN PANEL
   Replaces the native select sheet with a styled list:
   flag + code + currency name, check on the selected row.
   The native select is kept hidden as the value holder.
========================================= */

.fx-widget .fx-group {
  position: relative;   /* anchor for the panel */
}

.fx-widget .fx-ccy-native {
  display: none !important;
}

.fx-widget .fx-ccy-panel {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 270px;
  max-width: 100%;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(17, 24, 39, 0.16);
  padding: 6px;
  z-index: 60;
  box-sizing: border-box;
}

.fx-widget .fx-ccy-panel.is-open {
  display: block;
}

.fx-widget .fx-ccy-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  cursor: pointer;
  min-width: 0;
}

.fx-widget .fx-ccy-option:hover {
  background: #f3f4f6;
}

.fx-widget .fx-ccy-option .fx-ccy-opt-flag {
  width: 24px;
  height: 18px;
  border-radius: 3px;
  object-fit: cover;
  flex: 0 0 24px;
  display: block;
}

.fx-widget .fx-ccy-option .fx-ccy-opt-code {
  font-size: 16px;
  font-weight: 400;
  color: #111827;
  flex: 0 0 auto;
}

.fx-widget .fx-ccy-option .fx-ccy-opt-name {
  font-size: 14px;
  color: #6b7280;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fx-widget .fx-ccy-option .fx-ccy-opt-check {
  color: #0b5cff;
  flex: 0 0 auto;
  visibility: hidden;
}

.fx-widget .fx-ccy-option.is-selected .fx-ccy-opt-check {
  visibility: visible;
}

/* Full-width panel on small screens for comfortable tap targets */
@media (max-width: 480px) {
  .fx-widget .fx-ccy-panel {
    left: 0;
    right: 0;
    min-width: 0;
  }
}

/* Flip the panel above the field when there's no room below */
.fx-widget .fx-ccy-panel.fx-ccy-panel-up {
  top: auto;
  bottom: calc(100% + 8px);
}

/* =========================================
   HORIZONTAL TEMPLATE (design phase — not yet wired to shortcode)
   Activated by adding the fx-widget--horizontal class to the root
========================================= */

.fx-widget--horizontal.fx-card {
  max-width: 720px;
}

@media (min-width: 720px) {

  .fx-widget--horizontal .fx-stack {
    grid-template-columns: 1fr 1fr;
    column-gap: 16px;
  }

  /* Everything spans both columns by default... */
  .fx-widget--horizontal .fx-stack > * {
    grid-column: 1 / -1;
  }

  /* ...except the first two groups (send, convert) which pair up */
  .fx-widget--horizontal .fx-stack > .fx-group:nth-child(1) {
    grid-column: 1;
  }
  .fx-widget--horizontal .fx-stack > .fx-group:nth-child(2) {
    grid-column: 2;
  }

  /* Half-width fields: slightly smaller amount text so large
     figures fit beside the currency cluster */
  .fx-widget--horizontal .fx-field input {
    font-size: 22px;
  }
}