/* Container principal do chat */
.sistemapc-chat-container {
    display: flex;
    height: 80vh;
    max-height: 600px;
    border: 1px solid #e1e5e9;
    border-radius: 12px;
    overflow: hidden;
    background: white;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* Sidebar com conversas */
.chat-sidebar {
    width: 320px;
    border-right: 1px solid #e1e5e9;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
}

.chat-sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #e1e5e9;
    background: white;
}

.chat-sidebar-header h3 {
    margin: 0 0 10px 0;
    color: #2c3e50;
    font-size: 18px;
}

.chat-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #6c757d;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #28a745;
}

.status-indicator.online {
    background: #28a745;
}

.status-indicator.offline {
    background: #6c757d;
}

/* Lista de conversas */
.conversas-lista {
    flex: 1;
    overflow-y: auto;
}

.sem-conversas {
    padding: 40px 20px;
    text-align: center;
    color: #6c757d;
}

.sem-conversas-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.conversa-item {
    display: flex;
    padding: 16px 20px;
    border-bottom: 1px solid #e9ecef;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.conversa-item:hover {
    background: #e3f2fd;
}

.conversa-item.ativa {
    background: #2196f3;
    color: white;
}

.conversa-item.ativa .conversa-nome,
.conversa-item.ativa .conversa-ultima-mensagem,
.conversa-item.ativa .conversa-tempo {
    color: white;
}

.conversa-avatar {
    position: relative;
    margin-right: 12px;
}

.conversa-avatar img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

