/* ============================================
   EVY AI CHAT WIDGET
   Assistente especialista em tráfego pago
   ============================================ */

/* ── Bolinha Flutuante (Trigger) ─────────────── */
.evy-trigger {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7c3aed 0%, #ec4899 60%, #3b82f6 100%);
    border: none;
    cursor: pointer;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.5), 0 0 0 0 rgba(124, 58, 237, 0.4);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.25s ease;
    outline: none;
}

.evy-trigger:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(124, 58, 237, 0.7), 0 0 0 0 rgba(124, 58, 237, 0.4);
}

.evy-trigger:active {
    transform: scale(0.96);
}

/* Estado aberto */
.evy-trigger.is-open {
    background: linear-gradient(135deg, #4c1d95, #6d28d9);
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.4);
    animation: none !important;
}

/* Ícone dentro da bolinha */
.evy-trigger-icon,
.evy-trigger-close {
    position: absolute;
    transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.evy-trigger-icon { opacity: 1; transform: scale(1); }
.evy-trigger-close { opacity: 0; transform: scale(0.5); }

.evy-trigger.is-open .evy-trigger-icon {
    opacity: 0;
    transform: scale(0.5);
}
.evy-trigger.is-open .evy-trigger-close {
    opacity: 1;
    transform: scale(1);
}

/* Pulse animation — ativo quando fechado */
.evy-trigger:not(.is-open) {
    animation: evyPulse 3s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes evyPulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(124,58,237,0.5), 0 0 0 0 rgba(124,58,237,0.35); }
    50%       { box-shadow: 0 4px 20px rgba(124,58,237,0.6), 0 0 0 12px rgba(124,58,237,0); }
}

/* Badge de mensagem não lida */
.evy-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    background: #ef4444;
    border-radius: 999px;
    border: 2px solid #0a0a0f;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0);
    transition: opacity 0.2s, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.evy-badge.visible {
    opacity: 1;
    transform: scale(1);
}

/* Tooltip */
.evy-tooltip {
    position: absolute;
    bottom: 68px;
    right: 0;
    background: rgba(15, 15, 30, 0.95);
    border: 1px solid rgba(124, 58, 237, 0.3);
    border-radius: 10px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    color: #f1f5f9;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.evy-trigger:hover .evy-tooltip,
.evy-trigger:focus .evy-tooltip {
    opacity: 1;
    transform: translateY(0);
}
.evy-trigger.is-open .evy-tooltip {
    display: none;
}

/* ── Painel do Chat ───────────────────────────── */
.evy-panel {
    position: fixed;
    bottom: 100px;
    right: 28px;
    width: 375px;
    height: 540px;
    border-radius: 20px;
    background: rgba(17, 17, 30, 0.97);
    border: 1px solid rgba(124, 58, 237, 0.25);
    box-shadow:
        0 24px 60px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(255,255,255,0.04) inset,
        0 0 40px rgba(124, 58, 237, 0.08);
    backdrop-filter: blur(20px);
    z-index: 9998;
    display: flex;
    flex-direction: column;
    overflow: hidden;

    /* Estado inicial — oculto */
    opacity: 0;
    transform: translateY(20px) scale(0.97);
    pointer-events: none;
    transition:
        opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.3s cubic-bezier(0.34, 1.25, 0.64, 1);
}

.evy-panel.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* ── Header do Painel ─────────────────────────── */
.evy-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    background: linear-gradient(135deg, rgba(124,58,237,0.15) 0%, rgba(59,130,246,0.08) 100%);
    border-bottom: 1px solid rgba(124, 58, 237, 0.2);
    flex-shrink: 0;
}

.evy-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7c3aed 0%, #ec4899 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(124,58,237,0.3), 0 0 16px rgba(124,58,237,0.3);
    position: relative;
}

/* Indicador online na bolinha do avatar */
.evy-header-avatar::after {
    content: '';
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 10px;
    height: 10px;
    background: #10b981;
    border-radius: 50%;
    border: 2px solid rgba(17,17,30,0.97);
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

.evy-header-info {
    flex: 1;
}

.evy-header-name {
    font-size: 14px;
    font-weight: 700;
    color: #f1f5f9;
    line-height: 1;
    margin-bottom: 3px;
}

.evy-header-status {
    font-size: 11px;
    color: #10b981;
    display: flex;
    align-items: center;
    gap: 4px;
}

.evy-header-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 4px #10b981;
    display: inline-block;
}

.evy-header-close {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}
.evy-header-close:hover {
    background: rgba(239,68,68,0.2);
    color: #f87171;
    border-color: rgba(239,68,68,0.3);
}

/* ── Área de Mensagens ────────────────────────── */
.evy-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.evy-messages::-webkit-scrollbar { width: 4px; }
.evy-messages::-webkit-scrollbar-track { background: transparent; }
.evy-messages::-webkit-scrollbar-thumb { background: rgba(124,58,237,0.3); border-radius: 4px; }

