/* ===== CSS 변수 & 색상 시스템 ===== */
:root {
    --primary-color: #1ec800;
    --primary-light: #00c73c;
    --primary-dark: #16a500;
    --bg-main: #ffffff;
    --bg-light: #f8f9fa;
    --bg-dark: #f0f0f0;
    --text-dark: #000000;
    --text-main: #222222;
    --text-sub: #666666;
    --border-color: #e5e5e5;
    --border-light: #f0f0f0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.12);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.15);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-main: #1e1e1e;
        --bg-light: #2d2d2d;
        --bg-dark: #383838;
        --text-dark: #ffffff;
        --text-main: #e4e4e4;
        --text-sub: #999999;
        --border-color: #404040;
        --border-light: #303030;
        --shadow-sm: 0 1px 3px rgba(0,0,0,0.5);
        --shadow-md: 0 2px 8px rgba(0,0,0,0.5);
        --shadow-lg: 0 4px 16px rgba(0,0,0,0.6);
    }
}

/* ===== 기본 스타일 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    color: var(--text-main);
    background-color: var(--bg-light);
    line-height: 1.6;
}

/* ===== 레이아웃 ===== */
#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}

main {
    flex: 1;
    padding: 40px 0;
}

/* ===== 헤더 ===== */
#app > header {
    background: var(--bg-main);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
}

.logo {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
    cursor: pointer;
    letter-spacing: -0.5px;
}

.logo:hover {
    color: var(--primary-dark);
}

.search-box {
    flex: 1;
    max-width: 300px;
    margin: 0 20px;
}

.search-input {
    width: 100%;
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background: var(--bg-light);
    color: var(--text-main);
    font-size: 14px;
    transition: var(--transition);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--bg-main);
    box-shadow: 0 0 0 3px rgba(30, 200, 0, 0.1);
}

.header-actions {
    display: flex;
    gap: 16px;
    align-items: center;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: var(--transition);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--bg-light);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-dark);
    border-color: var(--text-sub);
}

.btn-small {
    padding: 8px 12px;
    font-size: 12px;
}

/* ===== 메인 콘텐츠 레이아웃 ===== */
.main-wrapper {
    display: grid;
    grid-template-columns: 250px 1fr 280px;
    gap: 20px;
}

.sidebar {
    background: var(--bg-main);
    border-radius: 8px;
    padding: 20px;
    height: fit-content;
    position: sticky;
    top: 100px;
    box-shadow: var(--shadow-sm);
}

.sidebar-section {
    margin-bottom: 24px;
}

.sidebar-section:last-child {
    margin-bottom: 0;
}

.sidebar-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.category-list, .tag-list {
    list-style: none;
}

.category-item, .tag-item {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
}

.category-item:last-child, .tag-item:last-child {
    border-bottom: none;
}

.category-link, .tag-link {
    color: var(--text-sub);
    text-decoration: none;
    cursor: pointer;
    font-size: 14px;
    transition: var(--transition);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.category-link {
    padding-left: 12px; /* 나머지 카테고리는 안쪽 영역으로 들여쓰기 */
}

/* 전체보기 카테고리 강조 스타일 */
.category-item-all .category-link {
    padding-left: 0; /* 전체보기는 들여쓰기 없음 */
    font-weight: 700; /* 볼드체 */
    color: var(--text-dark); /* 라이트 모드에선 검정색, 다크 모드에선 흰색 */
}

.category-link:hover, .tag-link:hover {
    color: var(--primary-color);
}

.category-item-all .category-link:hover {
    color: var(--primary-color);
}

.count-badge {
    background: var(--bg-light);
    color: var(--text-sub);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
}

/* ===== 메인 콘텐츠 ===== */
.main-content {
    background: var(--bg-main);
    border-radius: 8px;
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.home-top-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
}

.home-tab {
    border: 1px solid var(--border-color);
    background: var(--bg-light);
    color: var(--text-sub);
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.home-tab:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.home-tab.active {
    background: rgba(30, 200, 0, 0.12);
    color: var(--primary-dark);
    border-color: var(--primary-color);
}

.prologue-panel {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 22px;
    background: linear-gradient(180deg, var(--bg-main) 0%, var(--bg-light) 100%);
}

.prologue-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 14px;
    color: var(--text-main);
}

.prologue-text {
    color: var(--text-sub);
    font-size: 15px;
    line-height: 1.7;
    margin-bottom: 12px;
}

.prologue-actions {
    margin-top: 16px;
}

/* ===== 홈 페이지: 글 목록 ===== */
.posts-list {
    list-style: none;
}

.post-item {
    padding: 24px 0;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
}

.post-item:last-child {
    border-bottom: none;
}

.post-item-content {
    flex: 1;
    min-width: 0;
}

.post-item-thumbnail {
    width: 120px;
    height: 120px;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
    background: var(--bg-light);
    border: 1px solid var(--border-light);
}

.post-item-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

.post-item:hover .post-item-thumbnail img {
    transform: scale(1.05);
}

.post-item:hover {
    background: var(--bg-light);
    padding-left: 12px;
    padding-right: 12px;
    margin: 0 -12px;
    border-radius: 4px;
    box-shadow: inset 2px 0 0 var(--primary-color);
}

.post-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 8px;
    transition: var(--transition);
    letter-spacing: -0.3px;
}

