/* 메인 레이아웃 */
.main {
    display: flex;
    min-height: 100vh;
}

.main__container {
    display: flex;
    flex: 1;
    height: 100vh;
}

/* 사이드바 기본 스타일 */
.main__sidebar {
    display: flex;
    flex-direction: column;
    width: 6.4rem;
    background-color: #f8f9fa;
    border-right: 1px solid #e5e7eb;
    transition: width 0.2s ease;
    position: relative;
    z-index: 1000;
    height: 100vh;
    height: 100dvh; /* 동적 뷰포트 높이 사용 (모바일 지원) */
    overflow: hidden;
    min-height: 100vh;
    min-height: 100dvh; /* 동적 뷰포트 높이 사용 (모바일 지원) */
    /* 모바일에서 주소창이 스크롤 시 사라지는 경우를 대비 */
    position: fixed;
    /* 모바일에서 하단 노치 영역 확보 */
    padding-bottom: env(safe-area-inset-bottom);
}

/* 로고 스타일 */
.main__logo {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: 0.5rem 0.5rem 0.5rem 0.7rem;
    margin-bottom: 0.5rem;
    width: 100%;
    flex-shrink: 0;
    position: relative;
    height: 4.2rem;
    /* 핀 버튼을 포함한 안전 영역 확장 */
    transition: all 0.2s ease;
}

/* 로고 영역이 확장될 때 핀 버튼을 포함한 전체 영역을 안전하게 확장 */
.main__sidebar:hover .main__logo,
.main__sidebar.pinned .main__logo {
    padding-right: 3rem; /* 핀 버튼을 위한 공간 확보 */
}

.main__logo img {
    width: 4.5rem;
    height: 4.5rem;
    object-fit: contain;
}

/* 구분선 스타일 */
.main__divider {
    width: calc(100% - 1rem);
    height: 1px;
    background-color: rgba(229, 231, 235, 0.2);
    margin: 0 auto;
}

/* 메뉴 아이템 스타일 */
.main__menu-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3.5rem 0.5rem;
    cursor: pointer;
    transition: color 0.15s ease;
    position: relative;
    white-space: nowrap;
    color: #374151;
    font-size: 1.4rem;
    width: 100%;
    max-width: 6.4rem;
    height: 6.4rem;
    flex-shrink: 0;
    background-color: transparent;
    overflow: hidden;
}

.main__menu-item:hover,
.main__menu-item.active {
    overflow: visible;
    color: #111827;
}

/* Pin 버튼 스타일 */
.main__pin-btn {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding-top: 0.3rem;
    width: 3.2rem;
    height: 3.2rem;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: none;
    opacity: 0;
    z-index: 1001;
    pointer-events: auto;
}

.main__pin-btn .material-symbols-outlined {
    font-size: 1.8rem;
    color: #6b7280;
    transition: all 0.2s ease;
}

.main__pin-btn:hover {
    background-color: rgba(229, 231, 235, 0.5);
}

.main__pin-btn:hover .material-symbols-outlined {
    color: #374151;
}

/* Pin 버튼 표시 조건 단순화 - 안정적인 표시를 위해 */
.main__sidebar:hover .main__pin-btn,
.main__sidebar.pinned .main__pin-btn {
    display: block;
    opacity: 1;
}

/* 핀 버튼 자체에 hover 상태 추가 */
.main__pin-btn:hover {
    display: block !important;
    opacity: 1 !important;
    background-color: rgba(229, 231, 235, 0.5);
}

/* 사이드바 고정 상태 */
.main__sidebar.pinned {
    width: 22rem;
}

/* 사이드바가 펼쳐질 때 로고 영역 스타일 */
/* 로고 스타일 통합 - 고정 및 hover 상태에서 동일한 스타일 적용 */
.main__sidebar.pinned .main__logo,
.main__sidebar:hover .main__logo {
    width: 100%;
    justify-content: space-between;
}

.main__sidebar.pinned .main__pin-btn .material-symbols-outlined {
    color: #3b82f6;
}

/* hover 시 로고 스타일 (중복 제거) */

/* 다크 모드에서 Pin 버튼 스타일 */
@media (prefers-color-scheme: dark) {
    .main__pin-btn .material-symbols-outlined {
        color: #6b7280;
    }

    .main__pin-btn:hover {
        background-color: rgba(75, 85, 99, 0.5);
    }

    .main__pin-btn:hover .material-symbols-outlined {
        color: #d1d5db;
    }

    .main__sidebar.pinned .main__pin-btn .material-symbols-outlined {
        color: #60a5fa;
    }
}

