:root {
    --chat-primary: #8B5CF6;
    --chat-primary-hover: #7C3AED;
    --chat-secondary: #A855F7;
    --chat-accent: #EC4899;
    --chat-bg: #1F2937;
    --chat-bg-light: #374151;
    --chat-text: #F9FAFB;
    --chat-text-muted: #9CA3AF;
    --chat-border: #4B5563;
    --chat-success: #10B981;
    --chat-error: #EF4444;
    --chat-warning: #F59E0B;
    --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --gradient-primary: linear-gradient(135deg, var(--chat-primary), var(--chat-secondary));
    --gradient-accent: linear-gradient(135deg, var(--chat-accent), var(--chat-primary));
}

/* Container principal do chat */
#floating-chat-container { 
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.4;
}

/* Aba do chat (minimizada) - posicionamento vertical */
.chat-tab {
 /* Desvincula a aba do container para posicioná-la na lateral da tela */
    position: fixed;
    top: 50%;
    right: -38px; /* Esconde parte da aba, deixando só a borda visível */

    /* ===================================================================================
       CORREÇÃO: Inverte a ordem das transformações e ajusta o ângulo de rotação.
       =================================================================================== */
    transform: translateY(-50%) rotate(-90deg);
    transform-origin: top right; /* Ponto de rotação */

    background: var(--gradient-primary);
    color: white;
    padding: 12px 20px;
    border-radius: 10px 10px 0 0; /* Bordas arredondadas para a aba vertical */
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.1);
    z-index: 10000; /* Garante que a aba fique acima de tudo */

}

.chat-tab:hover {
    right: -5px; /* Mostra mais da aba ao passar o mouse */

    /* ===================================================================================
       CORREÇÃO: Mantém a rotação correta mesmo no hover.
       =================================================================================== */
    transform: translateY(-50%) rotate(-90deg) scale(1.05);
    box-shadow: var(--shadow-xl);

}

.chat-tab span {
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 1px;
    display: block;
}

/* Painel do chat (expandido) */
.chat-panel {
    width: 350px;
    height: 500px;
    background: var(--chat-bg);
    border-radius: 20px;
    box-shadow: var(--shadow-xl);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--chat-border);
    animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-panel.active {
    display: flex;
}

/* Cabeçalho do chat */
.chat-header {
    background: var(--gradient-primary);
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    border-radius: 20px 20px 0 0;
    position: relative;
    overflow: hidden;
}

.chat-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="20" cy="20" r="2" fill="rgba(255,255,255,0.1)"/><circle cx="80" cy="30" r="1.5" fill="rgba(255,255,255,0.1)"/><circle cx="40" cy="70" r="1" fill="rgba(255,255,255,0.1)"/></svg>');
    animation: float 6s ease-in-out infinite;
}

/* Abas do chat */
.chat-tabs {
    display: flex;
    gap: 10px;
}

.tab {
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    backdrop-filter: blur(10px);
}

.tab:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.tab.active {
    background: rgba(255, 255, 255, 0.25);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.tab-icon {
    font-size: 14px;
}

/* Botão minimizar */
.chat-minimize {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 18px;
    font-weight: bold;
    backdrop-filter: blur(10px);
}

.chat-minimize:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

/* Área de mensagens */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: var(--chat-bg);
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: var(--chat-primary) var(--chat-bg-light);
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: var(--chat-bg-light);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--chat-primary);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--chat-primary-hover);
}

/* Mensagem individual */
.message {
    background: var(--chat-bg-light);
    padding: 12px 15px;
    border-radius: 15px;
    border-left: 3px solid var(--chat-primary);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.message:hover {
    transform: translateX(5px);
    box-shadow: 0 5px 15px rgba(139, 92, 246, 0.2);
}

.message::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: var(--gradient-primary);
}

.message-username {
    font-weight: 600;
    color: var(--chat-primary);
    font-size: 13px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.message-username::before {
    content: ''; /* Remove o caractere de texto */
    display: inline-block;
    width: 16px;  /* Largura do ícone */
    height: 16px; /* Altura do ícone */
    background-color: var(--chat-primary); /* Cor do ícone */
    flex-shrink: 0;

    /* A mágica acontece aqui: usamos uma máscara SVG */
    -webkit-mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path><circle cx="9" cy="7" r="4"></circle><path d="M23 21v-2a4 4 0 0 0-3-3.87"></path><path d="M16 3.13a4 4 0 0 1 0 7.75"></path></svg>');
    mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path><circle cx="9" cy="7" r="4"></circle><path d="M23 21v-2a4 4 0 0 0-3-3.87"></path><path d="M16 3.13a4 4 0 0 1 0 7.75"></path></svg>');

    /* Garante que o ícone se ajuste ao tamanho definido */
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
}

.message-text {
    color: var(--chat-text);
    margin-bottom: 6px;
    word-wrap: break-word;
    line-height: 1.5;
}

.message-time {
    font-size: 11px;
    color: var(--chat-text-muted);
    opacity: 0.8;
}

/* Spinner de carregamento */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    gap: 15px;
    color: var(--chat-text-muted);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--chat-border);
    border-top: 3px solid var(--chat-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    position: relative;
}

