/* MDAO DEX — Mars Theme */
[v-cloak] { display: none !important; }

:root {
    --bg:          #0a0b0e;
    --bg-card:     #13151a;
    --bg-card2:    #191c22;
    --bg-input:    #1e2128;
    --bg-hover:    #22262f;
    --accent:      #FF5B04;
    --accent-h:    #ff7830;
    --accent-dim:  rgba(255, 91, 4, 0.14);
    --accent-glow: rgba(255, 91, 4, 0.25);
    --text:        #FFFFFF;
    --text2:       rgba(255,255,255,0.58);
    --text3:       rgba(255,255,255,0.32);
    --border:      rgba(255,255,255,0.07);
    --border-a:    rgba(255, 91, 4, 0.35);
    --success:     #22c55e;
    --error:       #f87171;
    --radius:      14px;
    --radius-sm:   8px;
    --radius-lg:   20px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    user-select: none;
    -webkit-user-select: none;
}

body {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    padding: 20px 12px 40px;
    background: radial-gradient(ellipse at 50% 0%, rgba(255,91,4,0.06) 0%, transparent 70%), var(--bg);
}

/* ── App Shell ─────────────────────────────────────────── */
#app {
    width: 100%;
    max-width: 440px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ── Header ─────────────────────────────────────────────── */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 0 8px;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.logo-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.logo-text {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--text);
}

.logo-dex {
    color: var(--accent);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.wallet-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 99px;
    font-size: 13px;
    color: var(--text2);
    cursor: pointer;
    transition: border-color 0.2s;
}
.wallet-pill:hover { border-color: var(--border-a); }

.wallet-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--success);
    animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.5} }

.connect-btn {
    padding: 8px 18px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 99px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}
.connect-btn:hover { background: var(--accent-h); }
.connect-btn:active { transform: scale(0.97); }

/* ── Swap Card ──────────────────────────────────────────── */
.swap-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Mode Toggle */
.mode-toggle {
    display: flex;
    background: var(--bg-input);
    border-radius: 10px;
    padding: 3px;
    margin-bottom: 4px;
}

.mode-btn {
    flex: 1;
    padding: 8px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text3);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.mode-btn.active {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 2px 12px var(--accent-glow);
}

/* Token Row Card */
.swap-box {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
.swap-box.clickable:hover {
    border-color: var(--border-a);
    background: var(--bg-hover);
}
.swap-box.fixed-token {
    cursor: default;
    opacity: 0.92;
}

.box-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

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

.token-selector-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.token-icon-wrap {
    position: relative;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}
.token-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-hover);
}
.chain-badge {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1.5px solid var(--bg-card);
    overflow: hidden;
    background: var(--bg-hover);
}
.chain-badge img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.token-meta {}
.token-symbol-row {
    display: flex;
    align-items: center;
    gap: 4px;
}
.token-symbol {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}
.chevron {
    color: var(--text3);
    flex-shrink: 0;
}
.chain-name-label {
    font-size: 11px;
    color: var(--text3);
    margin-top: 1px;
}

.amount-group {
    flex: 1;
    text-align: right;
}
.amount-input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 22px;
    font-weight: 700;
    text-align: right;
    width: 100%;
    min-width: 0;
    font-family: inherit;
}
.amount-input::placeholder { color: var(--text3); }
.output-amount {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    min-height: 33px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}
.output-amount.loading { color: var(--text3); }
.usd-value {
    font-size: 12px;
    color: var(--text3);
    text-align: right;
    margin-top: 2px;
}

/* Balance bar */
.balance-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2px;
    margin-top: -2px;
    font-size: 12px;
    color: var(--text3);
}
.max-btn {
    background: transparent;
    border: 1px solid var(--border-a);
    color: var(--accent);
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
}
.max-btn:hover { background: var(--accent-dim); }

/* Arrow Divider */
.arrow-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: -2px 0;
}
.arrow-line { flex: 1; height: 1px; background: var(--border); }
.swap-arrow-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text3);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}
.swap-arrow-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-dim);
}

/* Info rows */
.info-rows {
    border-top: 1px solid var(--border);
    padding-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
}
.info-label { color: var(--text3); }
.info-value { color: var(--text2); }
.fee-badge {
    background: var(--accent-dim);
    color: var(--accent);
    border: 1px solid var(--border-a);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 11px;
    font-weight: 600;
}

/* Error Banner */
.error-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: rgba(248, 113, 113, 0.08);
    border: 1px solid rgba(248, 113, 113, 0.25);
    border-radius: var(--radius-sm);
    color: var(--error);
    font-size: 12px;
}

/* Action Button */
.action-btn {
    width: 100%;
    padding: 15px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
    margin-top: 4px;
}
.action-btn:hover:not(.disabled):not(:disabled) {
    background: var(--accent-h);
    box-shadow: 0 4px 20px var(--accent-glow);
}
.action-btn:active:not(.disabled) { transform: scale(0.98); }
.action-btn.disabled, .action-btn:disabled {
    background: var(--bg-hover);
    color: var(--text3);
    cursor: not-allowed;
    box-shadow: none;
}

