/**
 * Estilos do Assistente IA com Suporte a Voz
 * Versão: Header Bar (botão no cabeçalho)
 */

/* Botão no Header — CENTRALIZADO (position absolute relativo ao .main-header-container) */
.assistente-ia-header-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    background: linear-gradient(135deg, #c8a663 0%, #b88842 100%);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
    border: none;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 4px 14px rgba(200,166,99,.35);
    z-index: 5;
    letter-spacing: .015em;
}
/* Garante que o container do header seja contexto pra position:absolute */
.main-header-container { position: relative !important; }

/* hover/active preservam o translate(-50%,-50%) do centramento — só mudam a sombra */
.assistente-ia-header-btn:hover {
    transform: translate(-50%, -50%) !important;
    box-shadow: 0 6px 18px rgba(184, 136, 66, 0.45);
    filter: brightness(1.05);
}

.assistente-ia-header-btn:active {
    transform: translate(-50%, -50%) !important;
    filter: brightness(0.95);
}

.assistente-ia-header-btn svg {
    width: 18px;
    height: 18px;
}

.assistente-ia-header-btn .btn-text {
    white-space: nowrap;
}

.assistente-ia-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #ef4444;
    color: white;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    border: 2px solid white;
}

/* Painel de Chat - Maior e deslizando da direita */
.assistente-ia-panel {
    position: fixed;
    top: 70px;
    right: 0;
    width: 480px;
    max-width: 100vw;
    height: calc(100vh - 70px);
    background: white;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    opacity: 0;
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 900;
    border-radius: 0;
}

.assistente-ia-panel.open {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
}

/* Header do Chat */
.assistente-ia-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, #c8a663 0%, #b88842 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.assistente-ia-header-content {
    display: flex;
    gap: 12px;
    align-items: center;
}

.assistente-ia-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.assistente-ia-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.assistente-ia-status {
    margin: 2px 0 0 0;
    font-size: 12px;
    opacity: 0.9;
}

.assistente-ia-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: white;
}

.assistente-ia-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Área de Mensagens */
.assistente-ia-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
}

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

.assistente-ia-messages::-webkit-scrollbar-track {
    background: transparent;
}

.assistente-ia-messages::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.assistente-ia-messages::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Tela de Boas-vindas */
.assistente-ia-welcome {
    text-align: center;
    padding: 20px 10px;
}

.assistente-ia-welcome-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.assistente-ia-welcome h4 {
    color: #1a202c;
    margin-bottom: 12px;
    font-size: 18px;
}

.assistente-ia-welcome p {
    color: #4a5568;
    margin-bottom: 12px;
}

.assistente-ia-welcome ul {
    text-align: left;
    color: #4a5568;
    padding-left: 20px;
    margin-bottom: 20px;
    list-style: none;
}

.assistente-ia-welcome ul li {
    padding: 6px 0;
    position: relative;
    padding-left: 24px;
}

.assistente-ia-welcome ul li:before {
    content: "✓";
    position: absolute;
    left: 0;
    color: #1B4D3E;
    font-weight: bold;
}

/* Capacidades do Assistente */
.assistente-ia-capabilities {
    background: #f7fafc;
    border-radius: 12px;
    padding: 16px;
    margin: 16px 0;
    text-align: left;
}

.capability-group {
    display: flex;
    flex-direction: column;
    padding: 8px 0;
    border-bottom: 1px solid #e2e8f0;
}

.capability-group:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.capability-group:first-child {
    padding-top: 0;
}

.capability-title {
    font-weight: 600;
    color: #1B4D3E;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.capability-items {
    color: #4a5568;
    font-size: 13px;
}

.assistente-ia-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

.quick-action-btn {
    background: white;
    border: 2px solid #e2e8f0;
    padding: 10px 14px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
    font-weight: 500;
    color: #2d3748;
    text-align: center;
    flex: 0 0 auto;
}

.quick-action-btn:hover {
    background: #1B4D3E;
    border-color: #1B4D3E;
    color: white;
    transform: translateY(-2px);
}

/* Mensagens */
.assistente-ia-message {
    margin-bottom: 16px;
    display: flex;
    animation: messageSlideIn 0.3s ease;
}

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

.assistente-ia-message.user {
    justify-content: flex-end;
}

.assistente-ia-message .message-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.5;
    word-wrap: break-word;
}

