/* ============================================
   Kalshi <> Polymarket Arbitrage
   A Modern Arbitrage Discovery Platform
   ============================================ */

:root {
    /* Core Colors - Cyberpunk/Trading Terminal Aesthetic */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a25;
    --bg-card: #15151f;
    --bg-card-hover: #1e1e2d;
    
    /* Accent Colors */
    --accent-kalshi: #00d4aa;
    --accent-kalshi-dim: rgba(0, 212, 170, 0.15);
    --accent-polymarket: #8b5cf6;
    --accent-polymarket-dim: rgba(139, 92, 246, 0.15);
    --accent-profit: #22c55e;
    --accent-profit-dim: rgba(34, 197, 94, 0.15);
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;
    --accent-info: #3b82f6;
    
    /* Text Colors */
    --text-primary: #f0f0f5;
    --text-secondary: #a0a0b0;
    --text-muted: #606070;
    
    /* Borders & Effects */
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-glow: rgba(139, 92, 246, 0.3);
    --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px rgba(139, 92, 246, 0.2);
    
    /* Typography */
    --font-primary: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    
    /* Spacing */
    --gap-xs: 4px;
    --gap-sm: 8px;
    --gap-md: 16px;
    --gap-lg: 24px;
    --gap-xl: 32px;
    
    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 9999px;
}

/* ============================================
   Base Styles
   ============================================ */

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

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
}

/* ============================================
   Animated Background
   ============================================ */

.bg-grid {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
    z-index: 0;
}

.bg-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.4;
    pointer-events: none;
    z-index: 0;
    animation: float 20s ease-in-out infinite;
}

.bg-glow-1 {
    width: 600px;
    height: 600px;
    background: var(--accent-polymarket);
    top: -200px;
    right: -200px;
    animation-delay: 0s;
}

.bg-glow-2 {
    width: 500px;
    height: 500px;
    background: var(--accent-kalshi);
    bottom: -150px;
    left: -150px;
    animation-delay: -7s;
}

.bg-glow-3 {
    width: 400px;
    height: 400px;
    background: var(--accent-info);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -14s;
    opacity: 0.2;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(30px, -30px) scale(1.05); }
    50% { transform: translate(-20px, 20px) scale(0.95); }
    75% { transform: translate(20px, 30px) scale(1.02); }
}

/* ============================================
   Main Container
   ============================================ */

.main-container {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: var(--gap-md);
    gap: var(--gap-md);
}

/* ============================================
   Site Header
   ============================================ */

.site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--gap-md) var(--gap-lg);
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(10px);
}

.site-title {
    display: flex;
    align-items: center;
    gap: var(--gap-sm);
    font-size: 1.5rem;
    font-weight: 700;
}

.site-title .platform {
    font-weight: 800;
}

.site-title .platform.kalshi {
    color: var(--accent-kalshi);
}

.site-title .platform.polymarket {
    color: var(--accent-polymarket);
}

.site-title .separator {
    color: var(--text-muted);
    font-weight: 400;
}

.site-title .title-label {
    color: var(--text-secondary);
    font-weight: 500;
    margin-left: var(--gap-xs);
}

.update-indicator {
    display: flex;
    align-items: center;
    gap: var(--gap-sm);
    color: var(--text-secondary);
    font-size: 0.9rem;
    background: var(--bg-tertiary);
    padding: var(--gap-sm) var(--gap-md);
    border-radius: var(--radius-full);
}

.update-indicator i {
    color: var(--accent-profit);
}

.update-indicator .update-label {
    color: var(--text-muted);
}

.update-indicator #last-update {
    font-family: var(--font-mono);
    font-weight: 600;
}

.pulse-indicator i {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ============================================
   3x3 Arbitrage Grid
   ============================================ */

.arb-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: var(--gap-md);
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.grid-cell {
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================
   Arbitrage Card (Single Trade)
   ============================================ */

.arb-card {
    width: 100%;
    height: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--gap-md);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.arb-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-kalshi), var(--accent-polymarket));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.arb-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-glow);
    transform: scale(1.02);
    box-shadow: var(--shadow-glow);
}

