/* ================================================================
   Sidebar Enhancement - Collapsible Sidebar with Icons
   Hedra-style toggle functionality
   - 펼침: 아이콘 + 텍스트 (14em)
   - 접힘: 아이콘만 (4em)
   - 1280px 이하: 기존 상단바 모드 유지 (토글 숨김)
   - 736px 이하: 사이드바 숨김 (기존 동작)
   ================================================================ */

/* ---- Smooth transitions ---- */
#sidebar {
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                padding 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#sidebar + #wrapper {
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#sidebar + #wrapper + #footer {
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ================================================================
   Sidebar Header (Brand + Toggle Button)
   ================================================================ */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.2em;
    padding-bottom: 0.7em;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

/* ---- Brand CI Styling ---- */
.sidebar-brand {
    font-size: 1.15em;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.25s ease, max-width 0.3s ease;
    max-width: 10em;
    line-height: 1;
    display: flex;
    align-items: baseline;
    gap: 0.05em;
    cursor: default;
    user-select: none;
}

.brand-seven {
    font-size: 1.35em;
    font-weight: 900;
    background: linear-gradient(135deg, #a259ff 0%, #6a5af9 50%, #b74e91 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 6px rgba(162, 89, 255, 0.35));
    font-style: italic;
    letter-spacing: -0.02em;
    line-height: 1;
}

.brand-eyes {
    font-size: 0.92em;
    font-weight: 700;
    background: linear-gradient(90deg, rgba(255,255,255,0.95) 0%, rgba(255,255,255,0.6) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 0.18em;
    text-transform: none;
    line-height: 1;
}

/* Brand hover glow */
.sidebar-brand:hover .brand-seven {
    filter: drop-shadow(0 0 10px rgba(162, 89, 255, 0.6));
}

.sidebar-brand:hover .brand-eyes {
    background: linear-gradient(90deg, rgba(255,255,255,1) 0%, rgba(255,255,255,0.8) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Toggle Button */
.sidebar-toggle {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
    flex-shrink: 0;
    padding: 0;
    font-size: 0.65em;
    outline: none;
}

.sidebar-toggle:hover {
    color: rgba(255, 255, 255, 0.85);
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-toggle i {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    line-height: 1;
}

/* ================================================================
   Nav Icon & Text
   ================================================================ */
.nav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.8em;
    min-width: 1.8em;
    font-size: 1em;
    transition: margin-right 0.3s ease, font-size 0.3s ease;
    margin-right: 0.5em;
}

.nav-text {
    transition: opacity 0.25s ease;
    white-space: nowrap;
    overflow: hidden;
}

/* ---- Desktop only: flex layout for icon+text alignment ---- */
@media screen and (min-width: 1281px) {
    #sidebar nav a {
        display: flex !important;
        align-items: center;
        justify-content: flex-end;
    }
}

/* ================================================================
   COLLAPSED STATE  (#sidebar.sidebar-collapsed)
   ================================================================ */
@media screen and (min-width: 1281px) {
    #sidebar.sidebar-collapsed {
        width: 4em;
        padding-left: 0.4em;
        padding-right: 0.4em;
        text-align: center;
    }

    #sidebar.sidebar-collapsed + #wrapper {
        margin-left: 4em;
    }

    #sidebar.sidebar-collapsed + #wrapper + #footer {
        margin-left: 4em;
    }

    /* Toggle icon rotates 180° */
    #sidebar.sidebar-collapsed .sidebar-toggle i {
        transform: rotate(180deg);
    }

    /* Brand text hidden */
    #sidebar.sidebar-collapsed .sidebar-brand {
        opacity: 0;
        max-width: 0;
        margin: 0;
        padding: 0;
        pointer-events: none;
    }

    #sidebar.sidebar-collapsed .sidebar-header {
        justify-content: center;
        border-bottom-color: rgba(255, 255, 255, 0.05);
    }

    /* Nav text hidden */
    #sidebar.sidebar-collapsed .nav-text {
        opacity: 0;
        max-width: 0;
        width: 0;
        display: none;
    }

    /* Icons centered, slightly larger */
    #sidebar.sidebar-collapsed .nav-icon {
        margin-right: 0;
        font-size: 1.2em;
    }

    #sidebar.sidebar-collapsed nav a {
        justify-content: center !important;
        padding-top: 1.1em;
        padding-bottom: 1.1em;
    }

    /* Underline bar: keep full width in collapsed mode */
    #sidebar.sidebar-collapsed nav a:before,
    #sidebar.sidebar-collapsed nav a:after {
        left: 0;
        right: 0;
    }

    /* ---- Tooltip on hover (collapsed mode only) ---- */
    /* li::after 사용 (a::after는 기존 언더라인 그라데이션에 사용됨) */
    #sidebar.sidebar-collapsed nav > ul > li {
        position: relative;
    }

    #sidebar.sidebar-collapsed nav > ul > li[data-tooltip]:hover::after {
        content: attr(data-tooltip);
        position: absolute;
        left: calc(100% + 0.5em);
        top: 50%;
        transform: translateY(-50%);
        background: rgba(26, 20, 48, 0.95);
        color: rgba(255, 255, 255, 0.85);
        padding: 0.45em 0.9em;
        border-radius: 6px;
        font-size: 0.65em;
        font-weight: 600;
        white-space: nowrap;
        z-index: 10001;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
        letter-spacing: 0.15em;
        text-transform: uppercase;
        pointer-events: none;
    }
}

