/* RA0 Edition - 비주얼 앵커 게시판 스킨 (vsanchor_up) */
/* CSS 변수 시스템 사용 */
/* anchor_up 스타일 참고 - grid + sticky 레이아웃 */

/* ========== 컨테이너 ========== */
.vsanchor-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px 20px;
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 30px;
    position: relative;
}

/* ========== 사이드 앵커 네비게이션 ========== */
.anchor-nav {
    position: sticky;
    top: 20px;
    align-self: start;
    max-height: calc(100vh - 40px);
    background: rgb(from var(--container-bg-color) r g b / 60%);
    border-radius: var(--container-border-radius);
    backdrop-filter: blur(5px);
}

.anchor-nav::before {
    content: '';
    position: absolute;
    inset: -6px;
    border: 30px solid transparent;
    pointer-events: none;
    z-index: 10;
}

.anchor-nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px 0px;
}

.nav-title {
    font-family: var(--title-font-family);
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent-color);
}

.btn-edit-mode {
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

.btn-edit-mode:hover {
    background: var(--container-bg-color);
    color: var(--content-font-color);
}

.btn-edit-mode.active {
    background: var(--accent-color);
    color: var(--black);
    border-color: var(--accent-color);
}

.anchor-list {
    list-style: none;
    margin: 0;
    padding: 10px 0;
}

.anchor-list li {
    margin: 0;
}

.anchor-item {
    display: flex;
    align-items: center;
    position: relative;
    transition: background 0.3s;
}

.anchor-item.current {
    background: rgb(from var(--accent-color) r g b / 8%);
}

.anchor-drag-handle {
    display: none;
    padding: 8px 4px 8px 12px;
    color: var(--text-muted);
    cursor: grab;
    font-size: 0.75rem;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.anchor-drag-handle:active {
    cursor: grabbing;
}

.edit-mode .anchor-drag-handle {
    display: block;
}

.edit-mode .anchor-drag-handle:hover {
    opacity: 1;
    color: var(--accent-color);
}

.edit-mode .anchor-link {
    padding-left: 8px;
}

/* 앵커 리스트 정렬 플레이스홀더 */
.anchor-list .ui-sortable-placeholder {
    background: rgb(from var(--accent-color) r g b / 20%);
    border: 1px dashed var(--accent-color);
    border-radius: 4px;
    height: 36px;
    margin: 2px 10px;
}

.anchor-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.2s;
    border-left: 2px solid transparent;
    margin-left: -2px;
    font-size: 0.9rem;
}

.anchor-link:hover {
    background: rgb(from var(--primary-color) r g b / 10%);
    color: var(--content-font-color);
}

.anchor-link.active {
    color: var(--accent-color);
    border-left-color: var(--accent-color);
    box-shadow: -3px 0 10px rgb(from var(--accent-color) r g b / 30%);
}

.anchor-num {
    font-family: 'Courier Prime', monospace;
    font-size: 0.7rem;
    font-weight: bold;
    color: var(--accent-color);
    opacity: 0.6;
}

.anchor-title {
    font-size: 0.85rem;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 섹션 추가 버튼 (네비게이션 내) */
.add-section-nav {
    padding: 10px 15px;
}

.btn-add-nav {
    width: 100%;
    padding: 8px;
    background: transparent;
    border: 1px dashed var(--border-light);
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.8rem;
}

.btn-add-nav:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

/* 모바일 네비게이션 토글 */
.nav-toggle {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    width: 40px;
    height: 40px;
    background: var(--container-bg-color);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    color: var(--content-font-color);
    cursor: pointer;
    z-index: 200;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

/* ========== 메인 콘텐츠 영역 ========== */
.anchor-content {
    min-width: 0; /* grid overflow 방지 */
}

/* ========== 섹션 ========== */
.sections-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 30px;
    background: var(--container-bg-color);
    border: 1px solid var(--container-border-color);
    border-radius: var(--container-border-radius);
    padding: 40px;
}

.sections-wrapper::before {
    content: '';
    position: absolute;
    inset: -9px;
    border: 60px solid transparent;
    pointer-events: none;
    z-index: 10;
}

.anchor-section {
    position: relative;
    overflow: hidden;
    transition: opacity 0.3s, transform 0.3s;
    scroll-margin-top: 100px; /* 앵커 스크롤 시 상단 여백 */
}

/* 관리자 바 */
.section-admin-bar {
    display: none;
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 10;
    gap: 8px;
    align-items: center;
    background: rgb(from var(--container-bg-color) r g b / 90%);
    padding: 5px 10px;
    border-radius: 4px;
    backdrop-filter: blur(5px);
}

.edit-mode .section-admin-bar {
    display: flex;
}

.drag-handle {
    cursor: grab;
    color: var(--text-muted);
    padding: 5px;
}

.drag-handle:active {
    cursor: grabbing;
}

.admin-actions {
    display: flex;
    gap: 5px;
}

.admin-actions button,
.admin-actions a {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    background: var(--container-bg-color);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    text-decoration: none;
}

.admin-actions button:hover,
.admin-actions a:hover {
    background: var(--accent-color);
    color: var(--black);
    border-color: var(--accent-color);
}

.btn-delete-section:hover {
    background: var(--error-color) !important;
    border-color: var(--error-color) !important;
    color: var(--white) !important;
}

/* 히어로 섹션 (이미지 있을 때) */
.section-hero {
    position: relative;
    height: 300px;
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: flex-end;
    padding: 30px 40px;
}

.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.section-title.hero-title {
    display: none;
}

/* 일반 섹션 헤더 (이미지 없을 때) */
.section-header {
    padding: 30px 40px 0px;
}

.section-title {
    font-family: var(--title-font-family);
    font-size: 1.5rem;
    color: var(--content-font-color);
    margin: 0;
    line-height: 1.3;
    display: flex;
    align-items: center;
}

.section-title.hero-title::before {
    display: none;
}

/* 섹션 본문 */
.section-body {
    padding: 30px 40px 40px;
}

.section-content {
    font-family: var(--content-font-family);
    font-size: var(--content-font-size);
    color: var(--content-font-color);
    line-height: 1.8;
    word-break: keep-all;
}

.section-content h3 {
    font-size: 1.2rem;
    margin: 1.5em 0 0.8em 0;
    color: var(--accent-color);
}

.section-content ul, .section-content ol {
    margin: 1em 0;
    padding-left: 1.5em;
}

.section-content li {
    margin-bottom: 0.5em;
}

.section-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--container-border-radius);
    margin: 1em 0;
}

