/* ============================================
   Global Styles & Variables
   ============================================ */

:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --secondary-color: #8b5cf6;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    
    --border-color: #334155;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding: 20px;
}

/* ============================================
   Container & Layout
   ============================================ */

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

header {
    text-align: center;
    padding: 40px 20px;
    margin-bottom: 40px;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

/* ============================================
   Architecture Diagram
   ============================================ */

.architecture-section {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 30px;
    margin-bottom: 40px;
    box-shadow: var(--shadow-lg);
}

.architecture-section h2 {
    text-align: center;
    margin-bottom: 30px;
    color: var(--text-primary);
    font-size: 1.5rem;
}

.pipeline-diagram {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    padding: 20px 0;
}

.pipeline-step {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 20px;
    text-align: center;
    min-width: 140px;
    transition: var(--transition);
    border: 2px solid transparent;
    position: relative;
}

.pipeline-step.active {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
}

.pipeline-step.completed {
    border-color: var(--success-color);
    background: rgba(16, 185, 129, 0.05);
}

.pipeline-step:hover {
    border-color: var(--primary-color);
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.step-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
    transition: var(--transition);
}

.pipeline-step.active .step-icon {
    animation: pulse 1.5s ease-in-out infinite;
}

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

.pipeline-step.completed .step-icon::after {
    content: '\2713';
    position: absolute;
    top: 15px;
    right: 15px;
    background: var(--success-color);
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
}

.step-label {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 5px;
    font-size: 1.1rem;
}

.step-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.pipeline-arrow {
    color: var(--primary-color);
    font-size: 2rem;
    font-weight: bold;
}

/* ============================================
   Main Content Layout
   ============================================ */

.main-content {
    display: grid;
    gap: 30px;
}

section {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 30px;
    box-shadow: var(--shadow-lg);
}

section h2 {
    margin-bottom: 20px;
    color: var(--text-primary);
    font-size: 1.5rem;
}

/* ============================================
   Upload Section
   ============================================ */

.upload-area {
    border: 3px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 60px 40px;
    text-align: center;
    transition: var(--transition);
    cursor: pointer;
    background: var(--bg-primary);
}

.upload-area:hover,
.upload-area.drag-over {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
}

.upload-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.upload-text {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.upload-subtext {
    color: var(--text-muted);
    margin: 15px 0;
}

.upload-button {
    display: inline-block;
    background: var(--primary-color);
    color: white;
    padding: 12px 30px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
    margin: 10px 0;
}

.upload-button:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.upload-info {
    margin-top: 15px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Upload Progress */
.upload-progress {
    margin-top: 20px;
}

.progress-bar {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 10px;
}

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

.progress-text {
    text-align: center;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Upload Status */
.upload-status {
    margin-top: 20px;
    padding: 15px;
    border-radius: var(--radius-sm);
    font-weight: 500;
}

.upload-status.success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid var(--success-color);
    color: var(--success-color);
}

.upload-status.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error-color);
    color: var(--error-color);
}

/* ============================================
   Video Player Section
   ============================================ */

.video-container {
    position: relative;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 30px;
}

#videoPlayer {
    width: 100%;
    height: auto;
    min-height: 400px;
    display: block;
}

.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
}

.player-controls {
    position: absolute;
    top: 15px;
    right: 15px;
    display: flex;
    gap: 10px;
    z-index: 10;
}

.control-btn {
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.control-btn:hover {
    background: rgba(0, 0, 0, 0.9);
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

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

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

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

/* ============================================
   Info Panel & Metrics
   ============================================ */

.info-panel {
    background: var(--bg-primary);
    border-radius: var(--radius);
    padding: 25px;
    margin-top: 20px;
}

.info-panel h3 {
    margin-bottom: 20px;
    color: var(--text-primary);
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.metric-card {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.metric-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.metric-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* Quality Selector */
.quality-selector {
    width: 100%;
    margin-top: 10px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}

.quality-selector:hover {
    border-color: var(--primary-color);
}

.quality-selector:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.quality-selector option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Event Log */
.event-log-container {
    margin-top: 20px;
}

.event-log-container h4 {
    margin-bottom: 15px;
    color: var(--text-secondary);
}

.event-log {
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    padding: 15px;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
}

.event-item {
    padding: 8px 12px;
    margin-bottom: 8px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    border-left: 3px solid var(--primary-color);
}

.event-item:last-child {
    margin-bottom: 0;
}

.event-item.quality-change {
    border-left-color: var(--success-color);
}

.event-item.buffering {
    border-left-color: var(--warning-color);
}

.event-item.error {
    border-left-color: var(--error-color);
}

/* Scrollbar Styling */
.event-log::-webkit-scrollbar {
    width: 8px;
}

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

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

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

/* ============================================
   Buttons
   ============================================ */

.reset-button {
    width: 100%;
    padding: 15px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 20px;
}

.reset-button:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    transform: translateY(-2px);
}

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

footer {
    text-align: center;
    padding: 40px 20px 20px;
    color: var(--text-muted);
}

footer p {
    margin: 5px 0;
}

.tech-stack {
    font-size: 0.9rem;
}

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

@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .pipeline-diagram {
        flex-direction: column;
    }
    
    .pipeline-arrow {
        transform: rotate(90deg);
    }
    
    .metrics-grid {
        grid-template-columns: 1fr;
    }
    
    #videoPlayer {
        min-height: 250px;
    }
    
    .upload-area {
        padding: 40px 20px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    section {
        padding: 20px;
    }
    
    header {
        padding: 20px 10px;
    }
}

/* ============================================
   Animations
   ============================================ */

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

.upload-section,
.player-section,
.architecture-section {
    animation: fadeIn 0.5s ease-out;
}
