/**
 * Sidebar Styles
 * Witit - AI Image Generator
 */

.sidebar {
    width: 280px;
    background: rgba(6, 6, 10, 0.98);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Desktop collapsed state - use negative margin to remove from flow */
.sidebar.collapsed {
    margin-left: -280px;
}

/* Sidebar Toggle Button */
.sidebar-toggle-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 101;
    width: 44px;
    height: 44px;
    background: rgba(6, 6, 10, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-toggle-btn svg {
    width: 20px;
    height: 20px;
}

.sidebar-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(0, 212, 255, 0.3);
    transform: scale(1.05);
    color: white;
    box-shadow: 0 4px 20px rgba(0, 212, 255, 0.15);
}

/* Move toggle button when sidebar is open - position inside sidebar */
body:not(.sidebar-collapsed) .sidebar-toggle-btn {
    left: 224px;
    background: transparent;
    border-color: rgba(255, 255, 255, 0.1);
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                background 0.2s ease,
                border-color 0.2s ease;
}

body:not(.sidebar-collapsed) .sidebar-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
}

body.sidebar-collapsed .sidebar-toggle-btn {
    left: 20px;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                background 0.2s ease,
                border-color 0.2s ease;
}

.sidebar-header {
    padding: 20px 56px 20px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

/* Logo */
.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-img {
    height: 48px;
    width: auto;
    filter: drop-shadow(0 0 20px rgba(0, 212, 255, 0.3));
    animation: logoGlow 3s ease-in-out infinite;
}

/* Performance: Disable logo glow animation on mobile */
@media (max-width: 768px) {
    .logo-img {
        animation: none;
        filter: drop-shadow(0 0 10px rgba(0, 212, 255, 0.2));  /* Simpler shadow */
    }
}

@media (prefers-reduced-motion: reduce) {
    .logo-img {
        animation: none !important;
    }
}

.logo-text {
    font-family: 'Pacifico', cursive;
    font-size: 32px;
    background: linear-gradient(135deg, #00d4ff 0%, #ff00aa 50%, #ffaa00 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* New Chat Button */
.new-chat-btn {
    width: 100%;
    margin-top: 16px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
}

.new-chat-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(0, 212, 255, 0.3);
}

.new-chat-btn svg {
    width: 18px;
    height: 18px;
    opacity: 0.7;
}

/* Personas Sidebar Button */
.personas-sidebar-btn {
    width: 100%;
    margin-top: 8px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
}

.personas-sidebar-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 0, 170, 0.3);
    color: white;
}

.personas-sidebar-btn svg {
    width: 18px;
    height: 18px;
    opacity: 0.7;
}

/* Chat List */
.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

/* Custom Scrollbar Styling */
.chat-list::-webkit-scrollbar {
    width: 6px;
}

.chat-list::-webkit-scrollbar-track {
    background: transparent;
}

