/* ══════════════════════════════════════════════
   board.css — 게시판 스타일
   ══════════════════════════════════════════════ */

/* ── 컨테이너 ────────────────────────────── */
.board-container {
    max-width: none;
    padding: 0;
}

/* ── 탭 ──────────────────────────────────── */
.board-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--c-border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.board-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--c-text-sec);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    transition: color 0.2s, border-color 0.2s;
}

.board-tab:hover {
    color: var(--c-primary);
}

.board-tab.active {
    color: var(--c-primary);
    border-bottom-color: var(--c-primary);
    font-weight: 600;
}

.board-tab-icon {
    font-size: 16px;
}

/* ── 리스트 헤더 ─────────────────────────── */
.board-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.board-list-header h3 {
    margin: 0;
    font-size: 18px;
    color: var(--c-text);
}

.board-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.board-search {
    display: flex;
    align-items: center;
    gap: 4px;
}

.board-search input {
    width: 160px;
    padding: 6px 10px;
    border: 1px solid var(--c-border);
    border-radius: 6px;
    font-size: 13px;
    background: var(--c-bg-card);
    color: var(--c-text);
}

/* ── 게시글 테이블 ───────────────────────── */
.board-table-wrap {
    overflow-x: auto;
}

.board-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.board-table th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--c-text-sec);
    border-bottom: 2px solid var(--c-border);
    background: var(--c-bg);
    white-space: nowrap;
}

.board-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--c-border-l);
    color: var(--c-text);
}

.board-table .col-id {
    width: 50px;
    color: var(--c-text-muted);
    text-align: center;
}

.board-table .col-cat { width: 100px; }
.board-table .col-author { width: 100px; }
.board-table .col-date { width: 80px; text-align: center; }

.board-row {
    cursor: pointer;
    transition: background-color 0.15s;
}

.board-row:hover {
    background-color: var(--c-primary-bg);
}

.board-row.pinned {
    background-color: var(--c-warning-bg);
}

.board-row.pinned:hover {
    background-color: #fef3c7;
}

.pin-badge {
    margin-right: 4px;
}

.secret-badge {
    display: inline-flex;
    align-items: center;
    margin-right: 4px;
    font-size: 12px;
    color: #d97706;
}

.anon-badge {
    display: inline-flex;
    align-items: center;
    margin-left: 4px;
    font-size: 11px;
    color: var(--c-text-muted);
    background: var(--c-bg-hover);
    padding: 1px 6px;
    border-radius: 8px;
}

.board-row.secret {
    opacity: 0.85;
}

.comment-count {
    margin-left: 6px;
    font-size: 12px;
    color: var(--c-primary);
    font-weight: 600;
}

.cat-label {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--c-primary-bg);
    color: var(--c-primary);
    font-size: 12px;
    font-weight: 500;
}

.board-empty {
    text-align: center;
    padding: 40px 0 !important;
    color: var(--c-text-muted);
}

/* ── 페이지네이션 ────────────────────────── */
.board-pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: 20px;
    padding: 12px 0;
}

.page-btn {
    padding: 6px 12px;
    border: 1px solid var(--c-border);
    border-radius: 6px;
    background: var(--c-bg-card);
    color: var(--c-text);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
}

.page-btn:hover {
    background: var(--c-primary-bg);
    border-color: var(--c-primary-l);
}

.page-btn.active {
    background: var(--c-primary);
    color: #fff;
    border-color: var(--c-primary);
    font-weight: 600;
}

/* ── 게시글 상세 ─────────────────────────── */
.board-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.board-detail-actions {
    display: flex;
    gap: 8px;
}

.board-post {
    background: var(--c-bg-card);
    border-radius: var(--radius);
    padding: 24px;
    border: 1px solid var(--c-border);
    margin-bottom: 24px;
}

.board-post-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--c-text);
    margin: 0 0 12px;
}

.board-post-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 13px;
    color: var(--c-text-sec);
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--c-border-l);
}

.board-post-meta .author {
    font-weight: 600;
    color: var(--c-text);
}

.board-post-meta .edited {
    font-style: italic;
    color: var(--c-text-muted);
}

.board-post-content {
    font-size: 15px;
    line-height: 1.7;
    color: var(--c-text);
    word-break: break-word;
}

.board-post-content a {
    color: var(--c-primary);
    text-decoration: underline;
}

/* ── 첨부파일 ────────────────────────────── */
.board-attachments {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--c-border-l);
}

.board-attachments h4 {
    font-size: 14px;
    color: var(--c-text-sec);
    margin: 0 0 12px;
}

.board-attachment-img {
    margin-bottom: 12px;
}

