/* OneAI-Inspired Sidebar - Modern Professional Design */

.sidebar-content {
    background: linear-gradient(180deg, #ffffff 0%, #fafbfc 100%);
    height: 100%; /* Full height của container cha */
    display: flex;
    flex-direction: column;
    padding: 10px 0 0 0;
    width: 100%; /* Chiếm full width của app-sidebar */
    transition: position 0.3s ease, width 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94), 
                box-shadow 0.3s ease,
                background 0.3s ease;
    overflow: hidden;
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.08);
    border-right: 1px solid #e8eaed;
    position: absolute; /* Absolute mặc định */
    top: 0;
    left: 0;
    z-index: 1000; /* Đảm bảo sidebar luôn ở trên */
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* Class dành riêng cho menu expanded */
.sidebar-content.menu-expanded {
    width: 300px !important;
    box-shadow: 2px 0 30px rgba(0, 0, 0, 0.12) !important;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%) !important;
    transition: width 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), 
                box-shadow 0.3s ease,
                background 0.3s ease !important;
}

.sidebar-content.menu-expanded::before {
    width: 4px !important;
    box-shadow: 0 0 15px rgba(247, 147, 30, 0.3) !important;
}

.sidebar-content.menu-expanded .brand-icon {
    transform: scale(1.05) !important;
    box-shadow: 0 6px 20px rgba(247, 147, 30, 0.35) !important;
}

.sidebar-content.menu-expanded .brand-text {
    opacity: 1 !important;
    transform: translateX(0) !important;
}

.sidebar-content.menu-expanded .pin-toggle {
    opacity: 1 !important;
}

.sidebar-content.menu-expanded .nav-link.active {
    border-radius: 12px !important;
}

.sidebar-content.menu-expanded .nav-link span {
    opacity: 1 !important;
    transform: translateX(0) !important;
    display: inline !important;
}

.sidebar-content.menu-expanded .recent-title {
    opacity: 1 !important;
    transform: translateX(0) !important;
}

.sidebar-content.menu-expanded .recent-item span {
    opacity: 1 !important;
    transform: translateX(0) !important;
}

.sidebar-content.menu-expanded .nav-link {
    transition-delay: calc(var(--item-index, 0) * 0.02s) !important;
}

.sidebar-content.menu-expanded .nav-link::after {
    display: none !important;
}

/* Pinned state - giữ mở rộng */
.sidebar-content.pinned {
    width: 300px !important;
    box-shadow: 2px 0 30px rgba(0, 0, 0, 0.12);
    transition: width 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), 
                box-shadow 0.3s ease,
                position 0.3s ease;
    position: relative !important; /* Chuyển thành relative khi pin */
}

/* Khi pinned hoặc expanded, không cần hover để hiển thị tooltip */
.sidebar-content.pinned .nav-link::after,
.sidebar-content.sidebar-expanded .nav-link::after {
    display: none !important;
}

/* Khi pinned và KHÔNG muốn expand main content - chỉ ảnh hưởng đến app-content margin, không ảnh hưởng đến sidebar width */

/* Subtle animation line */
.sidebar-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
}

.sidebar-content:hover::before,
.sidebar-content.expanded::before,
.sidebar-content.menu-expanded::before {
    width: 4px;
    box-shadow: 0 0 15px rgba(247, 147, 30, 0.3);
}

/* Brand Section - Professional */
.sidebar-brand {
    display: flex;
    align-items: center;
    padding: 0 1.5rem 9px 1.5rem;
    border-bottom: 1px solid #e8eaed;
    margin-bottom: 1.5rem;
    white-space: nowrap;
    position: relative;
}

.brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #ff6b35 0%, #f7931e 50%, #ff8c42 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 1rem;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(247, 147, 30, 0.25);
    transition: all 0.3s ease;
}

.sidebar-content:hover .brand-icon,
.sidebar-content.expanded .brand-icon,
.sidebar-content.menu-expanded .brand-icon {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(247, 147, 30, 0.35);
}

.brand-icon i {
    color: white;
    font-size: 1.25rem;
    font-weight: 600;
}

.brand-text {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1a1a1a;
    opacity: 0;
    transition: opacity 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.15s,
                transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.15s;
    transform: translateX(-10px);
    letter-spacing: -0.025em;
}

/* Pin Toggle Button */
.pin-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #6c757d;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    font-size: 16px;
    opacity: 0;
    transition: opacity 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                background 0.3s ease,
                color 0.3s ease,
                transform 0.3s ease;
    z-index: 10;
    line-height: 1;
}

.sidebar-content:hover .pin-toggle,
.sidebar-content.expanded .pin-toggle,
.sidebar-content.menu-expanded .pin-toggle {
    opacity: 1;
}

.pin-toggle:hover {
    background: #f1f3f4;
    color: #495057;
    transform: translateY(-50%) scale(1.1);
}

