/**
 * Chat-Box v2: Neues Design für Chat-Section und Add-Contact-Section
 * Überschreibt/ergänzt chat.css für Sidebar, Kontaktliste, Neue Kontakte, Chat-Header, Nachrichten, Eingabe
 */

/* ========== Chat Sidebar v2 ========== */
.chat-sidebar-v2 {
    display: flex;
    flex-direction: column;
    background: #fafafa;
    border-right: 1px solid #eee;
}

.chat-sidebar-toolbar {
    flex-shrink: 0;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border-bottom: 1px solid #eee;
}

.chat-sidebar-back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #1a1a1a;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.chat-sidebar-back-btn:hover {
    background: #e9ecef;
    color: #1a1a1a;
}

.chat-sidebar-search-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 12px;
    background: #f1f3f5;
    border-radius: 10px;
    border: 1px solid transparent;
    transition: background 0.2s, border-color 0.2s;
}

.chat-sidebar-search-wrap:focus-within {
    background: #fff;
    border-color: #dee2e6;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1);
}

.chat-sidebar-search-icon {
    flex-shrink: 0;
    color: #868e96;
}

.chat-sidebar-search-input {
    flex: 1;
    min-width: 0;
    border: none;
    background: none;
    font-size: 14px;
    color: #1a1a1a;
    outline: none;
}

.chat-sidebar-search-input::placeholder {
    color: #868e96;
}

.chat-sidebar-filter-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #1a1a1a;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.chat-sidebar-filter-btn:hover,
.chat-sidebar-filter-btn.active {
    background: #e9ecef;
    color: #1a1a1a;
}

/* Filter Dropdown v2 */
.chat-filter-dropdown-v2 {
    position: absolute;
    top: 100%;
    left: 12px;
    right: 12px;
    margin-top: 4px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.06);
    z-index: 100;
    overflow: hidden;
    display: none;
}

.chat-filter-dropdown-v2.active {
    display: block;
}

.chat-filter-dropdown-v2 .chat-filter-header {
    padding: 12px 14px;
    font-size: 13px;
    font-weight: 600;
    color: #1a1a1a;
    border-bottom: 1px solid #eee;
}

.chat-filter-dropdown-v2 .chat-filter-content {
    max-height: 220px;
    overflow-y: auto;
    padding: 8px;
}

.chat-filter-dropdown-v2 .chat-filter-group {
    margin-bottom: 10px;
}

.chat-filter-dropdown-v2 .chat-filter-group:last-child {
    margin-bottom: 0;
}

.chat-filter-dropdown-v2 .chat-filter-group-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #868e96;
    margin-bottom: 6px;
    padding: 0 4px;
}

