/* =========================================================
   Currency Exchange Calculator — Component Styles Only
   Global variables, reset, layout, buttons live in
   assets/css/style.css
   ========================================================= */

/* ── Converter card ── */
.fx-converter-card {
  max-width: 720px;
  margin: 0 auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 30px;
  box-shadow: 0 24px 60px -30px rgba(0, 0, 0, 0.45);
}

.fx-card-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 26px;
  flex-wrap: wrap;
}

.fx-card-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
}

.fx-bank-pick {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.fx-bank-pick label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

/* ── Bank picker (custom dropdown) ── */
.fx-bank-dd {
  position: relative;
  min-width: 230px;
}

/* Visually-hidden native select that backs every custom combo. */
.fx-combo-native {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
}

.fx-bank-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  font-family: inherit;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-primary);
  background:
    linear-gradient(var(--bg-surface), var(--bg-surface)) padding-box,
    linear-gradient(135deg, var(--primary), var(--secondary, var(--primary))) border-box;
  border: 1.5px solid transparent;
  border-radius: var(--radius-md);
  padding: 11px 14px;
  cursor: pointer;
  box-shadow: 0 6px 18px -12px var(--primary-glow, rgba(0, 0, 0, 0.4));
  transition: box-shadow var(--ease), transform var(--ease);
}

.fx-bank-trigger:hover {
  box-shadow: 0 10px 24px -12px var(--primary-glow, rgba(0, 0, 0, 0.45));
  transform: translateY(-1px);
}

.fx-bank-trigger:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--primary-glow);
}

.fx-bank-trigger-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.fx-bank-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fx-bank-logo {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
}

.fx-bank-logo--fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 800;
  color: #fff;
  background: var(--primary);
}

.fx-bank-caret {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--primary);
  border-bottom: 2px solid var(--primary);
  transform: translateY(-2px) rotate(45deg);
  transition: transform var(--ease);
}

.fx-bank-trigger[aria-expanded="true"] .fx-bank-caret {
  transform: translateY(2px) rotate(225deg);
}

.fx-bank-menu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 8px);
  right: 0;
  left: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 24px 50px -20px rgba(0, 0, 0, 0.5);
  max-height: 320px;
  overflow-y: auto;
}

.fx-bank-menu[hidden] { display: none; }

.fx-bank-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--ease);
}

.fx-bank-option > [data-combo-label] { flex: 1; min-width: 0; }
.fx-bank-option .fx-bank-name { flex: 1; }

.fx-bank-option:hover,
.fx-bank-option.is-active {
  background: var(--bg-row-hover, var(--bg-surface));
}

.fx-bank-option.is-selected { font-weight: 700; }

.fx-bank-check {
  flex-shrink: 0;
  color: var(--primary);
  font-weight: 800;
  opacity: 0;
}

.fx-bank-option.is-selected .fx-bank-check { opacity: 1; }

/* ── Converter rows + swap ── */
.fx-converter {
  display: flex;
  flex-direction: column;
}

.fx-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
}

.fx-amount {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  padding: 8px 4px;
  -moz-appearance: textfield;
}

.fx-amount::-webkit-outer-spin-button,
.fx-amount::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.fx-amount:focus { outline: none; }

.fx-amount::placeholder { color: var(--text-muted); font-weight: 600; }

/* ── Currency selector (custom dropdown inside the converter row) ── */
.fx-combo { position: relative; }
.fx-combo--cur { flex-shrink: 0; }

.fx-combo--cur .fx-combo-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  cursor: pointer;
  transition: background var(--ease);
}

.fx-combo--cur .fx-combo-trigger:hover { background: var(--bg-row-hover); }

.fx-combo--cur .fx-combo-trigger:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.fx-combo-current,
.fx-combo-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.fx-combo-logo {
  display: inline-block;
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  object-fit: contain;
  border-radius: 4px;
}

.fx-combo-flag { font-size: 1.2rem; line-height: 1; }

.fx-combo-code { font-weight: 700; }

.fx-combo--cur .fx-combo-caret {
  flex-shrink: 0;
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--text-secondary);
  border-bottom: 2px solid var(--text-secondary);
  transform: translateY(-2px) rotate(45deg);
  transition: transform var(--ease);
}

.fx-combo--cur .fx-combo-trigger[aria-expanded="true"] .fx-combo-caret {
  transform: translateY(2px) rotate(225deg);
}

.fx-combo--cur .fx-combo-menu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 8px);
  right: 0;
  min-width: 240px;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 24px 50px -20px rgba(0, 0, 0, 0.5);
  max-height: 320px;
  overflow-y: auto;
}

