/* 
    PythonCodingWeb - Premium Lab Theme
    Featuring: Glassmorphism, Gradients, and Micro-animations
*/

:root {
    --bg-dark: #0a0a0c;
    --bg-panel: rgba(23, 23, 26, 0.7);
    --bg-header: rgba(32, 32, 36, 0.8);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text-primary: #f0f0f2;
    --text-secondary: #9494a0;
    /* Gradients */
    --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    --run-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --error-gradient: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    --accent-color: #3b82f6;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.collection-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 16px;
    font-size: 12px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--glass-border);
}
.collection-toolbar [role="status"] { margin-right: auto; }
.collection-toolbar button, .collection-toolbar a {
    font: inherit;
    color: var(--text-primary);
    background: var(--bg-panel);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    padding: 5px 9px;
    text-decoration: none;
    cursor: pointer;
}
.collection-toolbar button:disabled { opacity: .5; cursor: default; }

/* Light theme overrides */
[data-theme="light"] {
    --bg-dark: #ffffff;
    --bg-panel: rgba(255, 255, 255, 0.9);
    --bg-header: rgba(250, 250, 250, 0.9);
    --glass-border: rgba(0, 0, 0, 0.08);
    --text-primary: #1a1a1a;
    --text-secondary: #555555;
    --accent-gradient: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
    --run-gradient: linear-gradient(135deg, #059669 0%, #10b981 100%);
    --error-gradient: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
    --accent-color: #2563eb;
}

/* Theme toggle button */
.theme-button {
    margin-left: 0.5rem;
    padding: 4px 8px;
    font-size: 0.9rem;
    background: transparent;
    border: 1px solid var(--glass-border);
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-primary);
    transition: var(--transition-smooth);
}
.theme-button:hover {
    background: var(--accent-color);
    color: #fff;
}



* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-dark);
    background-image:
        radial-gradient(circle at 10% 20%, rgba(59, 130, 246, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(139, 92, 246, 0.05) 0%, transparent 40%);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    /* Adding a subtle vignette */
    box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.5);
}

/* --- Top Navigation --- */
.top-nav {
    height: 60px;
    background: var(--bg-header);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    z-index: 100;
}

.logo {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.language-badge {
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    border: 1px solid var(--glass-border);
    font-weight: 500;
}

.analysis-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    padding: 0 12px;
    color: var(--text-primary);
    text-decoration: none;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    font-size: 0.86rem;
    font-weight: 700;
    transition: var(--transition-smooth);
}

.analysis-link:hover {
    border-color: var(--accent-color);
    color: #fff;
    background: var(--accent-color);
}

/* --- Premium Buttons --- */
.run-button,
.finish-button {
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    gap: 8px;
    color: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.run-button {
    background: var(--run-gradient);
}

.run-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.3);
}

.start-button {
    background: linear-gradient(135deg, #8b5cf6 0%, #d946ef 100%);
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    gap: 8px;
    color: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.start-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.3);
}

.finish-button {
    background: var(--accent-gradient);
}

.finish-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.3);
}

.run-button:active,
.start-button:active,
.finish-button:active {
    transform: translateY(0);
}

/* Disabled State */
button:disabled {
    background: #4a4a4e !important;
    color: #888 !important;
    cursor: not-allowed !important;
    box-shadow: none !important;
    transform: none !important;
    opacity: 0.6;
}

/* --- Layout --- */
.main-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    padding: 12px;
    gap: 12px;
}

.left-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    gap: 12px;
}

/* --- Section Styling (The Glass Panels) --- */
.task-panel,
.editor-section,
.panel-half,
.ai-chat-sidebar {
    background: var(--bg-panel);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

.task-panel {
    flex: 0 0 250px;
}

.bottom-workspace {
    display: flex;
    flex: 1;
    gap: 12px;
    min-height: 0;
}

.editor-section {
    flex: 2;
    position: relative;
}

.io-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.panel-half {
    flex: 1;
}

.panel-header {
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.03);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--glass-border);
}

#task-area,
#stdin-area,
.terminal-output {
    flex: 1;
    background: transparent;
    color: var(--text-primary);
    padding: 16px;
    font-family: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
    font-size: 14px;
    line-height: 1.6;
    border: none;
    outline: none;
    resize: none;
}

#task-area {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

.terminal-output {
    white-space: pre-wrap;
    overflow-y: auto;
}

.terminal-output.error {
    color: #f87171;
    background: rgba(239, 68, 68, 0.05);
}



/* --- AI Chat Sidebar --- */
.ai-chat-sidebar {
    width: 500px;
    display: flex;
    flex-direction: column;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
}

/* Custom Scrollbar */
#task-area::-webkit-scrollbar,
#stdin-area::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar,
.terminal-output::-webkit-scrollbar {
    width: 6px;
}

#task-area::-webkit-scrollbar-thumb,
#stdin-area::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb,
.terminal-output::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.chat-bubble {
    max-width: 90%;
    padding: 14px 18px;
    border-radius: 16px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    animation: fadeInSlide 0.4s ease-out;
}

@keyframes fadeInSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-bubble.user {
    align-self: flex-end;
    background: var(--accent-gradient);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.2);
}

.chat-bubble.ai {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.chat-bubble pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 12px;
    border-radius: 8px;
    margin: 10px 0;
    overflow-x: auto;
}

.chat-input-area {
    padding: 20px;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid var(--glass-border);
    display: flex;
    gap: 12px;
}

#chat-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    resize: none;
    transition: var(--transition-smooth);
}

#chat-input:focus {
    border-color: var(--accent-color);
    background: rgba(255, 255, 255, 0.08);
}

.send-chat-btn {
    background: var(--accent-gradient);
    border: none;
    width: 46px;
    height: 46px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: var(--transition-smooth);
}

.send-chat-btn:hover {
    transform: scale(1.05);
}

.typing-indicator {
    font-size: 0.8rem;
    color: var(--accent-color);
    margin-left: 10px;
    font-weight: 500;
}

/* --- Monaco Editor Overrides --- */
#monaco-container {
    width: 100%;
    height: 100%;
    background: transparent !important;
}

/* --- Modals --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    transition: var(--transition-smooth);
}

.modal-overlay.hidden {
    display: none;
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: rgba(20, 20, 25, 0.95);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 32px;
    width: 400px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    text-align: center;
}

.modal-content h3 {
    margin-bottom: 12px;
    color: var(--text-primary);
}

.modal-content p {
    white-space: pre-wrap;
    max-height: 45vh;
    overflow-y: auto;
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 0.9rem;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.modal-btn {
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition-smooth);
}

.modal-btn.cancel {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid var(--glass-border);
}

.modal-btn.cancel:hover {
    background: rgba(255, 255, 255, 0.1);
}

.modal-btn.confirm {
    background: var(--run-gradient);
    color: white;
}

.modal-btn.confirm:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.login-card { width:min(420px,calc(100% - 40px)); margin:12vh auto; padding:32px; border:1px solid var(--glass-border); border-radius:16px; background:rgba(20,20,25,.95); color:var(--text-primary); }
.login-card h1 { font-size:1.4rem; margin-top:0; }.login-card p { color:var(--text-secondary); }.login-card label { display:block; margin:16px 0 6px; }.login-card input { box-sizing:border-box; width:100%; margin-top:6px; padding:12px; border-radius:8px; border:1px solid var(--glass-border); background:rgba(255,255,255,.06); color:var(--text-primary); }.login-card button { width:100%; margin-top:20px; padding:12px; border:0; border-radius:8px; color:white; background:var(--accent-gradient); cursor:pointer; }.login-card #login-error { min-height:1.2em; color:#f87171; }
