:root {
    /* PRO Dark Studio Theme Colors */
    --bg-main: #09090b;
    --bg-panel: #18181b;
    --bg-input: #27272a;
    --border-color: rgba(255, 255, 255, 0.08);
    --text-primary: #f4f4f5;
    --text-secondary: #a1a1aa;
    --accent-primary: #6366f1;
    /* Indigo */
    --accent-glow: rgba(99, 102, 241, 0.4);
    --accent-secondary: #a855f7;
    /* Purple */

    /* Status Colors */
    --status-idle: #71717a;
    --status-active: #f59e0b;
    --status-success: #10b981;
    --status-error: #ef4444;

    --font-ui: 'Inter', sans-serif;
    --font-code: 'Fira Code', monospace;
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-ui);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

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

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

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

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

/* App Layout */
#app {
    display: flex;
    flex: 1;
    height: 100vh;
    overflow: hidden;
}

/* --- Left Sidebar --- */
.sidebar {
    width: 320px;
    min-width: 200px;
    max-width: 600px;
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 0;
    z-index: 10;
    overflow: hidden;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 25px;
}

.logo-text {
    font-size: 1.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.badge-pro {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 12px;
    letter-spacing: 0.5px;
    box-shadow: 0 0 10px var(--accent-glow);
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.input-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

select,
textarea {
    background-color: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px 14px;
    font-family: var(--font-ui);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    width: 100%;
}

select {
    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='%23a1a1aa' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}

select:hover {
    border-color: rgba(99, 102, 241, 0.4);
    background-color: rgba(39, 39, 42, 0.8);
}

select optgroup {
    background-color: var(--bg-panel);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.8rem;
}

select option {
    background-color: var(--bg-panel);
    color: var(--text-primary);
    padding: 8px 12px;
}

select:focus,
textarea:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
    background-color: rgba(15, 15, 20, 0.9);
}

textarea {
    resize: vertical;
    min-height: 120px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px var(--accent-glow);
}

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.prebuilt-prompts {
    flex: 1;
    overflow-y: auto;
}

.prebuilt-prompts h4 {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.prompt-chip {
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.8rem;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    line-height: 1.4;
}

.prompt-chip:hover {
    background-color: var(--border-color);
    border-color: var(--accent-primary);
}

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

.prompts-header h4 {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0;
}

.shuffle-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 6px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.shuffle-btn:hover {
    color: var(--accent-primary);
    border-color: var(--accent-primary);
    background-color: var(--bg-input);
    transform: rotate(20deg) scale(1.1);
}

.status-panel {
    margin-top: auto;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--status-idle);
    transition: background-color 0.3s;
}

.status-dot-mini {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--status-idle);
    transition: all 0.3s;
}

.status-dot-mini.active { background-color: var(--status-active); box-shadow: 0 0 8px var(--status-active); }
.status-dot-mini.success { background-color: var(--status-success); box-shadow: 0 0 8px var(--status-success); }
.status-dot-mini.error { background-color: var(--status-error); box-shadow: 0 0 8px var(--status-error); }

.status-dot.active {
    background-color: var(--status-active);
    animation: pulse 1.5s infinite;
}

.status-dot.success {
    background-color: var(--status-success);
}

.status-dot.error {
    background-color: var(--status-error);
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7);
    }

    70% {
        box-shadow: 0 0 0 6px rgba(245, 158, 11, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
    }
}

/* --- Middle Panel: Code Editor --- */
.middle-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-main);
    border-right: none;
    /* Removed as resizer acts as border */
    min-width: 300px;
}

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

