/* CSS Variables */
:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-tertiary: #0f0f1a;
    --bg-hover: #252545;
    --text-primary: #e4e4e7;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-success: #22c55e;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;
    --border-color: #2d2d44;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --radius: 8px;
    --radius-sm: 4px;
    --sidebar-width: 250px;
    --header-height: 56px;
}

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

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    z-index: 100;
}

.header-left, .header-center, .header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 18px;
    color: var(--text-primary);
}

.logo i {
    color: var(--accent-primary);
    font-size: 24px;
}

.project-name input {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.project-name input:hover {
    background: var(--bg-hover);
}

.project-name input:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: var(--bg-tertiary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-compile {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
}

.btn-compile:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

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

.btn-icon {
    padding: 8px 12px;
    background: var(--bg-hover);
    color: var(--text-secondary);
}

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

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

.btn-sm {
    padding: 4px 8px;
    font-size: 12px;
    background: transparent;
    color: var(--text-secondary);
}

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

.btn-primary {
    background: var(--accent-primary);
    color: white;
}

.btn-primary:hover {
    background: #5558e3;
}

.btn-secondary {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-ai {
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    color: white;
    border: none;
}

.btn-ai:hover {
    background: linear-gradient(135deg, #7c4ddb 0%, #5558e3 100%);
}

.btn-ai i {
    margin-right: 6px;
}

.modal-footer-spacer {
    flex: 1;
}

/* AI Context Modal */
.ai-context-description {
    margin-bottom: 16px;
    color: var(--text-secondary);
    font-size: 14px;
}

#aiContextInput {
    width: 100%;
    padding: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    min-height: 120px;
}

#aiContextInput:focus {
    outline: none;
    border-color: var(--accent-primary);
}

#aiContextInput::placeholder {
    color: var(--text-muted);
}

/* Login Button */
.btn-login {
    background: white;
    color: #333;
    border: 1px solid #ddd;
}

.btn-login:hover {
    background: #f5f5f5;
}

.btn-login i {
    color: #4285f4;
}

/* User Menu */
.user-menu {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    background: var(--bg-hover);
    border-radius: var(--radius);
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.user-name {
    font-size: 13px;
    color: var(--text-secondary);
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-logout {
    padding: 4px 8px;
    background: transparent;
    color: var(--text-muted);
}

.btn-logout:hover {
    background: var(--bg-tertiary);
    color: var(--accent-danger);
}

/* Credits Display */
.credits-display {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    border-radius: var(--radius);
    color: #1a1a2e;
    font-weight: 600;
    font-size: 13px;
}

.credits-display i {
    font-size: 14px;
}

.btn-add-credits {
    padding: 2px 6px;
    background: rgba(0, 0, 0, 0.2);
    color: #1a1a2e;
    border-radius: 4px;
    font-size: 10px;
}

.btn-add-credits:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* Project Selector */
.project-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
}

.project-selector select {
    flex: 1;
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
}

.project-selector select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.sidebar-subheader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-subheader h3 {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
}

.btn-danger {
    color: var(--accent-danger);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* Credit Packages */
.credit-packages {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 16px;
}

.credit-package {
    padding: 16px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.credit-package:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

.credit-package h4 {
    font-size: 16px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.credit-package .price {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent-success);
}

.credits-info {
    margin-bottom: 8px;
    font-size: 16px;
}

.credits-description {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 16px;
}

.insufficient-credits-message {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
}

/* Compile Status */
.compile-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 13px;
}

.compile-status.compiling {
    color: var(--accent-warning);
}

.compile-status.success {
    color: var(--accent-success);
}

.compile-status.error {
    color: var(--accent-danger);
}

/* Main Content */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: relative;
    transition: width 0.3s, min-width 0.3s;
}

.sidebar.collapsed {
    width: 0;
    min-width: 0;
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h3 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.sidebar-actions {
    display: flex;
    gap: 4px;
}

.file-tree {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.15s;
    position: relative;
}

.file-item:hover {
    background: var(--bg-hover);
}

.file-item.active {
    background: var(--accent-primary);
    color: white;
}

.file-item.main::after {
    content: 'main';
    position: absolute;
    right: 8px;
    font-size: 10px;
    padding: 2px 6px;
    background: var(--accent-secondary);
    border-radius: 10px;
    color: white;
}

.file-item i {
    font-size: 14px;
    width: 16px;
    color: var(--text-muted);
}

.file-item.active i {
    color: white;
}

.file-item .file-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-toggle {
    position: absolute;
    right: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 48px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-left: none;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    color: var(--text-muted);
    transition: all 0.2s;
}

.sidebar-toggle:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.sidebar.collapsed .sidebar-toggle {
    right: -24px;
}

.sidebar.collapsed .sidebar-toggle i {
    transform: rotate(180deg);
}

/* Editor Panel */
.editor-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 300px;
    background: var(--bg-tertiary);
}

.editor-header {
    display: flex;
    align-items: center;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    min-height: 40px;
}

.editor-tabs {
    display: flex;
    flex: 1;
    overflow-x: auto;
}

.editor-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    font-size: 13px;
    color: var(--text-secondary);
    border-right: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.editor-tab:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.editor-tab.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-bottom: 2px solid var(--accent-primary);
    margin-bottom: -1px;
}

.editor-tab.modified::after {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--accent-warning);
    border-radius: 50%;
}