.section-content strong {
    color: var(--accent-color);
}

/* 섹션 번호 */
.section-number {
    position: absolute;
    top: 15px;
    left: 15px;
    font-family: 'Courier Prime', monospace;
    font-size: 2.5rem;
    font-weight: bold;
    color: rgb(from var(--accent-color) r g b / 15%);
    pointer-events: none;
    line-height: 1;
}

/* ========== 편집 가능한 요소 ========== */
.editable {
    border-radius: 4px;
    transition: background 0.2s, box-shadow 0.2s;
    outline: none;
}

.edit-mode .editable {
    cursor: text;
}

.edit-mode .editable:hover {
    background: rgb(from var(--primary-color) r g b / 10%);
}

.edit-mode .editable:focus,
.edit-mode .editable.editing {
    background: rgb(from var(--primary-color) r g b / 15%);
    box-shadow: 0 0 0 2px var(--accent-color);
}

.editable.saving {
    opacity: 0.6;
}

.editable.saved {
    animation: savedPulse 0.5s ease;
}

@keyframes savedPulse {
    0% { box-shadow: 0 0 0 2px var(--success-color); }
    100% { box-shadow: 0 0 0 0 transparent; }
}

/* ========== 섹션 추가 ========== */
.add-section-trigger {
    display: none;
    padding: 20px;
    text-align: center;
}

.btn-add-section {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: transparent;
    border: 2px dashed var(--border-light);
    border-radius: var(--container-border-radius);
    color: var(--text-muted);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-add-section:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.add-section-form {
    padding: 30px;
    background: var(--container-bg-color);
    border: 1px solid var(--border-light);
    border-radius: var(--container-border-radius);
}

.form-inner {
    max-width: 500px;
    margin: 0 auto;
}

.input-title {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-light);
    border-radius: var(--container-border-radius);
    background: var(--container-bg-color);
    color: var(--content-font-color);
    font-size: 1rem;
    font-family: var(--title-font-family);
    margin-bottom: 12px;
}

