/**
 * RA0 Editor Styles
 */

.ra0-editor-wrapper {
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

/* 툴바 */
.ra0-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
    background: #f8f9fa;
    border-bottom: 1px solid #ddd;
}

.toolbar-group {
    display: flex;
    gap: 4px;
    align-items: center;
    padding-right: 6px;
    border-right: 1px solid #ddd;
}

.toolbar-group:last-child {
    border-right: none;
}

.toolbar-btn {
    min-width: 32px;
    height: 32px;
    padding: 4px 8px;
    border: 1px solid #ccc;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.toolbar-btn:hover {
    background: #e9ecef;
    border-color: #999;
}

.toolbar-btn:active {
    background: #dee2e6;
    transform: translateY(1px);
}

/* 폰트 선택 버튼 (넓게) */
.toolbar-btn-wide {
    min-width: 80px;
    padding: 4px 12px;
    gap: 6px;
}

.toolbar-btn-wide .btn-text {
    font-size: 13px;
    font-weight: 500;
}

.toolbar-btn-wide .fa-caret-down {
    font-size: 12px;
    margin-left: auto;
}

/* 색상 피커 */
.color-picker-wrapper {
    position: relative;
}

.color-palette {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: auto;
    margin-top: 4px;
    padding: 8px;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 1000;
    grid-template-columns: repeat(4, 24px);
    gap: 4px;
}

.color-palette.show {
    display: grid;
}

.color-palette span {
    width: 24px;
    height: 24px;
    border-radius: 3px;
    cursor: pointer;
    transition: transform 0.2s;
}

.color-palette span:hover {
    transform: scale(1.2);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* 뷰어 영역 */
.ra0-editor-viewer {
    padding: 20px;
    min-height: 300px;
    max-height: 600px;
    overflow-y: auto;
    outline: none;
}

.ra0-editor-viewer:focus {
    background: #fafbfc;
}

.ra0-editor-viewer:empty:before {
    content: '여기에 내용을 입력하세요...';
    color: #999;
}

/* 에디터 스크롤바 스타일 */
.ra0-editor-viewer::-webkit-scrollbar {
    width: 12px;
}

.ra0-editor-viewer::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.ra0-editor-viewer::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

.ra0-editor-viewer::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Firefox 스크롤바 */
.ra0-editor-viewer {
    scrollbar-width: thin;
    scrollbar-color: #888 #f1f1f1;
}

/* 이미지 플레이스홀더 배지 */
.image-placeholder {
    display: inline-block;
    padding: 2px 8px;
    margin: 0 2px;
    background: #e3f2fd;
    color: #1976d2;
    border: 1px solid #90caf9;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 12px;
    font-weight: 500;
    cursor: help;
    transition: all 0.2s;
    user-select: none;
}

.image-placeholder:hover {
    background: #bbdefb;
    border-color: #64b5f6;
    transform: scale(1.05);
}

/* 이미지 플레이스홀더 툴팁 */
.image-placeholder-tooltip {
    position: fixed;
    z-index: 10000;
    background: white;
    border: 2px solid #1976d2;
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    max-width: 400px;
}

.image-placeholder-tooltip img {
    display: block;
    max-width: 100%;
    max-height: 300px;
    height: auto;
    border-radius: 4px;
}

/* 이미지 크기 설정 모달 */
.image-size-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-size-modal .modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

.image-size-modal .modal-content {
    position: relative;
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.2s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.image-size-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.image-size-modal .modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.image-size-modal .btn-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #999;
    cursor: pointer;
    padding: 4px 8px;
    transition: color 0.2s;
}

.image-size-modal .btn-close:hover {
    color: #333;
}

.image-size-modal .modal-body {
    padding: 20px;
}

.image-size-modal .modal-body p {
    margin: 0 0 15px 0;
    color: #666;
    font-size: 14px;
}

.image-size-modal .form-group {
    margin-bottom: 15px;
}

.image-size-modal .form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.image-size-modal .form-control {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    transition: border-color 0.2s;
}

.image-size-modal .form-control:focus {
    outline: none;
    border-color: #1976d2;
}

.image-size-modal .size-presets {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.image-size-modal .btn-preset {
    padding: 8px 16px;
    font-size: 13px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.image-size-modal .btn-preset:hover {
    background: #f5f5f5;
    border-color: #1976d2;
}

.image-size-modal .modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 15px 20px;
    border-top: 1px solid #e0e0e0;
}

.image-size-modal .btn-secondary,
.image-size-modal .btn-primary {
    padding: 10px 20px;
    font-size: 14px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.image-size-modal .btn-secondary {
    background: #f5f5f5;
    color: #666;
}

.image-size-modal .btn-secondary:hover {
    background: #e0e0e0;
}

.image-size-modal .btn-primary {
    background: #1976d2;
    color: white;
}

.image-size-modal .btn-primary:hover {
    background: #1565c0;
}

/* HTML 소스 */
.ra0-editor-source {
    width: 100%;
    padding: 20px;
    border: none;
    outline: none;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
    resize: vertical;
}

/* 도움말 */
.ra0-editor-help {
    padding: 8px 12px;
    background: #f8f9fa;
    border-top: 1px solid #ddd;
    font-size: 12px;
    color: #666;
}

/* 드롭다운 메뉴 */
.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: auto;
    margin-top: 4px;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 1000;
    min-width: 150px;
}

.dropdown-menu.show {
    display: flex;
    flex-direction: column;
}

.dropdown-item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    text-align: center;
    padding: 10px 12px;
    background: #fff;
    border: none;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background: #f0f0f0;
}

/* 폰트 메뉴 */
.font-menu {
    max-height: 300px;
    overflow-y: auto;
}

.font-preview {
    font-size: 14px;
    color: #333;
    padding: 4px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.font-item:hover .font-preview {
    font-weight: 600;
}

/* 인용 미리보기 */
.quote-preview {
    font-size: 32px;
    color: #333;
    padding: 8px 0;
    font-family: Georgia, Times, serif;
    line-height: 1;
}

.quote-type1-preview {
    font-size: 48px;
}

.quote-type2-preview {
    font-size: 28px;
}

.quote-type3-preview {
    font-size: 28px;
}

.quote-block-preview {
    font-size: 13px;
    color: #666;
    font-style: italic;
    font-family: inherit;
}

/* 구분선 미리보기 */
.hr-preview {
    height: 2px;
    width: 100%;
    flex-shrink: 0;
}

.hr-full-preview {
    background: #dee2e6;
}

.hr-short-preview {
    width: 40%;
    margin: 0 auto;
    background: #dee2e6;
}

.hr-dot-full-preview {
    border-top: 2px dotted #999;
    background: transparent;
}

.hr-dot-short-preview {
    width: 40%;
    margin: 0 auto;
    border-top: 2px dotted #999;
    background: transparent;
}

/* 이미지 태그 플레이스홀더 */
.image-tag {
    display: inline-block;
    padding: 0.375rem 0.75rem;
    background: color-mix(in srgb, var(--info-color) 10%, transparent);
    color: var(--info-color);
    border: 1px dashed var(--info-color);
    border-radius: 0.25rem;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.875rem;
    margin: 0.25rem;
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    cursor: text;
}

/* 인라인 코드 블록 */
.ra0-editor-viewer code {
    display: inline;
    padding: 2px 6px;
    margin: 0 2px;
    background: #f5f5f5;
    color: #d63384;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    white-space: pre-wrap;
    word-break: break-word;
}

/* 코드 블록 (pre > code) */
.ra0-editor-viewer pre {
    margin: 1em 0;
    overflow: auto;
    border-radius: 6px;
}

.ra0-editor-viewer pre code {
    display: block;
    margin: 0;
    background: #2d2d2d;
    color: #ccc;
    border: none;
    border-radius: 0;
    font-size: 0.9em;
    line-height: 1.5;
    white-space: pre;
    word-break: normal;
    overflow-x: auto;
}

/* 리스트 스타일 (레벨별 다른 마커) */
#wr_content_viewer ul {
    list-style-type: disc;
    padding-left: 30px;
    margin: 3px 0;
}

#wr_content_viewer ol {
    list-style-type: decimal;
    padding-left: 30px;
    margin: 3px 0;
}

