/**
 * Chat Message Toolbar Flutuante
 * Toolbar contextual para ações em mensagens de chat
 * @version 1.0.0
 * @date 2025-11-14
 */

/* ========================================
   UTILIDADES GLOBAIS
   ======================================== */

.chat-hidden {
    display: none !important;
}

/* ========================================
   TOOLBAR FLUTUANTE
   ======================================== */

/* Mensagem em hover - feedback visual */
.chat-mensagem.toolbar-active {
    background: rgba(99, 147, 166, 0.05) !important;
    position: relative;
}

.chat-message-toolbar {
    position: fixed;
    background: rgba(255, 255, 255, 1);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    border: 2px solid #6393A6;
    padding: 4px;
    display: flex;
    gap: 4px;
    z-index: 999999;
    opacity: 0;
    transform: translateY(-5px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}

.chat-message-toolbar.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
}

.toolbar-btn {
    background: transparent;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #4a7a8a;
}

.toolbar-btn:hover {
    background: rgba(99, 147, 166, 0.1);
    color: #6393A6;
}

.toolbar-btn i {
    font-size: 18px;
}

.toolbar-btn-danger {
    color: #dc3545;
}

.toolbar-btn-danger:hover {
    background: rgba(220, 53, 69, 0.1);
    color: #c82333;
}

/* ========================================
   MODAL DE CHAT PRIVADO
   ======================================== */