.chat-filter-dropdown-v2 .chat-filter-options-compact {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chat-filter-dropdown-v2 .chat-filter-option-compact {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 13px;
    color: #1a1a1a;
    cursor: pointer;
    transition: background 0.15s;
}

.chat-filter-dropdown-v2 .chat-filter-option-compact:hover {
    background: #f1f3f5;
}

.chat-filter-dropdown-v2 .chat-filter-option-compact input {
    margin: 0;
}

.chat-filter-dropdown-v2 .chat-filter-actions {
    padding: 8px 10px;
    border-top: 1px solid #eee;
}

.chat-filter-dropdown-v2 .chat-filter-clear {
    width: 100%;
    padding: 8px 12px;
    font-size: 13px;
    color: #1a1a1a;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.chat-filter-dropdown-v2 .chat-filter-clear:hover {
    background: #e9ecef;
    border-color: #ced4da;
}

.chat-sidebar-toolbar {
    position: relative;
}

/* Contacts list v2 */
.chat-contacts-list-v2 {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

/* Contact items (Sidebar + Neue Kontakte) – einheitliches v2-Design */
.chat-sidebar-v2 .chat-contact-item,
.chat-new-contacts-view-v2 .chat-contact-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    cursor: pointer;
    border-radius: 10px;
    margin: 2px 8px;
    border: none;
}

.chat-sidebar-v2 .chat-contact-item:hover,
.chat-new-contacts-view-v2 .chat-contact-item:hover {
    background: #f1f3f5;
}

.chat-sidebar-v2 .chat-contact-item.active,
.chat-new-contacts-view-v2 .chat-contact-item.active {
    --kinma-chat-contact-active-grey: #1c1c1c;
    background: linear-gradient(
        90deg,
        rgba(28, 28, 28, 0.72) 0%,
        rgba(28, 28, 28, 0.38) 34%,
        rgba(28, 28, 28, 0.12) 58%,
        transparent 100%
    );
    box-shadow: inset 2px 0 0 #1c1c1c;
}

.chat-sidebar-v2 .chat-contact-item.active:hover,
.chat-new-contacts-view-v2 .chat-contact-item.active:hover {
    background: linear-gradient(
        90deg,
        rgba(28, 28, 28, 0.8) 0%,
        rgba(28, 28, 28, 0.44) 34%,
        rgba(28, 28, 28, 0.16) 58%,
        transparent 100%
    );
}

.chat-sidebar-v2 .chat-contact-item.active .chat-contact-name,
.chat-new-contacts-view-v2 .chat-contact-item.active .chat-contact-name {
    color: #1c1c1c !important;
    font-weight: 600;
    text-shadow:
        0 0 6px rgba(255, 255, 255, 0.95),
        0 0 14px rgba(255, 255, 255, 0.7),
        0 1px 2px rgba(255, 255, 255, 0.9);
}

.chat-sidebar-v2 .chat-contact-item.active .chat-contact-preview,
.chat-new-contacts-view-v2 .chat-contact-item.active .chat-contact-preview {
    color: #1c1c1c !important;
    font-weight: 400;
    text-shadow:
        0 0 6px rgba(255, 255, 255, 0.95),
        0 0 14px rgba(255, 255, 255, 0.7),
        0 1px 2px rgba(255, 255, 255, 0.9);
}

.chat-sidebar-v2 .chat-contact-item.active .chat-contact-drag-handle,
.chat-new-contacts-view-v2 .chat-contact-item.active .chat-contact-drag-handle {
    color: rgba(255, 255, 255, 0.92) !important;
}

.chat-sidebar-v2 .chat-contact-item.active .chat-contact-time,
.chat-new-contacts-view-v2 .chat-contact-item.active .chat-contact-time {
    color: #1c1c1c !important;
    font-size: 12px;
    font-weight: 400;
}

/* Mobil: kein hervorgehobener aktiver Kontakt (Sidebar v2) */
@media (max-width: 768px) {
    .chat-sidebar-v2 .chat-contact-item.active,
    .chat-new-contacts-view-v2 .chat-contact-item.active {
        background: transparent !important;
        box-shadow: none !important;
    }

    .chat-sidebar-v2 .chat-contact-item.active:hover,
    .chat-new-contacts-view-v2 .chat-contact-item.active:hover {
        background: #f1f3f5 !important;
    }

    .chat-sidebar-v2 .chat-contact-item.active .chat-contact-avatar,
    .chat-new-contacts-view-v2 .chat-contact-item.active .chat-contact-avatar {
        filter: brightness(1.06);
    }
}

.chat-sidebar-v2 .chat-contact-info,
.chat-new-contacts-view-v2 .chat-contact-info {
    flex: 1;
    min-width: 0;
}

.chat-sidebar-v2 .chat-contact-name,
.chat-new-contacts-view-v2 .chat-contact-name {
    font-size: 14px;
    font-weight: 500;
    color: #1a1a1a;
    margin-bottom: 2px;
}

.chat-sidebar-v2 .chat-contact-preview,
.chat-new-contacts-view-v2 .chat-contact-preview {
    font-size: 13px;
    color: #868e96;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-sidebar-v2 .chat-contact-meta,
.chat-new-contacts-view-v2 .chat-contact-meta {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.chat-sidebar-v2 .chat-contact-time,
.chat-new-contacts-view-v2 .chat-contact-time {
    font-size: 12px;
    color: #868e96;
}

.chat-sidebar-v2 .chat-contact-unread,
.chat-new-contacts-view-v2 .chat-contact-unread {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: #0d6efd;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-sidebar-v2 .chat-contact-avatar-wrapper,
.chat-new-contacts-view-v2 .chat-contact-avatar-wrapper {
    position: relative;
}

/* Self-chat (Notizen): Avatar-Farbe wie andere Kontakte (Kontoprofil / inline) */

/* ========== Neue Kontakte (Add Contact) v2 ========== */
.chat-new-contacts-view-v2 {
    display: flex;
    flex-direction: column;
    background: #fafafa;
    min-width: 0;
    overflow: hidden;
}

.chat-new-contacts-header-v2 {
    flex-shrink: 0;
    padding: 16px;
    background: #fff;
    border-bottom: 1px solid #eee;
}

.chat-new-contacts-title-v2 {
    margin: 0 0 12px 0;
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
}

.chat-new-contacts-search-v2 {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 42px;
    padding: 0 14px;
    background: #f1f3f5;
    border-radius: 10px;
    border: 1px solid transparent;
    transition: background 0.2s, border-color 0.2s;
}

.chat-new-contacts-search-v2:focus-within {
    background: #fff;
    border-color: #dee2e6;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.08);
}

.chat-new-contacts-search-icon {
    flex-shrink: 0;
    color: #868e96;
}

.chat-new-contacts-view-v2 .chat-new-contacts-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    padding: 8px;
}

/* ========== Chat Main v2 (rechter Bereich) ========== */
.chat-main-v2 {
    display: flex;
    flex-direction: column;
    background: #fff;
}

.chat-main-header-v2 {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    padding: 12px 16px;
    min-height: 64px;
    background: #fff;
    border-bottom: 1px solid #eee;
}

.chat-user-info-v2 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex: 1;
    min-width: 0;
    cursor: pointer;
}

.chat-user-info-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.chat-user-avatar-v2 {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #adb5bd 0%, #868e96 100%);
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-user-details {
    min-width: 0;
}

.chat-main-header-v2 .chat-user-name {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 2px;
}

.chat-main-header-v2 .chat-user-status-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #868e96;
}

.chat-main-header-v2 .chat-user-status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #adb5bd;
    flex-shrink: 0;
}

.chat-main-header-v2 .chat-user-status-indicator[data-status="green"] {
    background: #40c057;
}

.chat-call-btn-v2 {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: 10px;
    background: #f1f3f5;
    color: #1a1a1a;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.chat-call-btn-v2:hover,
.chat-call-btn-v2:focus-visible {
    background: #22c55e;
    color: #ffffff;
}

.chat-main-header-v2 .chat-call-buttons {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Messages area v2 */
.chat-messages-v2 {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    background: #f8f9fa;
}

.chat-empty-state-v2 {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px;
    text-align: center;
}

.chat-empty-state-v2 svg {
    color: #dee2e6;
    margin-bottom: 16px;
}

.chat-empty-state-v2 h3 {
    margin: 0 0 8px 0;
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
}

.chat-empty-state-v2 p {
    margin: 0;
    font-size: 14px;
    color: #868e96;
}

/* Input container v2 */
.chat-input-container-v2 {
    flex-shrink: 0;
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid #eee;
}

/* ========== Ein Chat-Avatar-Design (Kontakte, Nav, Header, Profil-Overlay) ========== */
#chatPopup,
.chat-popup-root,
#chatPopupMirror {
    --kinma-chat-avatar-size: 44px;
    --kinma-chat-left-family-name-color: #dc2626;
    --kinma-presence-dot-scale: 0.28;
    --kinma-presence-cutout-gap: 1.5px;
    --kinma-presence-green: #40c057;
    --kinma-presence-yellow: #fab005;
    --kinma-presence-red: #fa5252;
    --kinma-presence-gray: #adb5bd;
}

#chatPopup .chat-contact-avatar-wrapper,
#chatPopup .chat-nav-profile,
#chatPopup .chat-user-avatar-wrap,
#chatPopupMirror .chat-contact-avatar-wrapper,
#chatPopupMirror .chat-nav-profile,
#chatPopupMirror .chat-user-avatar-wrap,
.chat-popup-root .chat-contact-avatar-wrapper,
.chat-popup-root .chat-nav-profile,
.chat-popup-root .chat-user-avatar-wrap {
    --kinma-avatar-size: var(--kinma-chat-avatar-size);
    --kinma-presence-dot-size: clamp(
        10px,
        calc(var(--kinma-avatar-size) * var(--kinma-presence-dot-scale, 0.28)),
        32px
    );
    position: relative;
    overflow: visible;
    flex-shrink: 0;
}

#chatPopup .chat-nav-profile,
#chatPopupMirror .chat-nav-profile,
.chat-popup-root .chat-nav-profile {
    width: var(--kinma-chat-avatar-size);
    height: var(--kinma-chat-avatar-size);
}

/* Kontaktliste: gleiche Stack-Größe wie Nav (legacy chat.css/style.css hatten 10–11px-Dots) */
#chatPopup .chat-contact-avatar-wrapper,
#chatPopupMirror .chat-contact-avatar-wrapper,
.chat-popup-root .chat-contact-avatar-wrapper {
    width: var(--kinma-chat-avatar-size);
    height: var(--kinma-chat-avatar-size);
    margin-top: 0;
}

#chatPopup .chat-contact-status,
#chatPopupMirror .chat-contact-status,
.chat-popup-root .chat-contact-status {
    width: var(--kinma-presence-dot-size) !important;
    height: var(--kinma-presence-dot-size) !important;
    min-width: var(--kinma-presence-dot-size);
    min-height: var(--kinma-presence-dot-size);
    bottom: var(--kinma-presence-dot-offset) !important;
    right: var(--kinma-presence-dot-offset) !important;
}

#chatPopup .chat-user-avatar-wrap,
#chatPopupMirror .chat-user-avatar-wrap,
.chat-popup-root .chat-user-avatar-wrap,
#chatMain .chat-main-header .chat-user-avatar-wrap {
    width: var(--kinma-chat-avatar-size);
    height: var(--kinma-chat-avatar-size);
    --kinma-avatar-size: var(--kinma-chat-avatar-size);
    --kinma-presence-dot-size: clamp(
        10px,
        calc(var(--kinma-avatar-size) * var(--kinma-presence-dot-scale, 0.28)),
        32px
    );
}

#chatPopup .chat-contact-avatar,
#chatPopup .chat-nav-profile-avatar,
#chatPopup .chat-user-avatar,
#chatPopup .chat-header-profile-overlay-picture-circle,
#chatPopupMirror .chat-contact-avatar,
#chatPopupMirror .chat-nav-profile-avatar,
#chatPopupMirror .chat-user-avatar,
#chatPopupMirror .chat-header-profile-overlay-picture-circle,
.chat-popup-root .chat-contact-avatar,
.chat-popup-root .chat-nav-profile-avatar,
.chat-popup-root .chat-user-avatar,
.chat-popup-root .chat-header-profile-overlay-picture-circle {
    width: var(--kinma-avatar-size, var(--kinma-chat-avatar-size));
    height: var(--kinma-avatar-size, var(--kinma-chat-avatar-size));
    min-width: var(--kinma-avatar-size, var(--kinma-chat-avatar-size));
    min-height: var(--kinma-avatar-size, var(--kinma-chat-avatar-size));
    border-radius: 50% !important;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: calc(var(--kinma-avatar-size, var(--kinma-chat-avatar-size)) * 0.32);
    line-height: 1;
    color: #ffffff;
    background-color: #1a1a1a;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border: none !important;
    box-shadow: none !important;
    overflow: hidden;
    flex-shrink: 0;
}

#chatPopup .chat-nav-profile-avatar,
#chatPopupMirror .chat-nav-profile-avatar,
.chat-popup-root .chat-nav-profile-avatar {
    background-image: none !important;
    background: #1a1a1a;
}

#chatPopup .chat-header-profile-overlay-picture-circle,
#chatPopupMirror .chat-header-profile-overlay-picture-circle,
.chat-popup-root .chat-header-profile-overlay-picture-circle {
    font-weight: 700;
    font-size: calc(var(--kinma-avatar-size, var(--kinma-chat-avatar-size)) * 0.36);
}

:root {
    --kinma-presence-dot-offset: 0px;
    --kinma-presence-dot-size: clamp(
        10px,
        calc(var(--kinma-chat-avatar-size, 44px) * var(--kinma-presence-dot-scale, 0.28)),
        32px
    );
}

#chatMain .chat-user-avatar-wrap--group .chat-user-avatar-status-dot {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

.chat-contact-status,
.chat-user-avatar-status-dot,
.chat-header-profile-overlay-avatar-status-dot,
.chat-nav-profile-status,
.profile-picture-presence-dot {
    position: absolute;
    bottom: var(--kinma-presence-dot-offset);
    right: var(--kinma-presence-dot-offset);
    width: var(--kinma-presence-dot-size) !important;
    height: var(--kinma-presence-dot-size) !important;
    min-width: var(--kinma-presence-dot-size);
    min-height: var(--kinma-presence-dot-size);
    border-radius: 50%;
    border: none;
    box-sizing: border-box;
    flex-shrink: 0;
    z-index: 25;
    pointer-events: none;
    opacity: 1;
    box-shadow: none;
    transition: background-color 0.25s ease;
}

/* Aussparung in der Ecke + farbiger Statuspunkt darüber */
.chat-contact-avatar-wrapper:has(.chat-contact-status) .chat-contact-avatar,
.chat-nav-profile:has(.chat-nav-profile-status) .chat-nav-profile-avatar,
#chatMain .chat-user-avatar-wrap:not(.chat-user-avatar-wrap--group):has(.chat-user-avatar-status-dot) .chat-user-avatar,
.chat-header-profile-overlay-picture-wrapper:has(.chat-header-profile-overlay-avatar-status-dot)
    .chat-header-profile-overlay-picture-circle,
.profile-picture-wrapper-vertical:has(.profile-picture-presence-dot) .profile-picture-circle {
    --presence-cutout-r: calc(var(--kinma-presence-dot-size) * 0.5 + var(--kinma-presence-cutout-gap, 1.5px));
    --presence-mask-x: calc(100% - var(--kinma-presence-dot-offset) - var(--kinma-presence-dot-size) * 0.5);
    --presence-mask-y: var(--presence-mask-x);
    -webkit-mask-image: radial-gradient(
        circle at var(--presence-mask-x) var(--presence-mask-y),
        transparent 0,
        transparent var(--presence-cutout-r),
        #000 calc(var(--presence-cutout-r) + 0.5px)
    );
    mask-image: radial-gradient(
        circle at var(--presence-mask-x) var(--presence-mask-y),
        transparent 0,
        transparent var(--presence-cutout-r),
        #000 calc(var(--presence-cutout-r) + 0.5px)
    );
}

/* Familie verlassen: roter Name + Exit-Icon (kein Avatar-Verlauf) */

/* Name + Exit-Icon nebeneinander */
.chat-user-name-row,
.chat-header-profile-overlay-name-row {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    max-width: 100%;
}

.chat-user-name-row .chat-user-name,
.chat-header-profile-overlay-name-row .chat-header-profile-overlay-name {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
}

.chat-user-header-exit-icon,
.chat-header-profile-overlay-exit-icon {
    flex-shrink: 0;
    margin-left: 0;
}

#chatMain .chat-main-header--left-family .chat-user-name,
.chat-header-profile-overlay--left-family .chat-header-profile-overlay-name {
    color: var(--kinma-chat-left-family-name-color, #dc2626) !important;
}

#chatMain .chat-main-header--left-family .chat-user-header-exit-icon,
#chatMain .chat-main-header--left-family .chat-contact-exit-account-icon,
.chat-header-profile-overlay--left-family .chat-header-profile-overlay-exit-icon {
    color: var(--kinma-chat-left-family-name-color, #dc2626) !important;
}

.chat-nav-profile:hover .chat-nav-profile-avatar,
.chat-nav-profile:active .chat-nav-profile-avatar,
.chat-nav-profile:hover .chat-nav-profile-status,
.chat-nav-profile:active .chat-nav-profile-status {
    transform: none !important;
    box-shadow: none !important;
}

.chat-contact-status[data-status="green"],
.chat-contact-status[data-status="online"],
.chat-user-avatar-status-dot[data-status="green"],
.chat-user-avatar-status-dot[data-status="online"],
.chat-header-profile-overlay-avatar-status-dot[data-status="green"],
.chat-header-profile-overlay-avatar-status-dot[data-status="online"],
.chat-nav-profile-status[data-status="green"],
.chat-nav-profile-status[data-status="online"],
.profile-picture-presence-dot[data-status="green"],
.profile-picture-presence-dot[data-status="online"] {
    background-color: var(--kinma-presence-green) !important;
}

.chat-contact-status[data-status="yellow"],
.chat-contact-status[data-status="away"],
.chat-user-avatar-status-dot[data-status="yellow"],
.chat-user-avatar-status-dot[data-status="away"],
.chat-header-profile-overlay-avatar-status-dot[data-status="yellow"],
.chat-header-profile-overlay-avatar-status-dot[data-status="away"],
.chat-nav-profile-status[data-status="yellow"],
.chat-nav-profile-status[data-status="away"],
.profile-picture-presence-dot[data-status="yellow"],
.profile-picture-presence-dot[data-status="away"] {
    background-color: var(--kinma-presence-yellow) !important;
}

.chat-contact-status[data-status="red"],
.chat-contact-status[data-status="dnd"],
.chat-user-avatar-status-dot[data-status="red"],
.chat-user-avatar-status-dot[data-status="dnd"],
.chat-header-profile-overlay-avatar-status-dot[data-status="red"],
.chat-header-profile-overlay-avatar-status-dot[data-status="dnd"],
.chat-nav-profile-status[data-status="red"],
.chat-nav-profile-status[data-status="dnd"],
.profile-picture-presence-dot[data-status="red"],
.profile-picture-presence-dot[data-status="dnd"] {
    background-color: var(--kinma-presence-red) !important;
}

.chat-contact-status[data-status="gray"],
.chat-contact-status[data-status="offline"],
.chat-user-avatar-status-dot[data-status="gray"],
.chat-user-avatar-status-dot[data-status="offline"],
.chat-header-profile-overlay-avatar-status-dot[data-status="gray"],
.chat-header-profile-overlay-avatar-status-dot[data-status="offline"],
.chat-nav-profile-status[data-status="gray"],
.chat-nav-profile-status[data-status="offline"],
.profile-picture-presence-dot[data-status="gray"],
.profile-picture-presence-dot[data-status="offline"] {
    background-color: var(--kinma-presence-gray) !important;
}

/* Aktiver Kontakt: gleiche Dot-Farben wie inaktiv (kein zweites Farbschema) */
#chatPopup .chat-contact-item.active .chat-contact-status[data-status="green"],
#chatPopup .chat-contact-item.active .chat-contact-status[data-status="online"],
#chatPopupMirror .chat-contact-item.active .chat-contact-status[data-status="green"],
#chatPopupMirror .chat-contact-item.active .chat-contact-status[data-status="online"],
.chat-popup-root .chat-contact-item.active .chat-contact-status[data-status="green"],
.chat-popup-root .chat-contact-item.active .chat-contact-status[data-status="online"] {
    background-color: var(--kinma-presence-green) !important;
}

#chatPopup .chat-contact-item.active .chat-contact-status[data-status="yellow"],
#chatPopup .chat-contact-item.active .chat-contact-status[data-status="away"],
#chatPopupMirror .chat-contact-item.active .chat-contact-status[data-status="yellow"],
#chatPopupMirror .chat-contact-item.active .chat-contact-status[data-status="away"],
.chat-popup-root .chat-contact-item.active .chat-contact-status[data-status="yellow"],
.chat-popup-root .chat-contact-item.active .chat-contact-status[data-status="away"] {
    background-color: var(--kinma-presence-yellow) !important;
}

#chatPopup .chat-contact-item.active .chat-contact-status[data-status="red"],
#chatPopup .chat-contact-item.active .chat-contact-status[data-status="dnd"],
#chatPopupMirror .chat-contact-item.active .chat-contact-status[data-status="red"],
#chatPopupMirror .chat-contact-item.active .chat-contact-status[data-status="dnd"],
.chat-popup-root .chat-contact-item.active .chat-contact-status[data-status="red"],
.chat-popup-root .chat-contact-item.active .chat-contact-status[data-status="dnd"] {
    background-color: var(--kinma-presence-red) !important;
}

#chatPopup .chat-contact-item.active .chat-contact-status[data-status="gray"],
#chatPopup .chat-contact-item.active .chat-contact-status[data-status="offline"],
#chatPopupMirror .chat-contact-item.active .chat-contact-status[data-status="gray"],
#chatPopupMirror .chat-contact-item.active .chat-contact-status[data-status="offline"],
.chat-popup-root .chat-contact-item.active .chat-contact-status[data-status="gray"],
.chat-popup-root .chat-contact-item.active .chat-contact-status[data-status="offline"] {
    background-color: var(--kinma-presence-gray) !important;
}

/* Profil-Overlay: gleicher Kreis, 2× Größe der Listen-Avatare */
#chatPopup .chat-header-profile-overlay-picture-wrapper,
#chatPopupMirror .chat-header-profile-overlay-picture-wrapper,
.chat-popup-root .chat-header-profile-overlay-picture-wrapper {
    --kinma-avatar-size: calc(var(--kinma-chat-avatar-size) * 2);
    --kinma-presence-dot-size: clamp(
        10px,
        calc(var(--kinma-avatar-size) * var(--kinma-presence-dot-scale, 0.28)),
        32px
    );
    width: var(--kinma-avatar-size);
    height: var(--kinma-avatar-size);
    margin-top: calc(var(--kinma-avatar-size) * -0.5);
}

#chatPopup .chat-header-profile-overlay-picture-circle,
#chatPopupMirror .chat-header-profile-overlay-picture-circle,
.chat-popup-root .chat-header-profile-overlay-picture-circle {
    width: 100%;
    height: 100%;
}

#chatPopup .chat-header-profile-overlay-avatar-status-dot,
#chatPopupMirror .chat-header-profile-overlay-avatar-status-dot,
.chat-popup-root .chat-header-profile-overlay-avatar-status-dot {
    z-index: 30;
}

/* Header-Insel: Platz für Ecken-Statuspunkt (54px war exakt Avatar-Höhe → Dot hing unten raus) */
#chatMain .chat-main-header,
.chat-popup-content-wrapper #chatMain .chat-main-header-row {
    min-height: calc(var(--kinma-chat-avatar-size, 44px) + 10px) !important;
    height: auto !important;
    align-items: center !important;
    overflow: visible !important;
}

@media (min-width: 1025px) {
    .chat-popup-content-wrapper #chatMain .chat-main-header-row {
        min-height: calc(var(--kinma-chat-avatar-size, 44px) + 10px) !important;
        height: auto !important;
    }
    .chat-popup-content-wrapper #chatMain .chat-main-header {
        min-height: calc(var(--kinma-chat-avatar-size, 44px) + 10px) !important;
        height: auto !important;
    }
    .chat-popup-content-wrapper #chatMain .chat-main-header-ghost-close-island {
        min-height: calc(var(--kinma-chat-avatar-size, 44px) + 10px) !important;
        height: auto !important;
        aspect-ratio: auto !important;
    }
    .chat-popup-content-wrapper #chatMain .chat-main-header-search-island {
        width: var(--chat-pill-min-height, 48px) !important;
        height: var(--chat-pill-min-height, 48px) !important;
        min-width: var(--chat-pill-min-height, 48px) !important;
        max-width: var(--chat-pill-min-height, 48px) !important;
        min-height: var(--chat-pill-min-height, 48px) !important;
        max-height: var(--chat-pill-min-height, 48px) !important;
        aspect-ratio: 1 / 1 !important;
        border-radius: 50% !important;
        align-self: center !important;
    }
}

#chatPopup .chat-header-profile-overlay-symbol-badge,
#chatPopupMirror .chat-header-profile-overlay-symbol-badge,
.chat-popup-root .chat-header-profile-overlay-symbol-badge {
    width: calc(var(--kinma-avatar-size, 88px) * 0.36);
    height: calc(var(--kinma-avatar-size, 88px) * 0.36);
    top: calc(var(--kinma-avatar-size, 88px) * -0.04);
    right: calc(var(--kinma-avatar-size, 88px) * -0.04);
    border-width: 2px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

#chatMain .chat-main-header .chat-user-avatar-wrap {
    width: var(--kinma-chat-avatar-size, 44px) !important;
    height: var(--kinma-chat-avatar-size, 44px) !important;
}

/* Kleine Inline-Indikatoren (neben Text) — nicht die Avatar-Ecken */
.chat-user-status-indicator:not(.chat-user-avatar-status-dot):not(.chat-header-profile-overlay-avatar-status-dot):not(.profile-picture-presence-dot) {
    position: static;
    width: 8px;
    height: 8px;
    border: none;
    box-shadow: none;
}
