:root {
    /* Soft blues and greens theme - Dark Mode */
    --bg-base: #111827;
    --bg-panel: #1f2937;
    --bg-surface: #374151;
    
    --text-main: #f9fafb;
    --text-muted: #9ca3af;
    
    --border: #374151;
    --border-light: rgba(55, 65, 81, 0.5);
    
    --primary: #3b82f6; /* Blue */
    --primary-hover: #2563eb;
    
    --secondary: #10b981; /* Soft Green */
    --secondary-hover: #059669;
    
    --accent: #8b5cf6; /* Purple accent */
    
    --success: #10b981;
    --error: #ef4444;
    
    --radius: 12px;
    --radius-sm: 8px;
    
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
    
    --glass-bg: rgba(31, 41, 55, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
}

[data-theme="light"] {
    --bg-base: #f0fdf4; /* Slight green tint */
    --bg-panel: #ffffff;
    --bg-surface: #f3f4f6;
    
    --text-main: #111827;
    --text-muted: #6b7280;
    
    --border: #e5e7eb;
    --border-light: rgba(17, 24, 39, 0.05);
    
    --primary: #3b82f6;
    --secondary: #10b981;
    --accent: #6366f1;
    
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    
    --glass-bg: rgba(255, 255, 255, 0.8);
    --glass-border: rgba(0, 0, 0, 0.05);
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

/* Base Utility */
.w-full { width: 100%; }
.text-primary { color: var(--primary); }

/* Layout */
.app-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 1rem 1.5rem;
    gap: 1rem;
    max-width: 1600px;
    margin: 0 auto;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    flex-shrink: 0;
}

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

.logo-box {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
}
.logo-box i { width: 22px; height: 22px; }

.brand h1 { font-size: 1.15rem; font-weight: 700; background: linear-gradient(to right, var(--primary), var(--secondary)); -webkit-background-clip: text; -webkit-text-fill-color: transparent;}
.brand-subtitle { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; letter-spacing: 0.02em; }

.header-actions { display: flex; align-items: center; gap: 1rem; }
.user-menu { display: flex; align-items: center; gap: 0.75rem; border-right: 1px solid var(--border); padding-right: 1rem; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--bg-surface); display: flex; align-items: center; justify-content: center; color: var(--text-muted); border: 1px solid var(--border); cursor: pointer; }
.avatar i { width: 16px; height: 16px; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    font-family: inherit;
    transition: all 0.2s;
}
.btn i { width: 16px; height: 16px; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.85rem; }
.btn-icon { padding: 0.5rem; border-radius: 8px; background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-icon:hover { background-color: var(--bg-surface); color: var(--text-main); }

.btn-primary { background: linear-gradient(135deg, var(--primary), var(--secondary)); color: white; border: none; box-shadow: 0 4px 10px rgba(59, 130, 246, 0.3); }
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: 0 6px 12px rgba(59, 130, 246, 0.4); }
.btn-outline { background: transparent; color: var(--text-main); border-color: var(--border); }
.btn-outline:hover { background: var(--bg-surface); }
.btn-ghost { background: transparent; color: var(--text-muted); border: none; }
.btn-ghost:hover { color: var(--text-main); background: var(--bg-surface); }

.form-select {
    background: var(--bg-surface);
    color: var(--text-main);
    border: 1px solid var(--border);
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
}

/* Main Layout */
.main-content {
    display: flex;
    flex: 1;
    gap: 1rem;
    min-height: 0; /* Important for flex child scrolling */
}

@media (max-width: 900px) {
    .main-content { flex-direction: column; overflow-y: auto; }
}

/* Panels */
.panel {
    background-color: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background-color: var(--bg-surface);
    flex-shrink: 0;
}

.header-title { display: flex; align-items: center; gap: 0.75rem; }
.header-title h2 { font-size: 1rem; font-weight: 600; }
.header-controls { display: flex; align-items: center; gap: 0.5rem; }

.panel-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    background-color: var(--bg-surface);
    flex-shrink: 0;
}

/* Left Editor Panel */
.editor-panel {
    flex: 1;
    min-width: 450px;
}

.editor-container {
    flex: 1;
    position: relative;
    background: var(--bg-base);
    overflow: auto;
}

