/* Estilos de la barra lateral - Diseño Moderno 3D */

.sidebar {
    position: fixed;
    left: 0;
    top: 0; /* Banner desactivado - desde arriba */
    width: var(--sidebar-width, 320px);
    height: 100vh; /* Altura completa - banner desactivado */
    background: linear-gradient(180deg, rgba(11, 15, 27, 0.98) 0%, rgba(16, 24, 46, 0.98) 55%, rgba(12, 18, 30, 0.98) 100%);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    overflow: hidden;
    box-shadow: 4px 0 26px rgba(0, 0, 0, 0.55);
    transition: background 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease, color 0.22s ease;
}

.sidebar-nav{
    flex: 1 1 auto;
    min-height: 0; /* 중요: flex 컨테이너에서 overflow 스크롤이 정상 동작하게 함 */
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding: 0.75rem 0.55rem 1.1rem 0.55rem;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-gutter: stable both-edges;
    -webkit-overflow-scrolling: touch;

    /* Firefox */
    scrollbar-width: thin;
    scrollbar-color: rgba(88, 101, 242, 0.85) rgba(255, 255, 255, 0.06);
}

/* WebKit */
.sidebar-nav::-webkit-scrollbar{
    width: 8px;
}
.sidebar-nav::-webkit-scrollbar-track{
    background: rgba(255, 255, 255, 0.06);
    border-radius: 999px;
    margin: 10px 0;
}
.sidebar-nav::-webkit-scrollbar-thumb{
    background: linear-gradient(180deg, rgba(88, 101, 242, 0.95), rgba(147, 51, 234, 0.80));
    border-radius: 999px;
    box-shadow: 0 0 12px rgba(88, 101, 242, 0.25);
    border: 2px solid rgba(255, 255, 255, 0.06);
    background-clip: padding-box;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover{
    background: linear-gradient(180deg, rgba(125, 211, 252, 0.95), rgba(88, 101, 242, 0.90));
    box-shadow: 0 0 16px rgba(125, 211, 252, 0.25);
}


/* Sidebar Scrollbar */
/* Cuando el banner está oculto - Banner desactivado, mantener arriba */
body.banner-hidden .sidebar {
    top: 0;
    height: 100vh;
}


/* Scrollbar (sidebar-nav) - modern */
/* Scrollbar (sidebar) - thin & subtle */
.sidebar {
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.22);
    border-radius: 999px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.32);
}

.sidebar-header {
    height: var(--cordlook-header-height);
    min-height: var(--cordlook-header-height);
    padding: 0 var(--cordlook-header-pad-x);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.85rem;
    flex-shrink: 0;
    box-sizing: border-box;
}

.sidebar-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-primary);
}

.sidebar-logo {
    width: 50px;
    height: 50px;
    object-fit: contain;
    filter: drop-shadow(0 4px 8px rgba(102, 126, 234, 0.3));
    position: relative;
    z-index: 1;
}

.sidebar-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    position: relative;
    z-index: 1;
    margin: 0;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Secciones del Sidebar */
.nav-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    animation: slideInLeft 0.4s ease backwards;
}

.nav-section:nth-child(1) { animation-delay: 0.1s; }
.nav-section:nth-child(2) { animation-delay: 0.2s; }
.nav-section:nth-child(3) { animation-delay: 0.3s; }
.nav-section:nth-child(4) { animation-delay: 0.4s; }

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.nav-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0.04em;
    color: rgba(185, 194, 220, 0.78);
    padding: 0.35rem 0.85rem 0.2rem;
    margin: 1rem 0 0.35rem;
    border-radius: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    position: relative;
}

.nav-section-title::after {
    content: '';
    display: block;
    height: 1px;
    margin-top: 0.45rem;
    background: linear-gradient(90deg, rgba(88, 101, 242, 0.7), rgba(88, 101, 242, 0.25), transparent);
    opacity: 1;
}

.nav-item .nav-icon {
    width: 2.05rem;
    min-width: 2.05rem;
    height: 2.05rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.7rem;
    font-size: 1.15rem;
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
    transition: all 0.18s ease;
}

.nav-item:hover .nav-icon {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.09);
    transform: scale(1.08) rotate(3deg) translateZ(10px);
    filter: drop-shadow(0 4px 8px rgba(102, 126, 234, 0.5));
}
.nav-item.active .nav-icon {
    background: rgba(59, 130, 246, 0.18);
    border-color: rgba(59, 130, 246, 0.22);
    color: rgba(255, 255, 255, 0.95);
    box-shadow: 0 0 18px rgba(59, 130, 246, 0.24);
}

.nav-text {
    font-weight: 600;
    position: relative;
    z-index: 1;
    letter-spacing: 0.3px;
}