.badge-nao-lidas {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

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

.conversa-nome {
    font-weight: 600;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.badge-verificado {
    background: #28a745;
    color: white;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.conversa-ultima-mensagem {
    font-size: 14px;
    color: #6c757d;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversa-tempo {
    font-size: 12px;
    color: #adb5bd;
}

.conversa-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

/* Área principal do chat */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
}

/* Header da conversa */
.chat-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e1e5e9;
    background: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.header-details h4 {
    margin: 0;
    color: #2c3e50;
    font-size: 16px;
}

.header-meta {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: #6c757d;
    margin-top: 2px;
}

.anuncio-ref {
    background: #e3f2fd;
    padding: 2px 6px;
    border-radius: 4px;
    color: #1976d2;
}

.status-online {
    color: #28a745;
}

.status-offline {
    color: #6c757d;
}

.chat-header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.btn-compartilhar-contato,
.btn-solicitar-contato {
    background: #007bff;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-compartilhar-contato:hover,
.btn-solicitar-contato:hover {
    background: #0056b3;
}

.btn-compartilhar-contato:disabled,
.btn-solicitar-contato:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

/* Dropdown de ações */
.dropdown-actions {
    position: relative;
}

.btn-menu-conversa {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    color: #6c757d;
}

.btn-menu-conversa:hover {
    background: #f8f9fa;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid #e1e5e9;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 150px;
    z-index: 1000;
    display: none;
}

.dropdown-menu a {
    display: block;
    padding: 10px 16px;
    color: #495057;
    text-decoration: none;
    font-size: 14px;
    border-bottom: 1px solid #f8f9fa;
}

.dropdown-menu a:hover {
    background: #f8f9fa;
}

.dropdown-menu a:last-child {
    border-bottom: none;
}

/* Área de mensagens */
.chat-mensagens {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    position: relative;
}

.mensagens-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.loading-mensagens {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #6c757d;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e9ecef;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 12px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Mensagens */
.mensagem {
    display: flex;
    margin-bottom: 16px;
}

.mensagem.enviada {
    justify-content: flex-end;
}

.mensagem.recebida {
    justify-content: flex-start;
}

.mensagem-content {
    max-width: 70%;
    display: flex;
    flex-direction: column;
}

.mensagem.enviada .mensagem-content {
    align-items: flex-end;
}

.mensagem.recebida .mensagem-content {
    align-items: flex-start;
}

.mensagem-bubble {
    background: white;
    padding: 12px 16px;
    border-radius: 18px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    word-wrap: break-word;
    position: relative;
}

.mensagem.enviada .mensagem-bubble {
    background: #007bff;
    color: white;
    border-bottom-right-radius: 6px;
}

.mensagem.recebida .mensagem-bubble {
    background: white;
    color: #2c3e50;
    border-bottom-left-radius: 6px;
}

.mensagem-sistema .mensagem-bubble {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
    text-align: center;
    font-style: italic;
    margin: 0 auto;
}

.mensagem-meta {
    font-size: 11px;
    color: #adb5bd;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.mensagem.enviada .mensagem-meta {
    justify-content: flex-end;
}

.mensagem-status {
    font-size: 10px;
}

.mensagem-status.enviada::after {
    content: "✓";
}

.mensagem-status.entregue::after {
    content: "✓✓";
}

.mensagem-status.lida::after {
    content: "✓✓";
    color: #007bff;
}

/* Indicador de digitação */
.indicador-digitacao {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 12px;
    margin-top: 8px;
    font-size: 12px;
    color: #6c757d;
}

.digitacao-avatar img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
}

.digitacao-pontos {
    display: flex;
    gap: 2px;
}

.digitacao-pontos span {
    width: 4px;
    height: 4px;
    background: #6c757d;
    border-radius: 50%;
    animation: digitacao 1.4s infinite ease-in-out;
}

.digitacao-pontos span:nth-child(1) {
    animation-delay: -0.32s;
}

.digitacao-pontos span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes digitacao {

    0%,
    80%,
    100% {
        transform: scale(0);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Input de mensagem */
.chat-input-container {
    border-top: 1px solid #e1e5e9;
    background: white;
    padding: 16px 20px;
}

.chat-input-form {
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.input-actions-left {
    display: flex;
    gap: 8px;
}

.btn-anexo,
.btn-emoji {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    color: #6c757d;
    transition: all 0.2s ease;
}

.btn-anexo:hover,
.btn-emoji:hover {
    background: #f8f9fa;
    color: #495057;
}

.input-mensagem-container {
    flex: 1;
    position: relative;
}

#mensagem-input {
    width: 100%;
    border: 1px solid #e1e5e9;
    border-radius: 20px;
    padding: 12px 16px;
    font-size: 14px;
    resize: none;
    outline: none;
    transition: all 0.2s ease;
    font-family: inherit;
    line-height: 1.4;
    max-height: 120px;
}

#mensagem-input:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.contador-caracteres {
    position: absolute;
    bottom: -20px;
    right: 8px;
    font-size: 11px;
    color: #adb5bd;
}

.input-actions-right {
    display: flex;
    align-items: center;
}

.btn-enviar {
    background: #007bff;
    color: white;
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.btn-enviar:hover:not(:disabled) {
    background: #0056b3;
    transform: scale(1.05);
}

.btn-enviar:disabled {
    background: #e9ecef;
    color: #adb5bd;
    cursor: not-allowed;
    transform: none;
}

.btn-enviar-text {
    display: none;
}

/* Alertas de segurança */
.chat-alertas {
    margin-top: 12px;
    padding: 12px;
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 6px;
    color: #856404;
    font-size: 14px;
}

.chat-alertas .alerta-icon {
    margin-right: 8px;
}

/* Estado vazio */
.chat-vazio {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
}

.chat-vazio-content {
    text-align: center;
    max-width: 400px;
    padding: 40px;
}

.chat-vazio-icon {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.chat-vazio h3 {
    color: #495057;
    margin-bottom: 12px;
}

.chat-vazio p {
    color: #6c757d;
    margin-bottom: 24px;
}

.dica-cliente {
    background: white;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: 20px;
    text-align: left;
}

.dica-cliente h4 {
    color: #495057;
    margin-bottom: 12px;
}

.dica-cliente ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.dica-cliente li {
    padding: 4px 0;
    color: #6c757d;
}

/* Modal de compartilhar contato */
.modal-compartilhar-contato .modal-content {
    max-width: 480px;
}

.aviso-seguranca {
    display: flex;
    gap: 12px;
    padding: 16px;
    background: #e3f2fd;
    border-radius: 8px;
    margin-bottom: 20px;
}

.aviso-icon {
    font-size: 24px;
    color: #1976d2;
}

.aviso-texto strong {
    color: #1976d2;
    display: block;
    margin-bottom: 4px;
}

.aviso-texto p {
    margin: 0;
    color: #424242;
    font-size: 14px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    font-weight: 500;
}

.form-group input[type="checkbox"] {
    margin: 0;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e1e5e9;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.form-control:disabled {
    background: #f8f9fa;
    color: #6c757d;
}

/* Responsividade */
@media (max-width: 768px) {
    .sistemapc-chat-container {
        flex-direction: column;
        height: 100vh;
    }

    .chat-sidebar {
        width: 100%;
        height: 200px;
    }

    .chat-main {
        flex: 1;
    }

    .chat-header-actions {
        flex-direction: column;
        gap: 8px;
    }

    .btn-compartilhar-contato,
    .btn-solicitar-contato {
        font-size: 12px;
        padding: 6px 12px;
    }

    .mensagem-content {
        max-width: 85%;
    }

    .chat-input-form {
        flex-wrap: wrap;
    }

    .input-actions-left {
        order: 3;
        width: 100%;
        justify-content: center;
        margin-top: 8px;
    }
}

@media (max-width: 480px) {
    .chat-sidebar {
        height: 150px;
    }

    .conversa-item {
        padding: 12px 16px;
    }

    .conversa-avatar img {
        width: 40px;
        height: 40px;
    }

    .chat-header {
        padding: 12px 16px;
    }

    .chat-mensagens {
        padding: 16px;
    }

    .chat-input-container {
        padding: 12px 16px;
    }
}