/* ═══════════════════════════════════════════════════════════════
   Raven Core Bridge — Dashboard Styles
   Dark glassmorphism + animated gradients + premium feel
   ═══════════════════════════════════════════════════════════════ */

:root {
    --bg-primary: #06060e;
    --bg-secondary: #0c0c1a;
    --bg-card: rgba(15, 15, 35, 0.65);
    --bg-card-hover: rgba(20, 20, 50, 0.75);
    --border-glass: rgba(120, 100, 255, 0.12);
    --border-glass-hover: rgba(160, 130, 255, 0.25);

    --text-primary: #e8e6f0;
    --text-secondary: #9490b0;
    --text-muted: #5c5880;

    --accent-purple: #a855f7;
    --accent-cyan: #06b6d4;
    --accent-green: #22c55e;
    --accent-red: #ef4444;
    --accent-orange: #f97316;
    --accent-blue: #3b82f6;

    --gradient-raven: linear-gradient(135deg, #7c3aed 0%, #06b6d4 100%);
    --gradient-direct: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --gradient-success: linear-gradient(135deg, #22c55e 0%, #06b6d4 100%);

    --gauge-size: 140px;
    --glass-blur: 20px;
    --glass-blur-strong: 40px;

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;

    --font-main: 'Inter', -apple-system, system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    --transition-fast: 0.15s ease;
    --transition-med: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

body {
    font-family: var(--font-main);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ─── Animated Background ─────────────────────────────────────── */

.bg-grid {
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(120, 100, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(120, 100, 255, 0.03) 1px, transparent 1px);
    background-size: 60px 60px;
    z-index: 0;
    pointer-events: none;
}

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

.glow-1 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, #7c3aed 0%, transparent 70%);
    top: -200px;
    left: -100px;
    animation-delay: 0s;
}

.glow-2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, #06b6d4 0%, transparent 70%);
    bottom: -150px;
    right: -100px;
    animation-delay: -7s;
}

.glow-3 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, #8b5cf6 0%, transparent 70%);
    top: 40%;
    left: 50%;
    animation-delay: -14s;
}

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

/* ─── Glass Card ──────────────────────────────────────────────── */

.glass {
    background: var(--bg-card);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    transition: border-color var(--transition-med), transform var(--transition-med), box-shadow var(--transition-med);
}

.glass:hover {
    border-color: var(--border-glass-hover);
    box-shadow: 0 8px 32px rgba(120, 80, 255, 0.08);
}

/* ─── App Container ───────────────────────────────────────────── */

.app {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px 60px;
}

/* ─── Header ──────────────────────────────────────────────────── */

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0 32px;
    flex-wrap: wrap;
    gap: 16px;
}

.header-left { display: flex; align-items: center; gap: 16px; }

.logo {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-icon {
    width: 44px;
    height: 44px;
    filter: drop-shadow(0 0 12px rgba(168, 85, 247, 0.4));
    animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {
    0%, 100% { filter: drop-shadow(0 0 12px rgba(168, 85, 247, 0.4)); }
    50% { filter: drop-shadow(0 0 20px rgba(6, 182, 212, 0.6)); }
}

.logo h1 {
    font-size: 1.4rem;
    font-weight: 800;
    background: var(--gradient-raven);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.subtitle {
    font-size: 0.73rem;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

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

.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 999px;
    background: rgba(15, 15, 35, 0.7);
    border: 1px solid var(--border-glass);
    font-size: 0.8rem;
    font-weight: 600;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent-orange);
    animation: dotPulse 2s ease-in-out infinite;
}

.status-dot.online {
    background: var(--accent-green);
    box-shadow: 0 0 12px rgba(34, 197, 94, 0.5);
}

.status-dot.offline {
    background: var(--accent-red);
    animation: none;
}

@keyframes dotPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.85); }
}

.server-info {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.server-flag { font-size: 1.1rem; }

/* ─── Overview Grid ───────────────────────────────────────────── */

.overview-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 40px;
}

.stat-card {
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-align: center;
    cursor: default;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-icon {
    font-size: 1.5rem;
    margin-bottom: 4px;
}

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

.stat-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 500;
}

