/**
 * MTX Connect Page Styles
 * Dark premium corporate / fintech theme
 */

/* =========================================================================
   CSS Variables — Dark Premium Palette
   ========================================================================= */
:root {
    /* Dark background layers */
    --color-bg:           #0a0b0f;
    --color-bg-surface:   #111318;
    --color-bg-card:      #161820;
    --color-bg-elevated:  #1c1f2a;
    --color-bg-input:     #0e1016;

    /* Accent — gold/amber for corporate transactional */
    --color-accent:       #d4a843;
    --color-accent-hover: #e8bc55;
    --color-accent-dim:   rgba(212, 168, 67, 0.15);
    --color-accent-glow:  rgba(212, 168, 67, 0.25);

    --color-primary:      #d4a843;
    --color-primary-light:#f0c85a;

    /* Text */
    --color-text:         #e8eaf0;
    --color-text-secondary: #9aa0b4;
    --color-text-muted:   #5c6278;
    --color-text-dim:     #3d4255;

    /* Semantic */
    --color-success:      #22c55e;
    --color-success-dim:  rgba(34, 197, 94, 0.12);
    --color-success-glow: rgba(34, 197, 94, 0.2);
    --color-error:        #f04438;
    --color-error-dim:    rgba(240, 68, 56, 0.12);
    --color-warning:      #f59e0b;

    /* Borders */
    --color-border:       rgba(255, 255, 255, 0.07);
    --color-border-focus: rgba(212, 168, 67, 0.4);
    --color-border-success: rgba(34, 197, 94, 0.3);

    /* Gradients */
    --gradient-accent:    linear-gradient(135deg, #d4a843, #b8892e);
    --gradient-card:      linear-gradient(160deg, #161820 0%, #111318 100%);
    --gradient-success:   linear-gradient(135deg, #22c55e, #16a34a);

    /* Shadows */
    --shadow-card:        0 4px 32px rgba(0, 0, 0, 0.4), 0 1px 0 rgba(255,255,255,0.04) inset;
    --shadow-accent:      0 0 24px rgba(212, 168, 67, 0.2);
    --shadow-accent-hover:0 0 40px rgba(212, 168, 67, 0.35);
    --shadow-success:     0 0 24px rgba(34, 197, 94, 0.2);

    /* Radii */
    --radius-sm:  4px;
    --radius-md:  8px;
    --radius-lg:  12px;
    --radius-xl:  16px;
    --radius-2xl: 20px;

    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'SF Mono', 'JetBrains Mono', Monaco, 'Courier New', monospace;
}

/* =========================================================================
   Reset & Base
   ========================================================================= */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
}

body {
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-main);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Subtle ambient glow behind the card */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(ellipse 60% 40% at 50% 0%, rgba(212, 168, 67, 0.06) 0%, transparent 70%),
        radial-gradient(ellipse 40% 60% at 80% 100%, rgba(34, 197, 94, 0.04) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

/* =========================================================================
   Main Container
   ========================================================================= */
.mtx-container {
    position: relative;
    z-index: 1;
    padding: 60px 20px 80px;
    max-width: 480px;
    margin: 0 auto;
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* =========================================================================
   Connect Box — Main Card
   ========================================================================= */
.connect-box {
    border-radius: var(--radius-2xl);
    padding: 36px 32px;
    position: relative;
    overflow: hidden;
    isolation: isolate;
    background: rgba(22, 24, 32, 0.45);
    backdrop-filter: blur(24px) saturate(160%);
    -webkit-backdrop-filter: blur(24px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.45),
        0 2px 8px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.06),
        inset 0 -1px 0 rgba(0, 0, 0, 0.2);
}

/* Layer 1 — huge rotating square, clipped by overflow:hidden to border edge */
.connect-box::before {
    content: '';
    position: absolute;
    inset: -50%;
    border-radius: 0;
    background: conic-gradient(
        transparent 0deg,
        transparent 300deg,
        rgba(212,168,67,0.1) 320deg,
        rgba(212,168,67,0.5) 345deg,
        #d4a843 355deg,
        rgba(212,168,67,0.5) 360deg
    );
    animation: border-spin 3s linear infinite;
    z-index: 0;
}

/* Layer 2 — glass mask: covers interior, exposes only ~2px border strip */
.connect-box::after {
    content: '';
    position: absolute;
    inset: 2px;
    border-radius: calc(var(--radius-2xl) - 2px);
    background: linear-gradient(
        160deg,
        rgba(22, 24, 32, 0.97) 0%,
        rgba(17, 19, 24, 0.97) 100%
    );
    z-index: 1;
}

/* All direct children must sit above the mask */
.connect-box > * {
    position: relative;
    z-index: 2;
}

@keyframes border-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* =========================================================================
   Header
   ========================================================================= */
.connect-header {
    text-align: center;
    margin-bottom: 28px;
}

.connect-header h1 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--color-accent-hover);
    letter-spacing: -0.3px;
    line-height: 1.3;
}

.connect-header p {
    color: var(--color-text-secondary);
    font-size: 13px;
    line-height: 1.5;
}

/* =========================================================================
   Steps Indicator
   ========================================================================= */
.steps-indicator {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0;
    margin-bottom: 28px;
    padding: 0 16px;
}

.step-dot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    position: relative;
}

