/* ===================================
   Nova Code Executor — Stylesheet
   =================================== */

/* --- CSS Variables / Theme --- */
:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-tertiary: #1a2235;
    --bg-panel: #0f1629;
    --bg-header: rgba(15, 22, 41, 0.85);
    --border: #1e2a45;
    --border-glow: rgba(0, 212, 255, 0.15);
    --text-primary: #e4e8f1;
    --text-secondary: #8892a8;
    --text-muted: #4a5568;
    --accent-cyan: #00d4ff;
    --accent-purple: #7b2ff7;
    --accent-pink: #ff2daf;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --accent-yellow: #f59e0b;
    --gradient-primary: linear-gradient(135deg, #00d4ff, #7b2ff7);
    --gradient-secondary: linear-gradient(135deg, #7b2ff7, #ff2daf);
    --gradient-run: linear-gradient(135deg, #10b981, #059669);
    --shadow-glow: 0 0 30px rgba(0, 212, 255, 0.1);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
}

/* Light theme */
:root.light-theme {
    --bg-primary: #f0f2f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8eaf0;
    --bg-panel: #ffffff;
    --bg-header: rgba(255, 255, 255, 0.9);
    --border: #d1d5db;
    --border-glow: rgba(123, 47, 247, 0.1);
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;
    --shadow-glow: 0 0 30px rgba(123, 47, 247, 0.08);
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

/* --- Animated Star Background --- */
.bg-animation {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.stars, .stars2, .stars3 {
    position: absolute;
    inset: 0;
    background: transparent;
}

.stars {
    background-image:
        radial-gradient(1px 1px at 50px 100px, rgba(255,255,255,0.3), transparent),
        radial-gradient(1px 1px at 200px 300px, rgba(255,255,255,0.2), transparent),
        radial-gradient(1px 1px at 400px 150px, rgba(255,255,255,0.25), transparent),
        radial-gradient(1px 1px at 600px 400px, rgba(255,255,255,0.15), transparent),
        radial-gradient(1.5px 1.5px at 100px 450px, rgba(0,212,255,0.4), transparent),
        radial-gradient(1px 1px at 300px 50px, rgba(255,255,255,0.2), transparent),
        radial-gradient(1px 1px at 700px 250px, rgba(123,47,247,0.3), transparent),
        radial-gradient(1px 1px at 900px 350px, rgba(255,255,255,0.2), transparent),
        radial-gradient(1px 1px at 150px 550px, rgba(255,255,255,0.15), transparent),
        radial-gradient(1.5px 1.5px at 500px 500px, rgba(255,45,175,0.3), transparent);
    animation: drift 80s linear infinite;
}

.stars2 {
    background-image:
        radial-gradient(1px 1px at 120px 200px, rgba(255,255,255,0.25), transparent),
        radial-gradient(1px 1px at 350px 450px, rgba(255,255,255,0.2), transparent),
        radial-gradient(1px 1px at 550px 100px, rgba(0,212,255,0.25), transparent),
        radial-gradient(1px 1px at 750px 500px, rgba(255,255,255,0.15), transparent),
        radial-gradient(1px 1px at 250px 350px, rgba(123,47,247,0.2), transparent);
    animation: drift 120s linear infinite;
}

.stars3 {
    background-image:
        radial-gradient(1.5px 1.5px at 80px 350px, rgba(0,212,255,0.35), transparent),
        radial-gradient(1px 1px at 450px 250px, rgba(255,255,255,0.2), transparent),
        radial-gradient(1.5px 1.5px at 650px 450px, rgba(123,47,247,0.3), transparent);
    animation: drift 160s linear infinite;
}

:root.light-theme .bg-animation {
    opacity: 0.15;
}

@keyframes drift {
    from { transform: translateY(0); }
    to { transform: translateY(-100vh); }
}

/* --- App Container --- */
.app-container {
    position: relative;
    z-index: 1;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Navbar --- */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 60px;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    flex-shrink: 0;
}

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

.logo-icon svg {
    width: 36px;
    height: 36px;
    filter: drop-shadow(0 0 8px rgba(0, 212, 255, 0.4));
}

.logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.logo-name {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 3px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-sub {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.nav-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.language-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.language-selector label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.language-selector select {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    transition: border-color var(--transition-fast);
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238892a8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 28px;
}

.language-selector select:hover,
.language-selector select:focus {
    border-color: var(--accent-cyan);
}

.theme-toggle {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    border: 1px solid transparent;
}

.theme-toggle:hover {
    color: var(--accent-cyan);
    background: var(--bg-tertiary);
    border-color: var(--border);
}

.theme-icon {
    width: 18px;
    height: 18px;
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    min-height: 0;
    overflow: hidden;
}

/* --- Panels --- */
.panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.editor-panel {
    border-right: 1px solid var(--border);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: 44px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.panel-icon {
    width: 16px;
    height: 16px;
    opacity: 0.7;
}

.file-badge {
    font-size: 11px;
    font-weight: 500;
    font-family: var(--font-mono);
    padding: 2px 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: background var(--transition-normal);
}

.status-dot.running {
    background: var(--accent-yellow);
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
    animation: pulse 1s infinite;
}

.status-dot.success {
    background: var(--accent-green);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

.status-dot.error {
    background: var(--accent-red);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
}

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

.panel-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.exec-time {
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-muted);
    margin-right: 4px;
}

/* --- Buttons --- */
.btn {
    border: none;
    cursor: pointer;
    font-family: var(--font-sans);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    padding: 6px;
}

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

.btn-icon:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-run {
    gap: 6px;
    padding: 6px 16px;
    border-radius: var(--radius-sm);
    background: var(--gradient-run);
    color: white;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.3px;
    box-shadow: 0 2px 10px rgba(16, 185, 129, 0.3);
}

.btn-run svg {
    width: 14px;
    height: 14px;
}

.btn-run:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.5);
}

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

.btn-run.executing {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    box-shadow: 0 2px 10px rgba(245, 158, 11, 0.3);
    pointer-events: none;
}

/* --- Editor Wrapper --- */
.editor-wrapper {
    flex: 1;
    overflow: hidden;
    background: var(--bg-panel);
}

.CodeMirror {
    height: 100% !important;
    font-family: var(--font-mono) !important;
    font-size: 14px !important;
    line-height: 1.65 !important;
    padding-top: 8px;
}

.CodeMirror-gutters {
    border-right: 1px solid var(--border) !important;
    background: var(--bg-secondary) !important;
}

.CodeMirror-linenumber {
    color: var(--text-muted) !important;
    font-size: 12px !important;
    padding: 0 8px !important;
}

.CodeMirror-activeline-background {
    background: rgba(0, 212, 255, 0.04) !important;
}

.CodeMirror-cursor {
    border-left-color: var(--accent-cyan) !important;
    border-left-width: 2px !important;
}

.CodeMirror-selected {
    background: rgba(0, 212, 255, 0.12) !important;
}

/* Light theme CodeMirror overrides */
:root.light-theme .CodeMirror {
    background: #ffffff !important;
    color: #1e293b !important;
}

:root.light-theme .CodeMirror-gutters {
    background: #f8fafc !important;
    border-right-color: #e2e8f0 !important;
}

:root.light-theme .CodeMirror-linenumber {
    color: #94a3b8 !important;
}

:root.light-theme .CodeMirror-activeline-background {
    background: rgba(99, 102, 241, 0.06) !important;
}

:root.light-theme .CodeMirror-cursor {
    border-left-color: #6366f1 !important;
}

:root.light-theme .CodeMirror-selected {
    background: rgba(99, 102, 241, 0.15) !important;
}

/* --- Output Panel --- */
.output-wrapper {
    flex: 1;
    overflow: auto;
    background: var(--bg-panel);
}

.output-content {
    padding: 16px;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.7;
    min-height: 100%;
    white-space: pre-wrap;
    word-break: break-word;
}

.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 300px;
    color: var(--text-muted);
    gap: 8px;
}

.welcome-icon {
    font-size: 48px;
    margin-bottom: 8px;
    animation: float 3s ease-in-out infinite;
}

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

.welcome-message h3 {
    font-family: var(--font-sans);
    font-size: 18px;
    font-weight: 600;
    color: var(--text-secondary);
}

.welcome-message p {
    font-family: var(--font-sans);
    font-size: 13px;
    color: var(--text-muted);
}

.welcome-message kbd {
    display: inline-block;
    padding: 2px 6px;
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
}

/* Output log lines */
.log-line {
    padding: 2px 0;
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.log-line .log-prefix {
    color: var(--text-muted);
    user-select: none;
    flex-shrink: 0;
}

.log-line.log-info .log-content { color: var(--text-primary); }
.log-line.log-warn .log-content { color: var(--accent-yellow); }
.log-line.log-warn .log-prefix { color: var(--accent-yellow); }
.log-line.log-error .log-content { color: var(--accent-red); }
.log-line.log-error .log-prefix { color: var(--accent-red); }
.log-line.log-success .log-content { color: var(--accent-green); }
.log-line.log-success .log-prefix { color: var(--accent-green); }

.output-separator {
    border: none;
    border-top: 1px dashed var(--border);
    margin: 12px 0;
}

/* --- Footer --- */
.footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.footer-top {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 11px;
    color: var(--text-muted);
}

.footer-credit {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-muted);
}

.footer-credit strong {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
}

.footer-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition-fast);
}

.footer-link:hover {
    color: var(--accent-cyan);
}

.footer-link svg {
    width: 13px;
    height: 13px;
}

.separator {
    opacity: 0.3;
}

/* --- Toast --- */
.toast {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 100;
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-glow);
}

.toast.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* --- Scrollbar --- */
.output-wrapper::-webkit-scrollbar {
    width: 6px;
}
.output-wrapper::-webkit-scrollbar-track {
    background: transparent;
}
.output-wrapper::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
.output-wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
    }

    .editor-panel {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .logo-sub {
        display: none;
    }

    .language-selector label {
        display: none;
    }

    .btn-run span {
        display: none;
    }
}