/* 아이콘 스타일 */
.main__menu-item .material-symbols-outlined {
    font-size: 2.4rem;
    flex-shrink: 0;
    width: 3.2rem;
    height: 3.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    z-index: 0;
}

.main__menu-item:hover .material-symbols-outlined,
.main__menu-item.active .material-symbols-outlined {
    transform: translate(-50%, -50%) scale(1.15);
    color: #bfdbfe;
    filter: drop-shadow(0 0 2.5rem rgba(191, 219, 254, 1))
        drop-shadow(0 0 1rem rgba(191, 219, 254, 0.8));
    animation: glow-pulse 1.5s ease-in-out infinite;
}

/* 메뉴 텍스트 스타일 */
.main__menu-text {
    position: absolute;
    bottom: 0.5rem;
    left: 50%;
    transform: translateX(-50%);
    opacity: 1;
    font-size: 1.1rem;
    font-weight: 400;
    color: #1f2937;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    z-index: 1;
}

/* 서브메뉴 스타일 */
.main__submenu {
    position: fixed;
    left: 6.4rem;
    top: 0rem;
    width: 15.6rem;
    height: 100%;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 999;
    padding: 0;
    cursor: auto;
    pointer-events: none;
    padding-top: 7rem;
}

/* 서브메뉴 표시 스타일 (hover 및 터치/클릭 공통) */
.main__menu-item.has-submenu:hover .main__submenu,
.main__menu-item.has-submenu.submenu-open .main__submenu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* 서브메뉴 활성화 시 메뉴 아이템 스타일 */
.main__menu-item.has-submenu.submenu-open {
    color: #111827;
}

.main__submenu-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0.5rem 1.25rem;
    background-color: transparent;
    width: 100%;
    box-sizing: border-box;
}

.main__submenu-title {
    padding: 0.75rem 1rem;
    font-size: 1.3rem;
    font-weight: 400;
    color: #6b7280;
    cursor: default;
    transition: all 0.15s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-radius: 0.4rem;
    margin-bottom: 0.25rem;
}

.main__submenu-content {
    padding: 0.5rem 1.25rem;
}

.main__submenu-item {
    padding: 0.75rem 1rem;
    font-size: 1.3rem;
    color: #374151;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-radius: 0.4rem;
    margin-bottom: 0.25rem;
}

.main__submenu-item:hover,
.main__submenu-item.active {
    background-color: #e5e7eb;
    color: #111827;
}

/* 콘텐츠 영역 */
.main__content {
    flex: 1;
    padding: 2rem;
    background-color: white;
    overflow-y: auto;
}

/* 광원 애니메이션 효과 (통합) */
@keyframes glow-pulse {
    0%,
    100% {
        filter: drop-shadow(0 0 2.5rem rgba(59, 130, 246, 1))
            drop-shadow(0 0 1rem rgba(59, 130, 246, 0.8));
    }
    50% {
        filter: drop-shadow(0 0 3rem rgba(59, 130, 246, 1))
            drop-shadow(0 0 1.5rem rgba(59, 130, 246, 0.9));
    }
}

/* 다크 모드에서 색상만 변경 */
@media (prefers-color-scheme: dark) {
    .main__menu-item:hover .material-symbols-outlined {
        color: #bfdbfe;
        filter: drop-shadow(0 0 2.5rem rgba(191, 219, 254, 1))
            drop-shadow(0 0 1rem rgba(191, 219, 254, 0.8));
        animation: glow-pulse 1.5s ease-in-out infinite;
    }

    .main__bottom-menu-item:hover .material-symbols-outlined {
        color: #bfdbfe;
        filter: drop-shadow(0 0 2.5rem rgba(191, 219, 254, 1))
            drop-shadow(0 0 1rem rgba(191, 219, 254, 0.8));
        animation: glow-pulse 1.5s ease-in-out infinite;
    }
}

/* 사이드바 내비게이션 스타일 */
.main__sidebar-nav {
    display: flex;
    flex-direction: column;
    padding: 0.5rem 0;
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: hidden;
    width: 100%;
    height: 100%;
    /* iOS 모바일 스크롤 동작 개선 */
    -webkit-overflow-scrolling: touch;
    /* 모바일에서 스크롤이 잘 동작하도록 함 */
    overscroll-behavior-y: contain;
}

