/* =========================================
   TRADE HUB UI (Floating Window)
   ========================================= */
#trade-hub-widget {
    position: absolute;
    top: 80px;
    right: 60px;
    width: 520px;
    max-height: calc(100vh - 100px);
    background: transparent;
    border: 1px solid var(--color-accent-cyan);
    border-radius: 8px;
    z-index: 500;
    pointer-events: auto;
    box-shadow: 0 0 40px rgba(0, 242, 254, 0.12), 0 10px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Space Mono', monospace;
}

#trade-hub-widget.minimized .trade-hub-body {
    display: none !important;
}

.trade-hub-handle {
    padding: 10px 15px;
    background: transparent;
    border-bottom: 1px solid rgba(0, 242, 254, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: grab;
    user-select: none;
}

.trade-hub-handle:active {
    cursor: grabbing;
}

.trade-hub-title {
    font-size: 12px;
    color: var(--color-accent-cyan);
    font-weight: 700;
    font-family: 'Space Mono', monospace;
    text-transform: uppercase;
}

/* .trade-hub-close-btn — consolidated into universal close button rule in style.css */
.trade-hub-min-btn {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
    width: 26px;
    height: 26px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.trade-hub-min-btn:hover {
    color: #fff;
    border-color: var(--color-accent-cyan);
}

.trade-hub-body {
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.trade-hub-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Legacy container removed */
.close-btn {
    background: none;
    border: none;
    color: var(--color-text-dim);
    font-size: 24px;
    cursor: pointer;
    transition: color 0.2s;
}

.close-btn:hover {
    color: #ff5f57;
    /* Red on hover */
    text-shadow: 0 0 8px rgba(255, 95, 87, 0.5);
}

/* CHAIN CARDS */
.chain-selector-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 5px;
}

.chain-card {
    background: #0f1214;
    border: 1px solid rgba(0, 242, 254, 0.2);
    border-radius: 4px;
    padding: 10px 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    gap: 4px;
}

.chain-card:hover {
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(15, 18, 20, 0.8);
}

.chain-card .chain-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.chain-card .chain-icon svg {
    width: 20px;
    height: 20px;
}

.chain-card .chain-name {
    font-size: 10px;
    color: var(--color-text-dim);
    font-weight: 500;
    z-index: 2;
}

/* Active State: Full Color Fill */
/* Active State: Terminal Style */
.chain-card.active {
    background: rgba(0, 242, 254, 0.1);
    border-color: var(--color-accent-cyan);
    box-shadow: 0 0 15px rgba(0, 242, 254, 0.2);
}

.chain-card.active .chain-name {
    color: #fff;
    font-weight: 700;
}

/* SWAP CARD */
.swap-container {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--color-accent-cyan);
    border-radius: 8px;
    padding: 20px;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.swap-header-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 13px;
    color: var(--color-text-dim);
}

.swap-input-group {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
    border: 1px solid transparent;
    transition: border-color 0.2s;
    position: relative;
    /* Ensure it sits above divider */
    z-index: 10;
    /* Higher than divider */
}

.swap-input-group:focus-within {
    border-color: var(--color-accent-blue);
}

.swap-input {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 28px;
    width: 60%;
    outline: none;
    font-family: 'Space Mono', monospace;
    font-weight: 700;
}

.swap-input::placeholder {
    color: #444;
}

/* Percentage Buttons */
.percent-btn {
    background: rgba(11, 13, 15, 0.6);
    border: 1px solid var(--color-border);
    color: var(--color-text-dim);
    font-size: 10px;
    padding: 4px 10px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    font-family: 'Space Mono', monospace;
    font-weight: 600;
}

.percent-btn:hover {
    background: var(--color-accent-blue);
    border-color: var(--color-accent-blue);
    color: #000;
    box-shadow: 0 0 10px rgba(0, 243, 255, 0.3);
}

.percent-btn:active {
    transform: translateY(1px);
}

.token-selector-btn {
    background: rgba(0, 242, 254, 0.1);
    border: 1px solid rgba(0, 242, 254, 0.3);
    border-radius: 4px;
    padding: 8px 12px;
    color: #fff;
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}

.token-selector-btn:hover {
    background: #373c44;
}

.token-icon {
    margin-right: 6px;
    font-size: 14px;
}

/* Arrow Divider */
.swap-divider {
    height: 0;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0;
    z-index: 20;
}

.swap-arrow-circle {
    width: 32px;
    height: 32px;
    background: #0b0d0f;
    border: 4px solid #0b0d0f;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-dim);
    font-size: 14px;
    cursor: pointer;
    pointer-events: auto;
    position: absolute;
    top: -16px;
    /* Half height to center on line */
}

.swap-arrow-circle:hover {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.2);
}

/* Action Button */
.swap-action-btn {
    display: block;
    width: 60%;
    margin: 20px auto 0;
    height: 40px;
    border-radius: 4px;
    font-size: 12px;
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    background: transparent;
    border: 1px solid var(--color-accent-cyan);
    color: var(--color-accent-cyan);
    cursor: pointer;
    transition: all 0.2s ease;
}