.nav-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(102, 126, 234, 0.3), transparent);
    margin: 1rem 0.25rem;
    border: none;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

/* Beta notice should not shrink */
.sidebar-beta-notice {
    flex-shrink: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 1rem;
    background: linear-gradient(135deg, rgba(15, 80, 100, 0.25) 0%, rgba(30, 60, 100, 0.22) 100%);
    border-radius: 16px;
    border: 1px solid rgba(56, 189, 248, 0.22);
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.user-info::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.5s;
}

.user-info:hover::before {
    left: 100%;
}

.user-info:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.25);
    border-color: rgba(56, 189, 248, 0.4);
}

.user-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: 2px solid rgba(56, 189, 248, 0.4);
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.2);
    transition: all 0.3s;
    position: relative;
    z-index: 1;
}

.user-info:hover .user-avatar {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.35);
}

.user-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

.user-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.user-discriminator {
    font-size: 0.85rem;
    color: var(--text-muted);
    word-break: break-all;
}

.sidebar-action-group {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    flex-shrink: 0; /* ✅ 버튼 그룹 압축 방지 */
}

.logout-btn,
.sidebar-action-btn {
    display: block;
    width: 100%;
    padding: 0.85rem;
    min-height: 48px; /* ✅ 창 줄여도 버튼 높이 압축 방지 */
    box-sizing: border-box;
    color: rgba(245, 247, 255, 0.95);
    text-decoration: none;
    text-align: center;
    border-radius: 12px;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(125, 211, 252, 0.25);
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.28) 0%, rgba(59, 130, 246, 0.2) 55%, rgba(20, 184, 166, 0.18) 100%);
    text-shadow: 0 2px 10px rgba(6, 10, 24, 0.45);
}

.sidebar-action-btn.sidebar-action-primary {
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.42) 0%, rgba(59, 130, 246, 0.32) 55%, rgba(20, 184, 166, 0.26) 100%);
    border-color: rgba(34, 211, 238, 0.5);
}

.sidebar-action-btn.sidebar-action-secondary {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.45) 0%, rgba(59, 130, 246, 0.28) 55%, rgba(15, 23, 42, 0.88) 100%);
    border-color: rgba(99, 102, 241, 0.55);
    box-shadow: 0 16px 40px rgba(5, 10, 24, 0.55), inset 0 0 18px rgba(99, 102, 241, 0.22);
}

.logout-btn::before,
.sidebar-action-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.logout-btn:hover::before,
.sidebar-action-btn:hover::before {
    width: 300px;
    height: 300px;
}

.logout-btn:hover,
.sidebar-action-btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: var(--shadow-lg), 0 0 20px rgba(34, 211, 238, 0.35);
}

/* Main Content with Sidebar */
.main-content.with-sidebar{
    margin-left: var(--sidebar-width, 320px);
    width: calc(100% - var(--sidebar-width, 320px));
    min-height: 100vh;
    overflow-x: hidden;
}

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content.with-sidebar{
        margin-left: 0;
        width: 100%;
        min-height: 100vh;
        overflow-x: visible;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content.with-sidebar{
    margin-left: 0;
    width: 100%;
    min-height: 100vh;
    overflow-x: visible;
}
    
    .sidebar-toggle {
        display: block;
    }
}

/* =========================================================
   FINAL SIDEBAR PATCH (2026-01-14)
   - Align sidebar header height with top header
   - Nav item hover/active: no horizontal shift, consistent padding
   ========================================================= */

/* Sidebar Header: match the dashboard header height exactly */
.sidebar-header {
    height: var(--cordlook-header-height);
    min-height: var(--cordlook-header-height);
    padding: 0 var(--cordlook-header-pad-x);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.85rem;
    box-sizing: border-box;
    flex-shrink: 0;
}

.sidebar-header h2 {
    margin: 0;
    line-height: 1.05;
}

.sidebar-logo {
    height: 44px;
    width: auto;
    flex-shrink: 0;
}

/* Nav spacing: keep everything visually left-aligned and consistent */
.sidebar-nav {
    padding: 1rem 0.75rem 1.25rem;
}

.nav-section-title {
    padding: 0.35rem 0.85rem 0.2rem;
    margin: 1rem 0 0.35rem;
    z-index: 1;
}

.nav-divider {
    margin: 1rem 0.75rem;
}

/* Prevent any hover/active style from changing the layout */
.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    box-sizing: border-box;
    margin: 0.18rem 0;
    padding: 0.85rem 0.9rem;
    border-radius: 14px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.95rem;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(15, 22, 36, 0.55);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04) inset, 0 8px 22px rgba(0, 0, 0, 0.28);
    position: relative;
    overflow: hidden;
    transform: translateZ(0);
    transition: background 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease, color 0.22s ease, transform 0.22s ease;
}

