/* editor.css - 에디터 스타일시트 */

/* 기본 리셋 및 변수 */
:root {
    --primary-color: #2196f3;
    --secondary-color: #667eea;
    --danger-color: #f44336;
    --success-color: #4CAF50;
    --warning-color: #ff9800;
    --border-color: #dee2e6;
    --bg-light: #f8f9fa;
    --text-dark: #333;
    --shadow: 0 2px 5px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text-dark);
    background: #f5f5f5;
    line-height: 1.6;
}

/* 에디터 컨테이너 */
.editor-container {
    max-width: 1200px;
    margin: 20px auto;
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

/* 툴바 스타일 */
.editor-toolbar {
    background: var(--bg-light);
    border-bottom: 1px solid var(--border-color);
    padding: 8px 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    align-items: center;
}

.toolbar-separator {
    width: 1px;
    height: 24px;
    background: #ddd;
    margin: 0 8px;
}

.toolbar-btn {
    background: white;
    border: 1px solid #ddd;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-dark);
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
}

.toolbar-btn:hover {
    background: #e3f2fd;
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.toolbar-btn:active {
    transform: translateY(0);
    background: #bbdefb;
}

.toolbar-select {
    background: white;
    border: 1px solid #ddd;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    height: 32px;
}

.toolbar-select:hover {
    border-color: var(--primary-color);
}

/* 글자 수 표시 */
.word-count {
    color: #666;
    font-size: 12px;
    padding: 0 10px;
    font-weight: 500;
}

/* 에디터 본문 */
.editor-body {
    min-height: 500px;
    position: relative;
}

.editor-content {
    min-height: 500px;
    padding: 20px;
    font-size: 16px;
    line-height: 1.8;
    outline: none;
    border: none;
}

.editor-content:empty:before {
    content: attr(placeholder);
    color: #999;
    font-style: italic;
}

.editor-content:focus {
    outline: none;
}

/* 에디터 내 요소 스타일 */
.editor-content h1, 
.editor-content h2, 
.editor-content h3, 
.editor-content h4, 
.editor-content h5, 
.editor-content h6 {
    margin: 20px 0 10px;
    line-height: 1.4;
}

.editor-content h1 { font-size: 2em; }
.editor-content h2 { font-size: 1.75em; }
.editor-content h3 { font-size: 1.5em; }
.editor-content h4 { font-size: 1.25em; }
.editor-content h5 { font-size: 1.1em; }
.editor-content h6 { font-size: 1em; }

.editor-content p {
    margin: 10px 0;
}

.editor-content blockquote {
    border-left: 4px solid #ccc;
    padding-left: 16px;
    margin: 16px 0;
    color: #666;
    font-style: italic;
}

.editor-content pre {
    background: #f4f4f4;
    padding: 16px;
    border-radius: 4px;
    overflow-x: auto;
    margin: 16px 0;
}

.editor-content code {
    background: #f4f4f4;
    padding: 2px 4px;
    border-radius: 2px;
    font-family: 'Courier New', Courier, monospace;
}

.editor-content ul, 
.editor-content ol {
    margin: 10px 0;
    padding-left: 30px;
}

.editor-content li {
    margin: 5px 0;
}

.editor-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
}

.editor-content th, 
.editor-content td {
    border: 1px solid #dee2e6;
    padding: 12px;
    text-align: left;
}

.editor-content th {
    background: #f8f9fa;
    font-weight: 600;
}

.editor-content img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 20px auto;
    cursor: pointer;
}

.editor-content img.selected-media {
    border: 2px solid var(--primary-color);
}

.editor-content .youtube-embed {
    display: block;
    max-width: 100%;
    margin: 20px auto;
    cursor: pointer;
}

.editor-content .youtube-embed.selected-media {
    border: 2px solid var(--primary-color);
}

.editor-content hr {
    border: none;
    border-top: 1px solid #dee2e6;
    margin: 20px 0;
}

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

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

/* 상태바 */
.editor-statusbar {
    background: var(--bg-light);
    border-top: 1px solid var(--border-color);
    padding: 10px 20px;
    font-size: 13px;
    color: #666;
    display: flex;
    justify-content: space-between;
}