.input-title:focus {
    outline: none;
    border-color: var(--accent-color);
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.btn-cancel, .btn-confirm {
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-cancel {
    background: var(--btn-secondary-bg);
    color: var(--btn-secondary-text);
    border: 1px solid var(--border-light);
}

.btn-confirm {
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    border: none;
}

.btn-confirm:hover {
    filter: brightness(1.1);
}

/* ========== 빈 상태 ========== */
.empty-state {
    text-align: center;
    padding: 80px 30px;
    color: var(--text-muted);
    background: var(--container-bg-color);
    border: 1px solid var(--border-light);
    border-radius: var(--container-border-radius);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 15px;
    opacity: 0.3;
}

.empty-state p {
    font-size: 1rem;
    margin-bottom: 20px;
}

.btn-add-first {
    display: inline-block;
    padding: 12px 24px;
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    border: none;
    border-radius: var(--container-border-radius);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-add-first:hover {
    filter: brightness(1.1);
}

/* ========== 정렬 플레이스홀더 ========== */
.sortable-placeholder {
    background: rgb(from var(--primary-color) r g b / 10%);
    border: 2px dashed var(--accent-color);
    border-radius: var(--container-border-radius);
    min-height: 150px;
}

/* ========== 모달 ========== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgb(from var(--black) r g b / 80%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: var(--container-bg-color);
    border-radius: var(--container-border-radius);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgb(from var(--black) r g b / 50%);
}

.modal-content.modal-large {
    max-width: 700px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-light);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--content-font-color);
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
}

.modal-close:hover {
    background: var(--container-bg-color);
}

.modal-body {
    padding: 20px;
}

.modal-body textarea {
    width: 100%;
    min-height: 250px;
    padding: 12px;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    background: var(--container-bg-color);
    color: var(--content-font-color);
    font-family: var(--content-font-family);
    font-size: 0.9rem;
    resize: vertical;
}

.modal-body textarea:focus {
    outline: none;
    border-color: var(--accent-color);
}

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

/* 이미지 업로드 탭 */
.upload-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
}

.tab-btn {
    flex: 1;
    padding: 8px;
    border: 1px solid var(--border-light);
    background: transparent;
    color: var(--text-muted);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
}

.tab-btn.active {
    background: var(--accent-color);
    color: var(--black);
    border-color: var(--accent-color);
}

.upload-area {
    border: 2px dashed var(--border-light);
    border-radius: var(--container-border-radius);
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-muted);
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--accent-color);
    background: rgb(from var(--primary-color) r g b / 10%);
}

.upload-area i {
    font-size: 1.8rem;
    color: var(--accent-color);
    margin-bottom: 8px;
    display: block;
}

.upload-area p {
    margin: 0;
    font-size: 0.85rem;
}

#image-url-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    background: var(--container-bg-color);
    color: var(--content-font-color);
    font-size: 0.9rem;
}

#image-url-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.image-preview {
    margin-top: 15px;
    text-align: center;
}

.image-preview img {
    max-width: 100%;
    max-height: 180px;
    border-radius: var(--container-border-radius);
    margin-bottom: 10px;
}

.btn-remove-preview {
    padding: 6px 12px;
    background: var(--error-color);
    color: var(--white);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

.btn-save-image, .btn-save-content {
    padding: 8px 16px;
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.btn-save-image:disabled, .btn-save-content:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ========== 반응형 ========== */
@media screen and (max-width: 768px) {
    .anchor-nav::before {
        display: none;
    }

    .sections-wrapper::before {
        inset: -7px;
        border-width: 35px;
    }

    .vsanchor-container {
        grid-template-columns: 1fr;
        gap: 0px;
        padding: 0;
    }

    .sections-wrapper {
        padding: 0;
    }

    .anchor-nav {
        position: sticky;
        top: 0;
        z-index: 100;
        max-height: none;
        border-left: none;
        overflow-x: auto;
        background: var(--container-bg-color);
        border-bottom: 1px solid var(--border-light);
        border-radius: 0;
        margin: 0 -15px;
        padding: 0 15px;
        width: calc(100% + 30px);
    }

    .anchor-list {
        display: flex;
        padding: 5px 0;
        white-space: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Firefox */
    }

    .anchor-list::-webkit-scrollbar {
        display: none; /* Chrome, Safari */
    }

    .anchor-link {
        padding: 8px 12px;
        font-size: 0.85rem;
        border-left: none;
        border-bottom: 2px solid transparent;
        margin-left: 0;
    }

    .anchor-link.active {
        border-left-color: transparent;
        border-bottom-color: var(--accent-color);
        box-shadow: none;
    }

    .anchor-nav-header {
        padding: 10px 15px 0px;
    }

    .nav-title {
        font-size: 0.9rem;
    }

    .section-hero {
        height: 220px;
        padding: 20px;
    }

    .hero-title {
        font-size: 1.5rem;
    }

    .section-header {
        padding: 20px;
    }

    .section-title {
        font-size: 1.2rem;
    }

    .section-body {
        padding: 20px;
    }

    .section-number {
        font-size: 2rem;
        top: 10px;
        left: 10px;
    }

    .add-section-nav {
        display: none !important;
    }
}