/**
 * 🏥 ForNurse EMR - Sidebar Accordion Styles v1.0
 * 
 * 좌측 사이드바 아코디언 메뉴 시스템
 * - 280px 고정 폭
 * - 싱글 오픈 방식 (한 번에 하나의 섹션만 열림)
 * - 부드러운 transition 효과
 * - 3단계 계층: Section → Item → Submenu
 */

/* ========================================
   1) 기본 레이아웃
======================================== */

.emr-sidebar {
    width: 280px;
    min-width: 280px;
    max-width: 280px;
    background: #ffffff;
    border-right: 1px solid #e5e7eb;
    overflow-y: auto;
    overflow-x: hidden;
}

.menu-tree {
    padding: 16px 0;
}

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

/* ========================================
   2) 섹션 헤더 (아코디언 토글)
======================================== */

.menu-section {
    margin-bottom: 4px;
}

.section-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    position: relative;
}

.section-header:hover {
    background-color: #f9fafb;
}

.section-header i:first-child {
    font-size: 16px;
    width: 20px;
    margin-right: 10px;
    color: #6b7280;
    flex-shrink: 0;
}

.section-header span {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    letter-spacing: -0.01em;
}

.section-toggle {
    font-size: 12px !important;
    width: 16px !important;
    margin-right: 0 !important;
    margin-left: auto !important;
    color: #9ca3af !important;
    transition: transform 0.25s ease;
}

/* 섹션 열림 상태 */
.menu-section.open .section-toggle {
    transform: rotate(180deg);
}

.menu-section.open .section-header {
    background-color: #f3f4f6;
}

.menu-section.open .section-header span {
    color: #111827;
}

/* ========================================
   3) 섹션 아이템 컨테이너
======================================== */

.section-items {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, opacity 0.2s ease;
    opacity: 0;
}

.menu-section.open .section-items {
    max-height: 2000px; /* 충분히 큰 값 */
    opacity: 1;
    transition: max-height 0.4s ease-in, opacity 0.3s ease 0.1s;
}

/* ========================================
   4) 메뉴 아이템 (기본)
======================================== */

.menu-item {
    display: flex;
    align-items: center;
    padding: 10px 16px 10px 46px; /* 좌측 들여쓰기 46px */
    cursor: pointer;
    font-size: 13px;
    color: #4b5563;
    transition: all 0.15s ease;
    position: relative;
    border-left: 3px solid transparent;
}

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

.menu-item span {
    flex: 1;
}

.menu-item i {
    font-size: 14px;
    width: 16px;
    margin-right: 8px;
    color: #9ca3af;
    flex-shrink: 0;
}

/* Active 상태 */
.menu-item.active {
    background-color: #eff6ff;
    color: #1e40af;
    font-weight: 500;
    border-left-color: #3b82f6;
}

.menu-item.active i {
    color: #3b82f6;
}

/* ========================================
   5) 서브섹션 타이틀 (중간 계층)
======================================== */

.menu-item.subsection-title {
    padding: 8px 16px 8px 46px;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 8px;
    cursor: default;
    pointer-events: none;
}

.menu-item.subsection-title:hover {
    background-color: transparent;
}

.menu-item.subsection-title i {
    font-size: 13px;
    color: #9ca3af;
}

/* ========================================
   6) 서브메뉴 아이템 (3단계 계층)
======================================== */

.menu-item.submenu-item {
    padding-left: 62px; /* 추가 들여쓰기 */
    font-size: 13px;
}

.menu-item.submenu-item::before {
    content: '';
    position: absolute;
    left: 52px;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background-color: #d1d5db;
    transition: all 0.15s ease;
}

.menu-item.submenu-item:hover::before {
    background-color: #9ca3af;
}

.menu-item.submenu-item.active::before {
    background-color: #3b82f6;
    width: 6px;
    height: 6px;
}

/* ========================================
   7) 배지 & 알림
======================================== */

.badge-alert {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    font-size: 11px;
    font-weight: 700;
    border-radius: 50%;
    margin-left: 8px;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

/* ========================================
   8) 외상센터 전용 메뉴
======================================== */

.menu-item.trauma-only {
    padding-left: 16px;
    margin-top: 8px;
    border-top: 1px solid #e5e7eb;
    padding-top: 16px;
}

/* ========================================
   9) 스크롤바 스타일
======================================== */

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

.emr-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.emr-sidebar::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.emr-sidebar::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* ========================================
   10) 반응형 (모바일)
======================================== */

@media (max-width: 768px) {
    .emr-sidebar {
        width: 240px;
        min-width: 240px;
        max-width: 240px;
    }
    
    .section-header {
        padding: 10px 12px;
    }
    
    .menu-item {
        padding: 8px 12px 8px 38px;
        font-size: 12px;
    }
    
    .menu-item.submenu-item {
        padding-left: 50px;
    }
}

/* ========================================
   11) 애니메이션
======================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.menu-section.open .section-items > .menu-item {
    animation: fadeIn 0.2s ease-out;
    animation-fill-mode: both;
}

.menu-section.open .section-items > .menu-item:nth-child(1) {
    animation-delay: 0.02s;
}

.menu-section.open .section-items > .menu-item:nth-child(2) {
    animation-delay: 0.04s;
}

.menu-section.open .section-items > .menu-item:nth-child(3) {
    animation-delay: 0.06s;
}

.menu-section.open .section-items > .menu-item:nth-child(4) {
    animation-delay: 0.08s;
}

.menu-section.open .section-items > .menu-item:nth-child(5) {
    animation-delay: 0.1s;
}

/* ========================================
   12) 디버깅 & 개발용
======================================== */

/* 디버깅 시 섹션 경계 확인 */
.debug .menu-section {
    outline: 1px solid rgba(255, 0, 0, 0.2);
}

.debug .menu-item {
    outline: 1px solid rgba(0, 0, 255, 0.2);
}