/* 동적 메뉴 컨테이너 스타일 */
.main__dynamic-menu {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: hidden;
    /* iOS 모바일 스크롤 동작 개선 */
    -webkit-overflow-scrolling: touch;
    /* 모바일에서 스크롤이 잘 동작하도록 함 */
    overscroll-behavior-y: contain;
}

/* 사이드바 하단 고정 메뉴 스타일 */

.main__bottom-menu {
    display: flex;
    flex-direction: column;
    padding: 0.5rem 0;
    padding-bottom: max(
        0.5rem,
        env(safe-area-inset-bottom)
    ); /* 모바일 기기 하단 노치 영역 확보 */
    flex-shrink: 0;
    margin-top: auto;
    position: sticky;
    bottom: 0;
    background-color: #f8f9fa;
}

.main__bottom-menu-item {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem 0.5rem;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
    white-space: nowrap;
    color: #374151;
    font-size: 1.4rem;
    width: 100%;
    max-width: 6.4rem;
    height: 6.4rem;
    flex-shrink: 0;
    background-color: transparent;
    overflow: hidden;
}

.main__bottom-menu-item:hover {
    overflow: visible;
}

.main__bottom-menu-item:hover {
    color: #111827;
}

/* 프로필 팝업 관련 스타일 제거됨 */

.main__bottom-menu-item .material-symbols-outlined {
    font-size: 2.4rem;
    flex-shrink: 0;
    width: 3.2rem;
    height: 3.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* 알림 아이콘 크기 조정 */
#notification-icon .material-symbols-outlined {
    font-size: 1.8rem;
    width: 2.6rem;
    height: 2.6rem;
}

/* 프로필 아이콘 크기 조정 */
#profile-icon .material-symbols-outlined {
    font-size: 3.4rem;
    width: 4.2rem;
    height: 4.2rem;
}

.main__bottom-menu-item:hover .material-symbols-outlined {
    transform: scale(1.15);
    color: #bfdbfe;
    filter: drop-shadow(
        0 0 2.5rem rgba(191, 219, 254, 1),
        0 0 1rem rgba(191, 219, 254, 0.8)
    );
    animation: glow-pulse 1.5s ease-in-out infinite;
}

/* 알림 배지 스타일 */
.main__notification-badge {
    position: absolute;
    top: 0.8rem;
    right: 0.8rem;
    background-color: #ef4444;
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    min-width: 1.8rem;
    height: 1.8rem;
    border-radius: 50%;
    display: none; /* 기본적으로 숨김 */
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0 0.4rem;
    box-shadow:
        0 0 0 0.2rem white,
        0 0.3rem 0.5rem rgba(0, 0, 0, 0.15);
}

/* 프로필 드롭다운 메뉴 스타일 - 독립적인 구성 */
.main__profile-dropdown {
    position: fixed;
    width: 30rem;
    max-height: 80vh;
    overflow-y: auto;
    background-color: white;
    border-radius: 0.8rem;
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(229, 231, 235, 0.8);
    opacity: 0;
    visibility: hidden;
    transform: translateY(0.5rem);
    transition: all 0.2s ease;
    z-index: 1001;
    pointer-events: none;
}

.main__profile-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

/* 프로필 헤더 스타일 */
.main__profile-header {
    display: flex;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #e5e7eb;
}

.main__profile-avatar {
    width: 4.8rem;
    height: 4.8rem;
    border-radius: 50%;
    background-color: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 1.2rem;
    flex-shrink: 0;
}

.main__profile-avatar .material-symbols-outlined {
    font-size: 3.2rem;
    color: #6b7280;
}

.main__profile-info {
    flex: 1;
    overflow: hidden;
}

.main__profile-name-role {
    display: flex;
    align-items: center;
    margin-bottom: 0.4rem;
}

