/* ===== Collapsible Sidebar CSS - Magic MCP Design ===== */
/* Magic MCP 디자인 기반 + 네이버 스마트스토어 스타일 */
/* Phase 2.7 성능 최적화: CSS containment, will-change 최적화 */

/* =========================== */
/* 사이드바 컨테이너 */
/* =========================== */

.sidebar-new {
    width: var(--sidebar-width);  /* ✅ Phase 2.7.16: 변수 사용으로 변경 */
    background: #2c3e50;
    color: #ffffff;
    transition: width 0.3s ease-in-out;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100vh;  /* ✅ Phase 2.7.8: 전체 높이 채우기 */
    position: relative;

    /* ✅ 성능 최적화: CSS containment */
    contain: layout style;

    /* 하드웨어 가속 */
    will-change: width;
    transform: translateZ(0);
}

.sidebar-new.collapsed {
    width: var(--sidebar-width-collapsed);  /* ✅ Phase 2.7.16: 변수 사용으로 변경 */
}

/* ✅ Phase 2.7.16: expanded 상태 명시적 정의 (변수 사용) */
.sidebar-new.expanded {
    width: var(--sidebar-width);
}

/* =========================== */
/* 헤더 영역 */
/* =========================== */

.sidebar-header-new {
    padding: 16px;
    background: #34495e;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 60px;
    flex-shrink: 0;
}

.sidebar-title {
    font-size: 13px;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
    transition: opacity 0.15s ease, visibility 0.15s ease;
}

.sidebar-title.hidden {
    opacity: 0;
    visibility: hidden;
    width: 0;
}

.sidebar-toggle-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #ffffff;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    font-size: 14px;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.sidebar-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* 축소 시 버튼 중앙 정렬 */
.sidebar-new.collapsed .sidebar-header-new {
    justify-content: center;
    padding: 16px 0;
}

/* =========================== */
/* 네비게이션 영역 */
/* =========================== */

.sidebar-nav-new {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* 스크롤바 스타일 */
.sidebar-nav-new::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav-new::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

.sidebar-nav-new::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.sidebar-nav-new::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* =========================== */
/* 메뉴 리스트 */
/* =========================== */

.menu-list-new {
    list-style: none;
    padding: 8px 0;
    margin: 0;
}

.menu-item-new {
    position: relative;
}

/* =========================== */
/* 메뉴 링크/버튼 */
/* =========================== */

.menu-link-new {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: background 0.2s ease, color 0.2s ease, border-left-color 0.2s ease;
    cursor: pointer;
    border: none;
    border-left: 3px solid transparent;
    background: none;
    width: 100%;
    text-align: left;
    font-size: 12px;
}

.menu-link-new:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

/* ✅ 활성 메뉴 스타일: 왼쪽 액센트 바 + 배경 + 텍스트 강조 */
/* ✅ 활성 메뉴 스타일: 왼쪽 액센트 바 + 그라디언트 배경 + 텍스트 강조 */
.menu-link-new.active {
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.45) 0%, rgba(102, 126, 234, 0.08) 100%);
    border-left-color: #818cf8;
    color: #ffffff;
    font-weight: 600;
}

/* 활성 메뉴 hover */
.menu-link-new.active:hover {
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.58) 0%, rgba(102, 126, 234, 0.14) 100%);
}

/* 활성 메뉴의 아이콘 강조 */
.menu-link-new.active .menu-icon-new {
    color: #a5b4fc;
}

/* 활성 메뉴의 부모 메뉴: 미묘한 하이라이트 */
    .menu-link-new.parent-active {
    background: rgba(102, 126, 234, 0.1);
    border-left-color: rgba(129, 140, 248, 0.5);
    color: rgba(255, 255, 255, 0.9);
}

    .menu-link-new.parent-active .menu-icon-new {
    color: #818cf8;
}

.menu-link-new.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.menu-link-new.disabled:hover {
    background: transparent;
}

/* =========================== */
/* 메뉴 아이콘 */
/* =========================== */

.menu-icon-new {
    font-size: 16px;
    width: 20px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    transition: margin 0.3s ease;
}

/* 축소 시 아이콘 중앙 정렬 */
.sidebar-new.collapsed .menu-icon-new {
    margin-right: 0;
    width: 100%;
}

/* =========================== */
/* 메뉴 라벨 */
/* =========================== */

.menu-label-new {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.15s ease, visibility 0.15s ease, width 0.15s ease;
}

/* 축소 시 라벨 숨김 */
.sidebar-new.collapsed .menu-label-new {
    opacity: 0;
    visibility: hidden;
    width: 0;
}

/* =========================== */
/* 메뉴 화살표 */
/* =========================== */