/* Admin menu uses many direct nav items; keep fixed height and tighter spacing */
.admin-sidebar .sidebar-nav {
    gap: 0.45rem;
}

.admin-sidebar .sidebar-nav > .nav-item {
    flex: 0 0 auto;
    min-height: 48px;
}

/* Sidebar menu items must never shrink; overflow should be handled by scrolling */
.sidebar-nav > .nav-item,
.sidebar-nav > .nav-section,
.sidebar-nav > .nav-divider {
    flex: 0 0 auto;
}

.nav-section > .nav-item {
    flex: 0 0 auto;
    min-height: 48px;
}

.nav-item:hover {
    background: rgba(27, 36, 58, 0.92);
    border-color: rgba(34, 211, 238, 0.62);
    color: rgba(245, 247, 255, 0.96);

    /* “살짝 빛” + 입체감 */
    box-shadow:
        0 0 0 1px rgba(34, 211, 238, 0.38) inset,
        0 18px 38px rgba(0, 0, 0, 0.35),
        0 0 28px rgba(34, 211, 238, 0.3);

    transform: translateY(-2px);
}

.nav-item.active {
    background: rgba(30, 40, 68, 0.95);
    border-color: rgba(34, 211, 238, 0.7);
    color: rgba(245, 247, 255, 0.98);
    box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.3) inset, 0 18px 38px rgba(0, 0, 0, 0.32);
    transform: translateY(-1px);
}

/* Left indicator bar (no layout shift because it is absolutely positioned) */
.nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 10%;
    height: 80%;
    width: 4px;
    border-radius: 999px;
    background: var(--gradient-primary);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.nav-item:hover::before,
.nav-item.active::before {
    opacity: 1;
}

/* Premium Button - Gold Style */
.nav-item-premium:hover {
    background: rgba(40, 35, 20, 0.95);
    border-color: rgba(255, 215, 0, 0.7);
    color: rgba(255, 215, 0, 0.98);
    box-shadow:
        0 0 0 1px rgba(255, 215, 0, 0.25) inset,
        0 6px 20px rgba(255, 215, 0, 0.15),
        0 0 30px rgba(255, 215, 0, 0.2);
    transform: translateY(-2px);
}

.nav-item-premium.active {
    background: linear-gradient(135deg, rgba(50, 45, 25, 0.98) 0%, rgba(40, 35, 20, 0.95) 100%);
    border-color: rgba(255, 215, 0, 0.8);
    color: rgba(255, 215, 0, 1);
    box-shadow:
        0 0 0 1px rgba(255, 215, 0, 0.35) inset,
        0 8px 25px rgba(255, 215, 0, 0.2),
        0 0 40px rgba(255, 215, 0, 0.25);
    transform: translateY(-1px);
}

.nav-item-premium:hover .nav-icon,
.nav-item-premium.active .nav-icon {
    background: rgba(255, 215, 0, 0.15);
    border-color: rgba(255, 215, 0, 0.3);
    filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.5));
}

.nav-item-premium:hover::before,
.nav-item-premium.active::before {
    background: linear-gradient(180deg, #FFD700, #FFA500);
}

/* ✅ 로그아웃 버튼 (너무 빨강 X: 차분한 앰버/골드 톤) */
.logout-btn {
    background: linear-gradient(135deg,
        rgba(245, 158, 11, 0.26) 0%,
        rgba(251, 191, 36, 0.18) 52%,
        rgba(15, 23, 42, 0.90) 100%
    ) !important;
    border-color: rgba(245, 158, 11, 0.55) !important;
    box-shadow: 0 16px 40px rgba(5, 10, 24, 0.55), inset 0 0 18px rgba(245, 158, 11, 0.12) !important;
}

/* hover 시에도 기존 청록빛 대신 앰버 톤으로 */
.logout-btn:hover {
    box-shadow: var(--shadow-lg), 0 0 20px rgba(245, 158, 11, 0.28) !important;
    border-color: rgba(245, 158, 11, 0.75) !important;
}

/* =========================================================
   반응형 안정화 가드
   - 사이드바 텍스트 잘림/넘침 방지
   ========================================================= */
.nav-item {
    min-width: 0;
}

.nav-text {
    overflow-wrap: anywhere;
    word-break: break-word;
}

@media (max-width: 768px) {
    .sidebar-header {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .sidebar-header h2 {
        max-width: calc(100% - 60px);
        white-space: normal;
    }

    .nav-item {
        align-items: flex-start;
    }
}
