/* Editor-specific styles - extends style.css design system */

/* Brand subtitle for editor */
.brand-subtitle {
    margin-left: 0.5rem;
    padding-left: 0.5rem;
    border-left: 1px solid var(--border);
    font-size: 12px;
    font-weight: 400;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Editor layout */
.editor-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 1.5rem;
    align-items: start;
}

.editor-sidebar {
    position: sticky;
    top: 72px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-height: calc(100vh - 88px);
    overflow-y: auto;
}

.editor-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Chapter tabs */
.chapter-tabs {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    max-height: 400px;
    overflow-y: auto;
}

.chapter-tab {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    background: transparent;
}

.chapter-tab:hover {
    background: var(--gray-100);
}

.chapter-tab.active {
    background: var(--primary-alpha);
    border-color: var(--primary);
}

.chapter-tab-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}

.chapter-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
}

.chapter-tab.active .chapter-number {
    background: white;
    color: var(--primary);
}

.chapter-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chapter-tab-delete {
    opacity: 0;
    background: none;
    border: none;
    padding: 0.25rem;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.chapter-tab-delete svg {
    width: 16px;
    height: 16px;
}

.chapter-tab:hover .chapter-tab-delete {
    opacity: 1;
}

.chapter-tab-delete:hover {
    color: var(--error);
}

/* Editor panel */
.editor-panel {
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

/* Editor toolbar */
.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.chapter-title-input {
    flex: 1;
    font-size: 16px;
    font-weight: 600;
    border: none;
    background: transparent;
    color: var(--text);
    outline: none;
    min-width: 0;
}

.chapter-title-input::placeholder {
    color: var(--text-tertiary);
    font-weight: 400;
}

.chapter-title-input:focus {
    border-bottom: 2px solid var(--primary);
}

.editor-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-small {
    padding: 0.5rem 0.75rem;
    font-size: 13px;
    height: auto;
}

.btn-small svg {
    width: 16px;
    height: 16px;
}

.auto-save-indicator {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 12px;
    color: var(--text-tertiary);
    padding: 0.5rem 0.75rem;
}

.auto-save-indicator.saving {
    color: var(--primary);
}

.auto-save-indicator.saved {
    color: var(--success);
}

.auto-save-indicator.error {
    color: var(--error);
}

.auto-save-indicator .spinner-small {
    width: 14px;
    height: 14px;
    animation: spin 1s linear infinite;
}

.auto-save-indicator:not(.saving) .spinner-small {
    display: none;
}

/* Editor container */
.editor-container {
    position: relative;
    flex: 1;
    min-height: 500px;
}

/* SimpleMDE overrides */
.EasyMDEContainer {
    height: 100%;
}

.EasyMDEContainer .CodeMirror {
    height: 600px;
    border: none;
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1.6;
    background: var(--bg);
    color: var(--text);
}

.EasyMDEContainer .editor-toolbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    border-top: none;
    padding: 0.5rem;
}

.EasyMDEContainer .editor-toolbar button {
    color: var(--text-secondary) !important;
    border: none !important;
    background: transparent !important;
}

.EasyMDEContainer .editor-toolbar button:hover,
.EasyMDEContainer .editor-toolbar button.active {
    background: var(--gray-100) !important;
    border: none !important;
    color: var(--primary) !important;
}

.EasyMDEContainer .editor-toolbar i.separator {
    border-left: 1px solid var(--border);
    border-right: none;
}

.EasyMDEContainer .editor-statusbar {
    color: var(--text-tertiary);
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 0.5rem;
    font-size: 11px;
}

.CodeMirror-cursor {
    border-left-color: var(--primary);
}

/* Preview pane */
.preview-pane {
    padding: 1.5rem;
    background: var(--bg);
    min-height: 600px;
    max-height: 600px;
    overflow-y: auto;
}

.preview-content {
    max-width: 720px;
    margin: 0 auto;
    font-family: var(--font-sans);
    line-height: 1.7;
    color: var(--text);
}

.preview-content h1,
.preview-content h2,
.preview-content h3,
.preview-content h4,
.preview-content h5,
.preview-content h6 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
    line-height: 1.3;
}

.preview-content p {
    margin-bottom: 1rem;
}

.preview-content a {
    color: var(--primary);
    text-decoration: none;
}

.preview-content a:hover {
    text-decoration: underline;
}

.preview-content code {
    background: var(--gray-100);
    padding: 0.125rem 0.25rem;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 0.9em;
}

.preview-content pre {
    background: var(--gray-100);
    padding: 1rem;
    border-radius: var(--radius-md);
    overflow-x: auto;
}

.preview-content blockquote {
    border-left: 3px solid var(--primary);
    padding-left: 1rem;
    margin-left: 0;
    color: var(--text-secondary);
}

/* Generate bar */
.generate-bar {
    position: sticky;
    bottom: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem;
}

/* Scripture dialog */
.scripture-preview {
    padding: 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin: 1rem 0;
    text-align: center;
}

.scripture-preview code {
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--primary);
    background: none;
    padding: 0;
}

/* Cover preview */
.cover-row {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.cover-preview {
    width: 80px;
    height: 100px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
}

.cover-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: var(--gray-100);
    color: var(--text-tertiary);
}

.cover-placeholder svg {
    width: 32px;
    height: 32px;
}

#coverImg {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cover-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Responsive */
@media (max-width: 1024px) {
    .editor-layout {
        grid-template-columns: 280px 1fr;
    }
}

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

    .editor-sidebar {
        position: static;
        max-height: none;
    }

    .brand-subtitle {
        display: none;
    }

    .editor-toolbar {
        flex-wrap: wrap;
    }

    .chapter-title-input {
        width: 100%;
        flex-basis: 100%;
    }

    .EasyMDEContainer .CodeMirror {
        height: 400px;
    }

    .preview-pane {
        min-height: 400px;
        max-height: 400px;
    }
}

/* Dark mode overrides */
[data-theme="dark"] .chapter-tab:hover {
    background: var(--gray-800);
}

[data-theme="dark"] .EasyMDEContainer .editor-toolbar button:hover,
[data-theme="dark"] .EasyMDEContainer .editor-toolbar button.active {
    background: var(--gray-800) !important;
}

[data-theme="dark"] .preview-content code {
    background: var(--gray-800);
}

[data-theme="dark"] .preview-content pre {
    background: var(--gray-800);
}

[data-theme="dark"] .cover-placeholder {
    background: var(--gray-800);
}

/* Button icon */
.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--gray-100);
    color: var(--primary);
}

.btn-icon svg {
    width: 18px;
    height: 18px;
}

[data-theme="dark"] .btn-icon:hover {
    background: var(--gray-800);
}
