/* ── Call Overlays (shared) ─────────────────────────────────────────── */
#incoming-call-overlay,
#outgoing-call-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.85);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.call-overlay-content {
    background: #fff;
    border-radius: 20px;
    padding: 45px 50px;
    text-align: center;
    max-width: 380px;
    width: 90%;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5);
}

.call-overlay-content h3 {
    margin: 15px 0 5px;
    font-size: 22px;
    color: #1e293b;
    font-weight: 700;
}

.call-status-text {
    color: #64748b;
    font-size: 14px;
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* ── Avatar with ring animation ────────────────────────────────────── */
.call-avatar-ring {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    margin: 0 auto;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.call-avatar-ring::before,
.call-avatar-ring::after {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    border-radius: 50%;
    border: 2px solid #3c8dbc;
    opacity: 0;
}

.call-avatar-ring.ringing::before {
    animation: ringPulse 1.5s ease-out infinite;
}

.call-avatar-ring.ringing::after {
    animation: ringPulse 1.5s ease-out 0.5s infinite;
}

/* Outgoing call: slower pulse */
#outgoing-call-overlay .call-avatar-ring::before {
    animation: ringPulse 2s ease-out infinite;
}

#outgoing-call-overlay .call-avatar-ring::after {
    animation: ringPulse 2s ease-out 0.7s infinite;
}

.call-avatar {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border: 3px solid #3c8dbc;
    border-radius: 50%;
    position: relative;
    z-index: 1;
}

.call-avatar-icon {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e2e8f0, #cbd5e1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 44px;
    color: #64748b;
    position: relative;
    z-index: 1;
}

@keyframes ringPulse {
    0% {
        transform: scale(1);
        opacity: 0.6;
        border-color: #3c8dbc;
    }
    100% {
        transform: scale(1.35);
        opacity: 0;
        border-color: #3c8dbc;
    }
}

/* ── Calling dots animation ────────────────────────────────────────── */
.call-dots {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.call-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #64748b;
    animation: dotBounce 1.4s ease-in-out infinite;
}

.call-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.call-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dotBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ── Call action buttons ───────────────────────────────────────────── */
.call-actions {
    display: flex;
    justify-content: center;
    gap: 30px;
}

.btn-circle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    color: #fff;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-circle:hover {
    transform: scale(1.1);
}

.btn-circle.btn-success {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    box-shadow: 0 6px 20px rgba(34, 197, 94, 0.4);
    animation: acceptPulse 2s ease-in-out infinite;
}

.btn-circle.btn-success:hover {
    box-shadow: 0 8px 25px rgba(34, 197, 94, 0.5);
}

.btn-circle.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

.btn-circle.btn-danger:hover {
    box-shadow: 0 8px 25px rgba(239, 68, 68, 0.5);
}

@keyframes acceptPulse {
    0%, 100% { box-shadow: 0 6px 20px rgba(34, 197, 94, 0.4); }
    50% { box-shadow: 0 6px 20px rgba(34, 197, 94, 0.4), 0 0 0 10px rgba(34, 197, 94, 0.1); }
}

/* ── Active Call Bar ───────────────────────────────────────────────── */
#active-call-bar {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: linear-gradient(135deg, #1e293b, #334155);
    color: #fff;
    padding: 14px 22px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    gap: 14px;
    z-index: 99998;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
    font-size: 14px;
    animation: slideUp 0.3s ease-out;
}

.active-call-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    animation: liveIndicator 1.5s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes liveIndicator {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.active-call-phone-icon {
    color: #22c55e;
    font-size: 16px;
}

#active-call-bar #call-peer-name {
    font-weight: 600;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#active-call-bar #call-duration {
    font-family: 'Courier New', monospace;
    font-size: 16px;
    color: #22c55e;
    letter-spacing: 1px;
}

#active-call-bar .btn {
    border-radius: 50%;
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s;
}

#active-call-bar .btn:hover {
    transform: scale(1.1);
}

