/* ========================================
   Blog Post Editor Styles
   ======================================== */

/* Login Gate */
.login-overlay {
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: var(--bg-color);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.login-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 3rem 2.5rem;
    max-width: 400px;
    width: 100%;
    text-align: center;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.login-logo {
    font-size: 2rem;
    font-weight: 700;
    font-style: italic;
    color: var(--secondary-color);
    margin-bottom: 0.5rem;
    letter-spacing: 1px;
}

.login-card h2 {
    font-size: 1.4rem;
    color: var(--text-color);
    margin-bottom: 0.4rem;
}

.login-card p {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 1.75rem;
}

.login-field {
    text-align: left;
    margin-bottom: 1rem;
}

.login-field label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.4rem;
}

.login-field input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-color);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.login-field input:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.15);
}

.login-error {
    background: rgba(231, 76, 60, 0.1);
    color: #e74c3c;
    border: 1px solid rgba(231, 76, 60, 0.3);
    border-radius: 6px;
    padding: 0.6rem;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.login-btn {
    width: 100%;
    padding: 0.8rem;
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.login-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.btn-logout {
    background: transparent;
    color: var(--text-light);
    border: 1px solid var(--border-color);
    font-size: 0.8rem;
    margin-top: 0.5rem;
}

.btn-logout:hover {
    border-color: #e74c3c;
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.05);
}

.editor-container {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 0;
    min-height: calc(100vh - var(--nav-height));
    max-width: 100%;
}

/* Sidebar */
.editor-sidebar {
    background: var(--card-bg);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
    max-height: calc(100vh - var(--nav-height));
    position: sticky;
    top: var(--nav-height);
}

.sidebar-section h3 {
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.editor-field {
    margin-bottom: 1rem;
}

.editor-field label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.35rem;
}

.editor-field input,
.editor-field select,
.editor-field textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-color);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.editor-field input:focus,
.editor-field select:focus,
.editor-field textarea:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 2px rgba(74, 158, 255, 0.15);
}

.editor-field small {
    display: block;
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 0.25rem;
}

/* Drafts */
.drafts-list {
    max-height: 200px;
    overflow-y: auto;
}

.no-drafts {
    color: var(--text-light);
    font-size: 0.85rem;
    font-style: italic;
}

.draft-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.75rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.draft-item:hover {
    border-color: var(--secondary-color);
    background: rgba(74, 158, 255, 0.05);
}

.draft-info {
    flex: 1;
    min-width: 0;
}

.draft-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.draft-date {
    font-size: 0.7rem;
    color: var(--text-light);
}

.draft-delete {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    font-size: 1rem;
    padding: 0.25rem;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
    flex-shrink: 0;
}

.draft-delete:hover {
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.1);
}

/* Sidebar Buttons */
.sidebar-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: auto;
}

.sidebar-actions .editor-btn {
    width: 100%;
}

.editor-btn {
    padding: 0.7rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    font-family: inherit;
    text-decoration: none;
    display: inline-block;
}

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

.btn-primary:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    border-color: var(--secondary-color);
    background: rgba(74, 158, 255, 0.05);
}

.btn-accent {
    background: #27ae60;
    color: white;
}

.btn-accent:hover {
    background: #2ecc71;
    transform: translateY(-1px);
}

/* Main Editor */
.editor-main {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - var(--nav-height));
}

/* Toolbar */
.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    position: sticky;
    top: var(--nav-height);
    z-index: 50;
}

.toolbar-group {
    display: flex;
    gap: 0.25rem;
    padding-right: 0.75rem;
    border-right: 1px solid var(--border-color);
}

.toolbar-group:last-child {
    border-right: none;
}

.toolbar-right {
    margin-left: auto;
}

.toolbar-btn {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 0.4rem 0.65rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
    transition: all 0.15s;
    white-space: nowrap;
}

.toolbar-btn:hover {
    border-color: var(--secondary-color);
    background: rgba(74, 158, 255, 0.08);
}

.toolbar-btn.active {
    background: var(--secondary-color);
    color: white;
    border-color: var(--secondary-color);
}