/* ─── Section Headers ─────────────────────────────────────────── */

.section-header {
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.section-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.section-header p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    width: 100%;
}

/* ─── Speed Test Section ──────────────────────────────────────── */

.speed-test-section {
    margin-bottom: 40px;
}

.speed-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 20px;
    align-items: start;
}

.speed-card {
    padding: 24px;
}

.speed-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.speed-card-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.speed-icon {
    font-size: 1.6rem;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
}

.speed-icon.direct {
    background: rgba(99, 102, 241, 0.15);
}

.speed-icon.raven {
    background: rgba(124, 58, 237, 0.15);
}

.speed-card-title h3 {
    font-size: 1rem;
    font-weight: 700;
}

.speed-subtitle {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.btn-test {
    padding: 8px 20px;
    border: 1px solid var(--border-glass);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-med);
}

.btn-test:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-purple);
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.15);
}

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

.btn-test.raven-btn:hover {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 20px rgba(6, 182, 212, 0.15);
}

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

.btn-test.testing {
    position: relative;
    overflow: hidden;
}

.btn-test.testing::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Speed Gauges */
.speed-gauges {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin-bottom: 20px;
}

.gauge-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    width: var(--gauge-size);
}

.gauge-svg {
    width: var(--gauge-size);
    height: var(--gauge-size);
    transform: rotate(-90deg);
}

.gauge-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.05);
    stroke-width: 8;
}

.gauge-fill {
    fill: none;
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 326.73;
    stroke-dashoffset: 326.73;
    transition: stroke-dashoffset 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.direct-fill { stroke: url(#directGaugeGrad); }
.raven-fill { stroke: url(#ravenGaugeGrad); }

.gauge-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -60%);
    text-align: center;
    display: flex;
    flex-direction: column;
}

.gauge-value {
    font-size: 1.5rem;
    font-weight: 800;
    font-family: var(--font-mono);
    line-height: 1;
}

.gauge-unit {
    font-size: 0.6rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 2px;
}

.gauge-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 8px;
    font-weight: 500;
}

/* Speed Metrics */
.speed-metrics {
    display: flex;
    justify-content: center;
    gap: 32px;
    padding-top: 16px;
    border-top: 1px solid var(--border-glass);
}

.metric {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

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

.metric-value {
    font-size: 0.95rem;
    font-weight: 600;
    font-family: var(--font-mono);
}

/* Speed Progress */
.speed-progress {
    margin-top: 12px;
    min-height: 20px;
    font-size: 0.72rem;
    color: var(--text-secondary);
    text-align: center;
}

/* VS Divider */
.vs-divider {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding-top: 100px;
}

.vs-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--gradient-raven);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
    box-shadow: 0 0 30px rgba(124, 58, 237, 0.3);
    animation: vsPulse 3s ease-in-out infinite;
}

@keyframes vsPulse {
    0%, 100% { box-shadow: 0 0 20px rgba(124, 58, 237, 0.3); }
    50% { box-shadow: 0 0 40px rgba(6, 182, 212, 0.4); }
}

.vs-line {
    width: 2px;
    height: 100px;
    background: linear-gradient(to bottom, rgba(124, 58, 237, 0.3), transparent);
    margin-top: 12px;
}

/* Run Both Button */
.test-both-container {
    display: flex;
    justify-content: center;
    margin-top: 24px;
}

.btn-both {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 32px;
    background: var(--gradient-raven);
    border: none;
    border-radius: 999px;
    color: white;
    font-family: var(--font-main);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-med);
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.3);
}

.btn-both:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(124, 58, 237, 0.4);
}

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

.btn-both svg {
    width: 18px;
    height: 18px;
}

.btn-both:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ─── Traffic Section ─────────────────────────────────────────── */

.traffic-section {
    margin-bottom: 40px;
}

.traffic-controls {
    display: flex;
    gap: 6px;
}

