/* ========================================================================= */
/* 1. 공통 타이포그래피 설정 (Headings)                                      */
/* ========================================================================= */
#board h1 {
    display: block;
    font-size: 2em;
    font-weight: bold;
    margin: 0.67em 0;
    line-height: 1.2;
}

#board h2 {
    display: block;
    font-size: 1.5em;
    font-weight: bold;
    margin: 0.83em 0;
    line-height: 1.3;
    padding-bottom: 5px;
}

#board h3 {
    display: block;
    font-size: 1.17em;
    font-weight: bold;
    margin: 1em 0;
    line-height: 1.4;
}

#board h4 {
    display: block;
    font-size: 1em;
    font-weight: bold;
    margin: 1.33em 0;
}

/* ========================================================================= */
/* 2. 에디터 UI 및 툴바 스타일 (Editor Toolbar)                              */
/* ========================================================================= */
.editor-wrapper {
    width: 100%;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    font-size: 17px;
}

.toolbar {
    background-color: #f8f9fa;
    padding: 8px;
    border-bottom: 1px solid #ddd;
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 5px;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
    align-items: center;
    z-index: 10;
    position: relative;
}

.toolbar-extended {
    display: none;
    background-color: #f1f3f5;
    padding: 5px 8px;
    border-bottom: 1px solid #ddd;
    gap: 5px;
    align-items: center;
    animation: slideDown 0.2s ease-out;
}

.toolbar-extended.show {
    display: flex;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.toolbar::-webkit-scrollbar {
    height: 10px;
}

.toolbar::-webkit-scrollbar-track {
    background: #e0e0e0;
}

.toolbar::-webkit-scrollbar-thumb {
    background: var(--primary, #8a00fc);
    border-radius: 5px;
}

.toolbar button,
.toolbar-extended button {
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 4px;
    color: #555;
    font-size: 16px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toolbar button:hover:not(:disabled),
.toolbar-extended button:hover:not(:disabled) {
    background-color: #e2e6ea;
    color: #333;
}

.toolbar button.active,
.toolbar-extended button.active {
    color: #0098f7;
    background-color: #e5f5ff;
    border-color: #b3d7ff;
}

.toolbar button:disabled {
    color: #ccc;
    cursor: not-allowed;
}

.separator {
    width: 2px;
    height: 20px;
    background-color: #ccc;
    margin: 0 5px;
    flex-shrink: 0;
}

.color-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.font-size-select {
    padding: 4px 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #fff;
    font-size: 13px;
    color: #555;
    cursor: pointer;
    outline: none;
    height: 32px;
    min-width: 65px;
}

.font-size-select:hover {
    background-color: #e2e6ea;
}

.font-size-select:disabled {
    background-color: #f1f3f5;
    color: #ccc;
    cursor: not-allowed;
}

#foreColorInput {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* ========================================================================= */
/* 3. 에디터 본문 및 소스보기 스타일 (Editor Body & Source)                  */
/* ========================================================================= */
#editor,
#sourceEditor {
    height: 600px;
    padding: 20px;
    outline: none;
    line-height: 1.6;
    color: #333;
    overflow-y: auto;
    width: 100%;
    box-sizing: border-box;
}

/* 정렬 문제 해결을 위한 블록 스타일 */
#editor p,
#editor div {
    margin: 0;
    padding: 0;
    text-align: inherit;
}

#sourceEditor {
    display: none;
    background-color: #282c34;
    color: #abb2bf;
    font-family: 'Courier New', Courier, monospace;
    resize: vertical;
    border: none;
}

/* 이미지 정렬 문제 해결: display: inline-block으로 변경 */
#editor img {
    display: inline-block;
    max-width: 100%;
    height: auto;
    object-fit: contain;
    margin: 10px 0;
}

#editor blockquote {
    border-left: 4px solid #ccc;
    margin: 10px 0;
    padding: 10px 15px;
    color: #666;
    background: #f9f9f9;
}

#editor a {
    color: #0098f7;
    text-decoration: underline;
}

#editor:empty:before {
    content: '내용을 입력하세요...';
    color: #ccc;
    display: block;
}

/* ========================================================================= */
/* 4. 에디터 로딩 오버레이 (Loading Animation)                               */
/* ========================================================================= */
.editor-loader-overlay {
    position: absolute;
    top: 45px;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.7);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(2px);
}