.menu-arrow-new {
    margin-left: auto;
    font-size: 12px;
    transition: transform 0.2s ease, opacity 0.15s ease;
}

.menu-item-new.open > .menu-link-new .menu-arrow-new {
    transform: rotate(90deg);
}

/* 축소 시 화살표 숨김 */
.sidebar-new.collapsed .menu-arrow-new {
    opacity: 0;
    visibility: hidden;
}

/* =========================== */
/* 배지 */
/* =========================== */

.badge-new {
    margin-left: 8px;
    padding: 2px 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    font-size: 10px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
}

/* hover 시에만 뱃지 표시 */
.menu-link-new:hover .badge-new,
.submenu-link-new:hover .badge-new,
.menu-item-new:hover > .menu-link-new > .badge-new {
    opacity: 1;
    visibility: visible;
}

/* 축소 시 뱃지 완전 숨김 */
.sidebar-new.collapsed .badge-new {
    display: none;
}

/* =========================== */
/* 서브메뉴 래퍼 (애니메이션용) */
/* =========================== */

.submenu-wrapper-new {
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    background: rgba(0, 0, 0, 0.2);
    max-height: 0; /* 기본값: 닫힘 */

    /* ✅ 성능 최적화: will-change */
    will-change: max-height;
}

/* ✅ open 클래스로 제어 (JavaScript에서 classList.toggle) */
.menu-item-new.open > .submenu-wrapper-new {
    max-height: 1000px;
}

/* =========================== */
/* 서브메뉴 */
/* =========================== */

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

/* 1단계 메뉴 */
.menu-list-new.level-1 {
    padding: 8px 0;
}

/* 2단계 메뉴 (서브메뉴) */
.menu-list-new.level-2 {
    background: rgba(0, 0, 0, 0.1);
}

/* 3단계 메뉴 (서브-서브메뉴) */
.menu-list-new.level-3 {
    background: rgba(0, 0, 0, 0.15);
}

/* 축소 시 서브메뉴 완전 숨김 */
.sidebar-new.collapsed .submenu-wrapper-new {
    display: none !important;
    max-height: 0 !important;
}

.submenu-item-new {
    position: relative;
}

/* =========================== */
/* 메뉴 링크/버튼 레벨별 패딩 */
/* =========================== */

/* 2단계 메뉴 (1depth 서브메뉴) */
.menu-item-new.level-2 > .menu-link-new {
    padding-left: 32px;
    font-size: 11px;
}

/* 3단계 메뉴 (2depth 서브메뉴) */
.menu-item-new.level-3 > .menu-link-new {
    padding-left: 48px;
    font-size: 10px;
}

/* =========================== */
/* 푸터 영역 */
/* =========================== */

.sidebar-footer-new {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    transition: padding 0.3s ease;
}

.sidebar-new.collapsed .sidebar-footer-new {
    padding: 16px 0;
    justify-content: center;
    gap: 0;
}

.sidebar-new.collapsed .user-info {
    display: none;
}

/* =========================== */
/* 사용자 아바타 */
/* =========================== */

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
    flex-shrink: 0;
}

/* =========================== */
/* 사용자 정보 */
/* =========================== */

.user-info {
    flex: 1;
    min-width: 0;
    transition: opacity 0.15s ease, visibility 0.15s ease;
}

.user-info.hidden {
    opacity: 0;
    visibility: hidden;
    width: 0;
}

.user-name {
    font-size: 12px;
    font-weight: 600;
    margin: 0 0 2px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-email {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.7);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* =========================== */
/* 축소 시 아이콘 완전 중앙 정렬 */
/* =========================== */

.sidebar-new.collapsed .menu-link-new {
    justify-content: center;
    padding: 10px 0;
    border-left: none;
}

/* 축소 시 활성 메뉴: 배경 하이라이트 + 아이콘 색상 */
/* 축소 시 활성 메뉴: 강한 배경 하이라이트 + 밝은 아이콘 */
.sidebar-new.collapsed .menu-link-new.active {
    border-left: none;
    background: rgba(102, 126, 234, 0.45);
}
.sidebar-new.collapsed .menu-link-new.active .menu-icon-new {
    color: #a5b4fc;
}

/* =========================== */
/* 접근성 개선 */
/* =========================== */

@media (prefers-reduced-motion: reduce) {
    .sidebar-new,
    .menu-arrow-new,
    .submenu-new,
    .menu-icon-new,
    .menu-label-new,
    .badge-new,
    .user-info {
        transition: none;
    }
}

/* 키보드 네비게이션을 위한 포커스 스타일 */
.menu-link-new:focus,
.submenu-link-new:focus,
.sidebar-toggle-btn:focus {
    outline: 2px solid #667eea;
    outline-offset: -2px;
}
