/**
 * 땅튜브 사이드바 스타일
 *
 * @package DdangTube
 * @version 2.0.0
 */


/* ========== CSS Variables ========== */

:root {
    --header-height: 56px;
    --header-height-mobile: 65px;
    --sidebar-width: 240px;
    --sidebar-collapsed-width: 60px;
}


/* ========== Sidebar (헤더 아래, 좌측 고정) ========== */

.ddangtube-sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-primary);
    flex-shrink: 0;
    transition: width var(--transition-normal), transform var(--transition-normal);
}

.sidebar-inner {
    display: flex;
    flex-direction: column;
}


/* 사이드바 스크롤바 - 평소 숨김, hover 시 극히 얇게 */
.sidebar-inner {
    scrollbar-width: none;
}

.sidebar-inner::-webkit-scrollbar {
    width: 0;
    background: transparent;
}

.sidebar-inner:hover::-webkit-scrollbar {
    width: 3px;
}

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

.sidebar-inner:hover::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.12);
    border-radius: 2px;
}

.sidebar-inner:hover {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}


/* 사이드바 접힘 상태 */

.ddangtube-sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.ddangtube-sidebar.collapsed .menu-item a .menu-text,
.ddangtube-sidebar.collapsed .sidebar-widgets {
    display: none;
}

.ddangtube-sidebar.collapsed .menu-item a {
    justify-content: center;
    padding: 0.875rem;
}

.ddangtube-sidebar.collapsed .menu-icon {
    margin: 0;
}

.ddangtube-sidebar.collapsed .menu-badge {
    position: absolute;
    top: 4px;
    right: 10px;
    margin-left: 0;
    padding: 0;
    min-width: 8px;
    height: 8px;
    font-size: 0;
    line-height: 0;
    border-radius: 50%;
}


/* ========== Sidebar Online Users ========== */

.sidebar-online {
    padding: 0.625rem 1rem;
    border-bottom: 1px solid var(--border-primary);
}

.sidebar-online__header {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0;
    margin-bottom: 0.375rem;
}

.sidebar-online__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--accent-success);
    flex-shrink: 0;
    animation: sidebar-online-pulse 2s ease-in-out infinite;
}

@keyframes sidebar-online-pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

.sidebar-online__title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}

.sidebar-online__count {
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-left: auto;
}

.sidebar-online__list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    max-height: 180px;
    overflow-y: auto;
}

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

.sidebar-online__list::-webkit-scrollbar-thumb {
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-full);
    border: none;
}

.sidebar-online__item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.375rem;
    border-radius: var(--radius-sm);
    transition: background-color var(--transition-fast);
}

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

.sidebar-online__avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.sidebar-online__name {
    font-size: 0.775rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-online__role {
    font-size: 0.6rem;
    font-weight: 600;
    padding: 0.05rem 0.3rem;
    border-radius: var(--radius-sm);
    line-height: 1.4;
    margin-left: auto;
    flex-shrink: 0;
    white-space: nowrap;
}

.sidebar-online__role--administrator {
    color: #00bcd4;
    background-color: rgba(0, 188, 212, 0.12);
}

.sidebar-online__me {
    font-size: 0.6rem;
    font-weight: 600;
    padding: 0.05rem 0.3rem;
    border-radius: var(--radius-sm);
    line-height: 1.4;
    flex-shrink: 0;
    white-space: nowrap;
    color: var(--accent-success);
    background-color: rgba(74, 222, 128, 0.12);
}

.sidebar-online__item--guest {
    opacity: 0.7;
}

.sidebar-online__item--hidden {
    display: none;
}

.sidebar-online__more {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    padding: 6px 0;
    margin-top: 2px;
    border: none;
    background: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    transition: color 0.2s ease;
}

.sidebar-online__more:hover {
    color: var(--text-primary);
}

.sidebar-online__more-icon {
    transition: transform 0.2s ease;
}

.sidebar-online__more[data-expanded="true"] .sidebar-online__more-icon {
    transform: rotate(180deg);
}

.sidebar-online__guest-icon {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--text-muted);
}

