/* ── RESET & BASE ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #f0f4f8;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: #1a1a2e;
}

.container { width: 100%; max-width: 400px; }

/* ── TOP BAR ─────────────────────────────────────────────────────── */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.header-title { display: flex; align-items: center; gap: 8px; }
.logo-dot { width: 9px; height: 9px; background: #37d67a; border-radius: 50%; }
.header-title h1 { font-size: 17px; font-weight: 600; color: #1a1a2e; letter-spacing: -0.3px; }

.lang-toggle {
  display: flex;
  background: #ffffff;
  border-radius: 20px;
  padding: 3px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  gap: 2px;
}
.lang-btn {
  border: none;
  background: transparent;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: #8a94a6;
  padding: 4px 10px;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.18s ease;
}
.lang-btn.active { background: #1a1a2e; color: #ffffff; }

.subtitle {
  text-align: center;
  font-size: 12.5px;
  color: #8a94a6;
  margin-bottom: 20px;
  margin-top: -8px;
}

/* ── CARD ────────────────────────────────────────────────────────── */
.card {
  background: #ffffff;
  border-radius: 20px;
  padding: 24px 22px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.07), 0 1px 4px rgba(0,0,0,0.04);
}

/* ── DIRECTION TOGGLE ────────────────────────────────────────────── */
.direction-toggle {
  display: flex;
  background: #f5f7fa;
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 20px;
  gap: 4px;
}
.dir-btn {
  flex: 1;
  border: none;
  background: transparent;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: #8a94a6;
  padding: 9px 8px;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.dir-btn.active {
  background: #ffffff;
  color: #1a1a2e;
  box-shadow: 0 2px 8px rgba(0,0,0,0.10);
}

/* ── FIELD ───────────────────────────────────────────────────────── */
.field { margin-bottom: 6px; }
.field-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.field-label span {
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.currency-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f5f7fa;
  border-radius: 8px;
  padding: 4px 10px;
}
.currency-badge .flag { width: 22px; height: 16px; border-radius: 2px; object-fit: cover; display: inline-block; vertical-align: middle; }
.currency-badge .code { font-size: 13.5px; font-weight: 700; color: #1a1a2e; letter-spacing: 0.3px; }
.dir-flag { width: 18px; height: 13px; border-radius: 2px; object-fit: cover; vertical-align: middle; display: inline-block; }

/* ── INPUTS ──────────────────────────────────────────────────────── */
.input-wrapper { position: relative; }
.input-wrapper input[type="text"] {
  width: 100%;
  font-family: 'Inter', sans-serif;
  font-size: 28px;
  font-weight: 600;
  color: #1a1a2e;
  background: #f8f9fc;
  border: 2px solid #eef0f5;
  border-radius: 14px;
  padding: 14px 48px 14px 18px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
}
.input-wrapper input[type="text"]::placeholder { color: #c8cdd8; }
.input-wrapper input[type="text"]:focus {
  border-color: #37d67a;
  box-shadow: 0 0 0 4px rgba(55,214,122,0.1);
  background: #ffffff;
}
.copy-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 17px;
  color: #b0b8c8;
  padding: 4px 6px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  line-height: 1;
  user-select: none;
}
.copy-btn:hover { color: #37d67a; background: rgba(55,214,122,0.08); }
.copy-btn.copied { color: #37d67a; }

/* ── DIVIDER ─────────────────────────────────────────────────────── */
.divider {
  display: flex; align-items: center; justify-content: center;
  margin: 14px 0; position: relative;
}
.divider-line { width: 100%; height: 1px; background: #eef0f5; }
.divider-icon {
  position: absolute;
  width: 34px; height: 34px;
  background: #ffffff;
  border: 1.5px solid #eef0f5;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #8a94a6; font-size: 14px;
}

/* ── RECEIVE FIELD (green) ───────────────────────────────────────── */
.result-currency { font-size: 13px; color: #4ade80; font-weight: 500; margin-top: 6px; }
.receive-wrapper input[type="text"] {
  background: #f0fdf6;
  border: 1.5px solid #bbf7d0;
  color: #16a34a;
}
.receive-wrapper input[type="text"]:focus {
  border-color: #16a34a;
  box-shadow: 0 0 0 4px rgba(22,163,74,0.1);
  background: #f0fdf6;
}
.receive-wrapper input[type="text"]::placeholder { color: #86efac; }

/* ── COMMISSION BLOCK ────────────────────────────────────────────── */
.commission-block {
  margin-top: 16px;
  background: #f8f9fc;
  border-radius: 12px;
  padding: 14px 16px;
}
.commission-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.commission-label { font-size: 13px; color: #6b7280; font-weight: 500; }
.commission-right { display: flex; align-items: center; gap: 8px; }

/* ── WITHDRAWAL FEE ──────────────────────────────────────────── */
.withdrawal-row {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 10px; margin-top: 8px;
  border-top: 1px solid #eef0f5;
}
.withdrawal-label { font-size: 12.5px; color: #8a94a6; }
.toggle-switch { position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
  position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
  background: #d1d5db; border-radius: 20px; transition: background 0.2s;
}
.toggle-slider:before {
  position: absolute; content: ''; height: 14px; width: 14px;
  left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: transform 0.2s;
}
input:checked + .toggle-slider { background: #37d67a; }
input:checked + .toggle-slider:before { transform: translateX(16px); }

.fee-breakdown {
  margin-top: 8px; border-top: 1px solid #eef0f5; padding-top: 8px;
}
.fee-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 3px 0;
}
.fee-row-label { font-size: 12.5px; color: #8a94a6; }
.fee-row-value { font-size: 12.5px; color: #4b5563; font-weight: 500; text-align: right; }
.fee-row.total-row { margin-top: 4px; border-top: 1px dashed #eef0f5; padding-top: 6px; }
.fee-row.total-row .fee-row-label { font-weight: 600; color: #4b5563; font-size: 12.5px; }
.fee-row.total-row .fee-row-value { font-weight: 600; color: #1a1a2e; }
.fee-row.final-row .fee-row-label { font-weight: 700; color: #16a34a; font-size: 12.5px; }
.fee-row.final-row .fee-row-value { font-weight: 700; color: #16a34a; font-size: 13.5px; }

.commission-locked {
  display: flex; align-items: center; gap: 6px;
  background: #ffffff;
  border: 1.5px solid #eef0f5;
  border-radius: 8px;
  padding: 5px 12px;
}
.commission-locked .val { font-size: 14px; font-weight: 600; color: #1a1a2e; }
.commission-locked .pct { font-size: 13px; font-weight: 600; color: #8a94a6; }

.commission-input-wrap {
  display: flex; align-items: center; gap: 4px;
  background: #ffffff;
  border: 1.5px solid #37d67a;
  border-radius: 8px;
  padding: 5px 10px;
  box-shadow: 0 0 0 3px rgba(55,214,122,0.1);
}
.commission-input-wrap input {
  border: none; background: transparent;
  font-family: 'Inter', sans-serif;
  font-size: 14px; font-weight: 600; color: #1a1a2e;
  width: 44px; text-align: right; outline: none;
  -moz-appearance: textfield; appearance: textfield;
}
.commission-input-wrap input::-webkit-outer-spin-button,
.commission-input-wrap input::-webkit-inner-spin-button { -webkit-appearance: none; }
.commission-input-wrap .pct { font-size: 13px; font-weight: 600; color: #8a94a6; }

.lock-btn {
  width: 30px; height: 30px;
  border: none; background: #ffffff;
  border-radius: 8px; border: 1.5px solid #eef0f5;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #8a94a6; font-size: 14px;
  transition: all 0.18s ease; flex-shrink: 0;
}
.lock-btn:hover { border-color: #37d67a; color: #37d67a; }
.lock-btn.unlocked { border-color: #37d67a; color: #37d67a; background: #f0fdf6; }

/* ── MINIMUM AMOUNT MESSAGE ──────────────────────────────────────── */
.min-msg {
  font-size: 11.5px; color: #f87171;
  margin-top: 6px; min-height: 14px; display: none;
}
.min-msg.visible { display: block; }

/* ── SOURCE MODAL ────────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.35); z-index: 100;
  align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #ffffff; border-radius: 18px; padding: 28px 24px;
  width: 100%; max-width: 320px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.15);
  animation: slideUp 0.2s ease;
}
@keyframes slideUp {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.modal h2 { font-size: 16px; font-weight: 700; color: #1a1a2e; margin-bottom: 6px; }
.modal p  { font-size: 13px; color: #8a94a6; margin-bottom: 18px; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.btn-cancel {
  flex: 1; padding: 11px;
  background: #f5f7fa; border: none; border-radius: 10px;
  font-family: 'Inter', sans-serif; font-size: 14px; font-weight: 600; color: #8a94a6;
  cursor: pointer; transition: background 0.15s;
}
.btn-cancel:hover { background: #eef0f5; }

.source-choices { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.source-btn {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; background: #f8f9fc;
  border: 2px solid #eef0f5; border-radius: 12px;
  cursor: pointer; transition: all 0.18s ease;
  font-family: 'Inter', sans-serif; text-align: left; gap: 10px;
}
.source-btn:hover { border-color: #37d67a; background: #f0fdf6; }
.source-btn.active { border-color: #37d67a; background: #f0fdf6; box-shadow: 0 0 0 3px rgba(55,214,122,0.1); }
.source-btn-inner { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.source-btn-name { font-size: 13px; font-weight: 600; color: #1a1a2e; }
.source-btn-url  { font-size: 11px; color: #8a94a6; }
.source-check { font-size: 16px; flex-shrink: 0; }

/* ── RATE INFO ───────────────────────────────────────────────────── */
.rate-info { margin-top: 14px; padding: 12px 16px; background: #f8f9fc; border-radius: 10px; }
.rate-info-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12.5px;
}
.rate-info-row + .rate-info-row { margin-top: 6px; }
.rate-info-label { color: #6b7280; font-weight: 400; }
.rate-info-value { color: #1a1a2e; font-weight: 600; }
.rate-info-divider { height: 1px; background: #eef0f5; margin: 8px 0; }

/* ── STATUS BAR ──────────────────────────────────────────────────── */
.status-bar {
  display: flex; align-items: center; gap: 6px;
  margin-top: 16px; justify-content: center;
  cursor: pointer;
}
.status-bar:hover .status-text { color: #37d67a; }
.status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #c8cdd8; transition: background 0.3s ease;
}
.status-dot.live  { background: #37d67a; animation: pulse 2s infinite; }
.status-dot.error { background: #f87171; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.5} }
.status-text { font-size: 11.5px; color: #8a94a6; }

/* ── THEME BUTTON ────────────────────────────────────────────────── */
.theme-btn {
  width: 32px; height: 32px; border: none;
  background: #ffffff; border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.10);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 15px; transition: background 0.2s, box-shadow 0.2s; flex-shrink: 0;
}
.theme-btn:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.15); }

/* ── RESPONSIVE ──────────────────────────────────────────────────── */
@media (max-width: 480px) {
  body { padding: 10px; align-items: flex-start; }
  .container { max-width: 100%; }
  .top-bar { margin-bottom: 8px; }
  .header-title h1 { font-size: 15px; }
  .subtitle { font-size: 11px; margin-bottom: 8px; margin-top: -4px; }
  .card { padding: 14px 14px; border-radius: 16px; }
  .direction-toggle { margin-bottom: 12px; padding: 3px; }
  .dir-btn { font-size: 11.5px; padding: 6px 4px; }
  .field { margin-bottom: 4px; }
  .field-label { margin-bottom: 6px; }
  .field-label span { font-size: 10.5px; }
  .currency-badge { padding: 3px 8px; }
  .currency-badge .flag { width: 18px; height: 13px; }
  .currency-badge .code { font-size: 12.5px; }
  .input-wrapper input[type="text"] { font-size: 22px; padding: 10px 40px 10px 14px; border-radius: 11px; }
  .copy-btn { right: 10px; font-size: 15px; }
  .divider { margin: 6px 0; }
  .divider-icon { width: 28px; height: 28px; font-size: 12px; }
  .result-currency { font-size: 11.5px; margin-top: 3px; }
  .commission-block { margin-top: 8px; padding: 9px 12px; border-radius: 10px; }
  .commission-label { font-size: 11.5px; }
  .withdrawal-row { padding-top: 7px; margin-top: 5px; }
  .withdrawal-label { font-size: 11.5px; }
  .fee-breakdown { margin-top: 4px; padding-top: 5px; }
  .fee-row { padding: 2px 0; }
  .fee-row-label, .fee-row-value { font-size: 11.5px; }
  .fee-row.total-row .fee-row-label, .fee-row.total-row .fee-row-value { font-size: 11.5px; }
  .fee-row.final-row .fee-row-value { font-size: 12.5px; }
  .rate-info { margin-top: 8px; padding: 8px 12px; border-radius: 8px; }
  .rate-info-row { font-size: 11px; }
  .rate-info-row + .rate-info-row { margin-top: 4px; }
  .rate-info-divider { margin: 5px 0; }
  .status-bar { margin-top: 8px; }
  .status-text { font-size: 10.5px; }
}

/* ── DARK MODE ───────────────────────────────────────────────────── */
html.dark body { background: #0d0f1a; color: #dde1ed; }
html.dark .header-title h1 { color: #dde1ed; }
html.dark .lang-toggle { background: #1e2133; box-shadow: 0 1px 4px rgba(0,0,0,0.3); }
html.dark .lang-btn { color: #6b7280; }
html.dark .lang-btn.active { background: #37d67a; color: #0d0f1a; }
html.dark .theme-btn { background: #1e2133; box-shadow: 0 1px 4px rgba(0,0,0,0.3); }
html.dark .subtitle { color: #6b7280; }
html.dark .card { background: #161826; box-shadow: 0 4px 32px rgba(0,0,0,0.4), 0 1px 4px rgba(0,0,0,0.2); }
html.dark .direction-toggle { background: #0d0f1a; }
html.dark .dir-btn { color: #6b7280; }
html.dark .dir-btn.active { background: #161826; color: #dde1ed; box-shadow: 0 1px 6px rgba(0,0,0,0.4); }
html.dark .field-label span { color: #6b7280; }
html.dark .currency-badge { background: #0d0f1a; }
html.dark .currency-badge .code { color: #dde1ed; }
html.dark .input-wrapper input[type="text"] { color: #dde1ed; background: #0d0f1a; border-color: #252840; }
html.dark .input-wrapper input[type="text"]:focus { border-color: #37d67a; background: #0d0f1a; }
html.dark .copy-btn { color: #4a5568; }
html.dark .copy-btn:hover { color: #37d67a; background: rgba(55,214,122,0.08); }
html.dark .divider-line { background: #252840; }
html.dark .divider-icon { background: #161826; border-color: #252840; color: #6b7280; }
html.dark .receive-wrapper input[type="text"] { background: #0a1f14; border-color: #14532d; }
html.dark .result-currency { color: #86efac; }
html.dark .min-msg { color: #fca5a5; }
html.dark .commission-block { background: #0d0f1a; }
html.dark .commission-label { color: #6b7280; }
html.dark .withdrawal-row { border-top-color: #252840; }
html.dark .withdrawal-label { color: #6b7280; }
html.dark .toggle-slider { background: #374151; }
html.dark .fee-breakdown { border-top-color: #252840; }
html.dark .fee-row-label { color: #6b7280; }
html.dark .fee-row-value { color: #9ca3af; }
html.dark .fee-row.total-row { border-top-color: #252840; }
html.dark .fee-row.total-row .fee-row-label { color: #9ca3af; }
html.dark .fee-row.total-row .fee-row-value { color: #dde1ed; }
html.dark .fee-row.final-row .fee-row-label { color: #4ade80; }
html.dark .fee-row.final-row .fee-row-value { color: #4ade80; }
html.dark .commission-locked { background: #161826; border-color: #252840; }
html.dark .commission-locked .val { color: #dde1ed; }
html.dark .commission-locked .pct { color: #6b7280; }
html.dark .commission-input-wrap { background: #161826; border-color: #37d67a; }
html.dark .commission-input-wrap input { color: #dde1ed; }
html.dark .commission-input-wrap .pct { color: #6b7280; }
html.dark .lock-btn { background: #161826; border-color: #252840; color: #6b7280; }
html.dark .lock-btn.unlocked { border-color: #37d67a; color: #37d67a; background: #0a1f14; }
html.dark .rate-info { background: #0d0f1a; }
html.dark .rate-info-label { color: #6b7280; }
html.dark .rate-info-value { color: #dde1ed; }
html.dark .rate-info-divider { background: #252840; }
html.dark .status-text { color: #6b7280; }
html.dark .modal { background: #161826; }
html.dark .modal h2 { color: #dde1ed; }
html.dark .modal p  { color: #6b7280; }
html.dark .btn-cancel { background: #0d0f1a; color: #6b7280; }
html.dark .btn-cancel:hover { background: #252840; }
html.dark .source-btn { background: #0d0f1a; border-color: #252840; }
html.dark .source-btn:hover { background: #0a1f14; border-color: #37d67a; }
html.dark .source-btn.active { background: #0a1f14; border-color: #37d67a; }
html.dark .source-btn-name { color: #dde1ed; }
html.dark .source-btn-url  { color: #6b7280; }