.chat-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.chat-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.chat-item {
    padding: 12px 14px;
    border-radius: 10px;
    cursor: pointer;
    margin-bottom: 4px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.chat-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.chat-item.active {
    background: rgba(0, 212, 255, 0.1);
    border: 1px solid rgba(0, 212, 255, 0.2);
}

.chat-item-content {
    flex: 1;
    min-width: 0;
}

.chat-item-title {
    font-size: 13px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-meta {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 2px;
}

/* Stacked Persona Avatars in Sidebar */
.chat-item .chat-persona-stack {
    position: relative;
    height: 24px;
    flex-shrink: 0;
}

.chat-item .chat-persona-avatar {
    position: absolute;
    top: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(6, 6, 10, 0.98);
    background: rgba(255, 255, 255, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chat-item:hover .chat-persona-avatar {
    border-color: rgba(0, 212, 255, 0.3);
}

.chat-item.active .chat-persona-avatar {
    border-color: rgba(0, 212, 255, 0.4);
    box-shadow: 0 0 8px rgba(0, 212, 255, 0.2);
}

.chat-delete-btn {
    opacity: 0;
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.4);
    transition: all 0.2s ease;
    border-radius: 6px;
}

.chat-item:hover .chat-delete-btn {
    opacity: 1;
}

.chat-delete-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.chat-delete-btn svg {
    width: 14px;
    height: 14px;
}

/* Sidebar Overlay (Mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 90;
}

.sidebar-overlay.visible {
    display: block;
}

/* Mobile Header */
.mobile-header {
    display: none;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    align-items: center;
    gap: 12px;
}

.menu-btn {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.7);
    border-radius: 8px;
}

.menu-btn:hover {
    background: rgba(255, 255, 255, 0.05);
}

.menu-btn svg {
    width: 24px;
    height: 24px;
}

.mobile-logo {
    font-family: 'Pacifico', cursive;
    font-size: 28px;
    background: linear-gradient(135deg, #00d4ff 0%, #ff00aa 50%, #ffaa00 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 100;
        transform: translateX(-100%);
        margin-left: 0; /* Reset margin-left for mobile */
        transition: transform 0.3s ease;
        background: #06060a;
    }

    .sidebar.open {
        transform: translateX(0) !important;
    }

    /* Reset collapsed state on mobile - use open class instead */
    .sidebar.collapsed {
        margin-left: 0;
        transform: translateX(-100%);
    }

    .sidebar.collapsed.open {
        transform: translateX(0) !important;
    }

    .sidebar-header {
        background: #06060a;
    }

    .chat-list {
        background: #06060a;
    }

    .mobile-header {
        display: flex;
    }

    /* Hide desktop toggle on mobile, use mobile header instead */
    .sidebar-toggle-btn {
        display: none;
    }

    /* ============================================
       FLOATING MOBILE HEADER (when chat is active)
       ============================================ */
    .chat-active .mobile-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 50;
        padding: 12px 16px;
        padding-top: max(12px, env(safe-area-inset-top));
        border-bottom: none;
        background: transparent;
        pointer-events: none;
    }

    .chat-active .mobile-header > * {
        pointer-events: auto;
    }

    .chat-active .mobile-logo {
        display: none;
    }

    .chat-active .menu-btn,
    .chat-active .mobile-header .settings-btn {
        width: 42px;
        height: 42px;
        border-radius: 50%;
        background: rgba(15, 15, 20, 0.75);
        backdrop-filter: blur(24px);
        -webkit-backdrop-filter: blur(24px);
        border: 1px solid rgba(255, 255, 255, 0.08);
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3),
                    0 0 0 1px rgba(255, 255, 255, 0.03) inset,
                    0 8px 32px rgba(0, 0, 0, 0.2);
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        color: rgba(255, 255, 255, 0.85);
        transition: all 0.2s ease;
    }

    .chat-active .menu-btn:active,
    .chat-active .mobile-header .settings-btn:active {
        transform: scale(0.92);
        background: rgba(25, 25, 30, 0.9);
    }

    .chat-active .menu-btn svg,
    .chat-active .mobile-header .settings-btn svg {
        width: 18px;
        height: 18px;
        opacity: 0.9;
    }

    /* Adjust chat container when header is floating */
    .chat-active .chat-container {
        padding-top: 0;
    }

    .chat-active .chat-content {
        /* Account for fixed thread-header height: safe-area + 10px padding + 38px avatar + 6px gap + ~20px name + 10px padding */
        padding-top: calc(84px + env(safe-area-inset-top, 0px));
    }

    /* Active personas bar - sits at top center, buttons overlay corners */
    .chat-active .active-personas-bar {
        padding-top: max(12px, env(safe-area-inset-top));
        padding-left: 56px;
        padding-right: 56px;
    }
}

/* ============================================
   SIDEBAR BOTTOM SECTION
   ============================================ */
.sidebar-bottom {
    margin-top: auto;
    padding: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-bottom .sign-in-btn {
    width: 100%;
}

.sidebar-bottom .user-menu {
    padding: 0;
    border-top: none;
    margin-top: 0;
}

/* ============================================
   THREAD LIST (replaces Chat List)
   ============================================ */
.thread-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.thread-list::-webkit-scrollbar {
    width: 6px;
}

.thread-list::-webkit-scrollbar-track {
    background: transparent;
}

.thread-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.thread-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.thread-empty {
    text-align: center;
    padding: 40px 20px;
    color: rgba(255, 255, 255, 0.35);
    font-size: 13px;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.thread-empty-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 8px;
    opacity: 0.3;
    color: rgba(255, 255, 255, 0.4);
}

.thread-empty-title {
    font-size: 14px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 4px;
}

.thread-empty-subtitle {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.3);
}

