/* Import fonts */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700&family=Inter:wght@400;500;600&display=swap');

/* CSS Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #0a0f23;
    --secondary: #00d4ff;
    --accent: #39ff14;
    --text: #e0e6ed;
    --error: #ff4757;
    --success: #2ed573;
    --panel-bg: rgba(15, 25, 45, 0.9);
    --border: rgba(0, 212, 255, 0.3);
}

body {
    background: linear-gradient(135deg, #0a0f23 0%, #1a2344 50%, #0a0f23 100%);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Header Styles */
.header {
    position: relative;
    background: linear-gradient(90deg, #0a0f23 0%, #1e3a8a 50%, #0a0f23 100%);
    padding: 1rem 2rem;
    border-bottom: 2px solid var(--border);
    overflow: hidden;
}

.header-content {
    position: relative;
    z-index: 2;
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
}

.title {
    font-family: 'JetBrains Mono', monospace;
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(45deg, var(--secondary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 20px rgba(0, 212, 255, 0.5);
    animation: glow 2s ease-in-out infinite alternate;
}

.challenge-info {
    display: flex;
    flex-direction: column;
    text-align: right;
    gap: 0.5rem;
    font-family: 'JetBrains Mono', monospace;
}

.challenge-id {
    color: var(--secondary);
    font-size: 1.1rem;
    font-weight: 600;
}

.attribution {
    color: var(--text);
    opacity: 0.7;
    font-size: 0.9rem;
}

/* Particle Animation */
.particle-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.header-particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--secondary);
    border-radius: 50%;
    animation: float linear infinite;
    box-shadow: 0 0 10px var(--secondary);
}

/* Main Content */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

.workspace {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
    min-height: 600px;
}

/* Panel Styles */
.code-panel, .output-panel {
    background: var(--panel-bg);
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 1.5rem;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 212, 255, 0.1);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.panel-header h3 {
    font-family: 'JetBrains Mono', monospace;
    color: var(--secondary);
    font-size: 1.2rem;
}

.controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.performance-metrics {
    display: flex;
    gap: 1rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
}

/* Challenge Description */
.challenge-description {
    background: rgba(57, 255, 20, 0.1);
    border: 1px solid var(--accent);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.challenge-description h4 {
    color: var(--accent);
    margin-bottom: 0.5rem;
    font-family: 'JetBrains Mono', monospace;
}

.challenge-description p {
    opacity: 0.9;
    line-height: 1.5;
}

/* Code Editor */
.code-editor-container {
    display: flex;
    background: #1a1a2e;
    border-radius: 8px;
    border: 1px solid var(--border);
    overflow: hidden;
    margin-bottom: 1rem;
}

.line-numbers {
    background: #16213e;
    padding: 1rem 0.5rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    color: var(--text);
    opacity: 0.5;
    white-space: pre;
    text-align: right;
    min-width: 40px;
    border-right: 1px solid var(--border);
}

#codeEditor {
    flex: 1;
    background: transparent;
    border: none;
    padding: 1rem;
    color: var(--text);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: none;
    outline: none;
    min-height: 300px;
}

#codeEditor::placeholder {
    color: rgba(224, 230, 237, 0.5);
}

/* Editor Controls */
.editor-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.timer {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.2rem;
    color: var(--secondary);
}

/* Canvas */
#canvas {
    background: #0a0f23;
    border-radius: 8px;
    border: 2px solid var(--border);
    margin-bottom: 1rem;
    width: 100%;
    height: auto;
    max-height: 360px;
    box-shadow: 0 4px 20px rgba(0, 212, 255, 0.3);
}

/* Console Output */
.console-output {
    background: #1a1a2e;
    border-radius: 8px;
    border: 1px solid var(--border);
    padding: 1rem;
    min-height: 120px;
    max-height: 120px;
    overflow-y: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
}

.console-line {
    margin-bottom: 0.25rem;
    opacity: 0.8;
}

.console-error {
    color: var(--error);
}

.console-info {
    color: var(--text);
}

/* Button Styles */
.btn-primary, .btn-execute, .btn-secondary {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(45deg, var(--secondary), var(--accent));
    color: var(--primary);
}

.btn-execute {
    background: linear-gradient(45deg, var(--accent), #00ff88);
    color: var(--primary);
    font-size: 1rem;
    padding: 1rem 2rem;
    animation: pulse-glow 2s ease-in-out infinite;
}

.btn-secondary {
    background: rgba(0, 212, 255, 0.1);
    color: var(--secondary);
    border: 1px solid var(--secondary);
}

.btn-primary:hover, .btn-execute:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(57, 255, 20, 0.4);
}

.btn-secondary:hover {
    background: rgba(0, 212, 255, 0.2);
}

/* Select Styles */
select {
    background: var(--panel-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem;
    font-family: 'Inter', sans-serif;
}

select:focus {
    outline: none;
    border-color: var(--secondary);
    box-shadow: 0 0 0 2px rgba(0, 212, 255, 0.3);
}

/* Status Indicators */
.status-idle, .status-ready, .status-success, .status-error {
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
}

.status-idle {
    background: rgba(224, 230, 237, 0.1);
    color: var(--text);
}

.status-ready {
    background: rgba(57, 255, 20, 0.2);
    color: var(--accent);
}

.status-success {
    background: rgba(46, 213, 115, 0.2);
    color: var(--success);
}

.status-error {
    background: rgba(255, 71, 87, 0.2);
    color: var(--error);
}

/* Bottom Controls */
.bottom-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.completion-status {
    font-family: 'JetBrains Mono', monospace;
    color: var(--accent);
    font-weight: 600;
}

/* Background Effects */
.background-effects {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
    background: 
        radial-gradient(circle at 20% 80%, rgba(0, 212, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(57, 255, 20, 0.1) 0%, transparent 50%);
}

/* Animations */
@keyframes glow {
    from { text-shadow: 0 0 20px rgba(0, 212, 255, 0.5); }
    to { text-shadow: 0 0 30px rgba(0, 212, 255, 0.8), 0 0 40px rgba(57, 255, 20, 0.5); }
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 20px rgba(57, 255, 20, 0.4); }
    50% { box-shadow: 0 0 30px rgba(57, 255, 20, 0.8); }
}

@keyframes float {
    0% { transform: translateY(100vh) translateX(0); opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { transform: translateY(-20px) translateX(50px); opacity: 0; }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .workspace {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .header-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .title {
        font-size: 2rem;
    }
}

@media (max-width: 768px) {
    .main-content {
        padding: 1rem;
    }
    
    .code-panel, .output-panel {
        padding: 1rem;
    }
    
    .panel-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .controls {
        flex-direction: column;
    }
    
    .title {
        font-size: 1.5rem;
    }
    
    .header {
        padding: 1rem;
    }
    
    #canvas {
        height: 250px;
    }
}

@media (max-width: 480px) {
    .bottom-controls {
        flex-direction: column;
    }
    
    .btn-primary, .btn-execute, .btn-secondary {
        width: 100%;
    }
    
    #codeEditor {
        min-height: 200px;
    }
}

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

::-webkit-scrollbar-track {
    background: var(--primary);
}

::-webkit-scrollbar-thumb {
    background: var(--secondary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}