.board-attachment-img img {
    max-width: 100%;
    max-height: 500px;
    border-radius: 8px;
    border: 1px solid var(--c-border);
    display: block;
    margin-bottom: 4px;
}

.board-attachment-img .att-name,
.board-attachment-file {
    font-size: 12px;
    color: var(--c-text-muted);
}

/* ── 댓글 ────────────────────────────────── */
.board-comments {
    background: var(--c-bg-card);
    border-radius: var(--radius);
    padding: 20px 24px;
    border: 1px solid var(--c-border);
}

.board-comments h4 {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 16px;
    color: var(--c-text);
}

.comment-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.comment-form textarea,
.reply-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--c-border);
    border-radius: 8px;
    font-size: 14px;
    resize: vertical;
    background: var(--c-bg);
    color: var(--c-text);
    box-sizing: border-box;
}

.comment-form textarea:focus,
.reply-input:focus {
    border-color: var(--c-primary-l);
    outline: none;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.comment-form button {
    align-self: flex-end;
}

.comment-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--c-border-l);
}

.comment-item:last-child {
    border-bottom: none;
}

.comment-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.comment-author {
    font-weight: 600;
    font-size: 13px;
    color: var(--c-text);
}

.comment-date {
    font-size: 12px;
    color: var(--c-text-muted);
}

.comment-actions {
    margin-left: auto;
    display: flex;
    gap: 6px;
}

.comment-actions button {
    padding: 2px 8px;
    font-size: 12px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.15s;
}

.btn-reply {
    color: var(--c-primary);
}

.btn-reply:hover {
    background: var(--c-primary-bg);
}

.btn-comment-del {
    color: var(--c-danger);
}

.btn-comment-del:hover {
    background: var(--c-danger-bg);
}

.comment-body {
    font-size: 14px;
    line-height: 1.6;
    color: var(--c-text);
    white-space: pre-wrap;
}

.reply-form-container {
    margin-top: 8px;
}

.reply-form-actions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}

/* ── 에디터 ──────────────────────────────── */
.board-editor {
    max-width: 720px;
    margin: 0 auto;
}

.board-editor-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.board-editor-header h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    color: var(--c-text);
}

.editor-form {
    background: var(--c-bg-card);
    border-radius: var(--radius);
    padding: 24px;
    border: 1px solid var(--c-border);
}

.editor-row {
    margin-bottom: 16px;
}

.editor-row label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--c-text-sec);
    margin-bottom: 6px;
}

.editor-row-inline label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--c-text);
}

.editor-secret-anon {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}
.editor-secret-anon label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    cursor: pointer;
}

.editor-row .input,
.editor-row .select,
.editor-row .textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--c-border);
    border-radius: 8px;
    font-size: 14px;
    background: var(--c-bg);
    color: var(--c-text);
    box-sizing: border-box;
}

.editor-row .textarea {
    resize: vertical;
    font-family: inherit;
    line-height: 1.6;
}

.editor-row .input:focus,
.editor-row .select:focus,
.editor-row .textarea:focus {
    border-color: var(--c-primary-l);
    outline: none;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.editor-upload-area {
    display: flex;
    align-items: center;
    gap: 10px;
}

.upload-hint {
    font-size: 12px;
    color: var(--c-text-muted);
}

.editor-previews {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.preview-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px;
    background: var(--c-bg);
    border: 1px solid var(--c-border);
    border-radius: 8px;
    max-width: 120px;
}

.preview-item img {
    width: 100px;
    height: 80px;
    object-fit: cover;
    border-radius: 4px;
}

.preview-item span {
    font-size: 11px;
    color: var(--c-text-muted);
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-preview-del {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 50%;
    background: var(--c-danger);
    color: #fff;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.editor-actions {
    display: flex;
    justify-content: flex-end;
}

/* ── 카테고리 관리 ───────────────────────── */
.board-category-manager {
    max-width: 600px;
    margin: 0 auto;
}

.catmgr-form {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 16px;
    background: var(--c-bg-card);
    padding: 16px;
    border-radius: var(--radius);
    border: 1px solid var(--c-border);
}

.catmgr-form .input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--c-border);
    border-radius: 6px;
    font-size: 14px;
    background: var(--c-bg);
    color: var(--c-text);
}

.catmgr-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.catmgr-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--c-bg-card);
    border: 1px solid var(--c-border);
    border-radius: 8px;
    margin-bottom: 6px;
}

.catmgr-name {
    flex: 1;
    font-weight: 500;
    color: var(--c-text);
}

.catmgr-order {
    font-size: 12px;
    color: var(--c-text-muted);
}

.catmgr-empty {
    text-align: center;
    padding: 24px;
    color: var(--c-text-muted);
    background: var(--c-bg-card);
    border: 1px solid var(--c-border);
    border-radius: 8px;
}