.btn-time {
    padding: 6px 14px;
    border: 1px solid var(--border-glass);
    border-radius: 999px;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-time.active {
    background: rgba(168, 85, 247, 0.2);
    border-color: var(--accent-purple);
    color: var(--text-primary);
}

.btn-time:hover:not(.active) {
    border-color: var(--border-glass-hover);
    color: var(--text-primary);
}

.traffic-card {
    padding: 24px;
}

.traffic-legend {
    display: flex;
    gap: 24px;
    margin-bottom: 16px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.legend-dot.rx { background: var(--accent-cyan); box-shadow: 0 0 8px rgba(6, 182, 212, 0.5); }
.legend-dot.tx { background: var(--accent-purple); box-shadow: 0 0 8px rgba(168, 85, 247, 0.5); }

.legend-rate {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-primary);
}

#trafficChart {
    width: 100%;
    height: 200px;
    border-radius: var(--radius-md);
}

/* ─── Peers Section ───────────────────────────────────────────── */

.peers-section {
    margin-bottom: 40px;
}

.peers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.peer-card {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.peer-card.skeleton {
    min-height: 100px;
}

.peer-skeleton-line {
    height: 14px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    width: 80%;
    animation: skeletonPulse 1.5s ease-in-out infinite;
}

.peer-skeleton-line.short { width: 50%; }

@keyframes skeletonPulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.6; }
}

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

.peer-name {
    font-weight: 700;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.peer-status {
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.peer-status.online {
    background: rgba(34, 197, 94, 0.15);
    color: var(--accent-green);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.peer-status.offline {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.peer-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.peer-detail {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.peer-detail-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.peer-detail-value {
    font-size: 0.8rem;
    font-family: var(--font-mono);
    color: var(--text-secondary);
}

/* ─── Config Section ──────────────────────────────────────────── */

.config-section {
    margin-bottom: 40px;
}

.config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.config-card {
    padding: 28px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: all var(--transition-med);
}

.config-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 40px rgba(124, 58, 237, 0.12);
}

.config-icon {
    font-size: 2rem;
}

.config-card h3 {
    font-size: 1.1rem;
    font-weight: 700;
}

.config-card p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.config-tag {
    font-size: 0.7rem;
    font-family: var(--font-mono);
    color: var(--accent-cyan);
    padding: 4px 10px;
    background: rgba(6, 182, 212, 0.1);
    border-radius: 999px;
    align-self: flex-start;
}

.btn-download {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    margin-top: auto;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-med);
}

.btn-download:hover {
    background: var(--gradient-raven);
    border-color: transparent;
}

.btn-download svg {
    width: 16px;
    height: 16px;
}

/* QR Section */
.qr-section {
    padding: 28px;
}

.qr-section h3 {
    font-size: 1rem;
    margin-bottom: 8px;
}

.qr-section > p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.setup-steps {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.step {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.step-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--gradient-raven);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

/* ─── Footer ──────────────────────────────────────────────────── */

.footer {
    display: flex;
    justify-content: space-between;
    padding: 24px 0;
    border-top: 1px solid var(--border-glass);
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* ─── SVG Gradient Defs (hidden) ──────────────────────────────── */

/* These are injected by JS into the page */

/* ─── Responsive ──────────────────────────────────────────────── */

@media (max-width: 900px) {
    .overview-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .speed-grid {
        grid-template-columns: 1fr;
    }
    .vs-divider {
        flex-direction: row;
        padding: 0;
        gap: 12px;
    }
    .vs-line {
        width: 100px;
        height: 2px;
        background: linear-gradient(to right, rgba(124, 58, 237, 0.3), transparent);
        margin: 0;
    }
    .config-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    html { font-size: 14px; }
    .overview-grid {
        grid-template-columns: 1fr 1fr;
    }
    .speed-gauges {
        gap: 16px;
    }
    .gauge-container {
        --gauge-size: 110px;
    }
    .header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ─── Animations for speed results ────────────────────────────── */

.speed-card.result-better {
    border-color: rgba(34, 197, 94, 0.4);
    box-shadow: 0 0 30px rgba(34, 197, 94, 0.1);
}

.speed-card.result-worse {
    border-color: rgba(239, 68, 68, 0.2);
}

@keyframes resultPop {
    0% { transform: scale(0.95); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.gauge-value.animated {
    animation: resultPop 0.5s ease-out;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(120, 100, 255, 0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(120, 100, 255, 0.4);
}