#wr_content_viewer li {
}

/* 중첩 리스트 마커 스타일 */
#wr_content_viewer ul ul {
    list-style-type: circle;
}

#wr_content_viewer ul ul ul {
    list-style-type: square;
}

#wr_content_viewer ul ul ul ul {
    list-style-type: disc;
}

/* 번호 매기기 중첩 스타일 */
#wr_content_viewer ol ol {
    list-style-type: lower-alpha;
}

#wr_content_viewer ol ol ol {
    list-style-type: lower-roman;
}

/* 코드 블록 모달 */
.code-block-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
}

.code-block-modal .modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

.code-block-modal .modal-content {
    position: relative;
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.2s ease-out;
    display: flex;
    flex-direction: column;
}

.code-block-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.code-block-modal .modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.code-block-modal .btn-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    line-height: 1;
    transition: color 0.2s;
}

.code-block-modal .btn-close:hover {
    color: #333;
}

.code-block-modal .modal-body {
    padding: 20px;
    overflow-y: auto;
}

.code-block-modal .form-group {
    margin-bottom: 20px;
}

.code-block-modal .form-group:last-child {
    margin-bottom: 0;
}

.code-block-modal .form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.code-block-modal .form-control {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    transition: border-color 0.2s;
    font-family: inherit;
}

.code-block-modal .form-control:focus {
    outline: none;
    border-color: #1976d2;
}

.code-block-modal textarea.form-control {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    resize: vertical;
    min-height: 200px;
}

.code-block-modal .modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-top: 1px solid #e0e0e0;
}

.code-block-modal .btn-secondary,
.code-block-modal .btn-primary {
    padding: 10px 20px;
    font-size: 14px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.code-block-modal .btn-secondary {
    background: #f5f5f5;
    color: #666;
}

.code-block-modal .btn-secondary:hover {
    background: #e0e0e0;
}

.code-block-modal .btn-primary {
    background: #1976d2;
    color: white;
}

.code-block-modal .btn-primary:hover {
    background: #1565c0;
}

.code-block-modal .keyboard-hint {
    font-size: 12px;
    color: #999;
    margin-right: auto;
}

.code-block-modal .modal-buttons {
    display: flex;
    gap: 10px;
}

/* 반응형 */
@media (max-width: 768px) {
    .ra0-editor-toolbar {
        gap: 4px;
        padding: 8px;
    }

    .toolbar-group {
        gap: 2px;
        padding-right: 4px;
    }

    .toolbar-btn {
        min-width: 28px;
        height: 28px;
        padding: 2px 6px;
        font-size: 13px;
    }

    .ra0-editor-viewer {
        padding: 15px;
        font-size: 14px;
    }

    .code-block-modal .modal-content {
        width: 95%;
        max-height: 90vh;
    }
}