/* ── 다크 모드 ───────────────────────────── */
[data-theme="dark"] .board-row.pinned {
    background-color: rgba(245, 158, 11, 0.1);
}
[data-theme="dark"] .board-row.pinned:hover {
    background-color: rgba(245, 158, 11, 0.15);
}
[data-theme="dark"] .secret-badge {
    color: #fbbf24;
}
[data-theme="dark"] .anon-badge {
    background: rgba(255,255,255,0.08);
    color: var(--c-text-muted);
}

/* ══════════════════════════════════════════════
   Markdown 툴바
   ══════════════════════════════════════════════ */
.md-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 6px 8px;
    background: var(--c-bg-card);
    border: 1px solid var(--c-border);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
}

.md-tb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 30px;
    padding: 0 6px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    color: var(--c-text);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.md-tb-btn:hover {
    background: var(--c-bg-hover, rgba(0,0,0,0.06));
    border-color: var(--c-border);
}

.md-tb-btn:active {
    background: var(--c-primary-bg, rgba(59,130,246,0.12));
}

.md-tb-sep {
    width: 1px;
    height: 20px;
    align-self: center;
    margin: 0 4px;
    background: var(--c-border);
}

.md-toolbar + .textarea {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

.md-toolbar-hint {
    font-size: 12px;
    color: var(--c-text-muted);
    margin-top: 4px;
    padding: 0 2px;
}

/* ══════════════════════════════════════════════
   Markdown 렌더링 스타일 (.md-rendered)
   ══════════════════════════════════════════════ */
.md-rendered {
    line-height: 1.75;
    word-break: break-word;
}

.md-rendered p {
    margin: 0 0 12px;
}

.md-rendered p:last-child {
    margin-bottom: 0;
}

.md-rendered .md-h {
    margin: 20px 0 8px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--c-text);
}

.md-rendered h2.md-h { font-size: 1.5em; border-bottom: 2px solid var(--c-border); padding-bottom: 6px; }
.md-rendered h3.md-h { font-size: 1.25em; }
.md-rendered h4.md-h { font-size: 1.1em; }
.md-rendered h5.md-h { font-size: 1em; color: var(--c-text-sec); }

.md-rendered strong { font-weight: 700; }
.md-rendered em { font-style: italic; }
.md-rendered del { text-decoration: line-through; opacity: 0.7; }

.md-rendered a {
    color: var(--c-primary);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.md-rendered a:hover {
    opacity: 0.8;
}

/* 인라인 코드 */
.md-inline-code {
    background: var(--c-bg-hover, rgba(0,0,0,0.06));
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
    font-size: 0.88em;
    color: var(--c-danger, #e74c3c);
}

/* 코드 블록 */
.md-pre {
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 12px 0;
    font-size: 13px;
    line-height: 1.5;
}

.md-pre .md-code {
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
    background: none;
    padding: 0;
}

/* 인용문 */
.md-bq {
    border-left: 4px solid var(--c-primary, #3b82f6);
    margin: 12px 0;
    padding: 8px 16px;
    background: var(--c-bg-hover, rgba(59,130,246,0.06));
    border-radius: 0 6px 6px 0;
    color: var(--c-text-sec);
}

/* 리스트 */
.md-list {
    margin: 8px 0;
    padding-left: 24px;
}

.md-list li {
    margin-bottom: 4px;
    line-height: 1.6;
}

/* 테이블 */
.md-table-wrap {
    overflow-x: auto;
    margin: 12px 0;
}

.md-table {
    border-collapse: collapse;
    width: 100%;
    font-size: 14px;
}

.md-table th,
.md-table td {
    border: 1px solid var(--c-border);
    padding: 8px 12px;
}

.md-table th {
    background: var(--c-bg-hover, rgba(0,0,0,0.04));
    font-weight: 600;
}

.md-table tr:nth-child(even) td {
    background: var(--c-bg-card, rgba(0,0,0,0.02));
}

/* 구분선 */
.md-hr {
    border: none;
    border-top: 2px solid var(--c-border);
    margin: 16px 0;
}

/* 이미지 */
.md-img {
    max-width: 100%;
    border-radius: 8px;
    margin: 8px 0;
}

/* ── Markdown 다크 모드 보정 ────────────── */
[data-theme="dark"] .md-inline-code {
    background: rgba(255,255,255,0.1);
    color: #f38ba8;
}

[data-theme="dark"] .md-pre {
    background: #11111b;
}

[data-theme="dark"] .md-bq {
    background: rgba(59,130,246,0.1);
}

[data-theme="dark"] .md-tb-btn:hover {
    background: rgba(255,255,255,0.08);
}
