/* TeX Wizard — Styles */

:root {
    --bg: #0f1117;
    --bg-surface: #1a1d27;
    --bg-card: #21242f;
    --bg-hover: #2a2e3b;
    --border: #2e3345;
    --border-focus: #5b8def;
    --text: #e1e4ed;
    --text-muted: #8b90a0;
    --text-dim: #5c6070;
    --primary: #5b8def;
    --primary-hover: #7aa3f5;
    --secondary: #6c63ff;
    --accent: #10b981;
    --accent-hover: #34d399;
    --warning: #f59e0b;
    --warning-hover: #fbbf24;
    --error: #ef4444;
    --success: #10b981;
    --info: #3b82f6;
    --radius: 8px;
    --radius-sm: 4px;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

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

/* App Container */
.app-container {
    max-width: 1800px;
    margin: 0 auto;
    padding: 0 16px 32px;
}

/* Header */
.app-header {
    padding: 20px 0 16px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.app-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 2px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 12px;
}

.header-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.model-selectors {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.model-selectors label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.model-selectors select {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px 8px;
    font-size: 0.85rem;
    min-width: 180px;
}

.session-badge {
    font-size: 0.8rem;
    color: var(--text-dim);
    font-family: var(--font-mono);
    background: var(--bg-card);
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

/* Main Layout */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1.1fr 1.3fr;
    gap: 20px;
    align-items: start;
}

@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr 1fr;
    }
    .panel-output {
        grid-column: 1 / -1;
    }
}

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

/* Panels */
.panel > h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-muted);
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 14px;
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 8px;
}

.card-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
}

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

/* Editors */
.editor {
    width: 100%;
    background: var(--bg-surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 0.88rem;
    line-height: 1.5;
    resize: vertical;
    font-family: var(--font-sans);
    transition: border-color 0.2s;
}

.editor:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 2px rgba(91, 141, 239, 0.15);
}

.editor-mono {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    tab-size: 2;
}

.editor-tall {
    min-height: 350px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.8rem;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--secondary);
    color: #fff;
}
.btn-secondary:hover:not(:disabled) {
    background: #7c75ff;
}

.btn-accent {
    background: var(--accent);
    color: #fff;
}
.btn-accent:hover:not(:disabled) {
    background: var(--accent-hover);
}

.btn-warning {
    background: var(--warning);
    color: #000;
}
.btn-warning:hover:not(:disabled) {
    background: var(--warning-hover);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text);
}

/* Pipeline Steps */
.pipeline-step {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 12px;
    transition: border-color 0.3s;
}

.pipeline-step.active {
    border-color: var(--primary);
}

.pipeline-step.completed {
    border-color: var(--success);
}

.pipeline-step.error {
    border-color: var(--error);
}

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

.step-info {
    flex: 1;
}

.step-info h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 1px;
}

.step-info p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.step-info code {
    background: var(--bg-surface);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.78rem;
    font-family: var(--font-mono);
}

.step-status {
    margin-top: 8px;
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 0.85rem;
    font-weight: 700;
    flex-shrink: 0;
    transition: background 0.3s, color 0.3s;
}

.badge-pending {
    background: var(--bg-surface);
    color: var(--text-dim);
    border: 2px solid var(--border);
}

.badge-running {
    background: var(--primary);
    color: #fff;
    border: 2px solid var(--primary);
    animation: pulse-badge 1.5s ease-in-out infinite;
}

.badge-done {
    background: var(--success);
    color: #fff;
    border: 2px solid var(--success);
}

.badge-error {
    background: var(--error);
    color: #fff;
    border: 2px solid var(--error);
}

@keyframes pulse-badge {
    0%, 100% { box-shadow: 0 0 0 0 rgba(91, 141, 239, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(91, 141, 239, 0); }
}

/* Session Links */
.session-link-container {
    margin-top: 6px;
    font-size: 0.82rem;
}

.session-link-container a {
    color: var(--primary);
    text-decoration: none;
}

.session-link-container a:hover {
    text-decoration: underline;
}

/* Batch Log */
.batch-log {
    max-height: 250px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    line-height: 1.6;
    padding: 8px 0;
}

.batch-log:empty::after {
    content: 'Pipeline log will appear here...';
    color: var(--text-dim);
    font-style: italic;
}

.batch-log .log-entry {
    padding: 2px 0;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}

.batch-log .log-entry.success { color: var(--success); }
.batch-log .log-entry.error { color: var(--error); }
.batch-log .log-entry.info { color: var(--info); }
.batch-log .log-entry.warning { color: var(--warning); }

/* Log Viewer */
.log-viewer {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    line-height: 1.5;
    max-height: 300px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text-muted);
}

/* PDF Container */
.pdf-container {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.pdf-container iframe {
    width: 100%;
    height: 600px;
    border: none;
}

.placeholder-text {
    color: var(--text-dim);
    font-style: italic;
    font-size: 0.9rem;
}

/* Git Status */
.git-status {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
    max-height: 150px;
    overflow-y: auto;
}

.git-status:empty::after {
    content: 'No git info yet.';
    color: var(--text-dim);
    font-style: italic;
}

/* Usage */
.usage-summary {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.usage-summary strong {
    color: var(--text);
}

/* Status Messages */
.status-msg {
    font-size: 0.8rem;
    transition: opacity 0.3s;
}

.status-msg.success { color: var(--success); }
.status-msg.error { color: var(--error); }
.status-msg.info { color: var(--info); }
.status-msg.warning { color: var(--warning); }

/* Divider */
.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 16px 0;
}

/* Toast */
#toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 10px 18px;
    border-radius: var(--radius);
    font-size: 0.88rem;
    color: #fff;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    animation: toast-in 0.3s ease;
    max-width: 400px;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--error); }
.toast.info { background: var(--info); }
.toast.warning { background: var(--warning); color: #000; }

@keyframes toast-in {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

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

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