@keyframes slideUp {
    from { transform: translateY(100px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ── Chat Panel (inside modal) ─────────────────────────────────────── */
#chat-panel {
    border-top: 1px solid #eee;
    padding-top: 15px;
    margin-top: 15px;
}

#chat-messages {
    height: 300px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    background: #f9f9f9;
}

.chat-bubble {
    max-width: 75%;
    padding: 8px 14px;
    border-radius: 16px;
    margin-bottom: 8px;
    font-size: 13px;
    line-height: 1.4;
    word-wrap: break-word;
    clear: both;
}

.chat-bubble.sent {
    background: #3c8dbc;
    color: #fff;
    float: right;
    border-bottom-right-radius: 4px;
}

.chat-bubble.received {
    background: #e9ecef;
    color: #333;
    float: left;
    border-bottom-left-radius: 4px;
}

.chat-bubble .chat-time {
    font-size: 10px;
    opacity: 0.7;
    display: block;
    margin-top: 4px;
}

.chat-bubble.sent .chat-time {
    text-align: right;
    color: rgba(255, 255, 255, 0.7);
}

.chat-date-separator {
    text-align: center;
    color: #999;
    font-size: 11px;
    margin: 12px 0;
    clear: both;
}

#chat-messages::after {
    content: '';
    display: table;
    clear: both;
}

/* ── Online Status Dot ─────────────────────────────────────────────── */
.online-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-left: 6px;
    vertical-align: middle;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.online-status-dot.online {
    background: #00a65a;
}

.online-status-dot.offline {
    background: #aaa;
}

/* Dot on orgchart nodes */
.node .online-status-dot {
    position: absolute;
    top: 4px;
    right: 4px;
}

/* ── Navbar Unread Badge ───────────────────────────────────────────── */
#nav-messages-indicator > a {
    position: relative;
    color: #fff;
}

#nav-messages-indicator .label {
    position: absolute;
    top: 5px;
    right: 2px;
    font-size: 10px;
    padding: 2px 5px;
    border-radius: 10px;
}

/* ── Communication Buttons in Modal ────────────────────────────────── */
.comm-btn-group {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.comm-btn-group .btn {
    flex: 1;
}

.comm-btn-group .btn i {
    margin-right: 5px;
}

/* ── Typing / Empty States ─────────────────────────────────────────── */
.chat-empty-state {
    text-align: center;
    color: #aaa;
    padding: 60px 20px;
}

.chat-empty-state i {
    font-size: 48px;
    margin-bottom: 10px;
    display: block;
}

/* ── Navbar Messages Dropdown ──────────────────────────────────────── */
#nav-messages-dropdown .menu li {
    border-bottom: 1px solid #f0f0f0;
}

#nav-messages-dropdown .menu li:last-child {
    border-bottom: none;
}

#nav-messages-dropdown .menu li a {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    color: #333;
    text-decoration: none;
}

#nav-messages-dropdown .menu li a:hover {
    background: #f7f7f7;
}

.msg-dropdown-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    margin-right: 10px;
    object-fit: cover;
    flex-shrink: 0;
}

.msg-dropdown-avatar-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    margin-right: 10px;
    background: #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 18px;
    flex-shrink: 0;
}

.msg-dropdown-info {
    flex: 1;
    min-width: 0;
}

.msg-dropdown-name {
    font-weight: 600;
    font-size: 13px;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.msg-dropdown-preview {
    font-size: 12px;
    color: #888;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.msg-dropdown-badge {
    background: #dd4b39;
    color: #fff;
    border-radius: 10px;
    font-size: 10px;
    padding: 2px 6px;
    margin-left: 8px;
    flex-shrink: 0;
}

/* ── Global Floating Chat Window ───────────────────────────────────── */
#global-chat-window {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 370px;
    height: 480px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.25);
    z-index: 99990;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
}

.global-chat-header {
    background: #3c8dbc;
    color: #fff;
    padding: 12px 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.global-chat-header span {
    font-weight: 600;
    font-size: 15px;
}

.global-chat-header-actions {
    display: flex;
    gap: 5px;
}

.global-chat-header-actions .btn {
    color: #fff;
    border-color: rgba(255,255,255,0.3);
    background: transparent;
}

.global-chat-header-actions .btn:hover {
    background: rgba(255,255,255,0.2);
}

.global-chat-body {
    flex: 1;
    overflow-y: auto;
    background: #f9f9f9;
}

/* Conversation list items */
.conv-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background 0.15s;
}

.conv-item:hover {
    background: #edf5fb;
}

