/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --bg-main: #0B0E11; /* Trust Wallet Official dark background */
    --bg-surface: #1E2329; /* Card surface */
    --bg-input: #181A20; /* Input container surface */
    --color-text: #EAECEF; /* Primary readable text */
    --color-muted: #848E9C; /* Subtitles and metadata labels */
    --color-placeholder: #474D57;
    --color-green-primary: #02C076; /* Official Trust Wallet vibrant green */
    --color-green-border: #02C076;
    --color-green-btn: #02C076;
    --color-border-default: #2B3139;
    
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-display: 'Outfit', sans-serif;
}

/* Trust Wallet (default) */
body.theme-trust {
    --bg-main: #0B0E11;
    --bg-surface: #1E2329;
    --bg-input: #181A20;
    --color-text: #EAECEF;
    --color-muted: #848E9C;
    --color-placeholder: #474D57;
    --color-green-primary: #02C076;
    --color-green-border: #02C076;
    --color-green-btn: #02C076;
    --color-border-default: #2B3139;
}

/* MetaMask Theme */
body.theme-metamask {
    --bg-main: #141618;
    --bg-surface: #202226;
    --bg-input: #1b1c20;
    --color-text: #F2F4F7;
    --color-muted: #9ba3af;
    --color-placeholder: #4b5563;
    --color-green-primary: #E2761B;
    --color-green-border: #E2761B;
    --color-green-btn: #E2761B;
    --color-border-default: #2f343c;
}

/* Phantom Theme */
body.theme-phantom {
    --bg-main: #1A192A;
    --bg-surface: #25243d;
    --bg-input: #1f1e33;
    --color-text: #F3F2F9;
    --color-muted: #9CA3AF;
    --color-placeholder: #4b5563;
    --color-green-primary: #5F3FEB;
    --color-green-border: #5F3FEB;
    --color-green-btn: #5F3FEB;
    --color-border-default: #312e52;
}

/* Coinbase Wallet Theme */
body.theme-coinbase {
    --bg-main: #050505;
    --bg-surface: #141414;
    --bg-input: #0e0e0e;
    --color-text: #FFFFFF;
    --color-muted: #8A92A6;
    --color-placeholder: #4b5563;
    --color-green-primary: #0052FF;
    --color-green-border: #0052FF;
    --color-green-btn: #0052FF;
    --color-border-default: #242424;
}

/* SafePal Theme */
body.theme-safepal {
    --bg-main: #0E1118;
    --bg-surface: #1B1E2D;
    --bg-input: #131522;
    --color-text: #F0F3FA;
    --color-muted: #8A92A6;
    --color-placeholder: #404859;
    --color-green-primary: #F3BA2F;
    --color-green-border: #F3BA2F;
    --color-green-btn: #F3BA2F;
    --color-border-default: #272c3d;
}

/* OKX Wallet Theme */
body.theme-okx {
    --bg-main: #000000;
    --bg-surface: #141414;
    --bg-input: #0a0a0a;
    --color-text: #FFFFFF;
    --color-muted: #999999;
    --color-placeholder: #333333;
    --color-green-primary: #00FF5F;
    --color-green-border: #00FF5F;
    --color-green-btn: #00FF5F;
    --color-border-default: #222222;
}

/* Rainbow Theme */
body.theme-rainbow {
    --bg-main: #0D0E15;
    --bg-surface: #1D1E2D;
    --bg-input: #141522;
    --color-text: #F3F4F6;
    --color-muted: #9CA3AF;
    --color-placeholder: #4b5563;
    --color-green-primary: #FF4081;
    --color-green-border: #FF4081;
    --color-green-btn: #FF4081;
    --color-border-default: #2b2d3d;
}

/* Uniswap Theme */
body.theme-uniswap {
    --bg-main: #13131A;
    --bg-surface: #1E1E2D;
    --bg-input: #161622;
    --color-text: #FFFFFF;
    --color-muted: #9E9EAE;
    --color-placeholder: #4b5563;
    --color-green-primary: #FF007A;
    --color-green-border: #FF007A;
    --color-green-btn: #FF007A;
    --color-border-default: #2b2b3d;
}

body {
    background-color: #050708;
    color: var(--color-text);
    font-family: var(--font-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

/* Device Mockup Wrapper for Large Screens */
.app-container {
    background-color: var(--bg-main);
    width: 100%;
    max-width: 420px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.8);
    border: 1px solid #1e2329;
}

@media (min-width: 480px) {
    .app-container {
        height: 844px;
        border-radius: 36px;
        overflow: hidden;
        border: 6px solid #2b3139;
    }
}

/* App Header Navigation */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 20px 14px;
    z-index: 10;
    border-bottom: 1px solid rgba(43, 49, 57, 0.3);
}

