/* ================================================
   AGENTIC ROUTING - DARK THEME DESIGN SYSTEM
   Inspired by OKX Wallet Bridge Routing UI
   ================================================ */

:root {
    /* Background layers - deep void aesthetic */
    --bg-void: #050508;
    --bg-primary: #0a0a0f;
    --bg-secondary: #111118;
    --bg-elevated: #1a1a24;
    --bg-card: #1e1e2a;
    --bg-card-hover: #252535;
    --bg-glass: rgba(30, 30, 50, 0.6);

    /* Accent colors */
    --accent-agent: #0070f3;
    --accent-route: #00c853;
    --accent-score: #ffd700;
    --accent-warning: #ff6b35;
    --accent-danger: #ff3b3b;
    --accent-subtle: #6366f1;
    --accent-purple: #a855f7;

    /* Glow effects */
    --glow-agent: 0 0 30px rgba(0, 112, 243, 0.4);
    --glow-route: 0 0 40px rgba(0, 200, 83, 0.3);
    --glow-selected: 0 0 0 2px rgba(0, 200, 83, 0.5);

    /* Text hierarchy */
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-tertiary: rgba(255, 255, 255, 0.4);
    --text-muted: rgba(255, 255, 255, 0.25);

    /* Borders */
    --border: rgba(255, 255, 255, 0.08);
    --border-accent: rgba(0, 112, 243, 0.3);
    --border-selected: rgba(0, 200, 83, 0.6);

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', monospace;

    /* Animation */
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --duration-fast: 150ms;
    --duration-normal: 300ms;

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
}

/* ================================================
   BASE STYLES
   ================================================ */

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-void);
    color: var(--text-primary);
    min-height: 100vh;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 30%, rgba(99, 102, 241, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 70%, rgba(0, 112, 243, 0.04) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

/* ================================================
   LAYOUT
   ================================================ */

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

.demo-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.demo-header {
    padding: var(--space-md) 0;
    border-bottom: 1px solid var(--border);
    background: var(--bg-primary);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

.demo-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-weight: 700;
    font-size: 18px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: var(--accent-agent);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.demo-main {
    flex: 1;
    padding: var(--space-xl) 0;
}

/* ================================================
   HERO
   ================================================ */

.hero {
    text-align: center;
    padding: var(--space-xl) 0 var(--space-2xl);
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-xs) var(--space-md);
    background: var(--bg-glass);
    border: 1px solid var(--border-accent);
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-agent);
    margin-bottom: var(--space-md);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.hero-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--accent-agent);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

.hero-title {
    font-size: clamp(28px, 5vw, 48px);
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.03em;
    margin-bottom: var(--space-md);
}

.hero-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    max-width: 500px;
    margin: 0 auto;
    line-height: 1.5;
}

/* ================================================
   TWO COLUMN ROUTING LAYOUT (OKX Style)
   ================================================ */

.routing-layout {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: var(--space-xl);
    align-items: start;
}

@media (max-width: 900px) {
    .routing-layout {
        grid-template-columns: 1fr;
    }
}

/* ================================================
   QUERY PANEL (Left - From/To Style)
   ================================================ */

.query-panel {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.query-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.query-card-header {
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-elevated);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.query-label {
    font-size: 12px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.query-badge {
    font-size: 10px;
    padding: 2px 8px;
    background: var(--accent-agent);
    color: #fff;
    border-radius: 9999px;
    font-weight: 600;
}

.query-badge.constraint {
    background: var(--accent-purple);
}

.query-card-body {
    padding: var(--space-lg);
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.query-icon {
    width: 48px;
    height: 48px;
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.query-content {
    flex: 1;
}

.query-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.query-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}

.query-constraints {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-top: var(--space-xs);
}

.query-constraints span {
    font-size: 11px;
    padding: 2px 8px;
    background: var(--bg-elevated);
    border-radius: 4px;
    color: var(--text-secondary);
}

.query-arrow {
    display: flex;
    justify-content: center;
    color: var(--text-tertiary);
    padding: var(--space-xs) 0;
}

/* Selected Route Preview */
.selected-route-preview {
    margin-top: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
    font-size: 13px;
    color: var(--text-tertiary);
}

.preview-provider {
    color: var(--accent-agent);
    font-weight: 600;
    cursor: pointer;
}

.btn-full {
    width: 100%;
}

/* ================================================
   ROUTES PANEL (Right - Bridge Selection Style)
   ================================================ */

.routes-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    overflow: hidden;
}

.routes-header {
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-md);
}

.routes-title span:first-child {
    font-size: 16px;
    font-weight: 700;
    display: block;
}

.routes-subtitle {
    font-size: 12px;
    color: var(--text-tertiary);
    display: block;
    margin-top: 2px;
}

.prioritize-btn {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all var(--duration-fast);
}

.prioritize-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent-agent);
    color: var(--text-primary);
}

.routes-list {
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    max-height: 500px;
    overflow-y: auto;
}