.pin-toggle.pinned {
    color: #ff6b35;
    opacity: 1;
}

.pin-toggle.pinned i {
    transform: rotate(45deg);
}

/* Khi sidebar được pin, luôn hiển thị nút */
.sidebar-content.pinned .pin-toggle {
    opacity: 1;
}

/* Navigation - Modern & Professional */
.sidebar-nav {
    flex: 1; /* Chiếm toàn bộ không gian còn lại */
    padding: 0 0.75rem;
    display: flex;
    flex-direction: column; /* Đảm bảo hiển thị theo chiều dọc */
    overflow: hidden; /* Không để tràn ra ngoài */
    min-height: 0; /* Cho phép flex shrink */
    height: 100%; /* Đảm bảo full height */
    margin-bottom: 5px;
    border-bottom: 1px solid #e5e7eb;
    border-radius: 12px;
}

.sidebar-nav .nav {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column; /* Các nav items xếp theo chiều dọc */
    width: 100%;
    flex: 1; /* Chiếm không gian còn lại */
    height: 100%; /* Full height */
}

.nav-item {
    position: relative;
    width: 100%; /* Đảm bảo chiếm full width */
    display: block; /* Đảm bảo không có display flex */
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 1rem 1.25rem;
    color: #5f6368;
    text-decoration: none;
    border-radius: 12px;
    margin: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
    min-height: 48px;
    width: 100%; /* Đảm bảo chiếm full width container */
    box-sizing: border-box;
}

/* Mode thu gọn - chỉ hiện icon (chỉ khi KHÔNG có menu-expanded) */
.sidebar-content:not(.menu-expanded) .nav-link {
    padding: 1rem;
    border-radius: 12px 4px 4px 4px;
    width: 48px;
    height: 48px;
    justify-content: center;
    margin: 0 auto 0.5rem auto;
}

.nav-link:hover {
    background: rgba(255, 107, 53, 0.08);
    color: #ff6b35;
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.15);
}

/* Hover trong mode thu gọn */
.sidebar-content:not(:hover):not(.menu-expanded) .nav-link:hover {
    transform: scale(1.1);
}

.nav-link.active {
    background: linear-gradient(90deg, rgba(255, 107, 53, 0.12), rgba(247, 147, 30, 0.12));
    color: #ff6b35;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(255, 107, 53, 0.2);
}

/* Active state cho mode thu gọn */
.sidebar-content:not(:hover):not(.menu-expanded) .nav-link.active {
    width: 48px;
    height: 48px;
    border-radius: 12px; /* Bo tròn theo tỷ lệ 3:1:1:1 */
}

/* Active state cho mode mở rộng */
.sidebar-content:hover .nav-link.active,
.sidebar-content.expanded .nav-link.active,
.sidebar-content.menu-expanded .nav-link.active {
    border-radius: 12px;
}

.nav-link.active::after {
    content: '';
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    background: #ff6b35;
    border-radius: 50%;
    opacity: 1;
}

/* Ẩn dot indicator trong mode thu gọn */
.sidebar-content:not(:hover):not(.menu-expanded) .nav-link.active::after {
    display: none;
}

.nav-link i {
    width: 24px;
    height: 24px;
    margin-right: 1rem;
    font-size: 1.1rem;
    text-align: center;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 1;
    position: relative;
}

/* Icon trong mode thu gọn */
.sidebar-content:not(:hover):not(.menu-expanded) .nav-link i {
    margin-right: 0; /* Loại bỏ margin để icon ở giữa */
}

.nav-link:hover i {
    transform: scale(1.1);
    color: #ff6b35;
}

.nav-link span {
    opacity: 0;
    transition: opacity 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.15s,
                transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.15s;
    white-space: nowrap;
    transform: translateX(-10px);
    z-index: 1;
    position: relative;
    font-weight: 500;
}

/* Khi thu gọn, span mất nhanh hơn */
.sidebar-content:not(:hover):not(.menu-expanded) .nav-link span {
    transition: opacity 0.2s ease,
                transform 0.2s ease;
}

.sidebar-content:hover .nav-link span,
.sidebar-content.expanded .nav-link span,
.sidebar-content.menu-expanded .nav-link span {
    opacity: 1;
    transform: translateX(0);
    display: inline;
}

/* Ẩn hoàn toàn span trong mode thu gọn (chỉ khi KHÔNG có menu-expanded) */
.sidebar-content:not(.menu-expanded) .nav-link span {
    display: none;
}

/* Tooltip - Premium Design */
.nav-link::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 15px);
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(135deg, #2d3748, #1a202c);
    color: white;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    pointer-events: none;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
}

/* Tooltip Arrow - Sử dụng pseudo-element riêng */
.nav-item::before {
    content: '';
    position: absolute;
    left: calc(100% + 5px);
    top: 50%;
    transform: translateY(-50%);
    border: 8px solid transparent;
    border-right-color: #2d3748;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
}