/* New persona badge */
.new-badge {
    font-size: 10px;
    font-weight: 600;
    color: #00d4ff;
    background: rgba(0, 212, 255, 0.15);
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* New persona item styling */
.thread-item.is-new {
    opacity: 0.85;
}

.thread-item.is-new .thread-preview {
    color: rgba(255, 255, 255, 0.35);
    font-style: italic;
}

.thread-item.is-new:hover {
    opacity: 1;
}

/* Sidebar quick actions container (Add Friend + New Group) */
.sidebar-quick-actions {
    display: flex;
    gap: 8px;
    padding: 4px 8px 8px 8px;
}

/* Add Friend Button - top of thread list */
.add-friend-entry {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    flex: 1;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.08) 0%, rgba(123, 47, 247, 0.08) 100%);
    border: 1px dashed rgba(0, 212, 255, 0.25);
    cursor: pointer;
    transition: all 0.2s ease;
}

.add-friend-entry:hover {
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.15) 0%, rgba(123, 47, 247, 0.15) 100%);
    border-color: rgba(0, 212, 255, 0.4);
    transform: translateY(-1px);
}

/* New Group button variant */
.add-friend-entry.new-group-entry {
    background: linear-gradient(135deg, rgba(123, 47, 247, 0.08) 0%, rgba(255, 0, 170, 0.08) 100%);
    border-color: rgba(123, 47, 247, 0.25);
}

.add-friend-entry.new-group-entry:hover {
    background: linear-gradient(135deg, rgba(123, 47, 247, 0.15) 0%, rgba(255, 0, 170, 0.15) 100%);
    border-color: rgba(123, 47, 247, 0.4);
}

.add-friend-entry.new-group-entry .add-friend-icon svg {
    color: rgba(123, 47, 247, 0.9);
}

.add-friend-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.15) 0%, rgba(123, 47, 247, 0.15) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.add-friend-icon svg {
    width: 14px;
    height: 14px;
    color: rgba(0, 212, 255, 0.9);
}

.add-friend-text {
    font-size: 12px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.85);
    white-space: nowrap;
}

.thread-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 1px;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.thread-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.thread-item.active {
    background: rgba(0, 212, 255, 0.1);
    border-color: rgba(0, 212, 255, 0.2);
}

/* New persona highlight animation */
.thread-item.newly-created {
    animation: newPersonaPulse 1.5s ease-out forwards;
}

/* Thread Avatar - Compact size */
.thread-avatar {
    position: relative;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: visible;
    background: rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
}

.thread-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* SVG placeholder avatars */
.thread-avatar img[src$=".svg"] {
    object-fit: contain;
    padding: 5px;
}

.thread-avatar .thread-initial {
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
}

/* Unread message indicator - scaled for compact avatars */
.unread-badge {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 10px;
    height: 10px;
    background: linear-gradient(135deg, #00d4ff, #0096ff);
    border-radius: 50%;
    border: 2px solid rgba(6, 6, 10, 0.98);
    box-shadow: 0 0 6px rgba(0, 212, 255, 0.5);
}

.thread-item.has-unread {
    background: rgba(0, 212, 255, 0.03);
}

.thread-item.has-unread .thread-name {
    font-weight: 600;
}

/* Hide unread badge when thread is active */
.thread-item.active .unread-badge {
    display: none;
}

/* Utility persona indicator */
.thread-item.utility .thread-avatar {
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.2), rgba(0, 150, 255, 0.2));
    border: 1px solid rgba(0, 212, 255, 0.3);
}

/* Friend persona indicator */
.thread-item.friend .thread-avatar {
    background: linear-gradient(135deg, rgba(255, 0, 170, 0.2), rgba(255, 100, 200, 0.2));
    border: 1px solid rgba(255, 0, 170, 0.2);
}

/* ============================================
   RELATIONSHIP DEPTH INDICATOR
   ============================================ */
.thread-avatar {
    position: relative;
}

.relationship-dot {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid rgba(6, 6, 10, 0.98);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.thread-item:hover .relationship-dot {
    transform: scale(1.1);
}

/* Relationship stage colors */
.relationship-dot.gray {
    background: rgba(255, 255, 255, 0.3);
}

.relationship-dot.blue {
    background: #00d4ff;
    box-shadow: 0 0 6px rgba(0, 212, 255, 0.4);
}

.relationship-dot.green {
    background: #10b981;
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.4);
}

.relationship-dot.purple {
    background: #a855f7;
    box-shadow: 0 0 6px rgba(168, 85, 247, 0.4);
}