/* 모달 스타일 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.modal-content {
    background: white;
    border-radius: 8px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow: auto;
    box-shadow: var(--shadow-lg);
}

.modal-small {
    max-width: 500px;
}

.modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 8px 8px 0 0;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

.modal-header .close {
    color: white;
    font-size: 28px;
    cursor: pointer;
    background: none;
    border: none;
    line-height: 1;
}

.modal-header .close:hover {
    opacity: 0.8;
}

.modal-body {
    padding: 20px;
}

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

/* 폼 요소 */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--text-dark);
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
}

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

/* 버튼 스타일 */
.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: transform 0.2s;
}

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

.btn-secondary {
    background: white;
    color: var(--text-dark);
    border: 1px solid var(--border-color);
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

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

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    font-size: 20px;
}

/* 토스트 메시지 */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 4px;
    box-shadow: var(--shadow-lg);
    z-index: 10000;
    animation: slideIn 0.3s ease;
}

.toast-success {
    background: var(--success-color);
    color: white;
}

.toast-error {
    background: var(--danger-color);
    color: white;
}

.toast-warning {
    background: var(--warning-color);
    color: white;
}

.toast-info {
    background: var(--primary-color);
    color: white;
}

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

/* 전체화면 모드 */
.editor-container.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    max-width: none;
    margin: 0;
    border-radius: 0;
    z-index: 9998;
}

/* 반응형 디자인 */
@media (max-width: 768px) {
    .editor-container {
        margin: 0;
        border-radius: 0;
    }
    
    .toolbar-group {
        padding: 0 5px;
    }
    
    .toolbar-btn {
        padding: 6px 8px;
        font-size: 12px;
    }
    
    .editor-content {
        padding: 15px;
        font-size: 14px;
    }
    
    .modal-content {
        width: 95%;
        margin: 10px;
    }
}

/* 표 선택 스타일 */
.table-selected {
    outline: 2px solid var(--primary-color);
}

.cell-selected {
    background: rgba(33, 150, 243, 0.1) !important;
}

/* 정보/경고 박스 스타일 */
.info-box {
    background: #e3f2fd;
    border-left: 4px solid #2196f3;
    padding: 16px;
    margin: 16px 0;
    border-radius: 4px;
}

.warning-box {
    background: #fff3e0;
    border-left: 4px solid #ff9800;
    padding: 16px;
    margin: 16px 0;
    border-radius: 4px;
}

/* 로딩 오버레이 */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0,0,0,0.1);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* 에디터 내 형광펜 효과 */
.editor-content mark,
.editor-content .highlight {
    background-color: #ffeb3b;
    padding: 0 2px;
    border-radius: 2px;
}

/* 체크리스트 스타일 */
.editor-content ul.check-list {
    list-style: none;
    padding-left: 0;
}

.editor-content ul.check-list li {
    position: relative;
    padding-left: 24px;
    margin-bottom: 8px;
}

.editor-content ul.check-list li::before {
    content: '\2610';
    position: absolute;
    left: 0;
    top: 0;
    font-size: 18px;
}

.editor-content ul.check-list li.checked::before {
    content: '\2611';
    color: var(--primary-color);
}

/* 글자 색상 버튼 추가 스타일 */
.color-button {
    position: relative;
    padding: 0 !important;
    width: 32px;
    height: 32px;
    overflow: hidden;
}

.color-button .gradient-bar {
    position: absolute;
    top: 3px;
    left: 3px;
    right: 3px;
    height: 16px;
    background: linear-gradient(to right, #ff0000, #ff9800, #ffeb3b, #4caf50, #2196f3, #9c27b0);
    border-radius: 2px;
}

.color-button .color-indicator {
    position: absolute;
    bottom: 3px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 4px;
    background: #000;
    border-radius: 2px;
}

/* placeholder 스타일 */
.editor-content[data-placeholder]:empty:before {
    content: attr(data-placeholder);
    color: #999;
    font-style: italic;
    pointer-events: none;
    position: absolute;
}

/* 에디터 내부 이미지 스타일 */
#articleContent img {
    cursor: pointer !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    -webkit-user-drag: none !important;
    user-drag: none !important;
}

#articleContent img:hover {
    opacity: 0.9;
}

#articleContent img.selected-media {
    outline: 3px solid #667eea !important;
    outline-offset: 2px !important;
}