/* ================================================================
   RESPONSIVE: Tablet / Small Desktop (≤ 1280px)
   - 사이드바가 상단 가로바 모드 → 토글/아이콘 숨김, 기존 동작 유지
   - 단, 폴더블(700~1400px, 높이 600~1100px)은 세로 사이드바 유지하므로 제외
   ================================================================ */
@media screen and (max-width: 1280px) and (max-height: 599px) {
    .sidebar-header { display: none !important; }
    .nav-icon { display: none !important; }
    .nav-text { display: inline !important; opacity: 1 !important; max-width: none !important; width: auto !important; }
    #sidebar.sidebar-collapsed { width: 100% !important; height: 3.5em !important; padding: 0 !important; text-align: center !important; }
    #sidebar.sidebar-collapsed + #wrapper { margin-left: 0 !important; padding-top: 3.5em !important; }
    #sidebar.sidebar-collapsed + #wrapper + #footer { margin-left: 0 !important; }
    #sidebar.sidebar-collapsed > .inner { flex-direction: row !important; }
    #sidebar.sidebar-collapsed nav a { display: block !important; height: inherit !important; line-height: inherit !important; padding: 0 !important; }
    #sidebar.sidebar-collapsed nav ul li { display: block !important; height: inherit !important; line-height: inherit !important; margin: 0 0 0 2em !important; }
    #sidebar.sidebar-collapsed .nav-text { display: inline !important; opacity: 1 !important; max-width: none !important; width: auto !important; }
    #sidebar.sidebar-collapsed nav > ul > li[data-tooltip]:hover::after { display: none !important; content: none !important; }
}
/* 높이 1100px 초과 + 좁은 화면 = 일반 태블릿/세로 모드 → 상단바 모드 */
@media screen and (max-width: 1280px) and (min-height: 1101px) {
    .sidebar-header { display: none !important; }
    .nav-icon { display: none !important; }
    .nav-text { display: inline !important; opacity: 1 !important; max-width: none !important; width: auto !important; }
    #sidebar.sidebar-collapsed { width: 100% !important; height: 3.5em !important; padding: 0 !important; text-align: center !important; }
    #sidebar.sidebar-collapsed + #wrapper { margin-left: 0 !important; padding-top: 3.5em !important; }
    #sidebar.sidebar-collapsed + #wrapper + #footer { margin-left: 0 !important; }
    #sidebar.sidebar-collapsed > .inner { flex-direction: row !important; }
    #sidebar.sidebar-collapsed nav a { display: block !important; height: inherit !important; line-height: inherit !important; padding: 0 !important; }
    #sidebar.sidebar-collapsed nav ul li { display: block !important; height: inherit !important; line-height: inherit !important; margin: 0 0 0 2em !important; }
    #sidebar.sidebar-collapsed .nav-text { display: inline !important; opacity: 1 !important; max-width: none !important; width: auto !important; }
    #sidebar.sidebar-collapsed nav > ul > li[data-tooltip]:hover::after { display: none !important; content: none !important; }
}
/* 너비 699px 이하 + 높이 600~1100 = 일반 작은 태블릿 → 상단바 모드 */
@media screen and (max-width: 699px) and (min-height: 600px) and (max-height: 1100px) {
    .sidebar-header { display: none !important; }
    .nav-icon { display: none !important; }
    .nav-text { display: inline !important; opacity: 1 !important; max-width: none !important; width: auto !important; }
    #sidebar.sidebar-collapsed { width: 100% !important; height: 3.5em !important; padding: 0 !important; text-align: center !important; }
    #sidebar.sidebar-collapsed + #wrapper { margin-left: 0 !important; padding-top: 3.5em !important; }
    #sidebar.sidebar-collapsed + #wrapper + #footer { margin-left: 0 !important; }
    #sidebar.sidebar-collapsed > .inner { flex-direction: row !important; }
    #sidebar.sidebar-collapsed nav a { display: block !important; height: inherit !important; line-height: inherit !important; padding: 0 !important; }
    #sidebar.sidebar-collapsed nav ul li { display: block !important; height: inherit !important; line-height: inherit !important; margin: 0 0 0 2em !important; }
    #sidebar.sidebar-collapsed .nav-text { display: inline !important; opacity: 1 !important; max-width: none !important; width: auto !important; }
    #sidebar.sidebar-collapsed nav > ul > li[data-tooltip]:hover::after { display: none !important; content: none !important; }
}