.step-dot .dot {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--color-bg-elevated);
    border: 1.5px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    color: var(--color-text-muted);
    transition: all 0.3s ease;
    position: relative;
    z-index: 1;
}

.step-dot.active .dot {
    background: var(--color-bg-elevated);
    border: none;
    color: var(--color-accent);
    box-shadow: 0 0 0 4px var(--color-accent-dim);
    overflow: hidden;
}

.step-dot.active .dot::before {
    content: '';
    position: absolute;
    inset: -50%;
    background: conic-gradient(
        transparent 0deg,
        transparent 300deg,
        rgba(212,168,67,0.1) 320deg,
        rgba(212,168,67,0.5) 345deg,
        #d4a843 355deg,
        rgba(212,168,67,0.5) 360deg
    );
    animation: border-spin 3s linear infinite;
    z-index: 0;
}

.step-dot.active .dot::after {
    content: '';
    position: absolute;
    inset: 2px;
    border-radius: 50%;
    background: var(--color-bg-elevated);
    z-index: 1;
}

.dot-number {
    position: relative;
    z-index: 2;
}

.step-dot.completed .dot {
    background: var(--color-success);
    border-color: var(--color-success);
    color: #fff;
    font-size: 0;  /* hide number, show checkmark via pseudo */
}

.step-dot.completed .dot::after {
    content: '';
    display: block;
    width: 10px;
    height: 6px;
    border-left: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(-45deg) translateY(-1px);
}

.step-label {
    font-size: 11px;
    color: var(--color-text-muted);
    font-weight: 500;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.step-dot.active .step-label {
    color: var(--color-accent);
}

.step-dot.completed .step-label {
    color: var(--color-success);
}

.step-line {
    flex: 1;
    height: 1px;
    background: var(--color-border);
    margin: 0 6px;
    margin-bottom: 20px;
    min-width: 32px;
    max-width: 60px;
    transition: background 0.3s ease;
}

/* =========================================================================
   Content Area
   ========================================================================= */
.content {
    position: relative;
}

.step-content {
    display: none;
    animation: fadeSlideIn 0.25s ease;
}

.step-content.visible {
    display: block;
}

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.step-title {
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 16px;
    color: var(--color-accent-hover);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

/* =========================================================================
   Status Message
   ========================================================================= */
.status {
    padding: 10px 14px;
    border-radius: var(--radius-md);
    margin-bottom: 14px;
    font-size: 13px;
    text-align: center;
    display: none;
    line-height: 1.5;
    font-weight: 500;
    position: relative;
    z-index: 3;
}

.status.error,
.status.status-error {
    display: block;
    background: var(--color-error-dim);
    border: 1px solid rgba(240, 68, 56, 0.25);
    color: #f87171;
}

.status.success,
.status.status-success {
    display: block;
    background: var(--color-success-dim);
    border: 1px solid rgba(34, 197, 94, 0.25);
    color: #4ade80;
}

.status.info,
.status.status-info {
    display: block;
    background: rgba(212, 168, 67, 0.08);
    border: 1px solid rgba(212, 168, 67, 0.2);
    color: var(--color-accent);
}

/* =========================================================================
   Network Buttons
   ========================================================================= */
.network-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.network-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 14px 18px;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    position: relative;
    overflow: hidden;
}

.network-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--color-accent-dim) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.network-btn:hover {
    border-color: var(--color-border-focus);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.network-btn:hover::before {
    opacity: 1;
}

.network-btn.active {
    border-color: var(--color-accent);
    box-shadow: var(--shadow-accent);
}

.network-btn.active::before {
    opacity: 1;
}

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

.network-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: var(--color-bg-input);
    border: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    padding: 6px;
}

