﻿/* ═══════════════════════════════════════════════════════════════
   COMPACT ENTERPRISE COMMUNICATION UI (UPDATED)
   ═══════════════════════════════════════════════════════════════ */
:root {
    --comm-bg: #ffffff;
    --comm-border: #f1f5f9;
    --comm-hover: #f8fafc;
    --comm-primary: #3b82f6;
    --comm-primary-hover: #2563eb;
    --comm-text: #1e293b;
    --comm-text-muted: #64748b;
    --comm-shadow: 0 12px 48px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    --comm-radius-sm: 6px;
    --comm-radius-md: 10px;
}

/* Backdrop */
.comm-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(2px);
    z-index: 99998 !important;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

    .comm-backdrop.show {
        opacity: 1;
        visibility: visible;
    }

/* Dropdown Panels - No fixed left/right here, JS handles it */
.comm-dropdown {
    position: fixed;
    width: 320px;
    background: var(--comm-bg);
    border: 1px solid var(--comm-border);
    border-radius: var(--comm-radius-md);
    box-shadow: var(--comm-shadow);
    z-index: 99999 !important; /* Force on top */
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: commSlideIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    max-height: calc(100vh - 80px);
}

    .comm-dropdown.show {
        display: flex;
    }

@keyframes commSlideIn {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Header */
.comm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--comm-border);
    background: var(--comm-bg);
    flex-shrink: 0;
}

    .comm-header h6 {
        margin: 0;
        font-size: 13px;
        font-weight: 700;
        color: var(--comm-text);
    }

.comm-action-btn {
    background: none;
    border: none;
    font-size: 11px;
    font-weight: 600;
    color: var(--comm-primary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--comm-radius-sm);
    transition: background 0.2s;
}

    .comm-action-btn:hover {
        background: var(--comm-hover);
    }

/* Search Area */
.comm-search-wrap {
    position: relative;
    padding: 8px 14px;
    background: var(--comm-bg);
    border-bottom: 1px solid var(--comm-border);
    flex-shrink: 0;
}

.comm-search-icon {
    position: absolute;
    inset-inline-start: 24px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--comm-text-muted);
    font-size: 12px;
    pointer-events: none;
}

.comm-search-input {
    width: 100%;
    border: 1px solid var(--comm-border);
    border-radius: var(--comm-radius-sm);
    padding: 6px 10px 6px 30px;
    font-size: 12px;
    outline: none;
    background: var(--comm-hover);
    transition: all 0.2s ease;
    color: var(--comm-text);
}

[dir="rtl"] .comm-search-input {
    padding: 6px 30px 6px 10px;
}

.comm-search-input:focus {
    border-color: var(--comm-primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

/* List Container */
.comm-list {
    max-height: 350px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
    scroll-behavior: smooth;
    flex-grow: 1;
}

    .comm-list::-webkit-scrollbar {
        width: 4px;
    }

    .comm-list::-webkit-scrollbar-thumb {
        background: #cbd5e1;
        border-radius: 4px;
    }

/* List Items */
.notif-item, .contact-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--comm-border);
    cursor: pointer;
    transition: background 0.15s;
    text-decoration: none;
}

    .notif-item:hover, .contact-item:hover {
        background: var(--comm-hover);
    }

    .notif-item.unread {
        background: rgba(59, 130, 246, 0.04);
    }

/* Icons & Avatars */
.comm-icon {
    width: 30px;
    height: 30px;
    border-radius: var(--comm-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
}

    .comm-icon.info {
        background: #dbeafe;
        color: #2563eb;
    }

    .comm-icon.success {
        background: #dcfce7;
        color: #16a34a;
    }

    .comm-icon.warning {
        background: #fef3c7;
        color: #d97706;
    }

    .comm-icon.danger {
        background: #fee2e2;
        color: #dc2626;
    }

.comm-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.comm-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--comm-border);
}

.avatar-presence {
    position: absolute;
    bottom: -1px;
    inset-inline-end: -1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--comm-bg);
}

    .avatar-presence.online {
        background: #22c55e;
        box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
    }

/* Content */
.comm-content {
    flex: 1;
    min-width: 0;
}

.comm-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--comm-text);
    margin-bottom: 1px;
}

