/* === MESSAGING — Style panelu wiadomości prywatnych === */

/* --- OVERLAY (pełnoekranowy panel) --- */
#messaging-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fdfdfd;
    z-index: 3700;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

#messaging-overlay header {
    position: sticky;
    top: 0;
    z-index: 10;
}

/* --- WYSZUKIWARKA UŻYTKOWNIKÓW --- */
.dm-search-container {
    padding: 12px 16px;
    background: #fff;
    border-bottom: 1px solid #eee;
}

.dm-search-bar {
    display: flex;
    align-items: center;
    background: #f1f3f4;
    border-radius: 20px;
    padding: 8px 14px;
    gap: 8px;
}

.dm-search-bar svg {
    flex-shrink: 0;
    opacity: 0.5;
}

.dm-search-bar input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 14px;
    color: #333;
    font-family: inherit;
}

.dm-search-bar input::placeholder {
    color: #999;
}

/* Wyniki wyszukiwania */
#dm-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.12);
    z-index: 10;
    display: none;
    max-height: 250px;
    overflow-y: auto;
}

.dm-search-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    transition: background 0.15s;
}

.dm-search-item:hover {
    background: #f5f8ff;
}

.dm-search-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

/* --- LISTA ROZMÓW --- */
#dm-conversations-view {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 80px;
}

.dm-section-title {
    padding: 16px 20px 8px;
    font-size: 20px;
    font-weight: 600;
    color: #333;
}

.dm-conv-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid #f5f5f5;
}

.dm-conv-item:hover {
    background: #f5f8ff;
}

.dm-conv-item.dm-conv-unread {
    background: #f0f6ff;
}

.dm-conv-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.dm-conv-info {
    flex: 1;
    min-width: 0;
}

.dm-conv-name {
    font-weight: 600;
    font-size: 14px;
    color: #222;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dm-conv-last {
    font-size: 12px;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.dm-conv-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.dm-conv-time {
    font-size: 11px;
    color: #aaa;
}

.dm-conv-badge {
    background: #e74c3c;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}

/* --- WIDOK CZATU 1:1 --- */
#dm-chat-view {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.dm-chat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #fff;
    border-bottom: 1px solid #eee;
}

.dm-chat-back-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
}

.dm-chat-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.dm-chat-header-name {
    flex: 1;
    font-weight: 600;
    font-size: 15px;
    color: #333;
}

.dm-chat-delete-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.dm-chat-delete-btn:hover {
    opacity: 1;
}

/* Wiadomości czatu — reużycie istniejących styli .chat-msg, .chat-bubble itp. */
#dm-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #fafafa;
}

/* Input czatu */
.dm-chat-input-area {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    background: #fff;
    border-top: 1px solid #eee;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
}

.dm-chat-input-area input {
    flex: 1;
    min-width: 0;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 20px;
    outline: none;
    font-size: 14px;
    background: #f9f9f9;
    font-family: inherit;
}

.dm-chat-input-area .chat-send-btn {
    flex: 0 0 44px;
    height: 44px;
    background: #4A90E2;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* --- BADGE NA DOLNYM PASKU --- */
#dm-badge {
    position: absolute;
    top: -2px;
    right: 50%;
    transform: translateX(120%);
    background: #e74c3c;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* Badge w menu hamburger */
#dm-menu-badge {
    background: #e74c3c;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    margin-left: 8px;
    line-height: 1;
}

/* --- PRZYCISK "WYŚLIJ WIADOMOŚĆ" NA PROFILU PUBLICZNYM --- */
.dm-profile-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px;
    background: #4A90E2;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 15px;
    font-family: inherit;
    transition: background 0.2s;
}

.dm-profile-btn:hover {
    background: #3a7bd5;
}

/* --- E2EE INFO --- */
.dm-e2ee-notice {
    text-align: center;
    padding: 8px 12px;
    font-size: 11px;
    color: #aaa;
    background: #fafafa;
    border-bottom: 1px solid #f0f0f0;
}

.dm-e2ee-notice svg {
    vertical-align: middle;
    margin-right: 4px;
}