.sidebar-online__role--editor {
    color: var(--accent-info);
    background-color: rgba(0, 176, 244, 0.12);
}

.sidebar-online__membership {
    font-size: 0.6rem;
    font-weight: 600;
    padding: 0.05rem 0.3rem;
    border-radius: var(--radius-sm);
    line-height: 1.4;
    margin-left: auto;
    flex-shrink: 0;
    white-space: nowrap;
}

.sidebar-online__empty {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    padding: 0.5rem 0;
    margin: 0;
}


/* ========== Collapsed: hide online ========== */

.ddangtube-sidebar.collapsed .sidebar-online {
    display: none;
}


/* ========== Menu ========== */

.sidebar-menu {
    padding: 0.5rem 0;
}

.sidebar-menu-list {
    display: flex;
    flex-direction: column;
}

.menu-item {
    position: relative;
}

.menu-item a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.1rem;
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.85rem;
    font-family: 'Galmuri11', sans-serif;
    transition: all var(--transition-fast);
    position: relative;
}

.menu-item a .menu-text {
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.menu-item a:hover {
    background-color: var(--bg-hover);
}

.menu-item.current-menu-item a,
.menu-item.current-page-parent a {
    background-color: var(--bg-active);
    color: var(--text-primary);
}


/* ========== Menu Icon ========== */

.menu-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.menu-icon svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
}


/* ========== Menu Badge ========== */

.menu-badge {
    margin-left: auto;
    padding: 0rem 0.3rem;
    font-size: 0.6rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    line-height: 1.7;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", "Malgun Gothic", sans-serif;
    height: 1rem;
}

.menu-badge.badge-new {
    background-color: var(--accent-danger);
    color: white;
}

.menu-badge.badge-hot {
    background-color: var(--accent-warning);
    color: white;
}

.menu-badge.badge-info {
    background-color: var(--accent-info);
    color: white;
}

.menu-badge.badge-success {
    background-color: var(--accent-success);
    color: white;
}


/* ========== Menu Separator ========== */

.menu-separator {
    padding: 0.5rem 1.5rem;
    list-style: none;
}

.menu-separator hr {
    border: none;
    border-top: 1px solid var(--border-primary);
    margin: 0;
}

.ddangtube-sidebar.collapsed .menu-separator {
    padding: 0.5rem 0.875rem;
}


/* ========== Submenu ========== */

.sub-menu {
    background-color: var(--bg-primary);
    border-left: 2px solid var(--border-primary);
    margin-left: 1.5rem;
}

.sub-menu .menu-item a {
    padding-left: 2.5rem;
    font-size: 0.875rem;
}


/* ========== No Menu ========== */

.no-menu {
    padding: 1.5rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}


/* ========== Sidebar Popular Posts ========== */

.sidebar-popular {
    border-top: 1px solid var(--border-primary);
    padding: 0.625rem 0;
}

.sidebar-popular__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.25rem 1rem;
    margin-bottom: 0.25rem;
}

.sidebar-popular__title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}

.sidebar-popular__actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.sidebar-popular__refresh,
.sidebar-popular__collapse {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: color var(--transition-fast), background-color var(--transition-fast);
    padding: 0;
}

.sidebar-popular__refresh:hover,
.sidebar-popular__collapse:hover {
    color: var(--text-secondary);
    background-color: var(--bg-hover);
}

.sidebar-popular__collapse svg {
    transition: transform 0.2s ease;
}

.sidebar-popular__collapse.is-collapsed svg {
    transform: rotate(180deg);
}

/* List */
.sidebar-popular__list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
}

.sidebar-popular__item {
    transition: max-height 0.3s ease, opacity 0.2s ease;
    overflow: hidden;
}

.sidebar-popular__item--hidden {
    display: none;
}