.editor-tab .close-tab {
    opacity: 0;
    font-size: 10px;
    padding: 2px;
    border-radius: 2px;
    transition: all 0.15s;
}

.editor-tab:hover .close-tab {
    opacity: 0.6;
}

.editor-tab .close-tab:hover {
    opacity: 1;
    background: var(--bg-hover);
}

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

.CodeMirror {
    height: 100%;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 14px;
    line-height: 1.6;
}

.editor-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-muted);
}

/* Resizer */
.resizer {
    width: 6px;
    background: var(--border-color);
    cursor: col-resize;
    transition: background 0.2s;
}

.resizer:hover, .resizer.active {
    background: var(--accent-primary);
}

/* Preview Panel */
.preview-panel {
    width: 50%;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    background: var(--bg-tertiary);
    border-left: 1px solid var(--border-color);
}

.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.preview-tabs {
    display: flex;
    gap: 4px;
}

.preview-tab {
    padding: 6px 12px;
    font-size: 13px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
}

.preview-tab:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.preview-tab.active {
    background: var(--accent-primary);
    color: white;
}

.preview-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.zoom-level {
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 50px;
    text-align: center;
}

.preview-content {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.pdf-viewer {
    height: 100%;
    overflow: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    background: #525659;
}

.pdf-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
}

.pdf-placeholder i {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.pdf-placeholder .hint {
    font-size: 12px;
    margin-top: 8px;
    opacity: 0.6;
}

.pdf-page {
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    background: white;
}

.pdf-page canvas {
    display: block;
}

.log-viewer {
    height: 100%;
    overflow: auto;
    padding: 16px;
    background: var(--bg-tertiary);
}

.log-viewer pre {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: var(--text-secondary);
}

.log-viewer.has-error pre {
    color: var(--accent-danger);
}

.hidden {
    display: none !important;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    width: 400px;
    max-width: 90%;
    box-shadow: var(--shadow);
    animation: modalIn 0.2s ease;
}

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

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.15s;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}

.modal-body input[type="text"] {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
}

.modal-body input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
}

/* Settings */
.setting-group {
    margin-bottom: 20px;
}

.setting-group:last-child {
    margin-bottom: 0;
}

.setting-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.setting-group select {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    cursor: pointer;
}

.setting-group select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.setting-group input[type="checkbox"] {
    margin-right: 8px;
}

.checkbox-label {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Context Menu */
.context-menu {
    position: fixed;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    min-width: 160px;
    z-index: 1000;
    display: none;
}

.context-menu.show {
    display: block;
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s;
}

.context-menu-item:hover {
    background: var(--bg-hover);
}

.context-menu-item.danger {
    color: var(--accent-danger);
}

.context-menu-item i {
    width: 16px;
    color: var(--text-muted);
}

.context-menu-item.danger i {
    color: var(--accent-danger);
}

.context-menu-divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}

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

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

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

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

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--text-muted);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        z-index: 50;
        height: calc(100% - var(--header-height));
    }

    .header-left .project-name {
        display: none;
    }

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

/* Light theme overrides for CodeMirror default */
.cm-s-default.CodeMirror {
    background: #fafafa;
}

/* Error highlighting in log */
.log-error {
    color: var(--accent-danger);
    font-weight: 500;
}

.log-warning {
    color: var(--accent-warning);
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    font-size: 14px;
    z-index: 1001;
    animation: toastIn 0.3s ease;
}

.toast.success {
    border-color: var(--accent-success);
}