/* Hiển thị tooltip với animation đẹp */
.sidebar-content:not(:hover):not(.menu-expanded) .nav-link:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) translateX(5px);
}

.sidebar-content:not(:hover):not(.menu-expanded) .nav-item:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Background gradient cho nav-link */
.nav-link-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, rgba(255, 107, 53, 0.1), rgba(247, 147, 30, 0.1));
    transition: width 0.3s ease;
    z-index: 0;
    border-radius: inherit;
}

.nav-link:hover .nav-link-bg {
    width: 100%;
}

/* Recent Section - Elegant */
.sidebar-recent {
    margin-top: 2rem;
    padding: 1.5rem 0.75rem 0 0.75rem;
    border-top: 1px solid #e8eaed;
    position: relative;
}

.sidebar-recent::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 1px;
    background: linear-gradient(90deg, transparent, #ff6b35, transparent);
}

.recent-title {
    padding: 0 1.25rem 1rem 1.25rem;
    color: #9ca3af;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin: 0;
    opacity: 0;
    transition: opacity 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.2s,
                transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.2s;
    white-space: nowrap;
    transform: translateX(-10px);
}

.sidebar-content:hover .recent-title,
.sidebar-content.expanded .recent-title,
.sidebar-content.menu-expanded .recent-title {
    opacity: 1;
    transform: translateX(0);
}

.recent-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.recent-item {
    margin-bottom: 0.25rem;
}

.recent-item a {
    display: block;
    padding: 0.75rem 1.25rem;
    color: #6b7280;
    text-decoration: none;
    border-radius: 10px;
    margin: 0;
    transition: all 0.3s ease;
    font-size: 0.85rem;
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    position: relative;
}

.recent-item a:hover {
    background: rgba(255, 107, 53, 0.05);
    color: #ff6b35;
    transform: translateX(4px);
}

.recent-item a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    background: #ff6b35;
    border-radius: 2px;
    transition: height 0.3s ease;
}

.recent-item a:hover::before {
    height: 60%;
}

.recent-item span {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
    opacity: 0;
    transition: opacity 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.2s,
                transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.2s;
    transform: translateX(-10px);
}

.sidebar-content:hover .recent-item span,
.sidebar-content.expanded .recent-item span,
.sidebar-content.menu-expanded .recent-item span {
    opacity: 1;
    transform: translateX(0);
}

/* Scrollbar - Custom Premium Design */
.sidebar-content::-webkit-scrollbar {
    width: 6px;
}

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

.sidebar-content::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(255, 107, 53, 0.3), rgba(247, 147, 30, 0.3));
    border-radius: 3px;
    transition: all 0.3s ease;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, rgba(255, 107, 53, 0.6), rgba(247, 147, 30, 0.6));
}

/* Micro-interactions */
.sidebar-content:hover .nav-link,
.sidebar-content.expanded .nav-link,
.sidebar-content.menu-expanded .nav-link {
    transition-delay: calc(var(--item-index, 0) * 0.02s);
}

/* Modern glassmorphism effect */
.sidebar-content {
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

/* Add subtle animation on load */
@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.sidebar-content {
    animation: slideInLeft 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hover state for entire sidebar */
.sidebar-content:hover,
.sidebar-content.expanded,
.sidebar-content.menu-expanded {
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

/* Active state improvements */
.nav-link.active {
    position: relative;
    background: linear-gradient(90deg, 
        rgba(255, 107, 53, 0.15) 0%, 
        rgba(247, 147, 30, 0.1) 50%, 
        rgba(255, 107, 53, 0.05) 100%);
}

.nav-link.active::before {
    width: 100%;
    background: linear-gradient(90deg, 
        rgba(255, 107, 53, 0.1), 
        rgba(247, 147, 30, 0.08));
}

/* Enhanced shadows and depth */
.nav-link:hover {
    box-shadow: 
        0 4px 12px rgba(255, 107, 53, 0.15),
        0 2px 6px rgba(0, 0, 0, 0.05);
}

.nav-link.active {
    box-shadow: 
        0 2px 8px rgba(255, 107, 53, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Responsive Sidebar */
@media (max-width: 992px) {
    .sidebar-content {
        width: 60px; /* Thu nhỏ hơn trên tablet */
    }
    
    .sidebar-content:hover {
        width: 250px; /* Hover nhỏ hơn */
    }
    
    .sidebar-content.menu-expanded {
        width: 250px !important;
    }
    
    .sidebar-content.pinned {
        width: 250px !important;
    }
}

@media (max-width: 768px) {
    .sidebar-content {
        width: 280px; /* Mobile sidebar rộng hơn */
        transform: translateX(-100%); /* Ẩn mặc định */
        transition: transform 0.3s ease, width 0.3s ease;
    }
    
    .sidebar-content.mobile-open {
        transform: translateX(0); /* Hiện khi mở */
    }
    
    .sidebar-content:hover {
        width: 280px;
    }
}