.relationship-dot.gold {
    background: #fbbf24;
    box-shadow: 0 0 6px rgba(251, 191, 36, 0.5);
}

/* Active thread - make indicator more prominent */
.thread-item.active .relationship-dot {
    transform: scale(1.15);
}

.thread-item.active .relationship-dot.blue {
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.6);
}

.thread-item.active .relationship-dot.green {
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.6);
}

.thread-item.active .relationship-dot.purple {
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.6);
}

.thread-item.active .relationship-dot.gold {
    box-shadow: 0 0 10px rgba(251, 191, 36, 0.7);
}

/* Thread Info */
.thread-info {
    flex: 1;
    min-width: 0;
}

/* Thread content - simple horizontal layout */
.thread-content {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
}

.thread-name {
    font-size: 14px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.95);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.thread-preview {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Thread Meta (time) */
.thread-meta {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.thread-time {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
}

/* Thread type badge (utility/friend) */
.thread-type-badge {
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 8px;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.thread-type-badge.utility {
    background: rgba(0, 212, 255, 0.15);
    color: rgba(0, 212, 255, 0.9);
}

.thread-type-badge.friend {
    background: rgba(255, 0, 170, 0.15);
    color: rgba(255, 0, 170, 0.9);
}

/* ============================================
   THREAD HEADER (in main chat area) - iMessage Style
   ============================================ */
.thread-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px 20px;
    background: transparent;
    position: sticky;
    top: 0;
    z-index: 20;
}

.thread-persona-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.thread-persona-avatar {
    width: 67px;
    height: 67px;
    border-radius: 50%;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.thread-persona-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thread-persona-avatar .persona-initial {
    font-size: 20px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
}

.thread-persona-name {
    font-size: 15px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    text-align: center;
}

/* Group header - stacked avatars */
.thread-persona-avatar.avatar-stack {
    position: relative;
    width: 72px;
    height: 67px;
    background: transparent;
    box-shadow: none;
}

.thread-persona-avatar.avatar-stack .group-header-avatar {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.thread-actions {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
}

.thread-action-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.6);
    transition: all 0.2s ease;
}

.thread-action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-color: rgba(255, 255, 255, 0.2);
}

.thread-action-btn svg {
    width: 18px;
    height: 18px;
}

/* ============================================
   NEW GROUP BUTTON
   ============================================ */
.new-group-btn {
    width: 100%;
    margin-top: 8px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
}

.new-group-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(0, 212, 255, 0.3);
    color: white;
}

.new-group-btn svg {
    width: 18px;
    height: 18px;
    opacity: 0.7;
}

/* ============================================
   GROUP ITEMS IN THREAD LIST
   ============================================ */
.thread-item.group {
    border: 1px solid transparent;
}

.thread-item.group:hover {
    border-color: rgba(0, 212, 255, 0.15);
}

.thread-item.group.active {
    background: rgba(0, 212, 255, 0.1);
    border-color: rgba(0, 212, 255, 0.25);
}

/* Stacked Avatars for Groups - Compact */
.group-avatar-stack,
.thread-avatar.avatar-stack {
    position: relative;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.group-avatar-stack .stacked-avatar,
.avatar-stack .stacked-avatar {
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    object-fit: cover;
    border: 1.5px solid rgba(6, 6, 10, 0.98);
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
}

/* Position stacked avatars - overlapping grid */
.group-avatar-stack .stacked-avatar:nth-child(1) {
    top: 0;
    left: 0;
    z-index: 4;
}

.group-avatar-stack .stacked-avatar:nth-child(2) {
    top: 0;
    right: 0;
    z-index: 3;
}

.group-avatar-stack .stacked-avatar:nth-child(3) {
    bottom: 0;
    left: 0;
    z-index: 2;
}

.group-avatar-stack .stacked-avatar:nth-child(4) {
    bottom: 0;
    right: 0;
    z-index: 1;
}

/* When only 2 avatars, position them diagonally */
.group-avatar-stack.count-2 .stacked-avatar:nth-child(1) {
    top: 4px;
    left: 4px;
}

.group-avatar-stack.count-2 .stacked-avatar:nth-child(2) {
    bottom: 4px;
    right: 4px;
}

/* When only 3 avatars */
.group-avatar-stack.count-3 .stacked-avatar:nth-child(3) {
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
}

/* Group badge */
.group-badge {
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 8px;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
    background: rgba(0, 212, 255, 0.15);
    color: rgba(0, 212, 255, 0.9);
}

/* Mobile thread header */
@media (max-width: 768px) {
    .thread-header {
        padding: 10px 16px;
        padding-top: max(10px, env(safe-area-inset-top));
    }

    .thread-persona-avatar {
        width: 38px;
        height: 38px;
    }

    .thread-persona-name {
        font-size: 14px;
    }

    .chat-active .thread-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 45;
        padding-left: 60px;
        padding-right: 60px;
    }
}