.swap-action-btn:hover {
    background: rgba(0, 242, 254, 0.1);
    box-shadow: 0 0 16px rgba(0, 242, 254, 0.3);
}

.swap-action-btn:active {
    transform: translateY(1px);
}

.swap-action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

.swap-footer {
    text-align: center;
    margin-top: 15px;
    font-size: 11px;
    color: var(--color-text-dim);
    font-family: 'Space Mono', monospace;
    text-transform: uppercase;
    line-height: 1.4;
}

/* TOKEN SELECTOR MODAL */
.token-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(10px);
    z-index: 99999999;
    pointer-events: auto;
}

.token-modal-container {
    width: 100%;
    max-width: 420px;
    background: #111417;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    max-height: 80vh;
}

.token-modal-header {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.token-modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: #fff;
}

.token-search-container {
    padding: 15px 20px;
}

#token-search-input {
    width: 100%;
    background: #1a1d21;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px 15px;
    color: #fff;
    font-size: 15px;
    font-size: 15px;
    outline: none;
    box-sizing: border-box;
    /* Fix overflow */
    font-family: 'Space Mono', monospace;
    text-transform: uppercase;
}

#token-search-input:focus {
    border-color: var(--color-accent-blue);
}

.token-list-container {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.token-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.token-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.token-item-icon {
    width: 36px;
    height: 36px;
    background: #2c3036;
    border-radius: 50%;
    margin-right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: var(--color-text-dim);
    overflow: hidden;
}

.token-item-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.token-item-info {
    display: flex;
    flex-direction: column;
}

.token-item-symbol {
    font-weight: 700;
    color: #fff;
    font-size: 15px;
}

.token-item-name {
    font-size: 12px;
    color: var(--color-text-dim);
}

.token-list-loading,
.token-list-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--color-text-dim);
    font-size: 14px;
}

/* Scrollbar styling */
.token-list-container::-webkit-scrollbar {
    width: 6px;
}

.token-list-container::-webkit-scrollbar-track {
    background: transparent;
}

.token-list-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

/* =========================================
   TRADE HUB TABS (Swap / Buy)
   ========================================= */
.trade-hub-tabs {
    display: flex;
    gap: 0;
    padding: 0;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(0, 242, 254, 0.15);
}

.trade-hub-tab {
    flex: 1;
    padding: 12px 20px;
    background: transparent;
    border: none;
    color: var(--color-text-dim);
    font-family: 'Space Mono', monospace;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
}

.trade-hub-tab .tab-icon {
    font-size: 14px;
}

.trade-hub-tab:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.03);
}

.trade-hub-tab.active {
    color: var(--color-accent-cyan);
    background: rgba(0, 242, 254, 0.08);
}

.trade-hub-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--color-accent-cyan);
    box-shadow: 0 0 10px var(--color-accent-cyan);
}

/* Buy tab accent color override - MoonPay purple */
.trade-hub-tab[data-mode="buy"].active {
    color: #7D00FF;
}

.trade-hub-tab[data-mode="buy"].active::after {
    background: #7D00FF;
    box-shadow: 0 0 10px #7D00FF;
}

/* =========================================
   BUY CRYPTO UI
   ========================================= */
.buy-crypto-container {
    padding: 5px 0;
}

/* Coming Soon Screen */
.buy-coming-soon {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    gap: 12px;
}

.buy-cs-icon {
    opacity: 0.7;
    margin-bottom: 8px;
}

.buy-cs-label {
    font-family: 'Space Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.2em;
    color: #7D00FF;
    font-weight: 700;
    border: 1px solid #7D00FF44;
    padding: 3px 12px;
    border-radius: 20px;
    background: #7D00FF11;
}