.post-item:hover .post-title {
    color: var(--primary-color);
}

.post-meta {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--text-sub);
}

.post-date, .post-views, .post-category {
    display: flex;
    align-items: center;
    gap: 4px;
}

.post-category {
    background: var(--bg-light);
    color: var(--primary-color);
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
}

.post-excerpt {
    color: var(--text-sub);
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-clamp: 2;
}

.post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag-badge {
    background: var(--bg-light);
    color: var(--text-sub);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    transition: var(--transition);
}

.tag-badge:hover {
    background: var(--primary-color);
    color: white;
}

/* ===== 우측 사이드바 ===== */
.right-sidebar {
    background: var(--bg-main);
    border-radius: 8px;
    padding: 20px;
    height: fit-content;
    position: sticky;
    top: 100px;
    box-shadow: var(--shadow-sm);
}

.recent-posts, .popular-tags {
    list-style: none;
}

.recent-post-item, .popular-tag-item {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
}

.recent-post-item:last-child, .popular-tag-item:last-child {
    border-bottom: none;
}

.recent-post-link, .popular-tag-link {
    color: var(--text-sub);
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
}

.recent-post-link:hover, .popular-tag-link:hover {
    color: var(--primary-color);
}

/* ===== 글 상세 페이지 ===== */
.post-detail {
    background: transparent;
    border-radius: 8px;
    padding: 22px 16px;
    box-shadow: none;
    max-width: 1000px;
    margin: 0 auto;
}

.post-header {
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 14px;
    margin-bottom: 18px;
}

.post-detail-title {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 16px;
    line-height: 1.3;
}

.post-detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 13px;
    color: var(--text-sub);
    align-items: center;
}

.post-detail-content {
    font-size: 17px;
    line-height: 1.9;
    color: var(--text-main);
    margin-bottom: 32px;
    word-break: break-all;
    overflow-wrap: break-word;
}

.post-detail-content p {
    margin-bottom: 16px;
}

.post-detail-content img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 16px 0;
}

.post-footer {
    display: flex;
    gap: 12px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

/* ===== 관리자 대시보드 ===== */
.admin-dashboard {
    background: var(--bg-main);
    border-radius: 8px;
    padding: 32px;
    box-shadow: var(--shadow-sm);
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 2px solid var(--border-color);
}

.admin-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-main);
}

.posts-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.posts-table thead {
    background: var(--bg-light);
    border-top: 2px solid var(--border-color);
    border-bottom: 2px solid var(--border-color);
}

.posts-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-main);
}

.posts-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-sub);
}

.posts-table tbody tr:hover {
    background: var(--bg-light);
}

.action-buttons {
    display: flex;
    gap: 8px;
}

.btn-edit, .btn-delete {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    transition: var(--transition);
}

.btn-edit {
    background: var(--primary-color);
    color: white;
}

.btn-edit:hover {
    background: var(--primary-dark);
}

.btn-delete {
    background: #dc3545;
    color: white;
}

.btn-delete:hover {
    background: #c82333;
}

/* ===== 글 작성/수정 페이지 ===== */
.post-editor {
    background: var(--bg-main);
    border-radius: 8px;
    padding: 32px;
    box-shadow: var(--shadow-sm);
}

.editor-header {
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 2px solid var(--border-color);
}

.editor-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-main);
}

.form-group {
    margin-bottom: 24px;
}

.form-label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-main);
    font-size: 14px;
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    color: var(--text-main);
    background: var(--bg-main);
    font-family: inherit;
    transition: var(--transition);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(30, 200, 0, 0.1);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Quill Editor 커스터마이징 */
.ql-container {
    font-size: 14px;
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 4px 4px;
    background: var(--bg-main);
}

.ql-editor {
    min-height: 400px;
    color: var(--text-main);
}

.ql-toolbar {
    border: 1px solid var(--border-color);
    border-radius: 4px 4px 0 0;
    background: var(--bg-light);
    position: sticky;
    top: 65px;
    z-index: 10;
}

.ql-toolbar.ql-snow .ql-fill, .ql-toolbar.ql-snow .ql-stroke.ql-fill {
    fill: var(--text-main);
}

.ql-toolbar.ql-snow .ql-stroke {
    stroke: var(--text-sub);
}

.ql-toolbar.ql-snow button:hover, .ql-toolbar.ql-snow button:focus, .ql-toolbar.ql-snow button.ql-active {
    color: var(--primary-color);
}

.editor-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    justify-content: flex-end;
}