/* ================================================
   ROUTE CARD (OKX Bridge Card Style)
   ================================================ */

.route-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-out-expo);
    opacity: 0;
    transform: translateY(10px);
    animation: fadeInUp 0.4s var(--ease-out-expo) forwards;
}

.route-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent-agent);
    transform: translateY(-2px);
}

.route-card.selected {
    border-color: var(--border-selected);
    box-shadow: var(--glow-selected);
    background: rgba(0, 200, 83, 0.05);
}

.route-card.rejected {
    opacity: 0.4;
    pointer-events: none;
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.route-card-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.route-provider-icon {
    width: 28px;
    height: 28px;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.route-provider-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.route-rank {
    margin-left: auto;
    font-size: 11px;
    padding: 2px 8px;
    background: var(--accent-route);
    color: #000;
    border-radius: 9999px;
    font-weight: 700;
}

.route-card:not(.selected) .route-rank {
    background: var(--bg-elevated);
    color: var(--text-tertiary);
}

.route-value {
    margin-bottom: var(--space-md);
}

.route-value-main {
    font-size: 24px;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-primary);
}

.route-value-sub {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.route-metrics {
    display: grid;
    gap: var(--space-sm);
}

.route-metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

.route-metric-label {
    color: var(--text-tertiary);
}

.route-metric-value {
    color: var(--text-secondary);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

.route-metric-value.highlight {
    color: var(--accent-score);
}

/* Route Chain Visualization */
.route-chain {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}

.route-chain-icon {
    width: 20px;
    height: 20px;
    background: var(--bg-elevated);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
}

.route-chain-arrow {
    color: var(--text-muted);
    font-size: 10px;
}

/* ================================================
   AGENT LOG
   ================================================ */

.agent-log {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.agent-log-header {
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.agent-log-header::before {
    content: '🤖';
    font-size: 16px;
}

.agent-log-title {
    font-size: 14px;
    font-weight: 600;
}

.agent-log-status {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--accent-route);
}

.agent-log-status::before {
    content: '';
    width: 6px;
    height: 6px;
    background: currentColor;
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

.agent-log-content {
    padding: var(--space-lg);
    max-height: 250px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.8;
}

.log-entry {
    opacity: 0;
    animation: fadeInUp 0.3s var(--ease-out-expo) forwards;
}

.log-entry+.log-entry {
    margin-top: var(--space-xs);
}

.log-timestamp {
    color: var(--text-muted);
    margin-right: var(--space-sm);
}

.log-action {
    color: var(--accent-agent);
}

.log-success {
    color: var(--accent-route);
}

.log-data {
    color: var(--text-secondary);
}

.log-value {
    color: var(--accent-score);
    font-weight: 600;
}

/* ================================================
   BUTTONS
   ================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-xl);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--duration-fast);
}

.btn-primary {
    background: var(--text-primary);
    color: var(--bg-void);
}

.btn-primary:hover:not(:disabled) {
    background: var(--text-secondary);
    transform: translateY(-1px);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

/* ================================================
   PURCHASE SUCCESS OVERLAY
   ================================================ */

.success-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 5, 8, 0.95);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
    backdrop-filter: blur(20px);
}

.success-card {
    background: var(--bg-card);
    border: 1px solid var(--border-selected);
    border-radius: var(--radius-xl);
    padding: var(--space-2xl);
    max-width: 500px;
    width: 100%;
    text-align: center;
    box-shadow: 0 0 100px rgba(0, 200, 83, 0.2);
    transform: scale(0.9);
    opacity: 0;
    transition: all 0.5s var(--ease-out-expo);
}

.success-overlay.visible .success-card {
    transform: scale(1);
    opacity: 1;
}

.success-icon {
    width: 80px;
    height: 80px;
    background: var(--accent-route);
    border-radius: 50%;
    margin: 0 auto var(--space-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    color: #000;
    box-shadow: var(--glow-route);
}

.success-title {
    font-size: 32px;
    font-weight: 800;
    margin-bottom: var(--space-md);
    background: linear-gradient(135deg, #fff 0%, var(--accent-route) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.success-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: var(--space-2xl);
    line-height: 1.6;
}

.success-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
    margin-bottom: var(--space-2xl);
}

.success-stat {
    background: var(--bg-elevated);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    text-align: center;
}

.success-stat-label {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-bottom: 4px;
    text-transform: uppercase;
}

.success-stat-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent-score);
    font-family: var(--font-mono);
}

.success-hash {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    word-break: break-all;
    margin-bottom: var(--space-xl);
    padding: var(--space-sm);
    background: var(--bg-void);
    border-radius: 4px;
}

/* ================================================
   RESPONSIVE
   ================================================ */

@media (max-width: 768px) {
    .routing-layout {
        grid-template-columns: 1fr;
    }

    .routes-list {
        max-height: 400px;
    }

    .demo-header .container {
        flex-direction: column;
        gap: var(--space-md);
    }
}