/* ============================================
   WIT ENTRY (Pinned omniscient companion)
   ============================================ */
.thread-item.wit-entry {
    margin-bottom: 6px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
}

.thread-item.wit-entry:hover {
    background: rgba(255, 255, 255, 0.05);
}

.thread-item.wit-entry.active {
    background: rgba(0, 212, 255, 0.1);
    border-color: rgba(0, 212, 255, 0.2);
}

.wit-avatar {
    position: relative;
    background: rgba(255, 255, 255, 0.06);
    padding: 0;
}

.wit-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 4px;
}

.wit-indicator {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 9px;
    height: 9px;
    background: linear-gradient(135deg, #00d4ff, #ff00aa);
    border-radius: 50%;
    border: 2px solid rgba(6, 6, 10, 0.98);
    animation: wit-pulse 2s infinite;
}

@keyframes wit-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(0.9); }
}

/* ============================================
   THREAD SECTION DIVIDERS
   ============================================ */
.thread-section-divider {
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.08) 20%,
        rgba(255, 255, 255, 0.08) 80%,
        transparent 100%
    );
    margin: 6px 10px;
}

/* ============================================
   THREAD SECTIONS (Groups only now)
   ============================================ */
.thread-section {
    margin-bottom: 4px;
}

.thread-section-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 16px 12px 8px;
    color: rgba(255, 255, 255, 0.4);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.thread-section-header .section-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.thread-section-header .section-icon svg {
    width: 12px;
    height: 12px;
    stroke-width: 2;
}

.thread-section-header .section-label {
    flex: 1;
}

.thread-section-items {
    display: flex;
    flex-direction: column;
}

/* Wit intro styling (empty state) */
.wit-empty .wit-intro {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 40px;
}

.wit-intro-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 24px;
    border: 3px solid rgba(0, 212, 255, 0.3);
    box-shadow: 0 0 40px rgba(0, 212, 255, 0.15);
}

/* Wit uses same styling as other personas - no special treatment */

/* ============================================
   USER GROUP ITEMS (Real user groups)
   ============================================ */

/* User group item in sidebar */
.thread-item.user-group-item {
    border-radius: 8px;
}

/* User group stacked avatars - distinguish from persona groups */
.thread-item.user-group-item .avatar-stack.user-stack {
    position: relative;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.thread-item.user-group-item .stacked-avatar {
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    object-fit: cover;
    /* White border to distinguish from persona groups (which have gradient) */
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: #1a1a2e;
}

/* Position stacked avatars for user groups */
.user-stack .stacked-avatar:nth-child(1) {
    top: 0;
    left: 0;
    z-index: 4;
}

.user-stack .stacked-avatar:nth-child(2) {
    top: 0;
    right: 0;
    z-index: 3;
}

.user-stack .stacked-avatar:nth-child(3) {
    bottom: 0;
    left: 0;
    z-index: 2;
}

.user-stack .stacked-avatar:nth-child(4) {
    bottom: 0;
    right: 0;
    z-index: 1;
}

/* When only 2 avatars in user group */
.user-stack.count-2 .stacked-avatar:nth-child(1) {
    top: 4px;
    left: 4px;
}

.user-stack.count-2 .stacked-avatar:nth-child(2) {
    bottom: 4px;
    right: 4px;
}

/* When only 3 avatars in user group */
.user-stack.count-3 .stacked-avatar:nth-child(3) {
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
}

/* Online indicator on stacked avatars */
.user-stack .stacked-avatar.online {
    border-color: rgba(34, 197, 94, 0.6);
}

/* Thread preview for user groups */
.thread-item.user-group-item .thread-preview {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

/* Active state for user group */
.thread-item.user-group-item.active {
    background: rgba(0, 212, 255, 0.1);
}

.thread-item.user-group-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.thread-item.user-group-item.active:hover {
    background: rgba(0, 212, 255, 0.15);
}