/* ================================================================
   RESPONSIVE: Mobile (≤ 736px)
   - 사이드바 완전 숨김 (기존 동작)
   ================================================================ */
@media screen and (max-width: 736px) {
    .sidebar-header {
        display: none !important;
    }

    .nav-icon {
        display: none !important;
    }
}

/* ================================================================
   Galaxy Z Fold7 폴더블 디바이스 지원
   ================================================================ */
@media screen and (min-width: 700px) and (max-width: 1400px) and (max-height: 1100px) and (min-height: 600px) {
    .sidebar-header {
        display: flex !important;
        margin-bottom: 1em;
        padding-bottom: 0.6em;
    }

    .sidebar-brand {
        font-size: 0.9em;
    }

    .nav-icon {
        display: inline-flex !important;
        font-size: 0.9em;
        width: 1.5em;
        min-width: 1.5em;
        margin-right: 0.4em;
    }

    #sidebar.sidebar-collapsed {
        width: 4em !important;
        padding: 1.5em 0.3em 0.5em 0.3em !important;
    }

    #sidebar.sidebar-collapsed + #wrapper {
        margin-left: 4em !important;
    }

    #sidebar.sidebar-collapsed + #wrapper + #footer {
        margin-left: 4em !important;
    }

    #sidebar.sidebar-collapsed .nav-icon {
        margin-right: 0 !important;
    }

    #sidebar.sidebar-collapsed .nav-text {
        display: none !important;
        opacity: 0 !important;
    }

    #sidebar.sidebar-collapsed .sidebar-brand {
        display: none !important;
    }

    #sidebar.sidebar-collapsed .sidebar-header {
        justify-content: center !important;
    }

    /* 폴드 디바이스에서 nav a를 flex로 */
    #sidebar nav a {
        display: flex !important;
        align-items: center;
    }

    #sidebar.sidebar-collapsed nav a {
        justify-content: center !important;
    }
}
