/* Body scroll lock when chatlist is displayed */
body.chatlist-active {
    overflow: hidden !important;
    height: 100vh !important;
    height: 100dvh !important;
}

body.chatlist-active .site-footer,
body.chatlist-active #stickyBottomNav,
body.chatlist-active #chat-discovery {
    display: none !important;
}

/* Chat List Tabs Navigation */
#chat-list-tabs {
    background-color: #1a1a2e;
}

#chatListTabs {
    border-bottom: none;
    padding: 4px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin: 0 0.5rem;
    display: flex;
    gap: 8px;
}

#chatListTabs .nav-link {
    color: rgba(255, 255, 255, 0.7);
    border: none;
    border-bottom: none;
    padding: 12px 16px;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    border-radius: 10px;
    flex: 1;
    gap: 8px;
}

#chatListTabs .nav-link:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.05);
    border-bottom-color: transparent;
}

#chatListTabs .nav-link.active {
    color: #ffffff;
    background: linear-gradient(135deg, #b58afe 0%, #6c5ce7 100%);
    border-bottom-color: transparent;
}

#chatListTabs .nav-link i {
    font-size: 1.1rem;
}

/* Layout helpers to keep nav and spinner fixed while the tab panes scroll */
#chat-list {
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column;
    height: calc(100vh - 3rem);
    height: calc(100dvh - 3rem);
    background-color: #0f0f1a;
    background-image:
        radial-gradient(ellipse at top left, rgba(181, 138, 254, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at bottom right, rgba(108, 92, 231, 0.08) 0%, transparent 50%);
}

#chatListTabContent {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

#chat-latest-content,
#chat-favorites-content,
#chat-groups-content {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.5rem 0 1rem;
    position: relative;
    background-color: transparent;
}

#latest-chat-list,
#favorites-chat-list,
#groups-chat-list {
    padding: 0 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 80px;
}

/* Favorite Count Badge */
#favorite-count-badge {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.2) !important;
}

#chatListTabContent > .tab-pane {
    display: none;
    flex: 1 1 0;
    min-height: 0;
}

#chatListTabContent > .tab-pane.show,
#chatListTabContent > .tab-pane.active {
    display: flex;
    flex-direction: column;
}

/* Chat List Items - Favorites-style design */
#chat-list .cl-chat-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    color: inherit;
}

#chat-list .cl-chat-item:hover {
    background: rgba(181, 138, 254, 0.1);
    border-color: rgba(181, 138, 254, 0.3);
    transform: translateX(4px);
}

#chat-list .cl-chat-item.active {
    background: rgba(181, 138, 254, 0.15);
    border-color: rgba(181, 138, 254, 0.4);
}

#chat-list .cl-chat-avatar-wrapper {
    flex-shrink: 0;
    width: 52px;
    height: 52px;
}

#chat-list .cl-chat-avatar {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid rgba(181, 138, 254, 0.3);
}

/* Heart level badge on latest-chat-list avatar */
#chat-list .cl-heart-badge {
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 22px;
    height: 22px;
    pointer-events: none;
}

#chat-list .cl-heart-badge .heart-icon {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: brightness(1.4) drop-shadow(0 0 10px #c084fc);
}

#chat-list .cl-heart-badge .heart-number {
    position: absolute;
    font-size: 8px;
    font-weight: 900;
    text-shadow: 0 0 0px #000, 0 1px 1px rgba(0, 0, 0, 0.62);
    pointer-events: none;
}

#chat-list .cl-chat-info {
    flex: 1;
    min-width: 0;
}

#chat-list .cl-chat-name {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #ffffff;
}

#chat-list .cl-chat-preview {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#chat-list .cl-chat-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    flex-shrink: 0;
}

#chat-list .cl-chat-time {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
}

#chat-list .cl-favorite-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    transition: all 0.3s ease;
    line-height: 1;
}

#chat-list .cl-favorite-btn:hover,
#chat-list .cl-favorite-btn.active {
    color: #fdcb6e;
    background: rgba(253, 203, 110, 0.1);
}

#chat-list .cl-favorite-btn.active i {
    animation: clHeartBeat 0.5s ease;
}

@keyframes clHeartBeat {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* Empty State */
#chat-list .cl-empty-state {
    text-align: center;
    padding: 40px 20px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    margin: 1rem;
}

#chat-list .cl-empty-state-icon {
    font-size: 3rem;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 16px;
}

#chat-list .cl-empty-state-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: #ffffff;
}

#chat-list .cl-empty-state-text {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
}

/* Loading State */
.chat-loading-state {
    animation: fadeIn 0.3s ease-in;
}

/* Groups loading state - override absolute positioning from chat-history-sidebar */
#groups-loading-spinner.chat-loading-state {
    position: static;
    transform: none;
    width: auto !important;
    max-width: none !important;
    margin: 0.5rem 0.75rem !important;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Responsive Design */
@media (max-width: 768px) {
    #chatListTabs .nav-link {
        padding: 10px 12px;
        font-size: 0.85rem;
    }

    #chatListTabs .nav-link i {
        font-size: 1rem;
    }

    #favorite-count-badge {
        font-size: 0.65rem;
        padding: 0.2rem 0.4rem;
    }

    #chat-list .cl-chat-avatar-wrapper {
        width: 46px;
        height: 46px;
    }

    #chat-list .cl-chat-avatar {
        width: 46px;
        height: 46px;
    }

    #chat-list .cl-heart-badge {
        width: 20px;
        height: 20px;
        bottom: -5px;
    }
}

/* Tab Transitions */
#chatListTabContent > .tab-pane {
    animation: fadeInTab 0.2s ease-in;
}

@keyframes fadeInTab {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Dark theme text color overrides for chat list */
#chat-list .text-muted {
    color: rgba(255, 255, 255, 0.5) !important;
}

#chat-list .text-secondary {
    color: rgba(255, 255, 255, 0.7) !important;
}

/* Scrollbar */
#chat-latest-content::-webkit-scrollbar,
#chat-favorites-content::-webkit-scrollbar,
#chat-groups-content::-webkit-scrollbar {
    width: 6px;
}

#chat-latest-content::-webkit-scrollbar-track,
#chat-favorites-content::-webkit-scrollbar-track,
#chat-groups-content::-webkit-scrollbar-track {
    background: transparent;
}

#chat-latest-content::-webkit-scrollbar-thumb,
#chat-favorites-content::-webkit-scrollbar-thumb,
#chat-groups-content::-webkit-scrollbar-thumb {
    background: rgba(181, 138, 254, 0.3);
    border-radius: 3px;
}

#chat-latest-content::-webkit-scrollbar-thumb:hover,
#chat-favorites-content::-webkit-scrollbar-thumb:hover,
#chat-groups-content::-webkit-scrollbar-thumb:hover {
    background: rgba(181, 138, 254, 0.5);
}