.comm-text {
    font-size: 11px;
    color: var(--comm-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.comm-time {
    font-size: 9px;
    color: #94a3b8;
    margin-top: 2px;
    font-weight: 500;
}

.contact-unread-dot {
    width: 8px;
    height: 8px;
    background: var(--comm-primary);
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 12px;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.2);
}

/* Empty States */
.comm-empty {
    padding: 30px 20px;
    text-align: center;
    color: var(--comm-text-muted);
}

    .comm-empty i {
        font-size: 28px;
        opacity: 0.3;
        margin-bottom: 8px;
        display: block;
    }

    .comm-empty small {
        font-size: 11px;
        font-weight: 500;
    }

/* ═══════════════════════════════════════════════════════════════
   CHAT DRAWER
   ═══════════════════════════════════════════════════════════════ */
.chat-drawer {
    position: fixed;
    inset-block: 0;
    inset-inline-end: -400px;
    width: 360px;
    background: var(--comm-bg);
    box-shadow: -10px 0 40px rgba(0,0,0,0.15);
    z-index: 99999 !important;
    display: flex;
    flex-direction: column;
    transition: inset-inline-end 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

    .chat-drawer.open {
        inset-inline-end: 0;
    }

.chat-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--comm-border);
    background: var(--comm-bg);
    flex-shrink: 0;
}

.chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.chat-drawer-header h6 {
    font-size: 13px;
    font-weight: 700;
    color: var(--comm-text);
}

.chat-status {
    font-size: 10px;
    color: #16a34a;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
}

.chat-close-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: var(--comm-hover);
    color: var(--comm-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

    .chat-close-btn:hover {
        background: #e2e8f0;
        color: var(--comm-text);
    }

.chat-drawer-body {
    flex: 1;
    padding: 14px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f8fafc;
}

/* Chat Bubbles */
.bubble {
    max-width: 90%;
    padding: 8px 12px;
    border-radius: var(--comm-radius-md);
    font-size: 12px;
    line-height: 1.4;
    word-wrap: break-word;
}

    .bubble.sent {
        align-self: flex-end;
        background: var(--comm-primary);
        color: #fff;
        border-bottom-right-radius: 4px;
    }

[dir="rtl"] .bubble.sent {
    border-bottom-right-radius: var(--comm-radius-md);
    border-bottom-left-radius: 4px;
}

.bubble.received {
    align-self: flex-start;
    background: #fff;
    color: var(--comm-text);
    border: 1px solid var(--comm-border);
    border-bottom-left-radius: 4px;
}

[dir="rtl"] .bubble.received {
    border-bottom-left-radius: var(--comm-radius-md);
    border-bottom-right-radius: 4px;
}

.bubble-time {
    font-size: 9px;
    opacity: 0.75;
    margin-top: 4px;
    text-align: end;
}

/* Chat Input Area */
.chat-input-area {
    padding: 10px;
    background: var(--comm-bg);
    border-top: 1px solid var(--comm-border);
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

.chat-input {
    width: 100%;
    border: 1px solid var(--comm-border);
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 12px;
    outline: none;
    background: var(--comm-hover);
    resize: none;
    max-height: 120px;
    min-height: 34px;
}

    .chat-input:focus {
        border-color: var(--comm-primary);
        background: #fff;
        box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
    }

.chat-send-btn, .chat-attach-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.chat-send-btn {
    background: var(--comm-primary);
    color: #fff;
    border: none;
}

    .chat-send-btn:hover {
        background: var(--comm-primary-hover);
    }

.chat-attach-btn {
    background: transparent;
    color: var(--comm-text-muted);
    border: none;
}

    .chat-attach-btn:hover {
        background: var(--comm-hover);
        color: var(--comm-primary);
    }

/* Badges */
.comm-badge {
    position: absolute;
    top: 2px;
    inset-inline-end: 2px;
    min-width: 15px;
    height: 15px;
    background: #ef4444;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid #fff;
}

/* Image Lightbox */
.image-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    cursor: zoom-out;
}

    .image-lightbox img {
        max-width: 90vw;
        max-height: 90vh;
        border-radius: 8px;
    }

/* Responsive */
@media (max-width: 768px) {
    .comm-dropdown {
        width: auto;
        left: 10px !important;
        right: 10px !important;
        top: 60px !important;
    }

    .chat-drawer {
        width: 100%;
        inset-inline-end: -100%;
    }

        .chat-drawer.open {
            inset-inline-end: 0;
        }
}

/* Dark Mode */
html[data-theme="dark"] {
    --comm-bg: #1e293b;
    --comm-border: #334155;
    --comm-hover: #263449;
    --comm-text: #e2e8f0;
    --comm-text-muted: #94a3b8;
}

    html[data-theme="dark"] .chat-drawer-body {
        background: #0f172a;
    }

    html[data-theme="dark"] .bubble.received {
        background: #1e293b;
        border-color: #334155;
        color: #e2e8f0;
    }