.fx-combo--cur .fx-combo-menu[hidden] { display: none; }

.fx-combo-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--ease);
}

.fx-combo-name {
  flex: 1;
  color: var(--text-secondary);
  font-size: 0.85rem;
  white-space: nowrap;
}

.fx-combo-option:hover,
.fx-combo-option.is-active { background: var(--bg-row-hover, var(--bg-surface)); }

/* Currency not published by the selected bank — locked. */
.fx-combo-option.is-disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.fx-combo-option.is-selected .fx-combo-code { color: var(--primary); }

.fx-combo-check {
  flex-shrink: 0;
  color: var(--primary);
  font-weight: 800;
  opacity: 0;
}

.fx-combo-option.is-selected .fx-combo-check { opacity: 1; }

.fx-swap {
  align-self: center;
  margin: -14px 0;
  z-index: 2;
  width: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  border: 3px solid var(--bg-card);
  border-radius: var(--radius-full);
  cursor: pointer;
  box-shadow: var(--shadow-primary);
  transition: transform var(--ease), background var(--ease);
}

.fx-swap:hover { background: var(--primary-dark); transform: rotate(180deg); }
.fx-swap:focus-visible { outline: 2px solid var(--secondary); outline-offset: 2px; }

/* ── Rates section ── */
.fx-rates {
  max-width: 1000px;
  margin: 0 auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
}

.fx-rates-head {
  display: flex;
  align-items: center;
  gap: 16px 20px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.fx-rates-title {
  font-size: clamp(1.4rem, 3vw, 1.9rem);
  font-weight: 800;
  margin: 0;
}

.fx-toggle {
  margin-left: auto;
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
}

.fx-toggle-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  padding: 7px 20px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--ease), color var(--ease);
}

.fx-toggle-btn.is-active {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-primary);
}

/* ── Rates table ── */
.fx-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.fx-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.fx-table th,
.fx-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  text-align: center;
  font-size: 0.95rem;
}

.fx-table thead th {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-secondary);
  background: var(--bg-surface);
}

.fx-table tbody tr:last-child td { border-bottom: none; }
.fx-table tbody tr:hover td { background: var(--bg-row-hover); }

/* Soft vertical separators between the currency columns */
.fx-th-cur,
.fx-val-cell { border-left: 1px solid var(--border); }

/* Currency column headers: logo beside code */
.fx-th-cur {
  min-width: 132px;
  white-space: nowrap;
}

.fx-cur-logo {
  display: inline-block;
  width: 22px;
  height: 22px;
  margin-right: 7px;
  object-fit: contain;
  border-radius: 4px;
  vertical-align: middle;
}

.fx-th-code { vertical-align: middle; }

/* Sticky bank column (first). A definite min-width reliably widens the column
   (sticky cells don't always contribute their content width), padding-right
   guarantees a gap before the next column so long names can't overlap it. */
.fx-th-bank,
.fx-bank-cell {
  position: sticky;
  left: 0;
  z-index: 2;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
  min-width: 220px;
  padding-right: 24px;
}

.fx-th-bank { background: var(--bg-surface); z-index: 3; }
.fx-bank-cell { background: var(--bg-card); white-space: nowrap; }
/* Keep the sticky cell opaque on hover (the hover colour is translucent, which
   would otherwise let the scrolled-under cells show through). */
.fx-table tbody tr:hover .fx-bank-cell {
  background: linear-gradient(var(--bg-row-hover), var(--bg-row-hover)), var(--bg-card);
}

.fx-bank-cell .fx-bank-logo {
  display: inline-block;
  vertical-align: middle;
  margin-right: 9px;
}

.fx-bank-cell-name {
  vertical-align: middle;
  font-weight: 700;
  color: var(--text-primary);
}

/* Cash / non-cash value pair in each cell */
.fx-val-cell { vertical-align: middle; }

.fx-val-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.fx-val-line + .fx-val-line {
  margin-top: 5px;
  padding-top: 5px;
  border-top: 1px dashed var(--border);
}

.fx-val-tag {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.fx-val-num {
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.fx-no-data {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

/* ── Mobile ── */
@media (max-width: 640px) {
  .fx-card-head { align-items: stretch; }
  .fx-bank-pick { width: 100%; }
  .fx-bank-dd { min-width: 0; }
  .fx-rates { padding: 20px 16px; }
  .fx-table th,
  .fx-table td { padding: 12px 12px; }

  /* Free up horizontal space on small screens: don't pin the Bank column.
     Width still follows the content (min-width: max-content from the base). */
  .fx-th-bank,
  .fx-bank-cell {
    position: static;
    z-index: auto;
  }
}