.conv-item-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 12px;
    object-fit: cover;
    flex-shrink: 0;
}

.conv-item-avatar-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 12px;
    background: #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 20px;
    flex-shrink: 0;
}

.conv-item-info {
    flex: 1;
    min-width: 0;
}

.conv-item-name {
    font-weight: 600;
    font-size: 14px;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conv-item-last {
    font-size: 12px;
    color: #888;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 2px;
}

.conv-item-meta {
    text-align: right;
    flex-shrink: 0;
    margin-left: 8px;
}

.conv-item-time {
    font-size: 11px;
    color: #aaa;
    display: block;
}

.conv-item-unread {
    background: #dd4b39;
    color: #fff;
    border-radius: 10px;
    font-size: 10px;
    padding: 2px 7px;
    display: inline-block;
    margin-top: 4px;
}

/* Chat messages inside global chat */
#global-chat-messages {
    padding: 12px;
    min-height: 100%;
}

#global-chat-messages::after {
    content: '';
    display: table;
    clear: both;
}

#global-chat-messages .chat-bubble {
    max-width: 80%;
}

#global-chat-input-area {
    padding: 10px;
    border-top: 1px solid #eee;
    background: #fff;
    flex-shrink: 0;
}

/* ── Mobile Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
    /* Active call bar: full width on tablets and below */
    #active-call-bar {
        right: 10px;
        left: 10px;
        bottom: 10px;
        border-radius: 10px;
    }

    #active-call-bar #call-peer-name {
        max-width: 100px;
    }

    /* Global chat window: nearly full width */
    #global-chat-window {
        width: calc(100% - 20px);
        max-width: 400px;
        right: 10px;
        bottom: 10px;
        height: 60vh;
        max-height: 480px;
    }

    /* Nav messages dropdown */
    #nav-messages-dropdown {
        width: 300px !important;
        right: -50px;
    }

    /* Chat panel in modal */
    #chat-messages {
        height: 220px;
    }
}

@media (max-width: 480px) {
    /* Call overlays: tighter padding */
    .call-overlay-content {
        padding: 25px 20px;
        margin: 0 10px;
        border-radius: 16px;
    }

    .call-overlay-content h3 {
        font-size: 18px;
    }

    .call-status-text {
        font-size: 13px;
        margin-bottom: 20px;
    }

    /* Smaller avatar on mobile */
    .call-avatar-ring {
        width: 90px;
        height: 90px;
    }

    .call-avatar {
        width: 80px;
        height: 80px;
    }

    .call-avatar-icon {
        width: 80px;
        height: 80px;
        font-size: 36px;
    }

    /* Smaller call action buttons */
    .btn-circle {
        width: 52px;
        height: 52px;
        font-size: 20px;
    }

    .call-actions {
        gap: 24px;
    }

    /* Active call bar: compact */
    #active-call-bar {
        padding: 10px 14px;
        gap: 10px;
        font-size: 13px;
    }

    #active-call-bar #call-peer-name {
        max-width: 70px;
        font-size: 13px;
    }

    #active-call-bar #call-duration {
        font-size: 14px;
    }

    #active-call-bar .btn {
        width: 32px;
        height: 32px;
        font-size: 13px;
    }

    /* Global chat window: full screen on phones */
    #global-chat-window {
        width: 100%;
        max-width: none;
        height: 100%;
        max-height: none;
        right: 0;
        bottom: 0;
        border-radius: 0;
    }

    .global-chat-header {
        padding: 14px 15px;
        border-radius: 0;
    }

    /* Nav dropdown: full width */
    #nav-messages-dropdown {
        width: calc(100vw - 20px) !important;
        right: -10px;
        max-height: 400px;
    }

    /* Chat bubbles */
    .chat-bubble {
        max-width: 85%;
        font-size: 13px;
        padding: 7px 12px;
    }

    #global-chat-messages .chat-bubble {
        max-width: 85%;
    }

    /* Chat panel in modal */
    #chat-messages {
        height: 180px;
    }

    /* Comm buttons in modal footer */
    .comm-btn-group {
        flex-direction: column;
        gap: 6px;
    }

    .comm-btn-group .btn {
        font-size: 13px;
    }

    /* Online status dot - slightly smaller */
    .online-status-dot {
        width: 8px;
        height: 8px;
    }
}