@keyframes editor-spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.editor-loader-overlay i {
    font-size: 48px;
    color: #3b82f6;
    animation: editor-spin 1s linear infinite;
}

.editor-loader-overlay span {
    margin-top: 12px;
    font-weight: 600;
    color: #1e293b;
    font-size: 14px;
}

/* ========================================================================= */
/* 5. 게시판 테이블 및 미디어 객체 (Table & Media)                           */
/* ========================================================================= */
#board table {
    width: auto !important; /* 혹은 100% */
    border-collapse: collapse !important;
    border: 1px solid #ddd !important;
    margin: 10px 0 !important;
}

#board table th,
#board table td {
    border: 1px solid #ddd !important;
    padding: 8px 10px !important;
}

#board table th {
    background-color: #f8f9fa !important;
    font-weight: bold;
}

#board .content img {
    width: 100%;
    height: auto; /* 제거하거나 무시됨 */
    border-radius: 4px;
    margin: 20px 0;
    display: block;
}

#board embed,
#board object,
#board iframe {
    width: 100% !important;
    max-width: 100% !important;
    aspect-ratio: 16 / 9;
    height: auto !important;
    display: block;
    margin: 20px 0;
    border: 0 !important;
    outline: none;
    box-shadow: none;
}

/* ========================================================================= */
/* 6. 페이지네이션 (Pagination)                                              */
/* ========================================================================= */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px; /* 버튼 사이 간격 */
    margin-top: 60px; /* 리스트와의 상단 여백 */
    margin-bottom: 40px; /* 하단 여백 */
}

/* 1. 기본 버튼 (숫자 및 화살표 링크) */
.pagination a,
.pagination strong,
.pagination span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px; /* 버튼 최소 너비 (원형 유지) */
    height: 36px; /* 버튼 높이 */
    padding: 0 6px; /* 두 자릿수 숫자 대응 패딩 */

    font-size: 14px;
    font-weight: 500;
    font-family: var(--font-family); /* 공통 폰트 사용 */
    color: #4b5563; /* 기본 회색 글자 */

    background-color: #fff;
    border: 1px solid transparent; /* 호버 시 흔들림 방지용 투명 테두리 */
    border-radius: 6px; /* 살짝 둥근 사각형 (원형을 원하면 50%로 변경) */
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
}

/* 2. 마우스 올렸을 때 (Hover) */
.pagination a:hover {
    background-color: #f3f4f6; /* 연한 회색 배경 */
    color: #000; /* 진한 검정 글자 */
    border-color: #e5e7eb; /* 연한 테두리 */
}

/* 3. 현재 페이지 (Active - strong 태그 보통 사용) */
.pagination strong,
.pagination .active {
    background-color: #000; /* 브랜드 컬러 (검정) */
    color: #fff !important; /* 흰색 글자 */
    border-color: var(--black);
    font-weight: 700;
    cursor: default; /* 클릭 안 되는 느낌 */
    pointer-events: none;
}

/* 4. 이전/다음 화살표 버튼 스타일 (아이콘이나 텍스트) */
.pagination .prev,
.pagination .next,
.pagination .first,
.pagination .last {
    color: #9ca3af; /* 화살표는 조금 더 연하게 */
    font-size: 12px; /* 화살표 크기 조절 */
}
.pagination .prev:hover,
.pagination .next:hover {
    color: #000;
}

/* 📱 모바일 대응 */
@media (max-width: 768px) {
    .pagination {
        gap: 4px; /* 간격 좁힘 */
        margin-top: 40px;
    }
    .pagination a,
    .pagination strong {
        min-width: 32px; /* 크기 약간 축소 */
        height: 32px;
        font-size: 13px;
    }
}

/* ========================================================================= */
/* 7. 파일 업로드 메인 컨테이너 (File Upload Container)                      */
/* ========================================================================= */
#file {
    width: 100%;
    box-sizing: border-box;
}

#file .file-group {
    border-top: 1px solid #eee; /* 색상 미세 조정 */
    padding-top: 30px;
    margin-bottom: 30px;
}

/* 기존 파일 목록 & 뷰 페이지 목록 공통 래퍼 */
#file .existing-files-wrap {
    margin-bottom: 30px;
}

#file .existing-label {
    font-size: 14px;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 12px;
    display: flex; /* 아이콘 정렬 위해 flex 변경 */
    align-items: center;
}

