/*
===============================================================================
🐦 ::: PhoenixFlix - Multi-Purpose Movies & Christian Streaming Platform :::
🔥 with dual database architecture, WebAuthn authentication, and family-friendly streaming experience.
===============================================================================
© 2025 ThePhoenixFlix - Ben Tran
(https://github.com/ThePhoenixFlix)
Email: ThePhoenixFlix@gmail.com
Website: https://bit.ly/ThePhoenixFlix
===============================================================================
*/

/*
===============================================================================
🐦 ::: PhoenixFlix - Go Concurrency Visual Demos :::
🔥 Interactive visualizations for Worker Pool and Circuit Breaker patterns
===============================================================================
*/

/* ========================================== */
/* 🎨 CSS VARIABLES & RESET */
/* ========================================== */
:root {
    --bg-dark: #0f1419;
    --bg-surface: #1a1f2e;
    --bg-card: #242b3d;
    --primary-blue: #56bce8;
    --primary-green: #0ac189;
    --primary-red: #ff6b6b;
    --primary-yellow: #ffd93d;
    --text-primary: #e1e1e1;
    --text-secondary: #838981;
    --border-color: #3a4556;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--bg-dark) 0%, #1a1a2e 100%);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* ========================================== */
/* 📋 HEADER STYLES */
/* ========================================== */
.demo-header {
    text-align: center;
    margin-bottom: 3rem;
    padding: 2rem;
    background: linear-gradient(135deg, rgba(86, 188, 232, 0.1) 0%, rgba(10, 193, 137, 0.1) 100%);
    border-radius: 15px;
    border: 2px solid var(--border-color);
}

.demo-header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(45deg, var(--primary-blue), var(--primary-green));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

/* ========================================== */
/* 📦 SECTION STYLES */
/* ========================================== */
.demo-section {
    background: var(--bg-surface);
    border-radius: 15px;
    padding: 2rem;
    margin-bottom: 2rem;
    border: 2px solid var(--border-color);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

.section-header {
    text-align: center;
    margin-bottom: 2rem;
}

.section-header h2 {
    font-size: 2rem;
    color: var(--primary-blue);
    margin-bottom: 0.5rem;
}

.section-header p {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* ========================================== */
/* 🏁 RACE TRACK STYLES */
/* ========================================== */
.race-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.primary-btn, .secondary-btn {
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.primary-btn {
    background: linear-gradient(45deg, var(--primary-blue), var(--primary-green));
    color: white;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(86, 188, 232, 0.4);
}

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

.secondary-btn {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.secondary-btn:hover {
    background: var(--border-color);
}

.race-stats, .circuit-stats {
    display: flex;
    gap: 1.5rem;
    font-size: 1rem;
    color: var(--text-secondary);
}

.race-stats span, .circuit-stats span {
    padding: 8px 16px;
    background: var(--bg-card);
    border-radius: 20px;
    border: 1px solid var(--border-color);
}

/* Race Track Layout */
.race-track {
    position: relative;
    background: linear-gradient(to right, #1a1f2e 0%, #242b3d 50%, #1a1f2e 100%);
    border-radius: 10px;
    padding: 2rem;
    margin-bottom: 2rem;
    border: 2px solid var(--border-color);
}

.start-line, .finish-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 4px;
    display: flex;
    align-items: center;
    z-index: 10;
}

.start-line {
    left: 50px;
    background: repeating-linear-gradient(
        0deg,
        var(--primary-green) 0px,
        var(--primary-green) 10px,
        transparent 10px,
        transparent 20px
    );
}

.start-line span {
    position: absolute;
    left: -15px;
    top: 10px;
    writing-mode: vertical-rl;
    font-weight: bold;
    color: var(--primary-green);
    font-size: 0.8rem;
}

.finish-line {
    right: 50px;
    background: repeating-linear-gradient(
        45deg,
        white 0px,
        white 10px,
        black 10px,
        black 20px
    );
}

.finish-line span {
    position: absolute;
    right: -25px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.5rem;
}

/* Lane Styles */
.lane {
    position: relative;
    height: 80px;
    margin: 15px 0;
    border-bottom: 2px dashed var(--border-color);
    display: flex;
    align-items: center;
}

.lane-label {
    position: absolute;
    left: 10px;
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--text-secondary);
}

.racer {
    position: absolute;
    left: 60px;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 2rem;
    transition: left 0.5s ease-out;
    z-index: 5;
}

.racer-emoji {
    font-size: 2rem;
}

.racer-badge {
    background: var(--primary-blue);
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: bold;
}

.lane[data-worker="1"] .racer-badge {
    background: #ff6b6b;
}

.lane[data-worker="2"] .racer-badge {
    background: #4ecdc4;
}

.lane[data-worker="3"] .racer-badge {
    background: #ffe66d;
}

.lane-progress {
    position: absolute;
    left: 60px;
    height: 4px;
    background: rgba(86, 188, 232, 0.3);
    border-radius: 2px;
    width: 0;
    transition: width 0.5s ease-out;
    top: 50%;
    transform: translateY(-50%);
}

/* ========================================== */
/* 🚦 CIRCUIT BREAKER STYLES */
/* ========================================== */
.circuit-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.circuit-breaker-visual {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 3rem;
    align-items: center;
    margin-bottom: 2rem;
    padding: 2rem;
    background: var(--bg-card);
    border-radius: 10px;
}

/* Traffic Light */
.traffic-light {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.traffic-light-housing {
    background: #2d2d2d;
    padding: 20px;
    border-radius: 15px;
    box-shadow: 
        0 8px 30px rgba(0, 0, 0, 0.5),
        inset 0 2px 10px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.light {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    opacity: 0.3;
    transition: all 0.5s ease;
    border: 3px solid rgba(255, 255, 255, 0.1);
}

.light-label {
    position: absolute;
    bottom: -25px;
    font-size: 0.7rem;
    font-weight: bold;
    white-space: nowrap;
}

.red-light {
    background: radial-gradient(circle, #ff6b6b, #cc0000);
    box-shadow: 0 0 20px rgba(255, 107, 107, 0.3);
}

.yellow-light {
    background: radial-gradient(circle, #ffd93d, #ffa500);
    box-shadow: 0 0 20px rgba(255, 217, 61, 0.3);
}

.green-light {
    background: radial-gradient(circle, #0ac189, #00a86b);
    box-shadow: 0 0 20px rgba(10, 193, 137, 0.3);
}

.light.active {
    opacity: 1;
    animation: pulse 2s ease-in-out infinite;
}

.red-light.active {
    box-shadow: 
        0 0 30px rgba(255, 107, 107, 0.8),
        0 0 60px rgba(255, 107, 107, 0.4);
}

.yellow-light.active {
    box-shadow: 
        0 0 30px rgba(255, 217, 61, 0.8),
        0 0 60px rgba(255, 217, 61, 0.4);
}

.green-light.active {
    box-shadow: 
        0 0 30px rgba(10, 193, 137, 0.8),
        0 0 60px rgba(10, 193, 137, 0.4);
}

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

.circuit-state-label {
    text-align: center;
    font-size: 1.2rem;
    font-weight: bold;
    padding: 10px 20px;
    background: var(--bg-surface);
    border-radius: 20px;
    border: 2px solid var(--border-color);
}

#state-text {
    color: var(--primary-green);
}

/* Request Flow */
.request-flow {
    display: flex;
    align-items: center;
    justify-content: space-around;
    gap: 2rem;
}

.api-endpoint {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.endpoint-icon {
    font-size: 4rem;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.endpoint-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.flow-indicator {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.request-arrow {
    font-size: 3rem;
    animation: slide 1.5s ease-in-out infinite;
}

@keyframes slide {
    0%, 100% {
        transform: translateX(-10px);
        opacity: 0.5;
    }
    50% {
        transform: translateX(10px);
        opacity: 1;
    }
}

.request-arrow.blocked {
    animation: none;
    opacity: 0.2;
}

.circuit-gate {
    background: var(--bg-surface);
    padding: 2rem;
    border-radius: 15px;
    border: 3px solid var(--primary-green);
    transition: all 0.5s ease;
}

.circuit-gate.blocked {
    border-color: var(--primary-red);
    background: rgba(255, 107, 107, 0.1);
}

.gate-status {
    font-size: 1.5rem;
    font-weight: bold;
    text-align: center;
}

/* ========================================== */
/* 📊 LOG STYLES */
/* ========================================== */
.race-log, .circuit-log {
    background: var(--bg-card);
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid var(--border-color);
}

.log-header {
    background: linear-gradient(45deg, var(--primary-blue), var(--primary-green));
    padding: 12px 20px;
    font-weight: bold;
    color: white;
}

.log-content {
    max-height: 300px;
    overflow-y: auto;
    padding: 1rem;
}

.log-entry {
    padding: 8px 12px;
    margin-bottom: 6px;
    border-radius: 6px;
    border-left: 4px solid transparent;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.log-entry.worker-1 {
    background: rgba(255, 107, 107, 0.1);
    border-left-color: #ff6b6b;
    color: #ffb3b3;
}

.log-entry.worker-2 {
    background: rgba(78, 205, 196, 0.1);
    border-left-color: #4ecdc4;
    color: #9ee7e3;
}

.log-entry.worker-3 {
    background: rgba(255, 230, 109, 0.1);
    border-left-color: #ffe66d;
    color: #fff3b3;
}

.log-entry.success {
    background: rgba(10, 193, 137, 0.1);
    border-left-color: var(--primary-green);
    color: #69db7c;
}

.log-entry.error {
    background: rgba(255, 107, 107, 0.1);
    border-left-color: var(--primary-red);
    color: #ffb3b3;
}

.log-entry.info {
    background: rgba(86, 188, 232, 0.1);
    border-left-color: var(--primary-blue);
    color: #74c0fc;
}

.log-entry.warning {
    background: rgba(255, 217, 61, 0.1);
    border-left-color: var(--primary-yellow);
    color: #ffe066;
}

/* ========================================== */
/* 📚 PATTERN CARDS */
/* ========================================== */
.pattern-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 2rem;
}

.pattern-card {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 10px;
    border: 2px solid var(--border-color);
    transition: all 0.3s ease;
}

.pattern-card:hover {
    border-color: var(--primary-blue);
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(86, 188, 232, 0.2);
}

.pattern-card h3 {
    color: var(--primary-green);
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.pattern-card p {
    margin-bottom: 1rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

.pattern-card ul {
    list-style: none;
    padding-left: 0;
}

.pattern-card li {
    padding: 8px 0;
    padding-left: 25px;
    position: relative;
    color: var(--text-primary);
}

.pattern-card li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: var(--primary-blue);
    font-weight: bold;
}

/* ========================================== */
/* 📱 FOOTER */
/* ========================================== */
.demo-footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.demo-footer p {
    margin: 0.5rem 0;
}

/* ========================================== */
/* 📱 RESPONSIVE DESIGN */
/* ========================================== */
@media (max-width: 768px) {
    .demo-header h1 {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 0.9rem;
    }

    .circuit-breaker-visual {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .pattern-cards {
        grid-template-columns: 1fr;
    }

    .race-track {
        padding: 1rem;
    }

    .racer {
        font-size: 1.5rem;
    }

    .light {
        width: 70px;
        height: 70px;
    }

    .endpoint-icon {
        font-size: 3rem;
    }
}

/* ========================================== */
/* 🎭 SCROLL BAR STYLING */
/* ========================================== */
.log-content::-webkit-scrollbar {
    width: 8px;
}

.log-content::-webkit-scrollbar-track {
    background: var(--bg-surface);
    border-radius: 10px;
}

.log-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

.log-content::-webkit-scrollbar-thumb:hover {
    background: var(--primary-blue);
}

/* ========================================== */
/* 🏁 REAL API RACE STYLES */
/* ========================================== */
.api-race-track {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    border: 2px solid var(--border-color);
}

.api-racer {
    display: flex;
    align-items: center;
    margin: 15px 0;
    padding: 10px;
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
    transition: all 0.3s ease;
    position: relative;
}

.racer-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 120px;
    position: relative;
}

.racer-icon {
    font-size: 24px;
    position: absolute;
    left: 0;
    transition: left 0.5s ease-out;
    z-index: 5;
}

.racer-name {
    font-weight: bold;
    font-size: 16px;
    margin-left: 35px;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: #333;
    border-radius: 4px;
    overflow: hidden;
    margin: 0 15px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-blue), var(--primary-green));
    width: 0%;
    transition: width 0.3s ease;
}

.racer-status {
    min-width: 100px;
    text-align: right;
    font-size: 14px;
    font-weight: bold;
}

.api-results {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 1.5rem;
    border: 2px solid var(--border-color);
}

#api-podium {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.podium-place {
    text-align: center;
    padding: 20px;
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
    min-width: 150px;
}

.medal {
    font-size: 3rem;
    margin-bottom: 10px;
}

.coin-name {
    font-weight: bold;
    font-size: 1.2rem;
    margin-bottom: 5px;
    text-transform: capitalize;
}

.price {
    color: var(--primary-green);
    font-size: 1.1rem;
    font-weight: bold;
    margin-bottom: 5px;
}

.time {
    color: var(--text-secondary);
    font-size: 0.9rem;
}