/**
 * CKEditor 5 커스텀 스타일
 */

/* 에디터 컨테이너 */
.ck-editor__editable {
    min-height: 400px;
    max-height: 600px;
    overflow-y: auto;
}

.ck-editor__editable:focus {
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2) !important;
}

/* 툴바 스타일 */
.ck.ck-toolbar {
    border-color: #e5e7eb !important;
    background: #f9fafb !important;
    border-radius: 8px 8px 0 0 !important;
}

.ck.ck-toolbar .ck-toolbar__items {
    flex-wrap: wrap;
}

/* 에디터 본문 스타일 */
.ck-content {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 16px;
    line-height: 1.8;
    color: #1f2937;
}

.ck-content p {
    margin-bottom: 1em;
}

.ck-content h2 {
    font-size: 1.5em;
    font-weight: 700;
    margin: 1.5em 0 0.5em;
    color: #111827;
}

.ck-content h3 {
    font-size: 1.25em;
    font-weight: 600;
    margin: 1.25em 0 0.5em;
    color: #1f2937;
}

.ck-content h4 {
    font-size: 1.1em;
    font-weight: 600;
    margin: 1em 0 0.5em;
    color: #374151;
}

.ck-content ul,
.ck-content ol {
    margin: 1em 0;
    padding-left: 2em;
}

.ck-content li {
    margin-bottom: 0.5em;
}

.ck-content blockquote {
    border-left: 4px solid #3b82f6;
    padding-left: 1em;
    margin: 1em 0;
    color: #6b7280;
    font-style: italic;
}

.ck-content code {
    background: #f3f4f6;
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-family: 'Fira Code', monospace;
    font-size: 0.9em;
}

.ck-content pre {
    background: #1f2937;
    color: #f9fafb;
    padding: 1em;
    border-radius: 8px;
    overflow-x: auto;
}

.ck-content pre code {
    background: transparent;
    padding: 0;
    color: inherit;
}

.ck-content a {
    color: #3b82f6;
    text-decoration: underline;
}

.ck-content a:hover {
    color: #2563eb;
}

.ck-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

.ck-content figure {
    margin: 1.5em 0;
}

.ck-content figure.image {
    text-align: center;
}

.ck-content figcaption {
    font-size: 0.875em;
    color: #6b7280;
    margin-top: 0.5em;
}

.ck-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
}

.ck-content table th,
.ck-content table td {
    border: 1px solid #e5e7eb;
    padding: 0.75em;
}

.ck-content table th {
    background: #f9fafb;
    font-weight: 600;
}

/* 다크 모드 지원 */
.dark .ck-content {
    color: #f3f4f6;
}

.dark .ck-content h2,
.dark .ck-content h3,
.dark .ck-content h4 {
    color: #f9fafb;
}

.dark .ck-content code {
    background: #374151;
}

.dark .ck-content table th {
    background: #374151;
}

.dark .ck-content table th,
.dark .ck-content table td {
    border-color: #4b5563;
}

.dark .ck.ck-toolbar {
    background: #1f2937 !important;
    border-color: #374151 !important;
}

.dark .ck.ck-editor__main > .ck-editor__editable {
    background: #111827;
    border-color: #374151 !important;
}

/* 뷰어 스타일 (게시글 본문) */
.post-content {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 16px;
    line-height: 1.8;
    color: #1f2937;
}

.post-content p {
    margin-bottom: 1em;
}

.post-content h2 {
    font-size: 1.5em;
    font-weight: 700;
    margin: 1.5em 0 0.5em;
    padding-bottom: 0.3em;
    border-bottom: 1px solid #e5e7eb;
}

.post-content h3 {
    font-size: 1.25em;
    font-weight: 600;
    margin: 1.25em 0 0.5em;
}

.post-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1em 0;
}

.post-content iframe {
    max-width: 100%;
    border-radius: 8px;
}

/* 이미지 업로드 상태 */
.ck-editor__editable .image-inline.ck-widget_uploading,
.ck-editor__editable .image.ck-widget_uploading {
    opacity: 0.6;
}

.ck-editor__editable .ck-progress-bar {
    background: #3b82f6 !important;
    height: 4px;
}

/* 드래그 앤 드롭 오버레이 */
.ck-editor__editable.drag-over {
    border-color: #3b82f6 !important;
    background-color: rgba(59, 130, 246, 0.05) !important;
}

.ck-editor__editable.drag-over::before {
    content: '이미지를 여기에 놓으세요';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 1em 2em;
    background: rgba(59, 130, 246, 0.9);
    color: white;
    border-radius: 8px;
    font-weight: 500;
    z-index: 10;
}

/* 이미지 로딩 플레이스홀더 */
.ck-editor__editable figure.image.ck-widget_uploading::after {
    content: '업로드 중...';
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
}

/* 이미지 오류 상태 */
.ck-editor__editable .ck-upload-placeholder-loader {
    color: #3b82f6;
}

/* 에디터 내 이미지 스타일 */
.ck-content .image-style-side {
    float: right;
    max-width: 50%;
    margin-left: 1.5em;
    margin-bottom: 1em;
}

.ck-content .image-style-align-left {
    float: left;
    max-width: 50%;
    margin-right: 1.5em;
    margin-bottom: 1em;
}

.ck-content .image-style-align-center {
    margin-left: auto;
    margin-right: auto;
}

/* 반응형 */
@media (max-width: 640px) {
    .ck-content,
    .post-content {
        font-size: 15px;
    }
    
    .ck-editor__editable {
        min-height: 300px;
    }
    
    .ck-content .image-style-side,
    .ck-content .image-style-align-left {
        float: none;
        max-width: 100%;
        margin: 1em 0;
    }
}