.arb-card:hover::before {
    opacity: 1;
}

/* Card Header */
.arb-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--gap-sm);
    gap: var(--gap-sm);
}

.arb-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
    flex: 1;
}

.profit-badge {
    flex-shrink: 0;
    padding: 4px 10px;
    background: var(--accent-profit-dim);
    color: var(--accent-profit);
    border-radius: var(--radius-full);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 700;
}

.apy-badge {
    flex-shrink: 0;
    padding: 4px 10px;
    background: var(--accent-profit-dim);
    color: var(--accent-profit);
    border-radius: var(--radius-full);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
}

.apy-badge.high {
    background: linear-gradient(135deg, var(--accent-profit-dim), rgba(34, 197, 94, 0.3));
    animation: glow-pulse 2s ease-in-out infinite;
}

@keyframes glow-pulse {
    0%, 100% { box-shadow: 0 0 5px var(--accent-profit-dim); }
    50% { box-shadow: 0 0 15px var(--accent-profit); }
}

/* Key Metrics Row */
.arb-metrics {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--gap-sm);
    margin-bottom: var(--gap-sm);
    padding: var(--gap-sm);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.arb-metric {
    text-align: center;
}

.arb-metric-value {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.arb-metric-value.profit {
    color: var(--accent-profit);
    font-size: 1.3rem;
}

.arb-metric-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Execution Details */
.arb-execution {
    flex: 1;
    overflow: hidden;
}

.execution-title {
    font-size: 0.75rem;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
    margin-bottom: var(--gap-sm);
    display: flex;
    align-items: center;
    gap: var(--gap-xs);
    flex-wrap: wrap;
}

.execution-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.execution-row {
    display: grid;
    grid-template-columns: 55px 1fr 70px;
    gap: var(--gap-sm);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
}

.execution-row:hover {
    background: var(--bg-card-hover);
}

.exec-qty {
    color: var(--text-secondary);
}

.exec-prices {
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

.exec-prices .kalshi-price {
    color: var(--accent-kalshi);
}

.exec-prices .poly-price {
    color: var(--accent-polymarket);
}

.exec-profit {
    color: var(--accent-profit);
    text-align: right;
    font-weight: 600;
}

/* Card Footer */
.arb-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: var(--gap-sm);
    border-top: 1px solid var(--border-subtle);
}

.card-meta {
    display: flex;
    gap: var(--gap-md);
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.meta-item i {
    font-size: 0.7rem;
}

.meta-item.apy {
    color: var(--accent-info);
    font-weight: 600;
}

.meta-item.resolution {
    color: var(--text-secondary);
}

.card-links {
    display: flex;
    gap: var(--gap-sm);
}

.card-link {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 700;
    transition: all 0.2s ease;
}

.card-link.kalshi {
    background: var(--accent-kalshi-dim);
    color: var(--accent-kalshi);
    border: 1px solid var(--accent-kalshi);
}

.card-link.kalshi:hover {
    background: var(--accent-kalshi);
    color: var(--bg-primary);
}

.card-link.polymarket {
    background: var(--accent-polymarket-dim);
    color: var(--accent-polymarket);
    border: 1px solid var(--accent-polymarket);
}

.card-link.polymarket:hover {
    background: var(--accent-polymarket);
    color: white;
}

/* ============================================
   Center Stage - Face Tracker
   ============================================ */

.center-cell {
    flex-direction: column;
    gap: var(--gap-md);
}

.face-container {
    position: relative;
    width: 200px;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.face-ring {
    position: absolute;
    border-radius: 50%;
    border: 2px solid transparent;
    animation: ring-rotate 20s linear infinite;
}

.ring-outer {
    width: 100%;
    height: 100%;
    border-color: var(--accent-polymarket);
    opacity: 0.3;
    animation-direction: normal;
}

.ring-middle {
    width: 90%;
    height: 90%;
    border-color: var(--accent-kalshi);
    opacity: 0.4;
    animation-direction: reverse;
    animation-duration: 15s;
}

.ring-inner {
    width: 80%;
    height: 80%;
    border-color: var(--accent-info);
    opacity: 0.2;
    animation-duration: 25s;
}

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

.face-tracker {
    position: relative;
    width: 160px;
    height: 160px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--bg-tertiary);
    box-shadow: 
        0 0 0 4px var(--bg-secondary),
        0 0 40px rgba(139, 92, 246, 0.3),
        inset 0 0 30px rgba(0, 0, 0, 0.5);
    z-index: 2;
}

.face-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.1s ease-out;
}

.face-label {
    text-align: center;
}

.face-name {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.face-subtitle {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
}

/* ============================================
   Loading State
   ============================================ */

.loading-card {
    width: 100%;
    height: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--gap-md);
    color: var(--text-muted);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-subtle);
    border-top-color: var(--accent-polymarket);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ============================================
   Empty State
   ============================================ */

.empty-card {
    width: 100%;
    height: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-align: center;
    padding: var(--gap-lg);
}

.empty-card i {
    font-size: 2.5rem;
    margin-bottom: var(--gap-sm);
    opacity: 0.3;
}

/* ============================================
   Footer
   ============================================ */

.app-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--gap-md) var(--gap-lg);
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
}

