:root {
    --header-height: 70px;
    --sidebar-offset: var(--header-height);
}

@media (max-width: 768px) {
    :root {
        --header-height: 120px;
    }
}

@media (min-width: 769px) {
    .footer {
        margin-left: 230px;
        transition: margin-left 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .sidebar-collapse-input:checked~.footer {
        margin-left: 80px;
    }
}

@media (max-width: 480px) {
    :root {
        --header-height: 115px;
    }
}

@media (max-width: 360px) {
    :root {
        --header-height: 110px;
    }
}

.sidebar-toggle-input {
    display: none;
}

.main-layout {
    display: flex;
    min-height: calc(100vh - var(--sidebar-offset));
    background-color: #f5f7fa;
    position: relative;
    overflow-x: hidden;
    max-width: 100vw;
}

.sidebar-toggle-btn {
    display: none;
    position: fixed;
    top: 121px;
    left: 0;
    z-index: 1001;
    width: 28px;
    height: 56px;
    border-radius: 0 15px 15px 0;
    background: #ff6c0f;
    border: none;
    color: #ffffff;
    cursor: pointer;
    box-shadow: none;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    align-items: center;
    justify-content: center;
}

.sidebar-toggle-btn:hover {
    transform: scale(1.1);
}

.sidebar-toggle-btn:active {
    transform: scale(0.95);
}

.sidebar-toggle-btn svg {
    display: block;
}

.sidebar-toggle-input:checked~.sidebar-toggle-btn {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: var(--sidebar-offset);
    left: 0;
    width: 100%;
    height: calc(100vh - var(--sidebar-offset));
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    cursor: pointer;
}

.sidebar-toggle-input:checked~.sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
}

.sidebar {
    min-width: 230px;
    width: fit-content;
    background: #ffffff;
    /* border-right: 2px solid #e8ecf1; */
    display: flex;
    flex-direction: column;
    position: fixed;
    /* fixed에서 sticky로 변경 */
    top: var(--sidebar-offset);
    bottom: 0;
    /* 이 줄 유지 */
    left: 0;
    /* 추가 */
    height: calc(100vh - var(--sidebar-offset));
    align-self: flex-start;
    max-height: none;
    overflow-y: auto;
    overflow-x: hidden;
    animation: slideInLeft 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    scrollbar-width: thin;
    scrollbar-color: #d0d0d0 #f5f5f5;
    flex-shrink: 0;
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 100;
}


@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: #f5f5f5;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #d0d0d0;
    border-radius: 10px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #b0b0b0;
}

.user-profile-card {
    border-bottom: 2px solid #e8ecf1;
    padding: 14px 16px;
    position: relative;
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* 프로필 상단: 아바타 + 정보 가로 배치 */
.user-profile-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    border: 1px solid #ddd;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.user-avatar img {
    display: block;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
}

.user-avatar svg {
    width: 100%;
    height: 100%;
}

.user-profile-info {
    flex: 1;
    min-width: 0;
}

.user-name-row {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 1px;
}

.user-name {
    font-size: 14px;
    font-weight: 700;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-settings-btn {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: none;
    color: #ff6c0f;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all 0.3s ease;
    flex-shrink: 0;
    padding: 0;
    line-height: 0;
}

.user-settings-btn:hover {
    background-color: #fbdac5;
    transform: rotate(90deg);
}

.user-id {
    font-size: 11px;
    color: #999;
}

/* 하단: 역할 + 포인트 + 로그아웃 한 줄 */
.user-profile-bottom {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid #f0f2f5;
}

.user-stat-value {
    font-size: 16px;
    font-weight: 700;
    color: #ff6c0f;
}

/* 역할 행 (포인트 아래) */
.user-profile-role-row {
    padding-top: 6px;
}

.user-role {
    font-size: 14px;
    color: #333;
}

/* 구독하기 버튼 (프로필 카드 하단) */
.btn-subscribe-block {
    display: block;
    width: 100%;
    padding: 8px 0;
    margin-top: 8px;
    border-radius: 6px;
    background: #ff6c0f;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-subscribe-block:hover {
    background: #e55d0a;
}

.btn-logout-sm {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid #e8ecf1;
    background: #fff;
    color: #999;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    padding: 0;
}

.btn-logout-sm:hover {
    background: #f5f5f5;
    color: #ef4444;
    border-color: #ef4444;
}

.sidebar-close-btn {
    display: none;
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background-color: #ffffff;
    border: 1px solid rgba(255, 108, 15, 0.2);
    color: #ff6c0f;
    cursor: pointer;
    z-index: 10;
    transition: all 0.3s ease;
    align-items: center;
    justify-content: center;
}

.sidebar-close-btn:hover {
    background-color: #ff6c0f;
    color: #ffffff;
    transform: rotate(90deg);
}

.sidebar-close-btn svg {
    display: block;
    width: 18px;
    height: 18px;
}

.channel-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.channel-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid #fff;
    box-shadow: 0 4px 12px rgba(255, 108, 15, 0.2);
    flex-shrink: 0;
}