.main__profile-name {
    font-size: 1.6rem;
    font-weight: 600;
    color: #111827;
    margin-right: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

.main__profile-role {
    font-size: 1.2rem;
    font-weight: 500;
    color: white;
    padding: 0.2rem 0.8rem;
    border-radius: 10rem;
    background-color: #3b82f6;
    white-space: nowrap;
    display: inline-block;
    line-height: 1.4;
}

.main__profile-email {
    font-size: 1.4rem;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 프로필 메뉴 스타일 */
.main__profile-menu {
    padding: 0.5rem;
}

.main__profile-menu-item {
    display: flex;
    align-items: center;
    padding: 1rem 1.2rem;
    border-radius: 0.6rem;
    cursor: pointer;
    transition: background-color 0.15s ease;
    margin-bottom: 0.3rem;
}

.main__profile-menu-item:hover {
    background-color: #f3f4f6;
}

.main__profile-menu-item:last-child {
    margin-bottom: 0;
}

.main__profile-menu-item .material-symbols-outlined {
    font-size: 2rem;
    color: #6b7280;
    margin-right: 1.2rem;
    flex-shrink: 0;
    transition: color 0.15s ease;
}

.main__profile-menu-item:hover .material-symbols-outlined {
    color: #3b82f6;
}

.main__profile-menu-item span:not(.material-symbols-outlined) {
    font-size: 1.5rem;
    color: #374151;
}

/* 프로필 메뉴 구분선 */
.main__profile-divider {
    height: 1px;
    background-color: #e5e7eb;
    margin: 0.5rem 1rem;
}

/* 다크 모드에서 프로필 드롭다운 메뉴 스타일 */
@media (prefers-color-scheme: dark) {
    .main__profile-dropdown {
        background-color: #1f2937;
        border-color: #374151;
    }

    .main__profile-header {
        border-bottom-color: #374151;
    }

    .main__profile-avatar {
        background-color: #374151;
    }

    .main__profile-avatar .material-symbols-outlined {
        color: #9ca3af;
    }

    .main__profile-name {
        color: #f9fafb;
    }

    .main__profile-name-role .main__profile-role {
        background-color: #60a5fa;
    }

    .main__profile-email {
        color: #9ca3af;
    }

    .main__profile-menu-item:hover {
        background-color: #374151;
    }

    .main__profile-menu-item .material-symbols-outlined {
        color: #9ca3af;
    }

    .main__profile-menu-item:hover .material-symbols-outlined {
        color: #60a5fa;
    }

    .main__profile-menu-item span:not(.material-symbols-outlined) {
        color: #d1d5db;
    }

    .main__profile-divider {
        background-color: #374151;
    }
}

/* 하단 메뉴 텍스트 스타일 */
.main__bottom-menu-item::after {
    content: attr(data-text);
    position: absolute;
    bottom: 0.5rem;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    font-size: 1.1rem;
    font-weight: 400;
    color: #1f2937;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    max-width: 6.4rem;
    z-index: 1;
    transition: opacity 0.15s ease;
}

/* 다크 모드 지원 */
@media (prefers-color-scheme: dark) {
    .main__sidebar {
        background-color: #1f2937;
        border-color: #374151;
    }

    .main__bottom-menu {
        background-color: #1f2937;
        padding-bottom: max(
            0.5rem,
            env(safe-area-inset-bottom)
        ); /* 모바일 기기 하단 노치 영역 확보 (다크 모드) */
    }

    .main__menu-item {
        color: #d1d5db;
    }

    .main__menu-text {
        color: #9ca3af;
    }

    .main__menu-item:hover,
    .main__menu-item.active {
        color: #f9fafb;
    }

    .main__menu-item:hover .material-symbols-outlined {
        filter: drop-shadow(0 0 2.5rem rgba(96, 165, 250, 1))
            drop-shadow(0 0 1rem rgba(96, 165, 250, 0.8));
        animation: glow-pulse 1.5s ease-in-out infinite;
    }

    /* 터치/클릭으로 열린 서브메뉴 다크 모드 스타일 */
    .main__menu-item.has-submenu.submenu-open {
        color: #f9fafb;
    }

    .main__submenu-item {
        color: #d1d5db;
    }

    .main__submenu-item:hover,
    .main__submenu-item.active {
        background-color: #374151;
        color: #f9fafb;
    }

    .main__content {
        background-color: #111827;
        color: #f9fafb;
    }

    /* 하단 메뉴 구분선은 main__divider 클래스를 통해 처리되므로 제거 */

    .main__bottom-menu-item {
        color: #d1d5db;
    }

    .main__bottom-menu-item:hover {
        color: #f9fafb;
    }

    .main__bottom-menu-item:hover .material-symbols-outlined {
        filter: drop-shadow(0 0 2.5rem rgba(96, 165, 250, 1))
            drop-shadow(0 0 1rem rgba(96, 165, 250, 0.8));
        animation: glow-pulse 1.5s ease-in-out infinite;
    }

    .main__notification-badge {
        box-shadow:
            0 0 0 0.2rem #1f2937,
            0 0.3rem 0.5rem rgba(0, 0, 0, 0.3);
    }

    .main__bottom-menu-item::after {
        color: #9ca3af;
    }
}
