/* --- Sidebar-Styles aus chat-layout.css übernommen (modularisiert) --- */
/* entfernt doppelte Sidebar-Definition, Layout wird unten geregelt */
#sidebar-user-container {
    padding: 10px 12px !important;
    background: transparent !important;
    border-bottom: 1px solid #eee !important;
    display: flex !important;
    align-items: center !important;
    flex-shrink: 0 !important;
    position: relative !important;
    color: #0f172a !important;
    min-height: 64px !important;
}
.sidebar-topbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    width: 100%;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 10px 12px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.05);
}
.sidebar-user-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.sidebar-username {
    font-weight: 600;
    font-size: 14px;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    display: block;
}
.sidebar-pill {
    display: none;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #1f2937;
    font-weight: 600;
    font-size: 13px;
    line-height: 1;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
    cursor: pointer;
}
.sidebar-pill img {
    width: 16px;
    height: 16px;
}
.sidebar-action-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-start;
    width: 100%;
    padding-left: 4px;
    margin-top: 4px;
}

#btn-giftbox {
    order: -1;
}

#sidebar-stones-badge {
    order: -2;
}
.icon-btn {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #fff;
    transition: all 0.15s ease-in-out;
    cursor: pointer;
}
.icon-btn:hover,
.sidebar-pill:hover {
    background: #eef2ff;
    border-color: #c7d2fe;
}
.icon-btn img { width: 20px; height: 20px; }

.avatar-peek {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid #e5e7eb;
    background: #fff;
    cursor: default;
    position: relative;
    background-size: cover;
    background-position: center;
}

.avatar-peek::after {
    content: '';
    position: absolute;
    inset: 6px;
    border-radius: 50%;
    border: 2px solid #cbd5e1;
}

.sidebar-avatar-popover {
    display: none;
    position: absolute;
    top: 115%;
    left: 0;
    width: 140px;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.16);
    background: #fff;
    padding: 6px;
    object-fit: cover;
    z-index: 1002;
}

.sidebar-invisible-icon { width: 18px; height: 18px; cursor: pointer; }
.sidebar-invisible-icon { display: none; }
.sidebar-header {
    padding: 15px;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
    flex-shrink: 0;
}
.sidebar-header h5 {
    margin: 0 0 10px 0;
    font-size: 14px;
    font-weight: 600;
    color: #495057;
}
.sidebar-scroll-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
}
.online-users-section {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 15px 15px 5px 15px;
    border-bottom: 1px solid #eee;
    background: white;
    min-height: auto;
    max-height: 50vh;
}
.online-users-section h5 {
    margin: 0 0 10px 0;
    font-size: 14px;
    font-weight: 600;
    color: #495057;
    flex-shrink: 0;
}
.chat-rooms-section {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 15px 15px 15px 15px;
    border-bottom: none;
    background: white;
    min-height: 150px;
    max-height: none;
}
.chat-rooms-section h5 {
    display: block;
    margin: 0 0 10px 0;
    font-size: 14px;
    font-weight: 600;
    color: #495057;
    flex-shrink: 0;
}
#user-search {
    width: 100%;
    padding: 8px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background: white;
    color: #333;
    margin-bottom: 5px;
}
#user-search::placeholder {
    color: #6c757d;
}
#online-users-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    margin: 10px 0 0 0;
    padding: 0;
    list-style: none;
    min-height: 0;
}
.user-search {
    margin: 8px 0 5px 0;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    width: 100%;
    font-size: 14px;
}
#chat-rooms {
    overflow-y: auto;
    padding: 0px 0;
    flex: 1;
    min-height: 0;
    margin-top: 0;
}
#chat-rooms .room-item {
    padding: 8px 12px;
    margin: 2px 0;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border: 1px solid transparent;
    font-size: 14px;
}
#chat-rooms .room-item:hover {
    background-color: #f8f9fa;
    border-color: #dee2e6;
}
#chat-rooms .room-item.active {
    background-color: #4a90e2;
    color: white;
    font-weight: 500;
}
#chat-rooms .room-item.active:hover {
    background-color: #3a80d2;
}
/* Zentrale Sidebar-Styles für modularen Chat */

.sidebar {
    grid-area: sidebar;
    background-color: #fff;
    padding: 15px;
    color: #000;
    display: flex;
    flex-direction: column;
    box-shadow: -2px 0 5px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.sidebar-header {
    flex: 0 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap; /* prevent header elements from wrapping to next line */
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e0e0e0;
}

/* Ensure header action buttons (help / exit / giftbox) are aligned in one row */
.sidebar-header-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.sidebar-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 4px;
    border-radius: 10px;
    background: #fff;
    border: 1px solid #e5e7eb;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
}

.sidebar-action-btn img { width: 20px; height: 20px; }

.online-users-section {
    flex: 0 0 auto;
    max-height: 50vh;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    margin-bottom: 2px;
}

#online-users-list {
    max-height: 300px;
    overflow-y: auto;
    margin-top: 10px;
    margin-bottom: 8px;
    border-radius: 8px;
    background: #f8f9fa;
    box-shadow: 0 1px 4px #0001;
    padding: 6px 0 6px 0;
    display: flex;
    flex-direction: column;
}