/* Editor Split */
.editor-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    flex: 1;
    min-height: 0;
}

.editor-split.preview-only .editor-pane {
    display: none;
}

.editor-split.preview-only .preview-pane {
    grid-column: 1 / -1;
}

.editor-split.editor-only .preview-pane {
    display: none;
}

.editor-split.editor-only .editor-pane {
    grid-column: 1 / -1;
}

.editor-pane {
    display: flex;
    border-right: 1px solid var(--border-color);
}

#editor-content {
    width: 100%;
    height: 100%;
    min-height: 500px;
    padding: 1.5rem;
    background: var(--bg-color);
    color: var(--text-color);
    border: none;
    outline: none;
    font-family: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', 'Consolas', monospace;
    font-size: 0.95rem;
    line-height: 1.7;
    resize: none;
    tab-size: 4;
}

/* Preview Pane */
.preview-pane {
    overflow-y: auto;
    background: var(--bg-color);
}

.preview-content {
    padding: 1.5rem 2rem;
    max-width: 800px;
    margin: 0 auto;
}

.preview-placeholder {
    color: var(--text-light);
    font-style: italic;
    text-align: center;
    padding-top: 3rem;
}

/* Preview Rendered Styles */
.preview-content h1 {
    font-size: 2.2rem;
    margin-bottom: 0.75rem;
    color: var(--text-color);
}

.preview-content h2 {
    font-size: 1.6rem;
    margin: 2rem 0 0.75rem;
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.4rem;
}

.preview-content h3 {
    font-size: 1.3rem;
    margin: 1.5rem 0 0.5rem;
    color: var(--text-color);
}

.preview-content p {
    margin-bottom: 1rem;
    line-height: 1.8;
    color: var(--text-color);
}

.preview-content a {
    color: var(--secondary-color);
    text-decoration: none;
    border-bottom: 1px solid var(--secondary-color);
}

.preview-content a:hover {
    color: var(--accent-color);
}

.preview-content img {
    max-width: 100%;
    border-radius: 8px;
    margin: 1.5rem 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.preview-content blockquote {
    border-left: 4px solid var(--secondary-color);
    padding: 0.75rem 1.25rem;
    margin: 1.5rem 0;
    background: rgba(74, 158, 255, 0.05);
    border-radius: 0 6px 6px 0;
    color: var(--text-light);
    font-style: italic;
}

.preview-content ul, .preview-content ol {
    margin: 1rem 0 1rem 2rem;
}

.preview-content li {
    margin-bottom: 0.4rem;
    line-height: 1.7;
}

.preview-content code {
    background: rgba(0,0,0,0.1);
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-family: 'Cascadia Code', 'Fira Code', monospace;
    font-size: 0.9em;
}

.preview-content pre {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    overflow-x: auto;
    margin: 1.5rem 0;
}

.preview-content pre code {
    background: none;
    padding: 0;
}

/* Export Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 2rem;
    max-width: 800px;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.modal-header h3 {
    font-size: 1.3rem;
    color: var(--text-color);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-light);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: rgba(231, 76, 60, 0.1);
    color: #e74c3c;
}

.modal-hint {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 1rem;
}

.modal-hint code {
    background: var(--bg-color);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
    color: var(--secondary-color);
}

.export-textarea {
    flex: 1;
    min-height: 300px;
    padding: 1rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-color);
    font-family: 'Cascadia Code', 'Fira Code', monospace;
    font-size: 0.8rem;
    line-height: 1.5;
    resize: none;
    margin-bottom: 1rem;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--card-bg);
    color: var(--text-color);
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    border-left: 4px solid var(--secondary-color);
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 10000;
    animation: slideInToast 0.3s ease;
}

.toast.toast-success {
    border-left-color: #27ae60;
}

.toast.toast-error {
    border-left-color: #e74c3c;
}

@keyframes slideInToast {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}

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

    .editor-sidebar {
        position: static;
        max-height: none;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
}

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

    .editor-pane {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    #editor-content {
        min-height: 300px;
    }
}