.assistente-ia-message.user .message-content {
    background: linear-gradient(135deg, #c8a663 0%, #b88842 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.assistente-ia-message.assistant .message-content {
    background: white;
    color: #2d3748;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}

/* Links no Chat */
.chat-link {
    color: #3b82f6;
    text-decoration: none;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: #eff6ff;
    border-radius: 4px;
    margin-top: 8px;
}

.chat-link:hover {
    color: #1d4ed8;
    background: #dbeafe;
    text-decoration: none;
}

/* Sugestões de Resposta */
.message-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.suggestion-btn {
    background: white;
    border: 1px solid #e2e8f0;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    color: #4a5568;
}

.suggestion-btn:hover {
    background: #1B4D3E;
    border-color: #1B4D3E;
    color: white;
}

/* Indicador de Digitação */
.typing-indicator .message-content {
    padding: 16px !important;
}

.typing-dots {
    display: flex;
    gap: 6px;
    align-items: center;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: #cbd5e0;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

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

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

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* Cards de Confirmação e Sucesso */
.confirmation-card,
.success-card {
    background: #f7fafc;
    padding: 16px;
    border-radius: 10px;
    border: 2px solid #e2e8f0;
}

.confirmation-card h4 {
    color: #2d3748;
    margin-bottom: 12px;
    font-size: 15px;
}

.confirmation-details {
    background: white;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 13px;
    color: #4a5568;
}

.confirmation-details strong {
    color: #2d3748;
}

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

.success-card {
    text-align: center;
    border-color: #48bb78;
}

.success-icon {
    font-size: 48px;
    margin-bottom: 8px;
}

.success-card h4 {
    color: #2d3748;
    margin-bottom: 8px;
}

.success-card p {
    color: #4a5568;
    font-size: 14px;
}

/* Footer com Input */
.assistente-ia-footer {
    padding: 16px;
    background: white;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.assistente-ia-recording {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #fef3c7;
    border-radius: 10px;
    margin-bottom: 12px;
    color: #92400e;
    font-size: 14px;
}

.recording-animation {
    display: flex;
    gap: 4px;
}

.recording-animation span {
    width: 4px;
    height: 16px;
    background: #f59e0b;
    border-radius: 2px;
    animation: recordingPulse 0.8s infinite ease-in-out;
}

.recording-animation span:nth-child(1) {
    animation-delay: -0.4s;
}

.recording-animation span:nth-child(2) {
    animation-delay: -0.2s;
}

@keyframes recordingPulse {
    0%, 100% {
        height: 8px;
    }
    50% {
        height: 20px;
    }
}

.assistente-ia-input-container {
    display: flex;
    gap: 8px;
    align-items: center;
}

.assistente-ia-voice-btn {
    width: 40px;
    height: 40px;
    background: #f7fafc;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: #4a5568;
    flex-shrink: 0;
}

.assistente-ia-voice-btn:hover {
    background: #1B4D3E;
    border-color: #1B4D3E;
    color: white;
}

.assistente-ia-voice-btn.recording {
    background: #fef3c7;
    border-color: #f59e0b;
    color: #f59e0b;
    animation: recordingPulse2 1s infinite;
}

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

#assistente-input {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
}

#assistente-input:focus {
    border-color: #1B4D3E;
}

.assistente-ia-send-btn {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #c8a663 0%, #b88842 100%);
    border: none;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: white;
    flex-shrink: 0;
}

.assistente-ia-send-btn:hover {
    transform: scale(1.05);
}

.assistente-ia-send-btn:active {
    transform: scale(0.95);
}

/* Notificações */
.assistente-ia-notification {
    position: fixed;
    top: 80px;
    right: 20px;
    padding: 14px 20px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 950;
    opacity: 0;
    transform: translateX(100px);
    transition: all 0.3s ease;
    font-size: 14px;
    max-width: 320px;
}

.assistente-ia-notification.show {
    opacity: 1;
    transform: translateX(0);
}

.assistente-ia-notification.error {
    background: #fee;
    color: #c00;
    border-left: 4px solid #c00;
}

.assistente-ia-notification.warning {
    background: #fef3c7;
    color: #92400e;
    border-left: 4px solid #f59e0b;
}

.assistente-ia-notification.success {
    background: #d1fae5;
    color: #065f46;
    border-left: 4px solid #10b981;
}

/* Overlay quando o chat está aberto em mobile */
.assistente-ia-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.assistente-ia-overlay.show {
    display: block;
    opacity: 1;
}

/* Tema Escuro */
[data-theme-mode="dark"] .assistente-ia-header-btn {
    background: linear-gradient(135deg, #d9b97a 0%, #c8a663 100%);
}

[data-theme-mode="dark"] .assistente-ia-panel {
    background: #1a202c;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.4);
}

[data-theme-mode="dark"] .assistente-ia-messages {
    background: #2d3748;
}

[data-theme-mode="dark"] .assistente-ia-message.assistant .message-content {
    background: #374151;
    color: #e2e8f0;
    border-color: #4a5568;
}

[data-theme-mode="dark"] .assistente-ia-footer {
    background: #1a202c;
    border-top-color: #4a5568;
}

[data-theme-mode="dark"] #assistente-input {
    background: #2d3748;
    border-color: #4a5568;
    color: #e2e8f0;
}

[data-theme-mode="dark"] .assistente-ia-voice-btn {
    background: #2d3748;
    border-color: #4a5568;
    color: #e2e8f0;
}

[data-theme-mode="dark"] .quick-action-btn,
[data-theme-mode="dark"] .suggestion-btn {
    background: #374151;
    border-color: #4a5568;
    color: #e2e8f0;
}

[data-theme-mode="dark"] .assistente-ia-welcome h4 {
    color: #e2e8f0;
}

[data-theme-mode="dark"] .assistente-ia-welcome p,
[data-theme-mode="dark"] .assistente-ia-welcome ul {
    color: #a0aec0;
}

/* Responsividade */
@media (max-width: 768px) {
    .assistente-ia-panel {
        width: 100%;
        top: 60px;
        height: calc(100vh - 60px);
    }

    .assistente-ia-header-btn .btn-text {
        display: none;
    }

    .assistente-ia-header-btn {
        padding: 8px 10px;
    }
}

@media (max-width: 480px) {
    .assistente-ia-header-btn {
        padding: 6px 8px;
    }

    .assistente-ia-header-btn svg {
        width: 16px;
        height: 16px;
    }
}

/* ============================================
   AGENTES DE IA
   ============================================ */

.assistente-ia-agentes {
    margin: 16px 0;
}

.agentes-loading,
.agentes-empty,
.agentes-error {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    color: #6b7280;
}

.agentes-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.agente-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    flex: 0 0 auto;
    max-width: calc(50% - 3px);
}

.agente-card:hover {
    background: linear-gradient(135deg, #1B4D3E10 0%, #143d3110 100%);
    border-color: #1B4D3E50;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

.agente-card .agente-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: linear-gradient(135deg, #c8a663 0%, #b88842 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 13px;
    flex-shrink: 0;
}

.agente-card .agente-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.agente-card .agente-nome {
    font-size: 11px;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.agente-card .agente-origem {
    font-size: 9px;
    color: #f59e0b;
    font-weight: 600;
    text-transform: uppercase;
    margin-top: 2px;
}

/* Tarefas do Agente */
.tarefas-agente {
    padding: 4px;
}

.tarefas-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e2e8f0;
}

.tarefas-header i {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, #c8a663 0%, #b88842 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
}

.tarefas-header span {
    font-weight: 600;
    color: #1e293b;
    font-size: 14px;
}

.tarefas-desc {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 12px;
}

.tarefas-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.tarefa-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.tarefa-btn:hover {
    background: #1B4D3E10;
    border-color: #1B4D3E50;
}

.tarefa-btn .tarefa-nome {
    font-size: 13px;
    font-weight: 500;
    color: #334155;
}

.tarefa-btn i {
    color: #f59e0b;
    font-size: 14px;
}

.voltar-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: transparent;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    color: #6b7280;
    transition: all 0.2s ease;
}

.voltar-btn:hover {
    background: #f1f5f9;
    color: #334155;
}

/* Dark Mode - Agentes */
[data-theme-mode="dark"] .agente-card {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border-color: #334155;
}

[data-theme-mode="dark"] .agente-card:hover {
    background: linear-gradient(135deg, #1B4D3E20 0%, #143d3120 100%);
    border-color: #1B4D3E50;
}

[data-theme-mode="dark"] .agente-card .agente-nome {
    color: #e2e8f0;
}

[data-theme-mode="dark"] .tarefas-header {
    border-bottom-color: #334155;
}

[data-theme-mode="dark"] .tarefas-header span {
    color: #e2e8f0;
}

[data-theme-mode="dark"] .tarefas-desc {
    color: #94a3b8;
}

[data-theme-mode="dark"] .tarefa-btn {
    background: #1e293b;
    border-color: #334155;
}

[data-theme-mode="dark"] .tarefa-btn:hover {
    background: #1B4D3E20;
}

[data-theme-mode="dark"] .tarefa-btn .tarefa-nome {
    color: #e2e8f0;
}

[data-theme-mode="dark"] .voltar-btn {
    border-color: #334155;
    color: #94a3b8;
}

[data-theme-mode="dark"] .voltar-btn:hover {
    background: #1e293b;
    color: #e2e8f0;
}

/* Garantir que dropdowns do header fiquem acima do assistente */
.app-header .dropdown-menu,
.main-header-container .dropdown-menu,
.header-profile-dropdown,
#profileDropdown,
.dropdown-menu.show,
.header .dropdown-menu,
.dropdown-menu {
    z-index: 1050 !important;
}