.loading-state {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.powered-by {
    text-align: center;
    font-size: 11px;
    color: var(--text3);
    margin-top: 4px;
}
.powered-by strong { color: var(--text2); }

/* Spinner */
.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.shimmer-text {
    background: linear-gradient(90deg, var(--text3) 25%, var(--text2) 50%, var(--text3) 75%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: shimmer 1.5s linear infinite;
}
@keyframes shimmer { to { background-position: -200% center; } }

/* ── Token/Chain Selection View ─────────────────────────── */
.selection-view {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.selection-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 0 16px;
    flex-shrink: 0;
}
.back-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}
.back-btn:hover { border-color: var(--border-a); color: var(--text); }

.selection-title {
    font-size: 16px;
    font-weight: 700;
}

/* Chain section */
.chains-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 8px;
    flex-shrink: 0;
}

.section-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.chains-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chain-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text2);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}
.chain-btn:hover {
    border-color: var(--border-a);
    color: var(--text);
}
.chain-btn.selected {
    border-color: var(--accent);
    background: var(--accent-dim);
    color: var(--accent);
}
.chain-btn-icon {
    width: 18px;
    height: 18px;
    border-radius: 50%;
}

/* Token section */
.tokens-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.search-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin-bottom: 10px;
    flex-shrink: 0;
}
.search-wrap svg { color: var(--text3); flex-shrink: 0; }
.search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
}
.search-input::placeholder { color: var(--text3); }

.tokens-list {
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0 -4px;
    padding: 0 4px;
}

.token-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    transition: all 0.15s;
    width: 100%;
    text-align: left;
}
.token-item:hover {
    background: var(--bg-input);
    border-color: var(--border);
}
.token-item.selected {
    background: var(--accent-dim);
    border-color: var(--border-a);
}
.token-item-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-hover);
    flex-shrink: 0;
}
.token-item-info {
    flex: 1;
    min-width: 0;
}
.token-item-symbol {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}
.token-item-name {
    display: block;
    font-size: 11px;
    color: var(--text3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.token-item-balance {
    text-align: right;
    flex-shrink: 0;
}
.token-item-balance span {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}
.token-balance-usd {
    font-size: 11px !important;
    color: var(--text3) !important;
    font-weight: 400 !important;
}

.loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 24px;
    color: var(--text3);
    font-size: 13px;
}
.empty-state {
    padding: 32px;
    text-align: center;
    color: var(--text3);
    font-size: 13px;
}

/* ── Progress Overlay ───────────────────────────────────── */
.progress-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.progress-card {
    background: var(--bg-card2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    width: 100%;
    max-width: 360px;
}

.progress-title {
    font-size: 17px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 24px;
}

.progress-steps {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}

.progress-step {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text3);
    font-size: 14px;
    transition: color 0.3s;
}
.progress-step.active { color: var(--text); }
.progress-step.done { color: var(--success); }

.step-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid currentColor;
    flex-shrink: 0;
    transition: all 0.3s;
}
.progress-step.active .step-dot {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    animation: step-pulse 1.2s infinite;
}
.progress-step.done .step-dot {
    background: var(--success);
    border-color: var(--success);
}
@keyframes step-pulse { 0%,100%{box-shadow:0 0 0 2px var(--accent-glow)} 50%{box-shadow:0 0 0 5px rgba(255,91,4,0.1)} }

.tx-link {
    text-align: center;
    font-size: 12px;
}
.tx-link a {
    color: var(--accent);
    text-decoration: none;
}
.tx-link a:hover { text-decoration: underline; }

/* Success */
.success-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
}
.success-icon { margin-bottom: 4px; }
.success-label {
    font-size: 22px;
    font-weight: 700;
    color: var(--accent);
}
.success-amount {
    font-size: 18px;
    font-weight: 600;
}
.success-sub {
    font-size: 12px;
    color: var(--text3);
    margin-bottom: 8px;
}

/* ── Wallet Modal ───────────────────────────────────────── */
.wallet-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 200;
    backdrop-filter: blur(4px);
    padding: 0 12px 16px;
}

@media (min-width: 480px) {
    .wallet-modal-overlay {
        align-items: center;
    }
}

.wallet-modal {
    background: var(--bg-card2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0;
    width: 100%;
    max-width: 380px;
    overflow: hidden;
}

.wallet-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}
.wallet-modal-title {
    font-size: 16px;
    font-weight: 700;
}
.modal-close-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-input);
    border: none;
    color: var(--text2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.wallet-list {
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.wallet-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    transition: all 0.15s;
    width: 100%;
    text-align: left;
}
.wallet-item:hover {
    background: var(--bg-input);
    border-color: var(--border);
}
.wallet-item-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}
.wallet-item-info { flex: 1; }
.wallet-item-name {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}
.wallet-item-status {
    display: block;
    font-size: 11px;
    color: var(--text3);
}
.wallet-item-status.detected { color: var(--success); }
.wallet-item-arrow { color: var(--text3); }

/* ── Toast ──────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-card2);
    border: 1px solid var(--border);
    border-radius: 99px;
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s;
    z-index: 300;
    white-space: nowrap;
    max-width: 90vw;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.toast.error { color: var(--error); border-color: rgba(248,113,113,0.3); }
.toast.success { color: var(--success); border-color: rgba(34,197,94,0.3); }

/* ── Scrollbar ──────────────────────────────────────────── */
.tokens-list::-webkit-scrollbar { width: 4px; }
.tokens-list::-webkit-scrollbar-track { background: transparent; }
.tokens-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
