/* Buy Crypto widget, styled to match the homepage exchanger. */
#ghostswap-widget.gsb {
  --gsb-card: #1a1730;
  --gsb-field: #2a2550;
  --gsb-field-hi: #332c62;
  --gsb-line: rgba(255, 255, 255, 0.08);
  --gsb-text: #ffffff;
  --gsb-muted: #8a8fbd;
  --gsb-accent: #ff61d2;
  --gsb-accent2: #9b51e0;
  --gsb-warn: #ffb4c8;
  max-width: 520px;
  margin: 0 auto;
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  color: var(--gsb-text);
  text-align: left;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.45s ease, transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}
#ghostswap-widget.gsb.is-ready { opacity: 1; transform: none; }
/* Legacy markup is replaced by JS; keep it invisible to avoid a flash. */
#ghostswap-widget:not(.gsb) { visibility: hidden; min-height: 560px; }
#currencyPopup { display: none !important; }

.gsb *, .gsb *::before, .gsb *::after { box-sizing: border-box; }
.gsb button { font-family: inherit; }

.gsb-card {
  background: var(--gsb-card);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(155, 81, 224, 0.06);
  overflow: hidden;
}

.gsb-tabs { display: grid; grid-template-columns: 1fr 1fr; background: rgba(255, 255, 255, 0.02); }
.gsb-tab {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 16px 10px; font-size: 15px; color: var(--gsb-muted); text-decoration: none;
  transition: color 0.2s ease, background 0.2s ease;
}
.gsb-tab:hover { color: #fff; }
.gsb-tab.is-active {
  color: #fff; font-weight: 600;
  background: linear-gradient(180deg, #2d2458 0%, #2a2354 100%);
  border-radius: 0 0 18px 0;
  position: relative;
}
.gsb-tab.is-active::after {
  content: ''; position: absolute; left: 25%; right: 25%; bottom: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--gsb-accent), transparent);
}

.gsb-body { padding: 18px 24px 22px; display: flex; flex-direction: column; }
.gsb-label {
  display: block; margin: 12px 4px 8px; font-size: 12px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--gsb-muted);
}
.gsb-approx { text-transform: none; letter-spacing: 0; font-weight: 400; opacity: 0.8; margin-left: 4px; }

