/**
 * ToolZipper - Sidebar Styles (Light Premium Theme with Gold Accent)
 *
 * @package Zipper
 */

/* ==========================================================================
   CSS Variables
   ========================================================================== */
:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 56px;
    --sidebar-bg: #ffffff;
    --sidebar-bg-light: #faf9f7;
    --sidebar-border: #e8e4dc;
    --sidebar-text: #2d2a26;
    --sidebar-text-muted: #8c8579;
    --sidebar-hover-bg: linear-gradient(135deg, rgba(212, 175, 55, 0.08) 0%, rgba(184, 134, 11, 0.05) 100%);
    --sidebar-active-bg: linear-gradient(135deg, rgba(212, 175, 55, 0.15) 0%, rgba(184, 134, 11, 0.1) 100%);
    --sidebar-active-text: #b8860b;
    --sidebar-accent: #d4af37;
    --sidebar-accent-dark: #b8860b;
    --sidebar-gold-gradient: linear-gradient(135deg, #d4af37 0%, #b8860b 100%);
    --sidebar-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   Main Sidebar
   ========================================================================== */
.tool-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: width var(--sidebar-transition);
    overflow: hidden;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.03);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 접힌 상태 */
.tool-sidebar.is-collapsed {
    width: var(--sidebar-collapsed-width);
}

/* ==========================================================================
   Sidebar Header - 햄버거 + 로고 + 타이틀
   ========================================================================== */
.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 60px;
    padding: 0 16px;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.sidebar-toggle {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--sidebar-text);
    font-size: 20px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: var(--sidebar-hover-bg);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    overflow: hidden;
    flex: 1;
}

.brand-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--sidebar-gold-gradient);
    border-radius: 8px;
    color: #fff;
    font-size: 16px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(212, 175, 55, 0.3);
    overflow: hidden;
}

.brand-icon:has(.brand-logo) {
    background: transparent;
    box-shadow: none;
}

.brand-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.brand-text {
    font-size: 16px;
    font-weight: 600;
    color: var(--sidebar-text);
    white-space: nowrap;
    transition: opacity var(--sidebar-transition), width var(--sidebar-transition);
}

/* 접힌 상태 - 텍스트 숨김, 로고 아이콘만 표시 */
.tool-sidebar.is-collapsed .brand-text {
    display: none;
}

.tool-sidebar.is-collapsed .sidebar-header {
    justify-content: center;
    padding: 0 8px;
}

.tool-sidebar.is-collapsed .sidebar-brand {
    padding: 0;
}

.tool-sidebar.is-collapsed .sidebar-brand .brand-icon {
    width: 36px;
    height: 36px;
}

/* ==========================================================================
   Sidebar Search
   ========================================================================== */
.sidebar-search {
    padding: 16px;
    flex-shrink: 0;
    position: relative;
}

.search-icon {
    position: absolute;
    left: 28px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--sidebar-text-muted);
    font-size: 14px;
    pointer-events: none;
}

.search-input {
    width: 100%;
    height: 40px;
    padding: 0 12px 0 40px;
    border: 1px solid var(--sidebar-border);
    border-radius: 8px;
    font-size: 14px;
    background: var(--sidebar-bg-light);
    color: var(--sidebar-text);
    transition: all 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--sidebar-accent);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
}

.search-input::placeholder {
    color: var(--sidebar-text-muted);
}

/* 접힌 상태 - 검색 숨김 */
.tool-sidebar.is-collapsed .sidebar-search {
    padding: 12px;
}

.tool-sidebar.is-collapsed .search-input {
    width: 40px;
    padding: 0;
    background: transparent;
    border-color: transparent;
    cursor: pointer;
}

.tool-sidebar.is-collapsed .search-icon {
    left: 50%;
    transform: translate(-50%, -50%);
}

.tool-sidebar.is-collapsed .search-input::placeholder {
    color: transparent;
}

/* ==========================================================================
   Sidebar Navigation
   ========================================================================== */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 0;
}

/* 스크롤바 숨김 기본 */
.sidebar-nav {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

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

.sidebar-nav::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 2px;
    transition: background 0.3s ease;
}

/* 스크롤 시 표시 */
.sidebar-nav.is-scrolling::-webkit-scrollbar-thumb {
    background: rgba(212, 175, 55, 0.3);
}

.sidebar-nav.is-scrolling {
    scrollbar-width: thin;
    scrollbar-color: rgba(212, 175, 55, 0.3) transparent;
}

/* ==========================================================================
   Navigation Sections
   ========================================================================== */
.tool-sidebar .nav-section {
    margin-bottom: 4px;
}

.tool-sidebar .sidebar-nav .nav-section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 16px;
    margin: 0;
    border: none;
    border-radius: 0;
    background: transparent;
    color: var(--sidebar-text);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    text-transform: none;
    letter-spacing: normal;
    box-shadow: none;
    outline: none;
}

.tool-sidebar .sidebar-nav .nav-section-header:hover,
.tool-sidebar .sidebar-nav .nav-section-header:focus {
    background: var(--sidebar-bg-light);
    color: var(--sidebar-text);
    box-shadow: none;
    outline: none;
}

.tool-sidebar .nav-section-header .section-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    color: var(--sidebar-accent);
}

.tool-sidebar .sidebar-nav .nav-section-header .section-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 13px;
    font-weight: 500;
    margin: 0;
    padding: 0;
    border: none;
    display: inline;
    gap: 0;
    color: inherit;
    line-height: 1.4;
}

.tool-sidebar .nav-section-header .section-arrow {
    font-size: 10px;
    color: var(--sidebar-text-muted);
    transition: transform 0.2s ease;
}