.buy-cs-title {
    font-family: 'Space Mono', monospace;
    font-size: 20px;
    font-weight: 700;
    color: var(--color-text-primary, #fff);
    letter-spacing: 0.05em;
}

.buy-cs-desc {
    font-size: 12px;
    color: var(--color-text-dim, #aaa);
    max-width: 260px;
    line-height: 1.6;
    margin: 0;
}

.buy-cs-desc strong {
    color: #7D00FF;
}

.buy-cs-features {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}

.buy-cs-feature {
    font-family: 'Space Mono', monospace;
    font-size: 11px;
    color: var(--color-text-dim, #aaa);
}

/* MoonPay Provider Header */
.buy-provider-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 15px;
    background: rgba(125, 0, 255, 0.1);
    border: 1px solid rgba(125, 0, 255, 0.3);
    border-radius: 8px;
    margin-bottom: 15px;
}

.provider-logo-inline {
    display: flex;
    align-items: center;
    justify-content: center;
}

.provider-header-text {
    color: #fff;
    font-size: 13px;
    font-family: 'Space Mono', monospace;
}

.provider-header-text strong {
    color: #7D00FF;
}

.provider-header-badge {
    background: rgba(125, 0, 255, 0.2);
    color: #a855f7;
    font-size: 9px;
    padding: 3px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    font-family: 'Space Mono', monospace;
}

.buy-intro-text {
    color: var(--color-text-dim);
    font-size: 12px;
    text-align: center;
    margin: 0 0 15px 0;
}

/* Buy Form */
.buy-form-container {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(125, 0, 255, 0.2);
    border-radius: 8px;
    padding: 20px;
}

.buy-amount-section,
.buy-receive-section,
.buy-wallet-section {
    margin-bottom: 15px;
}

.buy-label {
    display: block;
    font-size: 11px;
    color: var(--color-text-dim);
    text-transform: uppercase;
    margin-bottom: 8px;
    font-family: 'Space Mono', monospace;
}

.buy-input-group {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    border: 1px solid transparent;
    transition: border-color 0.2s;
}

.buy-input-group:focus-within {
    border-color: #7D00FF;
}

.buy-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 22px;
    font-weight: 700;
    font-family: 'Space Mono', monospace;
    padding: 12px 15px;
    outline: none;
    min-width: 0;
}

.buy-input::placeholder {
    color: #444;
}

.buy-currency-select {
    background: rgba(125, 0, 255, 0.1);
    border: none;
    border-left: 1px solid rgba(125, 0, 255, 0.2);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    font-family: 'Space Mono', monospace;
    padding: 12px 15px;
    cursor: pointer;
    outline: none;
    min-width: 85px;
}

.buy-currency-select option {
    background: #111417;
    color: #fff;
}

/* Buy Divider */
.buy-divider {
    height: 0;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 10px 0;
    z-index: 5;
}

.buy-arrow-circle {
    width: 32px;
    height: 32px;
    background: #0b0d0f;
    border: 4px solid #0b0d0f;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #7D00FF;
    font-size: 14px;
    position: absolute;
    top: -16px;
}

/* Wallet Section */
.buy-wallet-display {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    padding: 12px 15px;
    min-height: 44px;
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.buy-wallet-display .wallet-placeholder {
    color: var(--color-text-dim);
    font-size: 12px;
}

.buy-wallet-display .wallet-address {
    color: #a855f7;
    font-size: 12px;
    font-family: 'Space Mono', monospace;
    word-break: break-all;
}

.buy-wallet-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    padding: 12px 15px;
    color: #fff;
    font-size: 12px;
    font-family: 'Space Mono', monospace;
    outline: none;
    margin-bottom: 10px;
}

.buy-wallet-input:focus {
    border-color: #7D00FF;
}

.buy-wallet-toggle {
    display: flex;
    gap: 5px;
}

.buy-wallet-option {
    flex: 1;
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    color: var(--color-text-dim);
    font-size: 10px;
    font-family: 'Space Mono', monospace;
    cursor: pointer;
    transition: all 0.2s;
}

.buy-wallet-option:hover {
    color: #fff;
}

.buy-wallet-option.active {
    background: rgba(125, 0, 255, 0.1);
    border-color: #7D00FF;
    color: #a855f7;
}

/* Buy Action Button - MoonPay Purple */
.buy-action-btn {
    width: 100%;
    margin-top: 15px;
    height: 52px;
    border-radius: 4px;
    font-size: 14px;
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    text-transform: uppercase;
    background: #7D00FF;
    border: 1px solid #7D00FF;
    color: #fff;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
}

.buy-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(125, 0, 255, 0.4);
}

.buy-action-btn:active {
    transform: translateY(0);
}

/* Buy Footer */
.buy-footer {
    text-align: center;
    margin-top: 15px;
    font-size: 10px;
    color: var(--color-text-dim);
    line-height: 1.6;
}

.buy-disclaimer {
    opacity: 0.7;
}

.buy-secure-badge {
    color: #a855f7;
}

/* =========================================
   EMBEDDED BUY WIDGET CONTAINER
   ========================================= */
.buy-widget-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(5, 10, 15, 0.98);
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.buy-widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: rgba(0, 255, 136, 0.08);
    border-bottom: 1px solid rgba(0, 255, 136, 0.2);
    flex-shrink: 0;
}

.buy-widget-title {
    color: #00FF88;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    font-family: 'Space Mono', monospace;
}

.buy-widget-back-btn {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--color-text-dim);
    font-size: 11px;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Space Mono', monospace;
    transition: all 0.2s;
}

.buy-widget-back-btn:hover {
    border-color: #00FF88;
    color: #00FF88;
}

.buy-widget-frame {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    overflow: hidden;
}

.buy-widget-frame iframe {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 8px;
    background: #111;
}

.buy-widget-loading {
    text-align: center;
    color: var(--color-text-dim);
    font-size: 12px;
}

.buy-widget-loading .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(0, 255, 136, 0.2);
    border-top-color: #00FF88;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}