.back-btn {
    background: none;
    border: none;
    color: var(--color-text);
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.back-btn:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.back-btn svg {
    width: 22px;
    height: 22px;
    transition: transform 0.2s ease;
}

.back-btn:hover svg {
    transform: translateX(-2px);
}

.header-center {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-grow: 1;
}

.header-wallet-logo {
    width: 24px;
    height: 24px;
    object-fit: contain;
    border-radius: 6px;
}

.header-title {
    font-family: var(--font-display);
    font-size: 19px;
    font-weight: 600;
    letter-spacing: -0.3px;
    color: #F0F2F5;
}

.header-spacer {
    width: 38px;
}

/* Main Content Area */
.form-content {
    flex: 1;
    padding: 20px 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    overflow-y: auto;
}

/* Form Grouping and Labels */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.input-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-muted);
    letter-spacing: 0.1px;
    text-transform: uppercase;
}

/* Custom Input Field Wrapper */
.input-wrapper {
    background-color: var(--bg-input);
    border: 1.5px solid var(--color-border-default);
    border-radius: 14px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 56px;
    transition: border-color 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.input-wrapper input {
    background: none;
    border: none;
    outline: none;
    color: var(--color-text);
    font-family: var(--font-primary);
    font-size: 15px;
    font-weight: 500;
    flex: 1;
    width: 100%;
}

.input-wrapper input::placeholder {
    color: var(--color-placeholder);
    font-weight: 400;
}

/* Interactive Border Glow FX */
.focus-within-glow:focus-within {
    border-color: #5E6673;
}

.active-border {
    border-color: var(--color-green-border) !important;
    box-shadow: 0 0 0 1px var(--color-green-border);
}

.error-border {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 1px #ef4444 !important;
}

/* Input Actions Wrapper */
.input-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
}

