/**
 * Perfex Chat Widget - Estilos CSS
 * Estilização completa do widget de chat
 */

/* Reset e Base */
.perfex-chat-widget * {
    box-sizing: border-box;
}

.perfex-chat-widget {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 14px;
    line-height: 1.4;
    color: #333;
    z-index: 999999;
}

/* Posicionamento */
.perfex-chat-widget.bottom-right {
    position: fixed;
    bottom: 20px;
    right: 20px;
}

.perfex-chat-widget.bottom-left {
    position: fixed;
    bottom: 20px;
    left: 20px;
}

.perfex-chat-widget.top-right {
    position: fixed;
    top: 20px;
    right: 20px;
}

.perfex-chat-widget.top-left {
    position: fixed;
    top: 20px;
    left: 20px;
}

/* Botão de Abertura */
.chat-toggle-button {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.chat-toggle-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.2);
}

.chat-toggle-button:active {
    transform: scale(0.95);
}

.chat-icon {
    width: 24px;
    height: 24px;
}

.chat-notification {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #e74c3c;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Container Principal */
.chat-container {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 500px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideIn 0.3s ease;
}

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

/* Posicionamento para diferentes cantos */
.perfex-chat-widget.bottom-left .chat-container {
    right: auto;
    left: 0;
}

.perfex-chat-widget.top-right .chat-container {
    bottom: auto;
    top: 80px;
}

.perfex-chat-widget.top-left .chat-container {
    bottom: auto;
    top: 80px;
    right: auto;
    left: 0;
}

/* Cabeçalho */
.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header-info h3 {
    margin: 0 0 5px 0;
    font-size: 18px;
    font-weight: 600;
}

.chat-header-info p {
    margin: 0;
    font-size: 14px;
    opacity: 0.9;
}

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

.chat-header-actions button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: background 0.2s ease;
}

