/* ========== Write Page ========== */
body {
    overflow: hidden;
}

/* Header */
.write-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
}

.back-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 20px;
    transition: var(--transition);
}

.back-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.title-input {
    flex: 1;
    max-width: 600px;
    font-size: 20px;
    font-weight: 600;
    background: transparent;
    color: var(--text-primary);
}

.title-input::placeholder {
    color: var(--text-muted);
}

.header-right {
    display: flex;
    gap: 12px;
}

/* Main Editor */
.write-main {
    padding-top: 60px;
    height: 100vh;
}

.editor-container {
    height: calc(100vh - 60px);
    display: flex;
    flex-direction: column;
}

/* Toolbar */
.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 24px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
}

.editor-toolbar button {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 18px;
    transition: var(--transition);
}

.editor-toolbar button:hover {
    background: var(--bg-tertiary);
    color: var(--primary);
}

.editor-toolbar .divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 8px;
}

/* Editor Wrapper */
.editor-wrapper {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.editor-wrapper textarea {
    flex: 1;
    padding: 32px;
    font-size: 16px;
    line-height: 1.8;
    resize: none;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: 'Fira Code', monospace;
}

.editor-wrapper textarea::placeholder {
    color: var(--text-muted);
}

.editor-wrapper .preview {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
    background: var(--bg-primary);
    border-left: 1px solid var(--border-color);
    display: none;
}

.editor-wrapper.show-preview .preview {
    display: block;
}

.editor-wrapper.show-preview textarea {
    flex: 0 0 50%;
}

/* Status Bar */
.editor-status {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 12px 24px;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    font-size: 13px;
    color: var(--text-muted);
}

.preview-toggle {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    transition: var(--transition);
}

.preview-toggle:hover {
    background: var(--bg-tertiary);
    color: var(--primary);
}

.preview-toggle.active {
    background: var(--primary);
    color: white;
}

/* Publish Panel */
.publish-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: var(--bg-primary);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
}

.publish-panel.open {
    right: 0;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.panel-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.close-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 20px;
}

.close-btn:hover {
    background: var(--bg-tertiary);
}

.panel-content {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

.panel-content .form-group {
    margin-bottom: 24px;
}

.panel-content label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.panel-content select,
.panel-content textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 14px;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: var(--transition);
}

.panel-content select:focus,
.panel-content textarea:focus {
    border-color: var(--primary);
    outline: none;
}

.panel-content textarea {
    resize: none;
}

/* Cover Upload */
.cover-upload {
    width: 100%;
    aspect-ratio: 16/9;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    transition: var(--transition);
    position: relative;
}

.cover-upload:hover {
    border-color: var(--primary);
}

.cover-upload img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
}

.upload-placeholder i {
    font-size: 32px;
}

/* Tags Input */
.tags-input {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    min-height: 44px;
}

.tags-input:focus-within {
    border-color: var(--primary);
}

.selected-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.selected-tags .tag {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--primary);
    color: white;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 13px;
}

.selected-tags .tag button {
    color: white;
    opacity: 0.8;
}

.selected-tags .tag button:hover {
    opacity: 1;
}

.tags-input input {
    flex: 1;
    min-width: 100px;
    border: none;
    background: transparent;
    font-size: 14px;
    color: var(--text-primary);
}

.tag-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.tag-suggestions .tag {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
}

.tag-suggestions .tag:hover {
    background: var(--primary-light);
    color: white;
}

/* Panel Footer */
.panel-footer {
    display: flex;
    gap: 12px;
    padding: 20px 24px;
    border-top: 1px solid var(--border-color);
}

.panel-footer .btn {
    flex: 1;
}

/* Overlay */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 150;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.overlay.show {
    opacity: 1;
    visibility: visible;
}

/* Responsive */
@media (max-width: 768px) {
    .publish-panel {
        width: 100%;
        right: -100%;
    }
    
    .editor-wrapper.show-preview textarea {
        display: none;
    }
    
    .editor-wrapper.show-preview .preview {
        flex: 1;
        border-left: none;
    }
}