.toast.error {
    border-color: var(--accent-danger);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Template Button */
.btn-templates {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
}

.btn-templates:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

/* Large Modal */
.modal-large {
    width: 800px;
    max-width: 95%;
    max-height: 85vh;
}

.modal-xlarge {
    width: 1200px;
    max-width: 95%;
    max-height: 90vh;
}

/* Template Categories */
.template-categories {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.category-tab {
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
}

.category-tab:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.category-tab.active {
    background: var(--accent-primary);
    color: white;
}

/* Template Grid */
.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    max-height: 60vh;
    overflow-y: auto;
    padding: 4px;
}

.template-card {
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.template-card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.template-card-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
    margin-bottom: 16px;
}

.template-card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.template-card-description {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.template-card-category {
    display: inline-block;
    margin-top: 12px;
    padding: 4px 10px;
    background: var(--bg-hover);
    border-radius: 12px;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Template Form */
.template-form-body {
    display: flex;
    gap: 24px;
    height: 70vh;
}

.template-form-container {
    flex: 1;
    overflow-y: auto;
    padding-right: 16px;
}

.template-preview-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.preview-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.template-live-preview {
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: auto;
    padding: 16px;
}

.template-live-preview pre {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-wrap: break-word;
    margin: 0;
}

/* Form Sections */
.form-section {
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.form-section:last-child {
    border-bottom: none;
}

.form-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-section-title i {
    font-size: 12px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group label .required {
    color: var(--accent-danger);
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="url"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    transition: border-color 0.15s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
}

/* Repeatable Sections */
.repeatable-section {
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 12px;
    position: relative;
}

.repeatable-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.repeatable-section-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.btn-remove-section {
    padding: 4px 8px;
    background: transparent;
    border: none;
    color: var(--accent-danger);
    cursor: pointer;
    font-size: 12px;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}

.btn-remove-section:hover {
    background: rgba(239, 68, 68, 0.1);
}

.btn-add-section {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 12px;
    background: transparent;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
    margin-top: 12px;
}

.btn-add-section:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

/* Modal Title Group */
.modal-title-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-back {
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

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

/* Template icons */
.template-icon-resume::before { content: '\f2c2'; }
.template-icon-letter::before { content: '\f0e0'; }
.template-icon-paper::before { content: '\f15c'; }
.template-icon-invoice::before { content: '\f571'; }
.template-icon-presentation::before { content: '\f1c4'; }
.template-icon-thesis::before { content: '\f19d'; }
.template-icon-report::before { content: '\f1ea'; }

/* Search Dialog Styling */
.CodeMirror-dialog {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 8px 12px;
    color: var(--text-primary);
    font-family: inherit;
}

.CodeMirror-dialog input {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 4px 8px;
    font-family: inherit;
    outline: none;
}

.CodeMirror-dialog input:focus {
    border-color: var(--accent-primary);
}

.CodeMirror-dialog button {
    background: var(--accent-primary);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    padding: 4px 12px;
    margin-left: 8px;
    cursor: pointer;
}

.CodeMirror-dialog button:hover {
    background: var(--accent-secondary);
}

/* Search Match Highlighting */
.cm-matchhighlight {
    background: rgba(99, 102, 241, 0.3);
    border-radius: 2px;
}

.cm-searching {
    background: rgba(245, 158, 11, 0.4);
    border-radius: 2px;
}

/* Scrollbar match markers */
.CodeMirror-search-match {
    background: var(--accent-warning);
    opacity: 0.8;
}

/* Login Required Modal */
.modal-login {
    max-width: 480px;
}

.login-promo {
    text-align: center;
    padding: 20px 0;
}

.login-promo-icon {
    font-size: 48px;
    color: var(--accent-primary);
    margin-bottom: 16px;
}

.login-required-message {
    font-size: 16px;
    margin-bottom: 24px;
    color: var(--text-primary);
}

.login-benefits {
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-align: left;
    max-width: 280px;
    margin: 0 auto;
}

.benefit-item {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
}

.benefit-item i {
    color: var(--accent-success);
    width: 20px;
}

.btn-google {
    background: #4285f4;
    border: none;
}

.btn-google:hover {
    background: #357abd;
}

/* AI Assistant Panel */
.ai-assistant-panel {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.ai-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    cursor: pointer;
    user-select: none;
}

.ai-panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.ai-panel-title i {
    color: var(--accent-primary);
}

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

.free-renders-display {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-primary);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}

.ai-toggle {
    padding: 4px 8px;
    background: transparent;
    border: none;
}

.ai-toggle i {
    transition: transform 0.2s;
}

.ai-assistant-panel.collapsed .ai-toggle i {
    transform: rotate(180deg);
}

.ai-panel-content {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ai-assistant-panel.collapsed .ai-panel-content {
    display: none;
}

.ai-input-container {
    display: flex;
    gap: 8px;
}

.ai-input-container textarea {
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 10px 12px;
    font-family: inherit;
    font-size: 13px;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
}

.ai-input-container textarea:focus {
    border-color: var(--accent-primary);
}

.ai-input-container textarea::placeholder {
    color: var(--text-muted);
}

.ai-submit {
    padding: 10px 16px;
    align-self: flex-end;
}

.ai-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.ai-suggestion {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    color: var(--text-secondary);
    padding: 4px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-suggestion:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

.ai-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-secondary);
}

.ai-status .spinner {
    width: 14px;
    height: 14px;
    border-width: 2px;
}