#online-users-list > div {
    padding: 7px 14px;
    border-bottom: 1px solid #e9ecef;
    font-size: 15px;
    color: #333;
    cursor: pointer;
    transition: background 0.15s;
}

#online-users-list > div:last-child {
    border-bottom: none;
}

#online-users-list > div:hover {
    background: #e9ecef;
}

.room-header {
    background: #f0f0f0;
    padding: 5px 8px;
    font-size: 12px;
    font-weight: bold;
    color: #333;
    border-radius: 3px;
    margin: 3px 0;
}

.online-user-item {
    padding: 3px 8px;
    font-size: 13px;
    color: #555;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.online-user-item:hover {
    background-color: #e9ecef;
}

.role-user { color: #333; }
.role-mod { color: #28a745; font-weight: bold; }
.role-admin { color: #dc3545; font-weight: bold; }
.role-super-admin { color: #6f42c1; font-weight: bold; }

.user-search-container {
    position: relative;
    margin-bottom: 5px;
}

.user-search-container .user-search {
    width: 100%;
    padding: 10px 80px 10px 12px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    background: #f8f9fa;
}

.user-search-container .user-search:focus {
    border-color: #007bff;
    box-shadow: 0 0 8px rgba(0, 123, 255, 0.3);
    background: #fff;
}

.online-count-badge {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(40, 167, 69, 0.3);
    pointer-events: none;
    white-space: nowrap;
}

#online-users-count {
    font-weight: 700;
}

.room-users {
    max-height: 300px;
    overflow-y: auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    border: 1px solid #ddd;
    border-top: none;
    padding: 5px 0;
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 0 0 6px 6px;
    list-style-type: none;
    margin: 0;
    will-change: contents;
    transition: all 0.2s ease-in-out;
}

.room-users .user-item {
    padding: 5px 10px;
    display: flex;
    align-items: center;
    font-size: 0.9rem;
    margin-bottom: 2px;
    min-height: 28px;
    transition: background-color 0.15s ease-in-out;
}

.room-users .user-item:hover {
    background-color: rgba(255, 255, 255, 0.5);
}

.room-users .no-users {
    font-style: italic;
    color: #666;
    padding: 5px 10px;
    font-size: 0.9rem;
}

.room-name {
    max-width: calc(100% - 50px);
    overflow: visible;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.room-name .password-icon {
    width: 16px !important;
    height: 16px !important;
    margin-left: 5px;
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    flex-shrink: 0;
}

.online-user-count {
    margin-left: auto;
    font-size: 0.8rem;
    color: #333;
    background-color: rgba(255, 255, 255, 0.5);
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 35px;
    text-align: center;
}

.username.admin {
    color: #e53935 !important;
    font-weight: bold !important;
}
.username.mod {
    color: #ff9800 !important;
    font-weight: bold !important;
}

.room-avatar-img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    vertical-align: middle;
    margin-right: 6px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    background: #fff;
}

.user-item {
    display: flex;
    align-items: center;
    gap: 4px;
    position: relative;
    min-height: 32px;
    padding: 2px 0;
    background: transparent !important;
}

.username {
    background: transparent !important;
}
.username.admin {
    color: #e53935 !important;
    font-weight: bold !important;
    background: transparent !important;
}
.username.mod {
    color: #ff9800 !important;
    font-weight: bold !important;
    background: transparent !important;
}

.room-username-hover {
    position: relative;
    cursor: pointer;
    font-weight: 500;
    z-index: 2;
}

@media (max-width: 600px) {
    .sidebar {
        flex: 0 0 auto;
        width: 100%;
        position: relative;
        box-shadow: none;
        padding: 10px;
        overflow-y: auto;
        max-height: 50vh;
    }
    .chat-room-list {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
        margin: 5px 0;
    }
    .chat-room-btn {
        font-size: 0.95em;
        padding: 8px 10px;
        border-radius: 6px;
        min-width: 90px;
    }
}

@media (min-width: 601px) and (max-width: 1024px) {
    .sidebar {
        position: relative !important;
        z-index: 1 !important;
        width: 100% !important;
        box-shadow: none !important;
        padding: 10px !important;
        background: #fff !important;
    }
}

/* ===== User Status Dropdown ===== */

.sidebar-status-icon {
    display: inline-block;
    margin-left: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: transform 0.2s ease;
}

.sidebar-status-icon:hover {
    transform: scale(1.2);
}

.sidebar-status-icon .status-icon {
    font-size: 14px;
}

.status-dropdown {
    position: absolute;
    top: 50px;
    left: 10px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 10000;
    min-width: 200px;
    padding: 8px 0;
}

.status-dropdown-item {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.status-dropdown-item:hover {
    background-color: #f5f5f5;
}

.status-dropdown-item .status-icon {
    margin-right: 12px;
    font-size: 16px;
}

.status-dropdown-item span {
    font-size: 14px;
    color: #333;
}

/* Dark Mode Unterstützung */
[data-theme="dark"] .status-dropdown {
    background: #2a2a2a;
    border-color: #444;
}

[data-theme="dark"] .status-dropdown-item {
    color: #fff;
}

[data-theme="dark"] .status-dropdown-item:hover {
    background-color: #3a3a3a;
}

[data-theme="dark"] .status-dropdown-item span {
    color: #fff;
}