.code-textarea, .editor-container pre, .editor-container code {
    margin: 0; padding: 1.5rem; border: none;
    width: 100%; height: 100%;
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    background: transparent;
    tab-size: 4;
}
.code-textarea {
    position: absolute; top: 0; left: 0;
    color: transparent; /* Text is invisible, caret is visible */
    caret-color: var(--primary);
    resize: none;
    outline: none;
    z-index: 2;
    white-space: pre;
}

/* Placeholder visibility */
.code-textarea::placeholder { color: var(--text-muted); }
.code-textarea:not(:placeholder-shown)::placeholder { color: transparent; }

.editor-container pre {
    position: absolute; top: 0; left: 0;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

/* Right Output Panel */
.output-panel {
    flex: 1.2;
    min-width: 500px;
}
.tab-header { padding: 0.75rem 1.5rem; gap: 1rem; }
.tabs { display: flex; gap: 0.5rem; border-radius: var(--radius-sm); background: var(--bg-base); padding: 0.25rem; }
.tab-btn {
    background: transparent; border: none; font-family: inherit; font-size: 0.85rem; font-weight: 500; color: var(--text-muted); padding: 0.5rem 1rem; border-radius: 6px; cursor: pointer; display: flex; align-items: center; gap: 0.5rem; transition: 0.2s;
}
.tab-btn i { width: 16px; height: 16px; }
.tab-btn:hover { color: var(--text-main); }
.tab-btn.active { background: var(--bg-panel); color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

/* Content Output */
.output-container {
    flex: 1;
    overflow-y: auto;
    position: relative;
    background-color: var(--bg-panel);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}
.empty-icon {
    width: 64px; height: 64px; border-radius: 50%; background: var(--bg-surface); display: flex; align-items: center; justify-content: center; color: var(--primary); margin-bottom: 1rem;
}
.empty-icon i { width: 32px; height: 32px; }
.empty-state h3 { color: var(--text-main); margin-bottom: 0.5rem; font-weight: 600; }
.empty-state p { max-width: 300px; font-size: 0.9rem; }

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-size: 0.9rem;
}
.spinner {
    width: 40px; height: 40px; border: 3px solid var(--border-light); border-top-color: var(--primary); border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 1rem;
}
@keyframes spin { 100% { transform: rotate(360deg); } }

/* Markdown Body for output */
.tab-content { padding: 2rem; }
.markdown-body {
    font-size: 0.95rem;
    color: var(--text-main);
}
.markdown-body h1 { font-size: 1.5rem; margin-bottom: 1rem; color: var(--primary); }
.markdown-body h2 { font-size: 1.25rem; margin: 1.5rem 0 0.75rem; color: var(--secondary); }
.markdown-body h3 { font-size: 1.1rem; margin: 1.25rem 0 0.5rem; }
.markdown-body p { margin-bottom: 1rem; line-height: 1.7; }
.markdown-body ul, .markdown-body ol { margin-bottom: 1rem; padding-left: 1.5rem; }
.markdown-body li { margin-bottom: 0.5rem; }
.markdown-body code {
    background: var(--bg-surface); border: 1px solid var(--border); padding: 0.1rem 0.3rem; border-radius: 4px; font-family: 'Fira Code', monospace; font-size: 0.85em; color: var(--accent);
}
.markdown-body pre { background: var(--bg-base); border: 1px solid var(--border); padding: 1rem; border-radius: var(--radius-sm); overflow-x: auto; margin-bottom: 1rem; }
.markdown-body pre code { background: transparent; border: none; padding: 0; color: inherit; }
.markdown-body blockquote { border-left: 4px solid var(--primary); padding-left: 1rem; color: var(--text-muted); margin-bottom: 1rem; font-style: italic; }

.feedback-widget {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.feedback-actions { display: flex; gap: 0.5rem; }

/* Toast */
.toast {
    position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%) translateY(100px); background: var(--text-main); color: var(--bg-base); padding: 0.75rem 1.5rem; border-radius: 30px; font-size: 0.9rem; font-weight: 600; box-shadow: 0 10px 25px rgba(0,0,0,0.2); opacity: 0; transition: all 0.3s ease; z-index: 2000; pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