.network-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.network-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    position: relative;
}

.network-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text);
    display: block;
}

.network-token {
    font-size: 12px;
    color: var(--color-text-secondary);
    display: block;
}

/* Chevron arrow for network buttons */
.network-btn::after {
    content: '';
    width: 6px;
    height: 6px;
    border-right: 1.5px solid var(--color-text-muted);
    border-top: 1.5px solid var(--color-text-muted);
    transform: rotate(45deg);
    flex-shrink: 0;
    transition: border-color 0.2s;
}

.network-btn:hover::after,
.network-btn.active::after {
    border-color: var(--color-accent);
}

/* =========================================================================
   Action Buttons
   ========================================================================= */
.action-btn {
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
    font-family: var(--font-main);
    letter-spacing: 0.1px;
    position: relative;
    overflow: hidden;
}

.action-btn.primary {
    background: var(--gradient-accent);
    color: #0a0b0f;
    box-shadow: var(--shadow-accent);
}

.action-btn.primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-accent-hover);
    filter: brightness(1.05);
}

.action-btn.primary:active:not(:disabled) {
    transform: translateY(0);
    filter: brightness(0.95);
}

.action-btn.secondary {
    background: var(--color-bg-elevated);
    color: var(--color-success);
    border: 1px solid var(--color-border-success);
    box-shadow: var(--shadow-success);
}

.action-btn.secondary:hover:not(:disabled) {
    transform: translateY(-2px);
    background: var(--color-success-dim);
    border-color: var(--color-success);
    box-shadow: 0 0 32px rgba(34, 197, 94, 0.3);
}

.action-btn.secondary:active:not(:disabled) {
    transform: translateY(0);
}

.action-btn.secondary.success {
    background: var(--gradient-success);
    color: #fff;
    border-color: transparent;
    cursor: default;
}

.action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
    filter: none !important;
}

.btn-icon {
    font-size: 16px;
    line-height: 1;
}

/* Back button */
.back-btn {
    background: transparent !important;
    color: var(--color-text-muted) !important;
    box-shadow: none !important;
    border: 1px solid var(--color-border) !important;
    margin-top: 10px !important;
    font-size: 13px !important;
    padding: 10px 20px !important;
}

.back-btn:hover:not(:disabled) {
    color: var(--color-text-secondary) !important;
    border-color: rgba(255,255,255,0.12) !important;
    transform: none !important;
}

/* =========================================================================
   Wallet Info Box (Step 3)
   ========================================================================= */
.wallet-info-box {
    background: var(--color-bg-input);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    margin-bottom: 14px;
    overflow: hidden;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
}

.info-row:not(:last-child) {
    border-bottom: 1px solid var(--color-border);
}

.info-label {
    color: var(--color-text-muted);
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-value {
    font-weight: 600;
    font-size: 13px;
    color: var(--color-text);
}

.info-value.address {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--color-accent);
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* =========================================================================
   Amount Intent Block (future-ready, hidden by default)
   ========================================================================= */
#amount-intent-block {
    display: none;
    background: var(--color-bg-input);
    border: 1px solid rgba(212, 168, 67, 0.2);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    margin-top: 14px;
}

#amount-intent-block.visible {
    display: block;
    animation: fadeSlideIn 0.25s ease;
}

.amount-intent-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.amount-intent-label {
    font-size: 11px;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.amount-intent-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-accent);
    letter-spacing: -0.3px;
}

.amount-intent-note {
    margin-top: 6px;
    font-size: 11px;
    color: var(--color-text-muted);
    text-align: right;
}

/* =========================================================================
   Result Box (Step 4 / Success)
   ========================================================================= */
#result,
#step-5-result {
    display: none;
    animation: fadeSlideIn 0.3s ease;
}

.result-box {
    background: var(--color-bg-elevated);
    border-radius: var(--radius-xl);
    padding: 28px 24px;
    text-align: center;
    border: 1px solid var(--color-border-success);
    box-shadow: 0 0 40px rgba(34, 197, 94, 0.08);
}

.result-icon {
    width: 60px;
    height: 60px;
    background: var(--gradient-success);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 18px;
    font-size: 0;
    box-shadow: var(--shadow-success);
    position: relative;
}