.channel-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.channel-details {
    flex: 1;
    min-width: 0;
}

.channel-name {
    font-size: 15px;
    font-weight: 700;
    color: #333;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.channel-id {
    font-size: 12px;
    color: #656565;
}

.sidebar-nav {
    flex: 1;
    /* padding: 8px 0; */
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 30px;
}

.nav-section {
    /* margin-bottom: 4px; */
    animation: fadeInUp 0.6s ease backwards;
    border-bottom: 1px solid #ddd;

}

.nav-section:nth-child(1) {
    animation-delay: 0.1s;
}

.nav-section:nth-child(2) {
    animation-delay: 0.15s;
}

.nav-section:nth-child(3) {
    animation-delay: 0.2s;
}

.nav-section:nth-child(4) {
    animation-delay: 0.25s;
}

.nav-section:nth-child(5) {
    animation-delay: 0.3s;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.nav-category {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px 4px;
    font-size: 11px;
    font-weight: 700;
    color: #ff6c0f;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-category svg {
    color: #ff6c0f;
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-category span {
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-items {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    text-decoration: none;
    color: #656565;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    white-space: nowrap;
    border-radius: 0;
}

.nav-item svg {
    flex-shrink: 0;
    transition: all 0.3s ease;
    width: 24px;
    height: 24px;
}

.nav-item svg .st0 {
    fill: transparent;
    stroke-width: 2.9px;
}

.nav-item span {
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-item:hover {
    background-color: #fff5ed;
    color: #ff6c0f;
    padding-left: 24px;
    text-decoration: none;
}

.nav-item:hover svg {
    color: #ff6c0f;
}

.nav-item:hover svg .st0 {
    stroke: #ff6c0f;
}

.nav-item.active svg .st0 {
    stroke: #ff6c0f;
}

.nav-item.active {
    background: rgba(255, 108, 15, 0.12);
    color: #ff6c0f;
    font-weight: 600;
    border-left: 3px solid #ff6c0f;
    padding-left: 17px;
}

/* .nav-item.active::after {
    content: '';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    background: #ff6c0f;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(255, 108, 15, 0.6);
} */

.nav-item.active svg {
    color: #ff6c0f;
    transform: scale(1.1);
}

.nav-item.active:hover {
    background: rgba(255, 108, 15, 0.15);
    padding-left: 20px;
}

/* ============================================
   반응형 (학생관리 기준)
   ============================================ */
@media (max-width: 768px) {

    /* 토글 버튼과 오버레이 표시 */
    .sidebar-toggle-btn {
        display: flex;
    }

    .sidebar-overlay {
        display: block;
    }

    /* 사이드바를 고정 위치로 변경하고 화면 밖으로 숨김 */
    .sidebar {
        position: fixed;
        top: var(--sidebar-offset);
        left: 0;
        height: calc(100vh - var(--sidebar-offset));
        min-width: 280px;
        width: 280px;
        z-index: 1000;
        transform: translateX(-100%);
        animation: none;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    }

    /* 체크박스 체크 시 사이드바 열림 */
    .sidebar-toggle-input:checked~.sidebar {
        transform: translateX(0);
    }

    /* 사이드바 닫기 버튼 표시 */
    .sidebar-close-btn {
        display: flex;
        opacity: 0;
        pointer-events: none;
    }

    .sidebar-toggle-input:checked~.sidebar .sidebar-close-btn {
        opacity: 1;
        pointer-events: auto;
    }

    .sidebar-close-btn:hover {
        background-color: #ff6c0f;
        color: #ffffff;
        transform: rotate(90deg);
    }

    .sidebar-close-btn svg {
        display: block;
        width: 18px;
        height: 18px;
    }

    /* 데스크톱 접기 버튼 완전히 숨기기 */
    .sidebar-collapse-btn,
    .sidebar-collapse-btn-external {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .sidebar {
        min-width: 260px;
        width: 260px;
    }
}

@media (max-width: 360px) {
    .sidebar {
        min-width: 240px;
        width: 240px;
    }
}

/* ============================================
   데스크톱 사이드바 접기/펼치기 (버튼 외부 배치)
   ============================================ */

/* 데스크톱 접기용 체크박스 (숨김) */
.sidebar-collapse-input {
    display: none;
}

/* 데스크톱 접기 버튼 - 기본 상태 (펼쳐진 상태) */
.sidebar-collapse-btn {
    display: none;
    position: absolute;
    top: 2px;
    right: 0;
    width: 28px;
    height: 40px;
    border-radius: 10px 0 0 10px;
    background-color: #ff6c0f;
    border: none;
    color: #fff;
    cursor: pointer;
    z-index: 10;
    transition: all 0.3s ease;
    align-items: center;
    justify-content: center;
}

.sidebar-collapse-btn:hover {
    width: 40px;
}

.sidebar-collapse-btn svg {
    display: block;
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
}

/* 데스크톱에서 접기 버튼 표시 */
@media (min-width: 769px) {
    .sidebar-collapse-btn {
        display: flex;
    }
}

/* 접힌 사이드바 상태 */
@media (min-width: 769px) {
    .sidebar-collapse-input:checked~.main-layout .main-content {
        margin-left: 80px;
        /* 접힌 사이드바 너비 */
        transition: margin-left 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .main-content {
        margin-left: 230px;
        transition: margin-left 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .sidebar-collapse-input:checked~.sidebar {
        min-width: 80px;
        width: 80px;
        overflow-x: hidden;
        overflow-y: auto;
        transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    }

    /* 접힌 상태에서 접기 버튼 - 사이드바 외부 오른쪽에 배치 */
    .sidebar-collapse-input:checked~.sidebar .sidebar-collapse-btn {
        position: absolute;
        top: 12px;
        right: -40px;
        width: 28px;
        height: 28px;
        transition: all 0.3s ease;
    }

    .sidebar-collapse-input:checked~.sidebar .sidebar-collapse-btn svg {
        width: 16px;
        height: 16px;
        transform: rotate(180deg);
    }

    /* 접힌 상태에서 텍스트 숨기기 및 크기 조정 - 애니메이션 추가 */
    .sidebar-collapse-input:checked~.sidebar .user-profile-card {
        padding: 10px 8px;
    }

    .sidebar-collapse-input:checked~.sidebar .user-profile-info,
    .sidebar-collapse-input:checked~.sidebar .user-profile-bottom,
    .sidebar-collapse-input:checked~.sidebar .user-profile-role-row,
    .sidebar-collapse-input:checked~.sidebar .btn-subscribe-block {
        display: none;
    }

    .sidebar-collapse-input:checked~.sidebar .user-profile-row {
        justify-content: center;
        margin-bottom: 0;
    }

    .sidebar-collapse-input:checked~.sidebar .user-avatar {
        margin: 0 auto;
        width: 36px;
        height: 36px;
    }

    .sidebar-collapse-input:checked~.sidebar .nav-category span,
    .sidebar-collapse-input:checked~.sidebar .nav-item span {
        opacity: 0;
        transition: opacity 0.3s ease;
        display: none;
    }

    .sidebar-collapse-input:checked~.sidebar .nav-category {
        justify-content: center;
        padding: 10px 10px 8px;
        transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .sidebar-collapse-input:checked~.sidebar .nav-item {
        justify-content: center;
        padding: 12px 0;
        min-height: 48px;
        transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    }

    /* active 표시 유지 (왼쪽 바 - box-shadow로 처리하여 가운데 정렬 유지) */
    .sidebar-collapse-input:checked~.sidebar .nav-item.active {
        box-shadow: inset 3px 0 0 #ff6c0f;
        background: rgba(255, 108, 15, 0.12);
    }

    /* 호버 효과 */
    .sidebar-collapse-input:checked~.sidebar .nav-item:not(.active):hover {
        padding-left: 0;
    }

    .sidebar-collapse-input:checked~.sidebar .nav-item.active:hover {
        background: rgba(255, 108, 15, 0.15);
    }

    .sidebar-collapse-input:checked~.sidebar .nav-item svg,
    .sidebar-collapse-input:checked~.sidebar .nav-category svg {
        width: 22px;
        height: 22px;
    }

    /* 접힌 사이드바 툴팁 */
    .sidebar-collapse-input:checked~.sidebar .nav-item,
    .sidebar-collapse-input:checked~.sidebar .nav-category {
        position: relative;
    }

    .sidebar-collapse-input:checked~.sidebar .nav-item::before,
    .sidebar-collapse-input:checked~.sidebar .nav-category::before {
        content: attr(data-tooltip);
        position: absolute;
        left: 100%;
        top: 50%;
        transform: translateY(-50%);
        margin-left: 12px;
        padding: 8px 14px;
        background: #333;
        color: #fff;
        border-radius: 8px;
        font-size: 13px;
        font-weight: 600;
        white-space: nowrap;
        opacity: 0;
        pointer-events: none;
        transition: all 0.3s ease;
        z-index: 1000;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    }

    /* 툴팁 화살표 */
    .sidebar-collapse-input:checked~.sidebar .nav-item:hover::before,
    .sidebar-collapse-input:checked~.sidebar .nav-category:hover::before {
        opacity: 1;
    }

    /* active 아이템은 툴팁 표시 안함 (선택사항) */
    .sidebar-collapse-input:checked~.sidebar .nav-item.active::before {
        display: none;
    }
}

/* 사이드바 펼치기 버튼 (기존 스타일 사용) */
.sidebar-expand-btn {
    display: none !important;
}

/* 접힌 상태에서 접기 버튼을 사이드바 밖으로 완전히 이동 */
@media (min-width: 769px) {

    /* 기존 사이드바 내부 버튼 숨기기 */
    .sidebar-collapse-input:checked~.main-layout .sidebar .sidebar-collapse-btn {
        display: none;
    }

    /* 새로운 외부 접기 버튼 (접힌 상태에서만 표시) */
    .sidebar-collapse-btn-external {
        display: none;
        position: fixed;
        left: 80px;
        top: calc(var(--sidebar-offset) + 2px);
        width: 28px;
        height: 40px;
        border-radius: 0px 10px 10px 0px;
        background-color: #ff6c0f;
        border: none;
        color: #fff;
        cursor: pointer;
        z-index: 1001;
        transition: all 0.3s ease;
        align-items: center;
        justify-content: center;
        opacity: 0;
        pointer-events: none;
        transform: scale(0.8);
    }

    .sidebar-collapse-input:checked~.main-layout .sidebar-collapse-btn-external {
        display: flex;
        opacity: 1;
        pointer-events: auto;
        transform: scale(1);
    }

    .sidebar-collapse-btn-external:hover {
        width: 40px;
    }

    .sidebar-collapse-btn-external svg {
        display: block;
        width: 20px;
        height: 20px;
    }
}

/* 구분선 */
.nav-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, #e8ecf1, transparent);
    margin: 12px 0;
}

/* 사이드바 접힌 상태에서 구분선 숨기기 */
.sidebar-collapse-input:checked~.sidebar .nav-divider {
    margin: 8px auto;
    width: 30px;
    background: #e8ecf1;
}

/* 계정 타입별 조건부 메뉴: JS 처리 전 노출 방지 (초기 숨김) */
.sidebar-menu-academy,
.sidebar-menu-teacher,
.sidebar-menu-student,
.sidebar-menu-creator,
.sidebar-menu-relation,
.sidebar-menu-shop,
#sidebarContentRevenueLink {
    display: none;
}