.spinner::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    background: var(--gradient-primary);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: pulse 1.5s ease-in-out infinite;
}

.spinner.small {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

.spinner.small::after {
    width: 10px;
    height: 10px;
}

/* Área de input */
.chat-input-area {
    padding: 15px;
    background: var(--chat-bg-light);
    border-top: 1px solid var(--chat-border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#chat-username {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid var(--chat-border);
    border-radius: 20px;
    background: var(--chat-bg);
    color: var(--chat-text);
    font-size: 13px;
    transition: all 0.3s ease;
    outline: none;
}

#chat-username:focus {
    border-color: var(--chat-primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

#chat-username::placeholder {
    color: var(--chat-text-muted);
}

/* Container da mensagem */
.message-input-container {
    display: flex;
    gap: 10px;
    align-items: center;
}

#chat-message {
    flex: 1;
    padding: 12px 15px;
    border: 1px solid var(--chat-border);
    border-radius: 20px;
    background: var(--chat-bg);
    color: var(--chat-text);
    font-size: 14px;
    transition: all 0.3s ease;
    outline: none;
    resize: none;
}

#chat-message:focus {
    border-color: var(--chat-primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

#chat-message::placeholder {
    color: var(--chat-text-muted);
}

/* Botão enviar */
#send-message {
    width: 45px;
    height: 45px;
    background: var(--gradient-primary);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

#send-message:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(139, 92, 246, 0.4);
}

#send-message:active {
    transform: scale(0.95);
}

#send-message:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.send-icon {
    width: 20px;
    height: 20px;
    transition: all 0.3s ease;
}

#send-message:hover .send-icon {
    transform: translateX(2px);
}

.button-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Contador de caracteres */
.character-counter {
    font-size: 11px;
    color: var(--chat-text-muted);
    text-align: right;
    transition: color 0.3s ease;
}

.character-counter.warning {
    color: var(--chat-warning);
}

.character-counter.error {
    color: var(--chat-error);
}

/* Mensagens de sistema */
.system-message {
    background: var(--chat-primary);
    color: white;
    padding: 10px 15px;
    border-radius: 20px;
    text-align: center;
    font-size: 13px;
    margin: 10px 0;
    animation: slideIn 0.5s ease;
}

.system-message.error {
    background: var(--chat-error);
}

.system-message.success {
    background: var(--chat-success);
}

/* Efeitos de hover e animações */
.message-fade-in {
    animation: fadeIn 0.5s ease;
}

/* Responsividade */
@media (max-width: 768px) {
    #floating-chat-container {
        bottom: 10px;
        right: 10px;
    }

    .chat-panel {
        width: 300px;
        height: 450px;
    }

    .chat-header {
        padding: 12px;
    }

    .chat-messages {
        padding: 12px;
    }

    .chat-input-area {
        padding: 12px;
    }
}

@media (max-width: 480px) {
    .chat-panel {
        width: 280px;
        height: 400px;
    }

    .tab {
        padding: 6px 12px;
        font-size: 11px;
    }

    .tab-icon {
        font-size: 12px;
    }
}

/* Estados especiais */
.chat-panel.minimizing {
    animation: slideDown 0.3s ease;
}

/* Notificação de nova mensagem */
.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--chat-error);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
    animation: bounce 1s infinite;
}

/* Efeitos de digitação */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    background: var(--chat-bg-light);
    border-radius: 15px;
    margin: 5px 0;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--chat-primary);
    animation: typingDot 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

/* Animações */
@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

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

@keyframes slideIn {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

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

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

@keyframes pulse {
    0%, 100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    50% { opacity: 0.6; transform: translate(-50%, -50%) scale(1.2); }
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

@keyframes typingDot {
    0%, 60%, 100% {
        opacity: 0.4;
        transform: scale(1);
    }
    30% {
        opacity: 1;
        transform: scale(1.2);
    }
}