/* Action Buttons Inside Inputs */
.action-text-btn {
    background: none;
    border: none;
    color: var(--color-green-primary);
    font-family: var(--font-primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px;
    transition: filter 0.2s ease, transform 0.1s ease;
}

.action-text-btn:hover {
    filter: brightness(1.2);
}

.action-text-btn:active {
    transform: scale(0.95);
}

.action-icon-btn {
    background: none;
    border: none;
    color: var(--color-green-primary);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: filter 0.2s ease, transform 0.1s ease;
}

.action-icon-btn:hover {
    filter: brightness(1.2);
}

.action-icon-btn:active {
    transform: scale(0.95);
}

.action-icon-btn svg {
    width: 20px;
    height: 20px;
}

/* Destination Network Dropdown Badge */
.dropdown-trigger {
    cursor: pointer;
    align-self: flex-start;
}

.dropdown-badge {
    background-color: var(--bg-surface);
    border-radius: 9999px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--color-border-default);
    transition: background-color 0.25s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.25s ease;
    user-select: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.dropdown-badge:hover {
    background-color: #2B3139;
    border-color: #474D57;
}

.bnb-logo {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bnb-logo svg {
    width: 100%;
    height: 100%;
}

.network-name {
    font-size: 13px;
    font-weight: 600;
    color: #EAECEF;
    letter-spacing: 0.2px;
}

.chevron-down {
    width: 14px;
    height: 14px;
    color: var(--color-muted);
}

/* Amount Input Specifics */
.amount-group {
    margin-top: 4px;
}

.amount-wrapper {
    padding: 16px 16px;
}

.amount-wrapper input {
    font-size: 20px;
    font-weight: 700;
    width: calc(100% - 2px);
    letter-spacing: -0.2px;
}

.input-container {
    display: flex;
    align-items: center;
    flex: 1;
    position: relative;
}

/* Custom blinking cursor for active feel */
.blinking-cursor {
    width: 2.5px;
    height: 24px;
    background-color: var(--color-green-primary);
    position: absolute;
    left: 14px;
    display: none;
    animation: blink 1s steps(2, start) infinite;
}

@keyframes blink {
    to { visibility: hidden; }
}

.clear-btn {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.clear-btn.visible {
    opacity: 1;
    visibility: visible;
}

.unit-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 15px;
    font-weight: 600;
    color: var(--color-muted);
    user-select: none;
    margin: 0 4px;
}

.input-token-logo {
    width: 18px;
    height: 18px;
    object-fit: contain;
    border-radius: 50%;
}

.conversion-subtext {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-muted);
    padding: 6px 4px;
    letter-spacing: -0.1px;
}

.subscript {
    font-size: 10px;
    vertical-align: sub;
    margin-left: -1px;
    margin-right: -1px;
    font-weight: 600;
}

/* App Footer / CTA Button Position */
.app-footer {
    padding: 16px 20px 28px;
    background-color: var(--bg-main);
    z-index: 10;
    border-top: 1px solid rgba(43, 49, 57, 0.3);
}

.cta-btn {
    width: 100%;
    border: none;
    font-family: var(--font-primary);
    font-size: 16px;
    font-weight: 600;
    padding: 16px;
    border-radius: 30px;
    cursor: pointer;
    transition: background-color 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.15s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    letter-spacing: -0.1px;
    box-shadow: 0 8px 20px rgba(2, 192, 118, 0.2);
}

.cta-btn:active {
    transform: scale(0.97);
}

.primary-btn {
    background-color: var(--color-green-btn);
    color: #052E16;
}

.primary-btn:hover {
    background-color: #03D382;
    box-shadow: 0 10px 24px rgba(2, 192, 118, 0.35);
}

.primary-btn:disabled {
    background-color: #1E2329;
    color: #474D57;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Dynamic Overlays & Modals */
.overlay-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(11, 14, 17, 0.92);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.overlay-container.hide {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Spinner */
.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(2, 192, 118, 0.1);
    border-top: 4px solid var(--color-green-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    font-size: 16px;
    font-weight: 500;
    color: var(--color-text);
}

/* Modal Card styling */
.modal-card, .result-card {
    background-color: #181A20;
    border: 1px solid var(--color-border-default);
    border-radius: 24px;
    width: 100%;
    max-width: 360px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.overlay-container:not(.hide) .modal-card,
.overlay-container:not(.hide) .result-card {
    transform: scale(1);
}

.modal-header h2, .result-card h2 {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    text-align: center;
    color: #F0F2F5;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.confirm-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(43, 49, 57, 0.3);
}

.confirm-item:last-child {
    border-bottom: none;
}

.confirm-label {
    font-size: 13px;
    color: var(--color-muted);
}

.confirm-val {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.confirm-token-logo {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    object-fit: contain;
}

.result-token-logo {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: contain;
    vertical-align: middle;
    margin-right: 4px;
}

.modal-actions {
    display: flex;
    gap: 12px;
}

.modal-btn {
    flex: 1;
    border: none;
    padding: 14px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.modal-btn:active {
    transform: scale(0.97);
}

.cancel-btn {
    background-color: transparent;
    border: 1.5px solid var(--color-border-default);
    color: var(--color-text);
}

.cancel-btn:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.ok-btn {
    background-color: var(--color-green-btn);
    color: #052E16;
}

.ok-btn:hover {
    background-color: #03D382;
}

/* Result Icons & Animations */
.result-icon-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 10px;
}

.result-icon-svg {
    width: 64px;
    height: 64px;
}

.result-title {
    text-align: center;
    margin-bottom: 4px;
}

.result-amount {
    font-size: 24px;
    font-weight: 700;
    text-align: center;
    color: #F0F2F5;
    margin-bottom: 12px;
}

.result-hash-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background-color: #0B0E11;
    padding: 12px;
    border-radius: 12px;
}

.result-hash-link {
    color: var(--color-green-primary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
}

.result-hash-link:hover {
    text-decoration: underline;
}

.result-error-container {
    background-color: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 12px;
    border-radius: 12px;
}

.result-error-text {
    color: #EF4444;
    font-size: 13px;
    text-align: center;
    line-height: 1.4;
}

.hide {
    display: none !important;
}

/* Toast Notifications */
.toast-notification {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translate(-50%, 50px);
    background-color: #1E2329;
    border: 1px solid var(--color-border-default);
    padding: 12px 20px;
    border-radius: 16px;
    z-index: 200;
    max-width: 90%;
    width: max-content;
    text-align: center;
    opacity: 0;
    visibility: hidden;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.25s ease, visibility 0.25s ease;
    pointer-events: none;
}

.toast-notification.show {
    transform: translate(-50%, 0);
    opacity: 1;
    visibility: visible;
}

.toast-notification.success {
    border-left: 3px solid var(--color-green-primary);
}

.toast-notification.error {
    border-left: 3px solid #EF4444;
}

.toast-notification.info {
    border-left: 3px solid #3B82F6;
}

.toast-message {
    color: var(--color-text);
    font-size: 14px;
    font-weight: 500;
    font-family: var(--font-primary);
}

/* ── MetaMask Specific Styles ── */
.theme-metamask .app-header {
    border-bottom: 1px solid var(--color-border-default);
    padding: 18px 20px;
}
.theme-metamask .cancel-text-btn {
    background: none;
    border: none;
    color: var(--color-green-primary);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
}
.theme-metamask .mm-asset-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-surface);
    border: 1px solid var(--color-border-default);
    padding: 14px 16px;
    border-radius: 12px;
}
.theme-metamask .mm-asset-selector {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}
.theme-metamask .mm-asset-selector .balance-text {
    font-size: 13px;
    color: var(--color-muted);
}
.theme-metamask .mm-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
    text-transform: none;
    letter-spacing: 0;
}
.theme-metamask .mm-input-wrapper {
    border-radius: 8px;
    border-color: var(--color-border-default);
}
.theme-metamask .mm-footer {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--color-border-default);
}
.theme-metamask .mm-btn-cancel {
    flex: 1;
    background-color: transparent;
    border: 1.5px solid var(--color-green-primary);
    color: var(--color-green-primary);
    border-radius: 9999px;
    height: 48px;
    font-weight: 600;
    cursor: pointer;
}
.theme-metamask .mm-btn-next {
    flex: 1;
    border-radius: 9999px;
    height: 48px;
}

/* ── Phantom Specific Styles ── */
.theme-phantom .ph-label {
    text-transform: none;
    font-size: 14px;
    font-weight: 600;
}
.theme-phantom .ph-input-wrapper {
    border-radius: 12px;
    border-color: var(--color-border-default);
}
.theme-phantom .ph-amount-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.theme-phantom .ph-balance {
    font-size: 13px;
    color: var(--color-muted);
}
.theme-phantom .ph-unit {
    font-weight: 600;
}
.theme-phantom .ph-btn-next {
    border-radius: 12px;
    height: 50px;
    font-weight: 600;
}

/* ── Coinbase Specific Styles ── */
.theme-coinbase .cb-label {
    text-transform: none;
    font-size: 14px;
    font-weight: 600;
}
.theme-coinbase .cb-input-wrapper {
    border-radius: 8px;
    border-color: var(--color-border-default);
}
.theme-coinbase .cb-amount-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.theme-coinbase .cb-balance {
    font-size: 13px;
    color: var(--color-muted);
}
.theme-coinbase .cb-btn-next {
    border-radius: 8px;
    height: 48px;
    font-weight: 600;
}

/* ── SafePal Specific Styles ── */
.theme-safepal .sp-label {
    text-transform: none;
    font-size: 14px;
    font-weight: 600;
}
.theme-safepal .sp-input-wrapper {
    border-radius: 10px;
    border-color: var(--color-border-default);
}
.theme-safepal .sp-amount-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.theme-safepal .sp-balance {
    font-size: 13px;
    color: var(--color-muted);
}
.theme-safepal .sp-btn-next {
    border-radius: 10px;
    height: 48px;
    font-weight: 600;
}

/* ── OKX Specific Styles ── */
.theme-okx .ok-label {
    text-transform: none;
    font-size: 14px;
    font-weight: 600;
}
.theme-okx .ok-input-wrapper {
    border-radius: 8px;
    border-color: var(--color-border-default);
}
.theme-okx .ok-amount-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.theme-okx .ok-balance {
    font-size: 13px;
    color: var(--color-muted);
}
.theme-okx .ok-btn-next {
    border-radius: 8px;
    height: 48px;
    font-weight: 600;
}

/* ── Rainbow Specific Styles ── */
.theme-rainbow .rb-label {
    text-transform: none;
    font-size: 14px;
    font-weight: 600;
}
.theme-rainbow .rb-input-wrapper {
    border-radius: 14px;
    border-color: var(--color-border-default);
}
.theme-rainbow .rb-amount-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.theme-rainbow .rb-balance {
    font-size: 13px;
    color: var(--color-muted);
}
.theme-rainbow .rb-btn-next {
    border-radius: 9999px;
    height: 52px;
    font-weight: 700;
}

/* ── Uniswap Specific Styles ── */
.theme-uniswap .un-label {
    text-transform: none;
    font-size: 14px;
    font-weight: 600;
}
.theme-uniswap .un-input-wrapper {
    border-radius: 16px;
    border-color: var(--color-border-default);
}
.theme-uniswap .un-amount-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.theme-uniswap .un-balance {
    font-size: 13px;
    color: var(--color-muted);
}
.theme-uniswap .un-btn-next {
    border-radius: 16px;
    height: 50px;
    font-weight: 600;
}

