/* assets/css/sidebar_resize.css */

/* 1. 기본 레이아웃 - 중앙 정렬 방지 */
body, html {
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: #edf2f9;
    display: block !important; 
    text-align: left !important;
}

/* PC 화면 (Desktop) */
@media (min-width: 992px) {
    .main-container-flex {
        display: flex;
        flex-direction: row;
        justify-content: flex-start;
        align-items: stretch;
        width: 100vw;
        height: 100vh;
        overflow: hidden;
        padding: 1rem;
        gap: 1rem;
        box-sizing: border-box;
    }

    /* 2. 좌측 사이드바 */
    #sidebar-wrapper {
        width: 22rem; 
        min-width: 280px;
        max-width: 45vw;
        height: calc(100vh - 2rem);
        flex-shrink: 0;
        background-color: #fff;
        border-radius: 1rem;
        box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.05);
        display: flex;
        flex-direction: column;
        z-index: 1000;
        position: relative;
        left: 0 !important;
        top: 0 !important;
        margin: 0 !important; /* 사이드바 자체 마진 제거, main-container-flex의 padding과 gap이 제어 */
        transition: width 0.2s ease-out;
    }

    #sidebar-wrapper.collapsed {
        width: 0 !important;
        min-width: 0 !important;
        padding: 0 !important;
        margin-right: -1rem !important; /* gap 보정 */
        opacity: 0;
        overflow: hidden;
    }

    /* 사이드바 내부 컨텐츠 강제 확장 (Dash 컴포넌트 타겟팅) */
    nav.navbar-vertical {
        width: 100% !important;
        height: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        position: static !important;
    }

    .navbar-vertical-content {
        flex-grow: 1;
        overflow-y: auto;
        padding: 1rem; /* 내부 패딩 */
        width: 100% !important; /* [수정] 95%로 변경 및 강제 적용 */
        height: 100% !important;
        margin: 0 auto; /* 중앙 정렬 */
    }

    /* [추가/수정] Dash의 html.Div 및 슬라이더가 100% 너비를 차지하도록 강제 */
    .navbar-vertical-content > ul > li > .nav.collapse > .nav-item.w-100 > .nav-link > div {
        width: 100% !important;
    }
    
    .rc-slider {
        width: 100% !important; /* 슬라이더 자체 너비 강제 */
        margin: 0 auto; /* 중앙 정렬 */
    }

    /* [수정] dcc.Slider 마크 텍스트 줄바꿈 방지 및 너비 조정 */
    .rc-slider-mark-text {
        white-space: nowrap !important; /* 텍스트 줄바꿈 방지 */
        word-break: normal !important; /* 단어 중간 줄바꿈 방지 */
        padding: 0 5px; /* 양쪽에 패딩을 주어 텍스트 간 간격 확보 */
        max-width: 40px; /* 텍스트가 너무 길어지는 것을 방지 */
        font-size: 0.75rem; /* 필요시 폰트 크기 조정 */
        transform: translateX(-50%); /* 텍스트를 마크 중앙에 배치 */
        left: 50%; /* transform과 함께 사용하여 중앙 정렬 */
        position: absolute; /* 절대 위치 지정 */
    }

    /* [수정] 마크 컨테이너는 rc-slider가 위치를 제어하도록 함 */
    .rc-slider-mark {
        /* width: fit-content; min-width: 25px; 등 제거 */
        text-align: center;
        /* transform: translateX(-50%); 제거. 텍스트에 적용 */
    }

    /* 3. 리사이즈 핸들 & 토글 */
    #sidebar-resizer {
        width: 12px;
        margin-left: -6px;
        margin-right: -6px;
        cursor: col-resize;
        z-index: 1010;
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative;
    }

    #resize-toggle-btn {
        width: 20px; height: 40px;
        background-color: #fff; border: 1px solid #edf2f9; border-radius: 10px;
        box-shadow: 0 2px 5px rgba(0,0,0,0.08);
        display: flex; align-items: center; justify-content: center;
        cursor: pointer; color: #5e6e82; font-size: 10px;
        transition: all 0.2s;
        position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
    }

    #resize-toggle-btn:hover {
        background-color: #2c7be5;
        color: white;
        border-color: #2c7be5;
        transform: translate(-50%, -50%) scale(1.1);
    }

    /* 4. 우측 컨텐츠 */
    #content-wrapper {
        flex-grow: 1; min-width: 0; height: 100%;
        display: flex; flex-direction: column;
        background-color: transparent; margin: 0 !important; gap: 1rem;
    }
    
    /* [신규] Content 컨테이너 (1:6 수직 레이아웃) */
    .content {
        display: flex;
        flex-direction: column; /* row -> column 변경 */
        height: 100%;
        gap: 1rem;
        width: 100%;
    }

    /* [핵심 수정] 타이틀 바 (상단, 높이 비율 1) */
    .header-navbar-wrapper {
        flex: 1; /* 높이 비율 1 */
        height: auto;
        min-height: 0; 
        background-color: #fff;
        border-radius: 1rem;
        box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.05);
        z-index: 900;
        width: 100% !important; /* width 100% 복구 */
        overflow: hidden;
        padding: 0 !important;
    }

    /* Nav 요소가 Wrapper를 꽉 채우도록 */
    .header-navbar-wrapper nav.navbar {
        width: 100% !important;
        height: 100% !important; 
        padding: 0.75rem 1.5rem !important;
        border-radius: 1rem;
    }

    /* [핵심 수정] 메인 컨텐츠 (하단, 높이 비율 6) */
    .main-content-scroll {
        flex: 9; /* 높이 비율 6 */
        height: auto;
        overflow-y: auto;
        padding: 1.5rem;
        background-color: #fff;
        border-radius: 1rem;
        box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.05);
        width: 100% !important; /* width 100% 복구 */
    }
}

/* 모바일 대응 */
@media (max-width: 991.98px) {
    #sidebar-resizer { display: none !important; }
    .main-container-flex { display: block; height: auto; overflow-x: hidden; padding: 0; }
    
    #sidebar-wrapper {
        position: fixed; top: 0; left: 0; bottom: 0;
        width: 18rem; max-width: 80vw; height: 100vh;
        z-index: 1050; background-color: #fff;
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
        border-right: 1px solid #edf2f9;
        box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
        border-radius: 0;
    }
    
    #sidebar-wrapper.sidebar-mobile-show { transform: translateX(0); }
    
    #mobile-sidebar-overlay {
        position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
        background-color: rgba(0, 0, 0, 0.5); z-index: 1040;
        display: none; opacity: 0; transition: opacity 0.3s ease-in-out;
    }
    #mobile-sidebar-overlay.overlay-show { display: block; opacity: 1; }
    
    #content-wrapper { width: 100%; height: auto; min-height: 100vh; padding-top: 0; gap: 0; }
    
    .header-navbar-wrapper {
        position: sticky; top: 0; z-index: 1020;
        padding: 0 !important; /* 모바일은 패딩 제거 */
        background-color: #fff; border-bottom: 1px solid #edf2f9;
        display: flex; align-items: center;
        border-radius: 0; box-shadow: none;
    }

    .header-navbar-wrapper nav.navbar {
        padding: 0.5rem 1rem !important;
    }
    
    .main-content-scroll { padding: 1rem; background-color: transparent; box-shadow: none; border-radius: 0; }
}