.gsb-field {
  display: flex; align-items: center; gap: 8px;
  background: var(--gsb-field); border: 1px solid transparent; border-radius: 16px;
  padding: 6px 8px 6px 20px; min-height: 64px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.gsb-field:focus-within { border-color: rgba(255, 97, 210, 0.45); box-shadow: 0 0 0 3px rgba(255, 97, 210, 0.12); }
.gsb-field.is-bad { border-color: rgba(255, 99, 132, 0.7); }
.gsb-field.is-good { border-color: rgba(76, 217, 140, 0.55); }

.gsb-input {
  flex: 1 1 auto; min-width: 0; width: 100%;
  background: transparent !important; border: 0 !important; outline: 0; box-shadow: none !important;
  color: #fff; font-size: 22px; font-weight: 600; padding: 8px 0 !important; margin: 0;
  font-variant-numeric: tabular-nums; font-family: inherit;
}
.gsb-input::placeholder { color: #6f6a9a; font-weight: 400; }
.gsb-addr { font-size: 15px; font-weight: 500; }
.gsb-field-addr { min-height: 56px; padding-right: 16px; }

.gsb-out { display: block; min-height: 30px; line-height: 30px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gsb-out.is-loading::before {
  content: ''; display: block; width: 150px; max-width: 70%; height: 24px; margin-top: 3px; border-radius: 8px;
  background: linear-gradient(90deg, rgba(255,255,255,0.06) 0%, rgba(255,97,210,0.28) 50%, rgba(255,255,255,0.06) 100%);
  background-size: 200% 100%;
  animation: gsb-shimmer 1.1s linear infinite;
}
.gsb-out.is-pop { animation: gsb-reveal 0.5s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes gsb-reveal { from { opacity: 0; filter: blur(6px); transform: translateY(6px); } to { opacity: 1; filter: none; transform: none; } }
@keyframes gsb-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@keyframes gsb-pop { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.gsb-pick {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.06); border-radius: 999px;
  color: #fff; padding: 8px 12px 8px 8px; font-size: 16px; font-weight: 600; cursor: pointer; line-height: 1;
  transition: background 0.2s ease, transform 0.15s ease;
}
.gsb-pick:hover { background: rgba(255, 255, 255, 0.1); }
.gsb-pick:active { transform: scale(0.97); }
.gsb-pick img { width: 26px; height: 26px; border-radius: 50%; }
.gsb-pick svg { color: var(--gsb-muted); }
.gsb-net {
  font-size: 10px; font-weight: 700; letter-spacing: 0.03em; padding: 3px 6px; border-radius: 6px;
  background: rgba(155, 81, 224, 0.25); color: #d9c2ff;
}

.gsb-mid { position: relative; height: 18px; margin: 10px 0 -4px; }
.gsb-mid::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: var(--gsb-line); }
.gsb-mid-dot {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--gsb-card); border: 1px solid var(--gsb-line); color: var(--gsb-accent);
}

.gsb-rate { min-height: 18px; margin: 8px 4px 0; font-size: 13px; color: var(--gsb-muted); font-variant-numeric: tabular-nums; }

.gsb-select {
  width: 100%; height: 52px; border-radius: 14px; padding: 0 16px;
  background: var(--gsb-field); color: #fff; border: 1px solid transparent; font-size: 15px; font-family: inherit;
  -webkit-appearance: none; appearance: none; 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='%238a8fbd' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 16px center;
}
.gsb-select option { background: #1d1831; color: #fff; }
.gsb-select:focus { outline: 0; border-color: rgba(255, 97, 210, 0.45); }

.gsb-offers { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; animation: gsb-pop 0.3s ease; }
.gsb-offers-h { margin: 4px 4px 0; font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--gsb-muted); }
.gsb-offers-one { margin: 0 4px; font-size: 13px; color: var(--gsb-muted); }
.gsb-offer {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: rgba(255, 255, 255, 0.03); border: 1px solid var(--gsb-line); border-radius: 14px;
  padding: 10px 14px; color: #fff; cursor: pointer; transition: border-color 0.2s ease, background 0.2s ease;
}
.gsb-offer:hover { background: rgba(255, 255, 255, 0.06); }
.gsb-offer.is-sel { border-color: rgba(255, 97, 210, 0.6); background: rgba(255, 97, 210, 0.07); }
.gsb-offer img { width: 34px; height: 34px; border-radius: 9px; flex: 0 0 auto; background: #fff; padding: 4px; object-fit: contain; }
.gsb-offer-n { flex: 1 1 auto; min-width: 0; font-weight: 600; font-size: 15px; }
.gsb-offer-n small { display: block; font-weight: 400; font-size: 12px; color: var(--gsb-muted); margin-top: 2px; }
.gsb-offer-v { text-align: right; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.gsb-offer-v em {
  display: block; font-style: normal; font-size: 11px; font-weight: 700; margin-top: 3px;
  background: linear-gradient(90deg, var(--gsb-accent), var(--gsb-accent2)); -webkit-background-clip: text; background-clip: text; color: transparent;
}

.gsb-msg { margin: 12px 4px 0; font-size: 14px; line-height: 1.4; color: var(--gsb-muted); }
.gsb-msg.is-warn { color: var(--gsb-warn); }

.gsb-buy {
  margin-top: 18px; width: 100%; padding: 16px 20px; border: 0; border-radius: 16px; cursor: pointer;
  background: linear-gradient(90deg, #ff61d2, #9b51e0); color: #fff; font-size: 17px; font-weight: 600;
  box-shadow: 0 8px 20px rgba(155, 81, 224, 0.4);
  transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.2s ease, filter 0.2s ease;
}
.gsb-buy:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 10px 28px rgba(155, 81, 224, 0.5); }
.gsb-buy:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; filter: saturate(0.7); }
.gsb-buy.is-busy { opacity: 0.85; cursor: progress; }

.gsb-pay {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 16px;
}
.gsb-pay span {
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em; color: #b9b6d8;
  padding: 5px 9px; border-radius: 999px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--gsb-line);
}
.gsb-help { margin-top: 14px; text-align: center; font-size: 14px; font-weight: 600; color: #d05fe8 !important; text-decoration: none; }
.gsb-help:hover { text-decoration: underline; }

/* Currency picker */
.gsb-pop {
  position: fixed; inset: 0; z-index: 2147483600; display: flex; align-items: center; justify-content: center;
  background: rgba(10, 8, 20, 0.88); padding: 16px; opacity: 0; transition: opacity 0.18s ease;
}
.gsb-pop.is-open { opacity: 1; }
.gsb-pop-box {
  width: 100%; max-width: 440px; height: min(640px, 86vh); display: flex; flex-direction: column;
  background: #1d1831; border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 20px; overflow: hidden;
  transform: translateY(10px) scale(0.98); transition: transform 0.2s ease;
  will-change: transform;
}
.gsb-pop.is-open .gsb-pop-box { transform: none; }
.gsb-pop-head { display: flex; gap: 8px; padding: 14px; border-bottom: 1px solid var(--gsb-line); }
.gsb-pop-search {
  flex: 1; min-width: 0; height: 46px; border-radius: 12px; padding: 0 14px !important; font-size: 16px; font-family: inherit;
  background: var(--gsb-field) !important; color: #fff !important; border: 1px solid transparent !important; outline: 0;
}
.gsb-pop-search:focus { border-color: rgba(255, 97, 210, 0.45) !important; }
.gsb-pop-x {
  width: 46px; height: 46px; border-radius: 12px; border: 0; cursor: pointer; font-size: 26px; line-height: 1;
  background: rgba(255, 255, 255, 0.06); color: #fff;
}
.gsb-pop-list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; overscroll-behavior: contain; contain: content; }
.gsb-pop-list li { margin: 0; padding: 0; }
.gsb-pop-list button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; border-radius: 12px;
  background: transparent; color: #fff; cursor: pointer; text-align: left; font-size: 15px;
}
.gsb-pop-list button:hover, .gsb-pop-list button:focus-visible { background: rgba(255, 255, 255, 0.06); outline: 0; }
.gsb-pop-list button.is-cur { background: rgba(255, 97, 210, 0.1); }
.gsb-pop-list img { width: 28px; height: 28px; border-radius: 50%; flex: 0 0 auto; }
.gsb-pop-list b { font-weight: 700; }
.gsb-pop-list span:last-child { color: var(--gsb-muted); font-size: 13px; margin-left: auto; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.gsb-pop-empty { padding: 24px; text-align: center; color: var(--gsb-muted); }
html.gsb-lock, html.gsb-lock body { overflow: hidden; }

@media (max-width: 560px) {
  .gsb-body { padding: 14px 14px 18px; }
  .gsb-field { padding-left: 16px; min-height: 60px; }
  .gsb-input { font-size: 20px; }
  .gsb-addr { font-size: 14px; }
  .gsb-pick { font-size: 15px; padding: 7px 10px 7px 7px; }
  .gsb-pop { align-items: flex-end; padding: 0; }
  .gsb-pop-box { max-width: none; height: 80vh; border-radius: 20px 20px 0 0; transform: translateY(24px); }
}
@media (prefers-reduced-motion: reduce) {
  #ghostswap-widget.gsb, .gsb-pop, .gsb-pop-box, .gsb-out.is-pop, .gsb-offers { transition: none; animation: none; }
  .gsb-out.is-loading::before { animation: none; }
}