.footer-left {
    display: flex;
    align-items: center;
    gap: var(--gap-sm);
}

.brand {
    font-weight: 700;
    font-size: 1rem;
    background: linear-gradient(135deg, var(--accent-kalshi), var(--accent-polymarket));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.version {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 2px 8px;
    background: var(--bg-card);
    border-radius: var(--radius-full);
}

.refresh-btn {
    display: flex;
    align-items: center;
    gap: var(--gap-sm);
    padding: var(--gap-sm) var(--gap-lg);
    background: linear-gradient(135deg, var(--accent-kalshi), var(--accent-polymarket));
    border: none;
    border-radius: var(--radius-full);
    color: white;
    font-family: var(--font-primary);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.refresh-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(139, 92, 246, 0.4);
}

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

.refresh-btn.loading i {
    animation: spin 1s linear infinite;
}

.disclaimer {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Made with love */
.made-with-love {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0;
}

.made-with-love .heart {
    color: #e74c3c;
    font-style: normal;
    animation: heartbeat 1.5s ease-in-out infinite;
    display: inline-block;
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.made-with-love a {
    color: var(--accent-polymarket);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}

.made-with-love a:hover {
    color: var(--accent-kalshi);
    text-decoration: underline;
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 1200px) {
    .arb-grid {
        gap: var(--gap-sm);
    }
    
    .arb-card {
        padding: var(--gap-sm);
    }
    
    .arb-title {
        font-size: 0.75rem;
    }
    
    .arb-metric-value {
        font-size: 0.85rem;
    }
    
    .arb-metric-value.profit {
        font-size: 1rem;
    }
}

@media (max-width: 900px) {
    .arb-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: auto;
    }
    
    .center-cell {
        order: -1;
        grid-column: span 2;
    }
    
    .face-container {
        width: 150px;
        height: 150px;
    }
    
    .face-tracker {
        width: 120px;
        height: 120px;
    }
    
    .site-title {
        font-size: 1.2rem;
    }
}

@media (max-width: 768px) {
    .site-header {
        flex-direction: column;
        gap: var(--gap-sm);
    }
    
    .app-footer {
        flex-direction: column;
        gap: var(--gap-md);
        text-align: center;
    }
}

@media (max-width: 600px) {
    .arb-grid {
        grid-template-columns: 1fr;
    }
    
    .center-cell {
        grid-column: span 1;
    }
}

/* ============================================
   Utility Classes
   ============================================ */

.text-kalshi { color: var(--accent-kalshi); }
.text-polymarket { color: var(--accent-polymarket); }
.text-profit { color: var(--accent-profit); }
.text-warning { color: var(--accent-warning); }
.text-danger { color: var(--accent-danger); }
.text-info { color: var(--accent-info); }
.text-muted { color: var(--text-muted); }