.chat-privado-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999999;
    display: none;
    align-items: center;
    justify-content: center;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.chat-privado-modal.show {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.chat-privado-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.chat-privado-container {
    position: relative;
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    height: 80vh;
    max-height: 700px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Header do Chat Privado */
.chat-privado-header {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, #6393A6 0%, #4a7a8a 100%);
    color: white;
    border-radius: 12px 12px 0 0;
}

.chat-privado-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-privado-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid white;
}

.chat-privado-username {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chat-privado-status {
    margin: 0;
    font-size: 12px;
    opacity: 0.9;
}

.chat-privado-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: white;
}

.chat-privado-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chat-privado-close i {
    font-size: 20px;
}

/* Área de Mensagens */
.chat-privado-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Mensagem individual */
.chat-privado-message {
    display: flex;
    gap: 10px;
    animation: messageSlideIn 0.3s ease;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-privado-message.me {
    flex-direction: row-reverse;
}

.chat-privado-message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.chat-privado-message-content {
    max-width: 70%;
}

.chat-privado-message.me .chat-privado-message-content {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.chat-privado-message-bubble {
    background: white;
    padding: 10px 14px;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.chat-privado-message.me .chat-privado-message-bubble {
    background: linear-gradient(135deg, #6393A6 0%, #4a7a8a 100%);
    color: white;
}

.chat-privado-message-text {
    margin: 0;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.chat-privado-message-time {
    margin-top: 4px;
    font-size: 11px;
    color: #888;
}

.chat-privado-message.me .chat-privado-message-time {
    color: rgba(255, 255, 255, 0.8);
}

/* Input de Mensagem */
.chat-privado-input-wrapper {
    padding: 16px 20px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
    background: white;
    border-radius: 0 0 12px 12px;
}

.chat-privado-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
}

.chat-privado-input:focus {
    border-color: #6393A6;
    box-shadow: 0 0 0 3px rgba(99, 147, 166, 0.1);
}

.chat-privado-input:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

.chat-privado-send-btn {
    background: linear-gradient(135deg, #6393A6 0%, #4a7a8a 100%);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: white;
}

.chat-privado-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(99, 147, 166, 0.3);
}

.chat-privado-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-privado-send-btn i {
    font-size: 18px;
}

/* Status de carregamento */
.chat-privado-loading {
    text-align: center;
    padding: 40px;
    color: #888;
}

.chat-privado-loading i {
    font-size: 32px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ========================================
   RESPONSIVO
   ======================================== */

@media (max-width: 768px) {
    .chat-privado-container {
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .chat-privado-header {
        border-radius: 0;
    }
    
    .chat-privado-input-wrapper {
        border-radius: 0;
    }
    
    .chat-privado-message-content {
        max-width: 85%;
    }
}

/* ========================================
   BOTÃO FLUTUANTE DE INBOX
   ======================================== */

.chat-inbox-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6393A6 0%, #4a7a8a 100%);
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(99, 147, 166, 0.4);
    transition: all 0.3s ease;
    z-index: 999998;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Ocultar em mobile e tablet */
@media (max-width: 1024px) {
    .chat-inbox-btn {
        display: none !important;
    }
}

.chat-inbox-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(99, 147, 166, 0.6);
}

.chat-inbox-btn:active {
    transform: scale(0.95);
}

.chat-inbox-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4757;
    color: white;
    font-size: 12px;
    font-weight: bold;
    min-width: 22px;
    height: 22px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    box-shadow: 0 2px 8px rgba(255, 71, 87, 0.4);
}

.chat-inbox-badge:empty {
    display: none;
}

/* ========================================
   MODAL DE INBOX
   ======================================== */

.chat-inbox-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999999;
    display: none;
    align-items: center;
    justify-content: center;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.chat-inbox-modal.show {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.chat-inbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

.chat-inbox-container-full {
    position: relative;
    width: 95%;
    max-width: 1200px;
    height: 85vh;
    max-height: 800px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    display: flex;
    overflow: hidden;
    animation: slideInUp 0.3s ease;
}

/* ========================================
   COLUNA 1: SIDEBAR DE CHATS
   ======================================== */

.chat-inbox-sidebar {
    width: 350px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #e0e0e0;
    background: #f8f9fa;
}

.chat-inbox-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    background: white;
    flex-shrink: 0;
}

.chat-inbox-header h2 {
    margin: 0;
    font-size: 20px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-inbox-header h2 i {
    color: #6393A6;
}

.chat-inbox-close {
    background: transparent;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease;
    color: #666;
    font-size: 24px;
}

.chat-inbox-close:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* Filtros */
.chat-inbox-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
    background: white;
}

.chat-filter-btn {
    padding: 8px 12px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    color: #666;
}

.chat-filter-btn:hover {
    background: rgba(99, 147, 166, 0.1);
    border-color: #6393A6;
}

.chat-filter-btn.active {
    background: #6393A6;
    color: white;
    border-color: #6393A6;
}

.chat-filter-btn i {
    font-size: 14px;
}

.chat-inbox-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.chat-inbox-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #999;
}

.chat-inbox-empty i {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.chat-inbox-empty p {
    font-size: 16px;
    margin: 0;
}

.chat-inbox-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s ease;
    border-bottom: 1px solid #f0f0f0;
}

.chat-inbox-item:hover {
    background: rgba(99, 147, 166, 0.05);
}

.chat-inbox-item.unread {
    background: rgba(99, 147, 166, 0.08);
}

.chat-inbox-item-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.chat-inbox-item-info {
    flex: 1;
    min-width: 0;
}

.chat-inbox-item-name {
    font-weight: 600;
    font-size: 15px;
    color: #333;
    margin-bottom: 4px;
}

.chat-inbox-item.unread .chat-inbox-item-name {
    color: #6393A6;
}

.chat-inbox-item-last-message {
    font-size: 14px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-inbox-item-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
    flex-shrink: 0;
}

.chat-inbox-item-time {
    font-size: 12px;
    color: #999;
}

.chat-inbox-item-badge {
    background: #ff4757;
    color: white;
    font-size: 11px;
    font-weight: bold;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}

.chat-inbox-item-type-badge {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    font-size: 9px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 8px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
    margin-top: 4px;
}

/* ========================================
   COLUNA 2: CONVERSA ATIVA
   ======================================== */

.chat-inbox-conversation {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
}

.chat-conversation-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #999;
    padding: 40px;
}

.chat-conversation-empty i {
    font-size: 80px;
    opacity: 0.3;
    margin-bottom: 20px;
}

.chat-conversation-empty p {
    font-size: 18px;
    font-weight: 500;
    margin: 0 0 8px 0;
}

.chat-conversation-empty small {
    font-size: 14px;
    color: #bbb;
}

.chat-conversation-active {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.chat-conversation-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    background: white;
}

.chat-conversation-user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.chat-conversation-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
}

.chat-conversation-username {
    margin: 0 0 4px 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.chat-conversation-type {
    margin: 0;
    font-size: 13px;
    color: #666;
}

.chat-conversation-back {
    background: transparent;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease;
    color: #666;
    font-size: 20px;
}

.chat-conversation-back:hover {
    background: rgba(0, 0, 0, 0.05);
}

.chat-conversation-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column-reverse; /* Mensagens mais recentes primeiro */
}

.chat-conversation-input-wrapper {
    display: flex;
    gap: 10px;
    padding: 20px;
    border-top: 1px solid #e0e0e0;
    background: white;
}

.chat-conversation-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
}

.chat-conversation-input:focus {
    border-color: #6393A6;
}

.chat-conversation-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #6393A6;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-conversation-send-btn:hover:not(:disabled) {
    background: #4a7a8a;
    transform: scale(1.05);
}