.sidebar-popular__link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 1rem;
    text-decoration: none;
    color: inherit;
    border-radius: 0;
    transition: background-color var(--transition-fast);
}

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

/* Rank number */
.sidebar-popular__rank {
    width: 18px;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    text-align: center;
    flex-shrink: 0;
    line-height: 1;
}

.sidebar-popular__rank--top {
    color: var(--accent-primary, #EA7E11);
}

/* Board badge dot */
.sidebar-popular__badge {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Info */
.sidebar-popular__info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.sidebar-popular__subject {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.sidebar-popular__meta {
    font-size: 0.65rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

/* Hit count (right side) */
.sidebar-popular__hits {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-muted);
    flex-shrink: 0;
    white-space: nowrap;
}

/* More button */
.sidebar-popular__more {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    width: 100%;
    padding: 0.5rem;
    margin-top: 0.125rem;
    background: transparent;
    border: none;
    border-top: 1px solid var(--border-primary);
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    transition: color var(--transition-fast), background-color var(--transition-fast);
}

.sidebar-popular__more:hover {
    color: var(--text-secondary);
    background-color: var(--bg-hover);
}

.sidebar-popular__more-icon {
    transition: transform 0.2s ease;
}

.sidebar-popular__more[data-expanded="true"] .sidebar-popular__more-icon {
    transform: rotate(180deg);
}

/* Refresh spin animation */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Collapsed sidebar: hide popular section */
.ddangtube-sidebar.collapsed .sidebar-popular {
    display: none;
}


/* ========== Sidebar Membership Banner ========== */

.sidebar-membership-wrap {
    padding: 0.625rem 0.625rem;
}

.sidebar-membership {
    display: block;
    position: relative;
    margin: 0;
    padding: 0.7rem 0.8rem 0.65rem;
    background: linear-gradient(160deg, #3a3a42 0%, #2c2c34 40%, #333340 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    text-decoration: none;
    color: inherit;
    overflow: hidden;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

/* 상단 광택 — 은색 메탈 느낌 */
.sidebar-membership::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, transparent 100%);
    border-radius: 14px 14px 0 0;
    pointer-events: none;
}

/* 대각선 빛줄기 */
.sidebar-membership__shine {
    position: absolute;
    top: -30%;
    left: -20%;
    width: 50%;
    height: 160%;
    background: linear-gradient(
        105deg,
        transparent 40%,
        rgba(255, 255, 255, 0.03) 45%,
        rgba(255, 255, 255, 0.06) 50%,
        rgba(255, 255, 255, 0.03) 55%,
        transparent 60%
    );
    pointer-events: none;
    transition: left 0.5s ease;
}

.sidebar-membership:hover {
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.sidebar-membership:hover .sidebar-membership__shine {
    left: 100%;
}

/* 텍스트 영역 */
.sidebar-membership__text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    position: relative;
    z-index: 1;
}

.sidebar-membership__sub {
    font-size: 0.6rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-membership__title {
    font-size: 0.8rem;
    font-weight: 700;
    background: linear-gradient(135deg, #e0e0e0, #ffffff, #c0c0c0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.4;
    white-space: nowrap;
}

/* Collapsed sidebar: hide membership banner */
.ddangtube-sidebar.collapsed .sidebar-membership-wrap {
    display: none;
}


/* ========== Sidebar Overlay (모바일) ========== */

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 199;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}


/* ========== Responsive ========== */

@media (max-width: 1024px) {
    .menu-item a {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }

    .sidebar-online {
        padding: 0.5rem 0.75rem;
    }

    .menu-separator {
        padding: 0.5rem 1rem;
    }
}

@media (max-width: 768px) {
    .ddangtube-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 200;
        transform: translateX(-100%);
        width: 280px;
        height: 100vh;
        box-shadow: var(--shadow-lg);
    }

    .ddangtube-sidebar .sidebar-inner {
        height: 100%;
        overflow-y: auto;
    }

    .ddangtube-sidebar.active {
        transform: translateX(0);
    }
}

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