.panel-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.action-btn {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.action-btn:hover {
    color: var(--text-primary);
    background-color: var(--bg-input);
    border-color: var(--accent-primary);
}

.editor-container {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

.line-numbers {
    width: 50px;
    background-color: #0d0d0f;
    color: #52525b;
    font-family: var(--font-code);
    font-size: 0.9rem;
    line-height: 1.5;
    padding: 15px 0;
    text-align: right;
    user-select: none;
    overflow-y: hidden;
    border-right: 1px solid var(--border-color);
}

.line-numbers div {
    padding-right: 15px;
}

.code-textarea {
    flex: 1;
    background-color: transparent;
    color: #e4e4e7;
    font-family: var(--font-code);
    font-size: 0.9rem;
    line-height: 1.5;
    padding: 15px;
    border: none;
    resize: none;
    outline: none;
    white-space: pre;
    overflow-wrap: normal;
    overflow-x: auto;
}

.code-textarea::selection {
    background-color: rgba(99, 102, 241, 0.3);
}

/* --- Right Panel: Live Preview --- */
.right-panel {
    flex: 1.2;
    display: flex;
    flex-direction: column;
    background-color: #ffffff;
    min-width: 400px;
}

/* --- Resizers --- */
.resizer {
    width: 5px;
    background-color: var(--border-color);
    cursor: col-resize;
    z-index: 20;
    transition: background-color 0.2s, width 0.2s;
    flex-shrink: 0;
    position: relative;
}

.resizer:hover,
.resizer.resizing {
    background-color: var(--accent-primary);
    width: 6px;
}

.resizer::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -5px;
    right: -5px;
}

.browser-header {
    height: 50px;
    background-color: #e4e4e7;
    border-bottom: 1px solid #d4d4d8;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
}

.browser-dots {
    display: flex;
    gap: 6px;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.dot.red {
    background-color: #ef4444;
}

.dot.yellow {
    background-color: #f59e0b;
}

.dot.green {
    background-color: #10b981;
}

.preview-actions {
    display: flex;
    gap: 10px;
}

.preview-actions .action-btn {
    background-color: #ffffff;
    color: #3f3f46;
    border-color: #d4d4d8;
}

.preview-actions .action-btn:hover {
    background-color: #f4f4f5;
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.preview-iframe {
    flex: 1;
    width: 100%;
    border: none;
    background-color: #ffffff;
}

.spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 1024px) {
    #app {
        flex-direction: column;
        overflow-y: auto;
        height: auto;
    }

    .sidebar {
        width: 100% !important;
        max-width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .middle-panel,
    .right-panel {
        width: 100% !important;
        min-height: 500px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .resizer {
        display: none;
    }
}

/* =========================================
   Ollama & Model Settings (Sync from Agent)
   ========================================= */

.ollama-settings-group {
    margin: 12px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    animation: fadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.ollama-field {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 10px;
}

.ollama-field label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.ollama-field label i {
    color: var(--accent-primary);
    font-size: 0.85rem;
}

.ollama-field .input-wrapper {
    position: relative;
    display: flex;
    width: 100%;
}

.ollama-field input, 
.ollama-field select {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.ollama-field input:focus, 
.ollama-field select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
    background: rgba(0, 0, 0, 0.5);
    outline: none;
}

.pull-status {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pull-progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.pull-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent-primary);
    box-shadow: 0 0 10px var(--accent-glow);
    transition: width 0.3s ease;
}

#pullStatusText {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: var(--font-code);
}

.select-with-btn {
    display: flex;
    gap: 8px;
}

.btn-fetch-models {
    background: linear-gradient(135deg, var(--accent-primary), #4f46e5);
    border: none;
    color: white;
    border-radius: 8px;
    width: 40px;
    min-width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-fetch-models:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.5);
    filter: brightness(1.1);
}

.btn-fetch-models i.spinning {
    animation: fa-spin 1s linear infinite;
}

/* Actions & Info */
.ollama-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 4px;
}

.btn-download-colab {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #f59e0b, #d97706); /* Premium Amber Gradient */
    border: none;
    border-radius: 10px;
    color: white;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(217, 119, 6, 0.3);
}

.btn-download-colab:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(217, 119, 6, 0.4);
    filter: brightness(1.1);
}

.btn-toggle-instructions {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    padding: 10px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-toggle-instructions:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.model-info-card {
    margin: 12px;
    padding: 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.model-info-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.model-info-row i {
    color: var(--accent-primary);
    width: 14px;
}

.ollama-instructions-card {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 16px;
    margin: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.ollama-instructions-card ol {
    margin: 0;
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ollama-instructions-card li {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.ollama-instructions-card a {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 500;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Custom Dropdown Styles --- */
.custom-select-wrapper {
    position: relative;
    user-select: none;
    width: 100%;
}

.custom-select-trigger {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px 14px;
    font-family: var(--font-ui);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.custom-select-trigger:hover, 
.custom-select-wrapper.open .custom-select-trigger {
    border-color: var(--accent-primary);
    background-color: rgba(39, 39, 42, 0.8);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.custom-select-trigger i {
    color: var(--text-secondary);
    font-size: 0.8rem;
    transition: transform 0.2s;
}

.custom-select-wrapper.open .custom-select-trigger i {
    transform: rotate(180deg);
}

.custom-options {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    width: 100%;
    background-color: rgba(28, 28, 32, 0.95);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-5px);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-height: 250px;
    overflow-y: auto;
    backdrop-filter: blur(10px);
}

.custom-select-wrapper.open .custom-options {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.custom-option {
    padding: 8px 12px;
    font-size: 0.85rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.custom-option:hover, 
.custom-option.selected {
    background-color: var(--bg-input);
    color: var(--accent-primary);
}

.custom-optgroup {
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(0,0,0,0.2);
    margin-top: 4px;
}

.custom-optgroup:first-child {
    margin-top: 0;
}

/* =========================================
   UI Collapse & Resizing
   ========================================= */
.sidebar {
    transition: width 0.3s ease, min-width 0.3s ease, padding 0.3s ease;
}

.sidebar.collapsed {
    width: 0 !important;
    min-width: 0 !important;
    padding: 0 !important;
    overflow: hidden;
    border-right: none;
}

.right-panel.collapsed {
    width: 0 !important;
    min-width: 0 !important;
    display: none;
}

.floating-preview-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 100;
    align-items: center;
    gap: 6px;
    background: var(--bg-panel, #09090b);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    transition: all 0.2s;
    display: flex;
}

.floating-preview-btn:hover {
    background: rgba(255, 255, 255, 0.05);
}

.terminal-resizer {
    height: 4px;
    cursor: ns-resize;
    background: transparent;
    transition: background 0.2s;
    z-index: 10;
}

.terminal-resizer:hover, .terminal-resizer.dragging {
    background: var(--accent-primary, #6366f1);
}