.chat-conversation-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Mensagem de contexto */
.chat-context-message {
    margin: 20px;
    padding: 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-left: 4px solid #6393A6;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.chat-context-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: #6393A6;
    margin-bottom: 12px;
    font-size: 13px;
}

.chat-context-header i {
    font-size: 18px;
}

.chat-context-content {
    padding: 15px;
    background: white;
    border-radius: 6px;
    color: #333;
    font-size: 14px;
    line-height: 1.6;
    font-style: italic;
    margin-bottom: 10px;
}

.chat-context-footer {
    text-align: center;
    color: #6c757d;
    font-size: 12px;
}

.chat-context-footer small {
    display: inline-block;
    padding: 6px 12px;
    background: rgba(99, 147, 166, 0.1);
    border-radius: 12px;
}

.chat-no-messages {
    text-align: center;
    color: #999;
    padding: 40px 20px;
    font-size: 14px;
}

/* Mensagens na conversa */
.chat-conversation-message {
    margin-bottom: 16px;
    display: flex;
    gap: 10px;
}

.chat-conversation-message.own {
    flex-direction: row-reverse;
}

.chat-conversation-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.chat-conversation-message-content {
    max-width: 70%;
}

.chat-conversation-message.own .chat-conversation-message-content {
    background: #6393A6;
    color: white;
    border-radius: 18px 18px 4px 18px;
}

.chat-conversation-message:not(.own) .chat-conversation-message-content {
    background: white;
    color: #333;
    border-radius: 18px 18px 18px 4px;
}

.chat-conversation-message-sender {
    font-size: 12px;
    font-weight: 600;
    color: #6393A6;
    padding: 8px 14px 0 14px;
}

.chat-conversation-message.own .chat-conversation-message-sender {
    display: none;
}

.chat-conversation-message-text {
    padding: 10px 14px;
}

.chat-conversation-message-time {
    font-size: 11px;
    opacity: 0.7;
    padding: 0 14px 6px;
}

/* Responsivo */
@media (max-width: 768px) {
    .chat-inbox-container-full {
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .chat-inbox-sidebar {
        width: 100%;
        border-right: none;
    }
    
    .chat-inbox-sidebar.chat-hidden {
        display: none;
    }
    
    /* Conversa ocupa 100% no mobile */
    .chat-inbox-conversation {
        width: 100%;
        flex: 1;
    }
    
    .chat-inbox-conversation.chat-hidden {
        display: none;
    }
    
    .chat-conversation-back {
        display: flex;
    }
}

@keyframes slideInUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}