/* Bubble genérica */
.evy-bubble {
    max-width: 90%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.55;
    color: #e2e8f0;
    animation: evyBubbleIn 0.3s cubic-bezier(0.34, 1.25, 0.64, 1);
    word-break: break-word;
}

@keyframes evyBubbleIn {
    from { opacity: 0; transform: translateY(8px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Bubble da EVY (IA) */
.evy-bubble.bot {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}

/* Bubble do usuário */
.evy-bubble.user {
    background: linear-gradient(135deg, rgba(124,58,237,0.35), rgba(99,58,237,0.25));
    border: 1px solid rgba(124,58,237,0.3);
    border-bottom-right-radius: 4px;
    align-self: flex-end;
    color: #f1f5f9;
}

/* Nome da EVY acima da bubble */
.evy-bubble-sender {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 4px;
    color: #7c3aed;
}

/* Link de navegação dentro das respostas */
.evy-nav-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 8px;
    padding: 5px 10px;
    background: rgba(124,58,237,0.15);
    border: 1px solid rgba(124,58,237,0.35);
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    color: #a78bfa;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    text-decoration: none;
}
.evy-nav-link:hover {
    background: rgba(124,58,237,0.3);
    color: #c4b5fd;
}
.evy-nav-link svg { flex-shrink: 0; }

/* ── Typing Indicator ─────────────────────────── */
.evy-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.2s, transform 0.2s;
}
.evy-typing.visible {
    opacity: 1;
    transform: translateY(0);
}
.evy-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #94a3b8;
    display: inline-block;
    animation: evyTypingDot 1.2s infinite ease-in-out;
}
.evy-typing span:nth-child(2) { animation-delay: 0.2s; }
.evy-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes evyTypingDot {
    0%, 80%, 100% { transform: scale(1); opacity: 0.4; }
    40%            { transform: scale(1.3); opacity: 1; }
}

/* ── Quick Action Chips ───────────────────────── */
.evy-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 16px 4px;
    flex-shrink: 0;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.evy-chip {
    padding: 5px 12px;
    background: rgba(124,58,237,0.1);
    border: 1px solid rgba(124,58,237,0.25);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    color: #a78bfa;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
    white-space: nowrap;
}
.evy-chip:hover {
    background: rgba(124,58,237,0.25);
    transform: translateY(-1px);
}
.evy-chip:active { transform: scale(0.96); }

/* ── Input Area ───────────────────────────────── */
.evy-input-area {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 12px 14px;
    border-top: 1px solid rgba(255,255,255,0.07);
    background: rgba(255,255,255,0.02);
    flex-shrink: 0;
}

.evy-input {
    flex: 1;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 13px;
    color: #f1f5f9;
    font-family: var(--font-family, 'Inter', sans-serif);
    resize: none;
    min-height: 40px;
    max-height: 100px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    line-height: 1.4;
}
.evy-input::placeholder { color: #475569; }
.evy-input:focus {
    border-color: rgba(124,58,237,0.5);
    box-shadow: 0 0 0 3px rgba(124,58,237,0.12);
    background: rgba(255,255,255,0.08);
}

.evy-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
    box-shadow: 0 2px 10px rgba(124,58,237,0.4);
}
.evy-send-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(124,58,237,0.6);
}
.evy-send-btn:active { transform: scale(0.95); }
.evy-send-btn:disabled {
    background: rgba(124,58,237,0.3);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}
.evy-send-btn svg { color: #fff; flex-shrink: 0; }

/* ── Linha divisória de dia ───────────────────── */
.evy-day-divider {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 10px;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.evy-day-divider::before,
.evy-day-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255,255,255,0.06);
}

/* ── Responsividade Mobile ────────────────────── */
@media (max-width: 480px) {
    .evy-panel {
        width: calc(100vw - 20px);
        height: 70vh;
        bottom: 90px;
        right: 10px;
        border-radius: 16px;
    }
    .evy-trigger {
        bottom: 16px;
        right: 16px;
        width: 52px;
        height: 52px;
    }
}

/* ── Light mode overrides ─────────────────────── */
.light-mode .evy-panel {
    background: rgba(255,255,255,0.97);
    border-color: rgba(124,58,237,0.2);
    box-shadow: 0 24px 60px rgba(0,0,0,0.15), 0 0 40px rgba(124,58,237,0.06);
}
.light-mode .evy-bubble.bot {
    background: rgba(0,0,0,0.04);
    border-color: rgba(0,0,0,0.08);
    color: #1e293b;
}
.light-mode .evy-bubble.user { color: #f1f5f9; }
.light-mode .evy-input {
    background: rgba(0,0,0,0.04);
    border-color: rgba(0,0,0,0.1);
    color: #1e293b;
}
.light-mode .evy-input::placeholder { color: #94a3b8; }
.light-mode .evy-badge { border-color: #f8fafc; }
.light-mode .evy-messages::-webkit-scrollbar-thumb { background: rgba(124,58,237,0.2); }