/* ===== 모달 ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-main);
    border-radius: 8px;
    padding: 32px;
    max-width: 400px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease-out;
    position: relative;
}

@keyframes slideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-main);
}

.modal-body {
    margin-bottom: 24px;
}

.modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-sub);
}

/* ===== 푸터 ===== */
footer {
    background: var(--bg-main);
    border-top: 1px solid var(--border-color);
    padding: 40px 0 20px;
    text-align: center;
    color: var(--text-sub);
    font-size: 13px;
    margin-top: auto;
}

/* ===== 반응형 디자인 ===== */
@media (max-width: 1024px) {
    .main-wrapper {
        grid-template-columns: 1fr;
    }

    .sidebar, .right-sidebar {
        position: static;
    }

    .sidebar {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 16px;
    }

    .sidebar-section {
        margin-bottom: 0;
    }
}

@media (max-width: 768px) {
    .main-wrapper {
        grid-template-columns: 1fr;
    }

    .header-content {
        flex-wrap: wrap;
        gap: 12px;
    }

    .search-box {
        margin: 0;
        max-width: 100%;
        order: 3;
        flex-basis: 100%;
    }

    .post-detail {
        padding: 20px;
    }

    .post-detail-title {
        font-size: 24px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .main-content {
        padding: 16px;
    }

    .sidebar, .right-sidebar {
        position: static;
    }

    .sidebar {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 16px;
    }

    .sidebar-section {
        margin-bottom: 0;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 12px;
    }

    .main-content {
        padding: 12px;
    }

    .post-item {
        padding: 16px 0;
    }

    .logo {
        font-size: 20px;
    }

    .post-detail {
        padding: 16px;
    }

    .modal-content {
        padding: 24px;
    }
}

/* ===== 유틸리티 ===== */
.hidden {
    display: none;
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-sub);
}

.alert {
    padding: 16px;
    border-radius: 4px;
    margin-bottom: 16px;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-sub);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.empty-state-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-main);
}

@media (max-width: 600px) {
    .post-item {
        flex-direction: column-reverse;
        align-items: stretch;
        gap: 12px;
    }
    .post-item-thumbnail {
        width: 100%;
        height: 160px;
    }
}

/* ===== 댓글 시스템 스타일 ===== */
.comment-section {
    max-width: 1000px;
    margin: 48px auto 0;
    border-top: 1px solid var(--border-color);
    padding-top: 32px;
}

.comment-list {
    margin-bottom: 24px;
}

.comment-item {
    padding: 16px 10px;
    border-bottom: 1px solid var(--border-light);
    transition: var(--transition);
}

.comment-item:hover {
    background: rgba(0, 0, 0, 0.005);
}

.btn-cmt-delete, .btn-cmt-reply-toggle {
    transition: var(--transition);
    opacity: 0.75;
}

.btn-cmt-delete:hover, .btn-cmt-reply-toggle:hover {
    opacity: 1;
}

.cmt-private-content {
    transition: var(--transition);
}

.cmt-private-content:hover {
    background: var(--bg-dark) !important;
    border-color: var(--primary-color) !important;
}

/* ===== 댓글 수 뱃지 & 페이지네이션 스타일 ===== */
.comment-count-badge {
    color: #e53e3e;
    font-size: 0.78em;
    font-weight: bold;
    margin-left: 6px;
    vertical-align: baseline;
}

.pagination-container .page-btn {
    transition: var(--transition);
}

.pagination-container .page-btn:hover:not(:disabled):not(.active) {
    border-color: var(--primary-color) !important;
    color: var(--primary-color) !important;
    background: var(--bg-main) !important;
}

.pagination-container .page-btn:disabled {
    cursor: not-allowed !important;
}

/* ===== 방문자 통계 스타일 ===== */
.visitor-stats-box {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 8px;
    margin-top: 8px;
}

.visitor-stats-box .stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.visitor-stats-box .stat-item:not(:last-child) {
    border-right: 1px solid var(--border-color);
}

.visitor-stats-box .stat-label {
    font-size: 11px;
    color: var(--text-sub);
    margin-bottom: 4px;
    font-weight: 500;
}

.visitor-stats-box .stat-value {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-dark);
}

@media (max-width: 600px) {
    .sidebar {
        grid-template-columns: 1fr !important;
    }
}

/* ===== Quill Alignment Styles for Post Detail Content ===== */
.post-detail-content .ql-align-center {
    text-align: center;
}
.post-detail-content .ql-align-right {
    text-align: right;
}
.post-detail-content .ql-align-justify {
    text-align: justify;
}

/* ===== HTML view editor textarea ===== */
#htmlEditor {
    display: none;
    font-family: 'Consolas', 'Courier New', monospace;
    height: 500px;
    width: 100%;
    resize: vertical;
    background: var(--bg-light);
    color: var(--text-main);
    line-height: 1.5;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
}

