/* ==========================================================================
 * Popup Individual de Conversa
 * Extraido de: protected/views/layouts/main.php
 * ========================================================================== */

#chat-popups-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9994;
}

.chat-popup {
    position: fixed;
    width: 380px;
    height: 500px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    pointer-events: auto;
    resize: both;
    min-width: 320px;
    min-height: 400px;
    max-width: 90vw;
    max-height: 90vh;
    animation: chatPopupSlideUp 0.3s ease;
}

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

/* Header */
.chat-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
    color: white;
    cursor: move;
    user-select: none;
    flex-shrink: 0;
}

.chat-popup-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.chat-popup-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.3);
    flex-shrink: 0;
}

.chat-popup-contact {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-popup-name {
    font-weight: 600;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: white;
    text-decoration: none;
    cursor: pointer;
    transition: opacity 0.2s;
}

.chat-popup-name:hover {
    opacity: 0.8;
    text-decoration: underline;
}

.chat-popup-phone {
    font-size: 11px;
    opacity: 0.9;
}

.chat-popup-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.chat-popup-btn-minimize,
.chat-popup-btn-end {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 12px;
}

.chat-popup-btn-minimize:hover {
    background: rgba(255,255,255,0.3);
}

.chat-popup-btn-end:hover {
    background: #dc2626;
}

/* Area de Mensagens */
.chat-popup-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    background: #e5ddd5;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-popup-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.chat-popup-loading.hidden {
    display: none;
}

/* Mensagens */
.chat-popup-messages .message {
    max-width: 85%;
    display: flex;
    flex-direction: column;
}

.chat-popup-messages .message.inbound {
    align-self: flex-start;
}

.chat-popup-messages .message.outbound {
    align-self: flex-end;
}

.chat-popup-messages .message .bubble {
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    position: relative;
}

.chat-popup-messages .message.inbound .bubble {
    background: white;
    color: #374151;
    border-bottom-left-radius: 2px;
}

.chat-popup-messages .message.outbound .bubble {
    background: #dcf8c6;
    color: #374151;
    border-bottom-right-radius: 2px;
}

.chat-popup-messages .message .bubble .msg-time {
    font-size: 10px;
    color: #8696a0;
    margin-top: 4px;
    text-align: right;
    display: block;
}

.chat-popup-messages .message .bubble img.msg-media {
    max-width: 100%;
    border-radius: 6px;
    margin-bottom: 4px;
}

/* Composer */
.chat-popup-composer {
    position: relative;
    padding: 10px 12px;
    background: #f0f2f5;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.chat-popup-composer-inner {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: white;
    border-radius: 24px;
    padding: 6px 6px 6px 14px;
    border: 1px solid #d1d5db;
}

.chat-popup-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 14px;
    resize: none;
    max-height: 80px;
    line-height: 1.4;
    background: transparent;
    font-family: inherit;
}

.chat-popup-send-btn {
    background: #25d366;
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-popup-send-btn:hover {
    background: #128c7e;
    transform: scale(1.05);
}

.chat-popup-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.chat-popup-send-btn img {
    filter: brightness(0) invert(1);
}

/* Botão de respostas rápidas */
.chat-popup-quickreply-btn {
    background: white;
    border: 1px solid #d1d5db;
    color: #6b7280;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-popup-quickreply-btn:hover {
    background: #f3f4f6;
    color: #374151;
}

/* Painel de respostas rápidas */
.chat-quickreply-panel {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 100%;
    margin-bottom: 8px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    max-height: 260px;
    overflow-y: auto;
    z-index: 10;
}

.chat-quickreply-panel-title {
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    border-bottom: 1px solid #f3f4f6;
}

.chat-quickreply-panel-list {
    padding: 4px 0;
}

.chat-quickreply-item {
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.15s;
}

.chat-quickreply-item:hover {
    background: #f9fafb;
}

.chat-quickreply-item-titulo {
    font-weight: 600;
    font-size: 13px;
    color: #111827;
}

.chat-quickreply-item-mensagem {
    font-size: 12px;
    color: #6b7280;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-quickreply-empty {
    padding: 16px 14px;
    text-align: center;
    color: #9ca3af;
    font-size: 13px;
}

/* Responsivo */
@media (max-width: 480px) {
    .chat-list-modal-container {
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .chat-popup {
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
        border-radius: 0;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        resize: none;
    }
}