/* Checkmark via pseudo-element */
.result-icon::after {
    content: '';
    display: block;
    width: 18px;
    height: 11px;
    border-left: 2.5px solid #fff;
    border-bottom: 2.5px solid #fff;
    transform: rotate(-45deg) translateY(-2px);
}

.result-box h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--color-text);
}

.result-subtitle {
    font-size: 13px;
    color: var(--color-text-secondary);
    margin-bottom: 20px;
    line-height: 1.5;
}

.result-details {
    background: var(--color-bg-input);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    overflow: hidden;
    text-align: left;
}

.result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 11px 14px;
}

.result-row:not(:last-child) {
    border-bottom: 1px solid var(--color-border);
}

.result-label {
    color: var(--color-text-muted);
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.result-value {
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-secondary);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: right;
}

.result-link {
    color: var(--color-accent);
    text-decoration: none;
    font-weight: 600;
    font-family: var(--font-mono);
    font-size: 11px;
}

.result-link:hover {
    text-decoration: underline;
    color: var(--color-accent-hover);
}

/* =========================================================================
   Processing Overlay
   ========================================================================= */
#processing-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 11, 15, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 20px;
    z-index: 9999;
}

#processing-overlay.visible {
    display: flex;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 2px solid rgba(255, 255, 255, 0.06);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.processing-text {
    color: var(--color-text-secondary);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.2px;
}

/* =========================================================================
   Mobile Responsive
   ========================================================================= */
@media (max-width: 600px) {
    .mtx-container {
        padding: 20px 16px 40px;
        min-height: auto;
        align-items: flex-start;
    }

    .connect-box {
        padding: 24px 20px;
        border-radius: var(--radius-xl);
    }

    .connect-header h1 {
        font-size: 19px;
    }

    .steps-indicator {
        padding: 0 8px;
    }

    .step-dot .dot {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }

    .step-line {
        min-width: 20px;
    }

    .step-label {
        font-size: 9px;
    }

    .network-icon {
        width: 38px;
        height: 38px;
    }

    .network-name {
        font-size: 14px;
    }

    .info-value.address {
        max-width: 120px;
    }

    .result-value {
        max-width: 150px;
        font-size: 11px;
    }
}

@media (max-width: 380px) {
    .step-line {
        min-width: 14px;
    }

    .network-btn {
        padding: 12px 14px;
        gap: 10px;
    }
}

/* =========================================================================
   Accessibility
   ========================================================================= */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    /* Keep decorative border animations running */
    .connect-box::before,
    .step-dot.active .dot::before {
        animation-duration: 3s !important;
        animation-iteration-count: infinite !important;
    }
}

button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

::selection {
    background: rgba(10, 11, 15, 0.01);
    color: var(--color-accent-hover);
}

/* =========================================================================
   WalletConnect Modal Overrides — hide unwanted elements
   ========================================================================= */
w3m-alertbar,
wui-alertbar,
[class*="w3m-alertbar"],
[class*="alertbar"] {
    display: none !important;
}

w3m-all-wallets-widget,
wui-list-wallet[name="All Wallets"],
[data-testid="all-wallets"],
w3m-modal w3m-router w3m-connect-view w3m-wallet-login-list wui-list-wallet:last-child,
w3m-connect-view wui-list-wallet[name="All Wallets"] {
    display: none !important;
}

w3m-modal [class*="all-wallet"],
w3m-modal [class*="AllWallet"] {
    display: none !important;
}

/* =========================================================================
   Step 4: Payment Confirmation Form
   ========================================================================= */

.step4-amount-wrap {
    margin-top: 14px;
    margin-bottom: 14px;
}

.step4-amount-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.step4-amount-input {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 16px;
    background: var(--color-bg-input);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-size: 20px;
    font-weight: 700;
    font-family: var(--font-mono);
    outline: none;
    transition: border-color 0.15s;
    -moz-appearance: textfield;
}

.step4-amount-input::-webkit-outer-spin-button,
.step4-amount-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
}

.step4-amount-input:focus {
    border-color: var(--color-border-focus);
}

.step4-amount-input.error {
    border-color: var(--color-error);
}

.step4-amount-error {
    display: block;
    min-height: 16px;
    margin-top: 4px;
    font-size: 11px;
    color: var(--color-error);
}

.step-subtitle {
    font-size: 12px;
    color: var(--color-text-secondary);
    margin-top: -8px;
    margin-bottom: 12px;
    display: none;
}