.chat-header-actions button:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Conteúdo */
.chat-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Seção de Funcionários */
.chat-staff-section {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.staff-section-header {
    margin-bottom: 20px;
}

.staff-section-header h4 {
    margin: 0 0 15px 0;
    font-size: 16px;
    color: #333;
}

.staff-search input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.staff-search input:focus {
    outline: none;
    border-color: #667eea;
}

/* Lista de Funcionários */
.staff-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.staff-member {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.staff-member:hover {
    background: #f8f9fa;
    border-color: #e1e5e9;
}

.staff-member.active {
    background: #e3f2fd;
    border-color: #2196f3;
}

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

.staff-info {
    flex: 1;
}

.staff-name {
    margin: 0 0 4px 0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.staff-role {
    font-size: 12px;
    color: #666;
}

.staff-status {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 12px;
    font-weight: 500;
}

.staff-status.online {
    background: #e8f5e8;
    color: #2e7d32;
}

.staff-status.offline {
    background: #ffebee;
    color: #c62828;
}

.staff-status.away {
    background: #fff3e0;
    color: #ef6c00;
}

/* Seção de Mensagens */
.chat-messages-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.messages-header {
    padding: 15px 20px;
    border-bottom: 1px solid #e1e5e9;
    display: flex;
    align-items: center;
    gap: 15px;
}

.back-to-staff {
    background: none;
    border: none;
    color: #667eea;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    transition: background 0.2s ease;
}

.back-to-staff:hover {
    background: #f0f2ff;
}

.current-staff-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.current-staff-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.current-staff-details h5 {
    margin: 0 0 2px 0;
    font-size: 14px;
    font-weight: 600;
}

/* Container de Mensagens */
.messages-container {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.messages-welcome {
    text-align: center;
    color: #666;
    padding: 40px 20px;
}

.messages-welcome p {
    margin: 0;
}

/* Mensagens */
.chat-message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
}

.client-message {
    align-self: flex-end;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin-left: auto;
}

.staff-message {
    align-self: flex-start;
    background: #f1f3f4;
    color: #333;
    margin-right: auto;
}

.message-content {
    margin-bottom: 4px;
    word-wrap: break-word;
}

.message-time {
    font-size: 11px;
    opacity: 0.7;
}

/* Input de Mensagem */
.messages-input {
    padding: 20px;
    border-top: 1px solid #e1e5e9;
}

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

.input-wrapper textarea {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e1e5e9;
    border-radius: 20px;
    font-size: 14px;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    transition: border-color 0.2s ease;
}

.input-wrapper textarea:focus {
    outline: none;
    border-color: #667eea;
}

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

.input-actions button {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.attach-file-btn {
    background: #f1f3f4;
    color: #666;
}

.attach-file-btn:hover {
    background: #e8eaed;
}

.send-message-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.send-message-btn:hover:not(:disabled) {
    transform: scale(1.05);
}

.send-message-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Indicador de Digitação */
.typing-indicator {
    padding: 8px 20px;
    font-size: 12px;
    color: #666;
    font-style: italic;
}

/* Área de Upload */
.file-upload-area {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    z-index: 10;
    display: flex;
    flex-direction: column;
}

.file-upload-header {
    padding: 20px;
    border-bottom: 1px solid #e1e5e9;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.file-upload-header h4 {
    margin: 0;
}

.close-file-upload {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}

.file-upload-content {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.file-upload-content input[type="file"] {
    padding: 20px;
    border: 2px dashed #e1e5e9;
    border-radius: 8px;
    text-align: center;
}

.file-upload-info {
    color: #666;
    font-size: 12px;
}

.file-upload-info p {
    margin: 5px 0;
}

.upload-file-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
}

.upload-file-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Rodapé */
.chat-footer {
    padding: 15px 20px;
    border-top: 1px solid #e1e5e9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
}

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

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

.status-indicator.online {
    background: #4caf50;
}

.status-indicator.offline {
    background: #f44336;
}

.chat-actions button {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: background 0.2s ease;
}

.chat-actions button:hover {
    background: #e9ecef;
}

/* Modal de Configurações */
.chat-settings-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000000;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #e1e5e9;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h4 {
    margin: 0;
}

.close-modal {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}

.modal-body {
    padding: 20px;
}

.setting-group {
    margin-bottom: 20px;
}

.setting-group label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.setting-group select {
    margin-top: 8px;
    padding: 8px 12px;
    border: 1px solid #e1e5e9;
    border-radius: 6px;
    width: 100%;
}

/* Estados de Carregamento */
.loading-staff {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.spinner {
    width: 30px;
    height: 30px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px auto;
}

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

/* Mensagens de Erro */
.error {
    color: #d32f2f;
    text-align: center;
    padding: 20px;
}

.no-staff {
    text-align: center;
    color: #666;
    padding: 40px 20px;
}

/* Temas */
.light-theme {
    /* Tema claro (padrão) */
}

.dark-theme {
    background: #1a1a1a;
    color: #ffffff;
}

.dark-theme .chat-container {
    background: #2d2d2d;
    color: #ffffff;
}

.dark-theme .chat-header {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
}

.dark-theme .staff-member:hover {
    background: #3a3a3a;
}

.dark-theme .staff-message {
    background: #4a5568;
    color: #ffffff;
}

.dark-theme .input-wrapper textarea {
    background: #3a3a3a;
    border-color: #4a5568;
    color: #ffffff;
}

.dark-theme .chat-footer {
    background: #3a3a3a;
    border-color: #4a5568;
}

/* Responsividade */
@media (max-width: 480px) {
    .chat-container {
        width: calc(100vw - 40px);
        height: calc(100vh - 120px);
        bottom: 80px;
        right: 20px;
        left: 20px;
    }
    
    .perfex-chat-widget.bottom-left .chat-container {
        left: 20px;
        right: 20px;
    }
    
    .perfex-chat-widget.top-right .chat-container {
        top: 80px;
        bottom: 20px;
        right: 20px;
        left: 20px;
    }
    
    .perfex-chat-widget.top-left .chat-container {
        top: 80px;
        bottom: 20px;
        left: 20px;
        right: 20px;
    }
}

/* Animações */
.fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.slide-up {
    animation: slideUp 0.3s ease;
}

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

/* Utilitários */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.text-muted {
    color: #666;
}

.mb-10 {
    margin-bottom: 10px;
}

.mt-10 {
    margin-top: 10px;
}