.tool-sidebar .nav-section-header[aria-expanded="false"] .section-arrow {
    transform: rotate(-90deg);
}

/* 접힌 상태 */
.tool-sidebar.is-collapsed .sidebar-nav .nav-section-header .section-title,
.tool-sidebar.is-collapsed .sidebar-nav .nav-section-header .section-arrow {
    display: none;
}

.tool-sidebar.is-collapsed .sidebar-nav .nav-section-header {
    justify-content: center;
    padding: 10px 8px;
}

/* ==========================================================================
   Navigation Menu Items
   ========================================================================== */
.tool-sidebar .sidebar-nav .nav-menu {
    list-style: none;
    margin: 0;
    padding: 0 0 8px 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.tool-sidebar .nav-section-header[aria-expanded="false"] + .nav-menu {
    max-height: 0;
    padding: 0;
}

.tool-sidebar .nav-menu .nav-item {
    position: relative;
    margin: 0;
    padding: 0;
    list-style: none;
}

.tool-sidebar .nav-menu .nav-item a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px 8px 48px;
    margin: 1px 12px 1px 0;
    color: var(--sidebar-text-muted);
    text-decoration: none;
    font-family: inherit;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.4;
    border: none;
    border-radius: 6px;
    background: transparent;
    transition: all 0.15s ease;
}

.tool-sidebar .nav-menu .nav-item a:hover {
    color: var(--sidebar-text);
    background: var(--sidebar-bg-light);
    text-decoration: none;
}

.tool-sidebar .nav-menu .nav-item.active a {
    color: var(--sidebar-accent-dark);
    background: var(--sidebar-bg-light);
    font-weight: 500;
}

.tool-sidebar .nav-menu .nav-item .item-icon {
    font-size: 15px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    color: var(--sidebar-text-muted);
}

.tool-sidebar .nav-menu .nav-item a:hover .item-icon {
    color: var(--sidebar-accent);
}

.tool-sidebar .nav-menu .nav-item.active a .item-icon {
    color: var(--sidebar-accent);
}

.tool-sidebar .nav-menu .nav-item .item-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 접힌 상태 */
.tool-sidebar.is-collapsed .nav-menu {
    padding-left: 0;
}

.tool-sidebar.is-collapsed .nav-item a {
    justify-content: center;
    padding: 10px 8px;
    margin: 2px 4px;
}

.tool-sidebar.is-collapsed .item-text {
    display: none;
}

/* ==========================================================================
   Favorite Button
   ========================================================================== */
.favorite-btn {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--sidebar-text-muted);
    font-size: 13px;
    cursor: pointer;
    border-radius: 6px;
    opacity: 0;
    transition: all 0.15s ease;
}

.nav-item:hover .favorite-btn {
    opacity: 1;
}

.favorite-btn:hover {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
}

.favorite-btn.is-favorite {
    opacity: 1;
    color: #fbbf24;
}

.tool-sidebar.is-collapsed .favorite-btn {
    display: none;
}

/* Empty State (Favorites & Categories) */
.favorites-empty,
.nav-empty {
    padding: 16px;
    color: var(--sidebar-text-muted);
    font-size: 13px;
    text-align: center;
    font-style: italic;
    opacity: 0.7;
}

.nav-empty .item-text {
    display: block;
    text-align: center;
}

/* ==========================================================================
   Sidebar Footer
   ========================================================================== */
.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.footer-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: var(--sidebar-text-muted);
    text-decoration: none;
    font-size: 14px;
    border-radius: 8px;
    transition: all 0.15s ease;
}

.footer-item:hover {
    color: var(--sidebar-accent-dark);
    background: var(--sidebar-bg-light);
}

.footer-item i {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.tool-sidebar.is-collapsed .footer-item span {
    display: none;
}

.tool-sidebar.is-collapsed .footer-item {
    justify-content: center;
    padding: 10px 8px;
}

/* ==========================================================================
   Mobile
   ========================================================================== */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity var(--sidebar-transition);
}

.sidebar-overlay.is-active {
    display: block;
    opacity: 1;
}

/* ==========================================================================
   Content Offset
   ========================================================================== */
.site-content-with-sidebar {
    margin-left: var(--sidebar-width);
    transition: margin-left var(--sidebar-transition);
    min-height: 100vh;
    background: #f8fafc;
}

.tool-sidebar.is-collapsed ~ .site-content-with-sidebar,
body.sidebar-collapsed .site-content-with-sidebar {
    margin-left: var(--sidebar-collapsed-width);
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1024px) {
    .tool-sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
    }

    .tool-sidebar.is-open {
        transform: translateX(0);
    }

    /* 모바일에서 열렸을 때는 항상 전체 너비 */
    .tool-sidebar.is-open .brand-text,
    .tool-sidebar.is-open .section-title,
    .tool-sidebar.is-open .section-arrow,
    .tool-sidebar.is-open .item-text,
    .tool-sidebar.is-open .footer-item span {
        display: block !important;
    }

    .tool-sidebar.is-open .sidebar-header,
    .tool-sidebar.is-open .nav-section-header,
    .tool-sidebar.is-open .nav-item a,
    .tool-sidebar.is-open .footer-item {
        justify-content: flex-start !important;
        padding-left: 16px !important;
    }

    .tool-sidebar.is-open .sidebar-search {
        display: block !important;
    }

    .site-content-with-sidebar {
        margin-left: 0 !important;
    }
}

@media (max-width: 480px) {
    .tool-sidebar {
        width: 100%;
    }
}