#file .existing-label i {
    margin-right: 6px;
    color: #f59e0b;
    font-size: 16px;
}

/* 업로드 박스 (스타일 유지) */
#file .file-upload-container {
    width: 100%;
    margin-top: 10px;
    margin-bottom: 20px;
}

#file .upload-box {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100%;
    height: 70px;
    background-color: #f8fafc;
    border: 2px dashed #cbd5e1;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #64748b;
    text-align: center !important;
    gap: 12px;
    margin-bottom: 30px;
}

#file .upload-box:hover,
#file .upload-box.drag-over {
    background-color: #eff6ff;
    border-color: #3b82f6;
    color: #3b82f6;
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.1);
}

#file .upload-box i {
    font-size: 20px;
    margin-bottom: 0;
}

#file .text-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

#file .upload-text {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
}

#file .upload-hint {
    font-size: 13px;
    color: #94a3b8;
    margin-top: 2px;
    white-space: nowrap;
}

#file .upload-hint::before {
    content: '|';
    margin-right: 10px;
    color: #cbd5e1;
}

/* ========================================================================= */
/* 8. 파일 목록 및 아이콘 스타일 (File List & Icons)                         */
/* ========================================================================= */
#file .file-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 2단 그리드 */
    gap: 12px;
    margin-top: 10px;
}

#file .file-item {
    display: flex;
    align-items: center;
    background-color: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px;
    transition: all 0.2s;
    text-decoration: none; /* 링크 밑줄 제거 */
}

#file .file-item:hover {
    border-color: #cbd5e1;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    transform: translateY(-2px);
}

#file .icon-box {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    margin-right: 12px;
    flex-shrink: 0;
}

/* 아이콘 색상 (유지) */
#file .icon-box.pdf {
    color: #e11d48;
    background-color: #fff1f2;
}
#file .icon-box.xls {
    color: #059669;
    background-color: #ecfdf5;
}
#file .icon-box.ppt {
    color: #ea580c;
    background-color: #fff7ed;
}
#file .icon-box.doc,
#file .icon-box.hwp {
    color: #2563eb;
    background-color: #eff6ff;
}
#file .icon-box.img {
    color: #7c3aed;
    background-color: #f5f3ff;
}
#file .icon-box.zip {
    color: #d97706;
    background-color: #fffbeb;
}
#file .icon-box.txt {
    color: #475569;
    background-color: #f1f5f9;
}
#file .icon-box.default {
    color: #64748b;
    background-color: #f8fafc;
}

#file .file-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

#file .file-name {
    font-size: 15px;
    font-weight: 600;
    color: #334155;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-decoration: none;
}
/* a태그일 경우 호버 색상 변경 */
a.file-name:hover {
    color: #2563eb;
}

#file .file-size {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 2px;
}

/* 버튼 공통 (삭제/다운로드) */
#file .btn-remove,
#file .btn-download {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: #f1f5f9;
    color: #64748b; /* 기본 색상 통일 */
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    margin-left: 10px;
    flex-shrink: 0;
    text-decoration: none; /* a태그일 경우 */
}

/* 삭제 버튼 호버 (빨강) */
#file .btn-remove:hover {
    background-color: #fee2e2;
    color: #ef4444;
}

/* 다운로드 버튼 호버 (파랑) */
#file .btn-download:hover {
    background-color: #eff6ff;
    color: #3b82f6;
}

/* 신규 첨부파일 라벨 스타일 */
#file .new-file-label {
    font-size: 14px;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    margin-top: 30px; /* 기존 파일 목록과의 간격 */
}

/* 신규 파일 아이콘 (파란색 +) */
#file .new-file-label i {
    color: #3b82f6;
    font-size: 16px;
    margin-right: 6px;
}

/* ========================================================================= */
/* 9. 모바일 반응형 설정 (Mobile Responsive)                                  */
/* ========================================================================= */
@media (max-width: 768px) {
    #file .upload-box {
        flex-direction: column !important;
        height: auto;
        padding: 15px 0;
        gap: 5px;
    }
    #file .text-group {
        flex-direction: column;
        gap: 2px;
    }
    #file .upload-hint::before {
        display: none;
    }
    #file .file-list {
        grid-template-columns: 1fr; /* 모바일 1단 */
    }
}
