/* ═══════════════════════════════════════
   AFETO CHAT WIDGET — Enterprise Design
═══════════════════════════════════════ */
#afeto-chat-root {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 9998;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    --afc-brand: #0b7a75;
    --afc-brand-l: #0fa99f;
    --afc-bg: rgba(7, 15, 24, 0.97);
    --afc-surface: rgba(11, 122, 117, 0.09);
    --afc-border: rgba(11, 122, 117, 0.22);
    --afc-text: #e0f7f6;
    --afc-text-dim: rgba(224,247,246,0.5);
    --afc-radius: 20px;
    --afc-shadow: 0 28px 90px rgba(0,0,0,.65), 0 0 0 1px rgba(11,122,117,.14), 0 0 80px rgba(11,122,117,.05);
}

/* ── Launcher ─────────────────────────── */
.afc-launcher {
    position: relative;
    width: 62px;
    height: 62px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.afc-btn {
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: linear-gradient(145deg, #0b7a75 0%, #0fa99f 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 24px rgba(11,122,117,.5), 0 0 0 0 rgba(11,122,117,.35);
    transition: transform .22s cubic-bezier(.34,1.56,.64,1), box-shadow .22s;
    position: relative;
    z-index: 1;
    animation: afc-float 5s ease-in-out infinite;
    overflow: hidden;
}

.afc-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(145deg, rgba(255,255,255,.15), transparent);
    border-radius: 50%;
    pointer-events: none;
}

.afc-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 36px rgba(11,122,117,.65);
    animation-play-state: paused;
}

.afc-btn svg {
    pointer-events: none;
    transition: opacity .2s, transform .25s cubic-bezier(.34,1.56,.64,1);
    position: absolute;
}

.afc-icon-close { opacity: 0; transform: rotate(-90deg) scale(.7); }
.afc-icon-chat  { opacity: 1; transform: rotate(0deg) scale(1); }

.afc-btn.open .afc-icon-close { opacity: 1; transform: rotate(0deg) scale(1); }
.afc-btn.open .afc-icon-chat  { opacity: 0; transform: rotate(90deg) scale(.7); }

.afc-pulse-ring {
    position: absolute;
    inset: -5px;
    border-radius: 50%;
    border: 2px solid rgba(11,122,117,.45);
    animation: afc-pulse 2.8s ease-out infinite;
    pointer-events: none;
}

.afc-pulse-ring:nth-child(2) { animation-delay: 1.4s; }

.afc-badge {
    position: absolute;
    top: 0; right: 0;
    width: 18px; height: 18px;
    background: #ef4444;
    color: #fff;
    border-radius: 50%;
    border: 2.5px solid #fff;
    font-size: 10px;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    line-height: 1;
    box-shadow: 0 2px 8px rgba(239,68,68,.4);
}

.afc-badge.show { display: flex; }

@keyframes afc-pulse {
    0%   { opacity: .75; transform: scale(1); }
    100% { opacity: 0;   transform: scale(1.75); }
}

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

/* ── Chat Panel ───────────────────────── */
.afc-panel {
    position: fixed;
    bottom: 108px;
    right: 28px;
    width: 390px;
    height: 545px;
    background: var(--afc-bg);
    backdrop-filter: blur(28px) saturate(200%);
    -webkit-backdrop-filter: blur(28px) saturate(200%);
    border: 1px solid var(--afc-border);
    border-radius: var(--afc-radius);
    box-shadow: var(--afc-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transform: scale(.88) translateY(16px);
    opacity: 0;
    pointer-events: none;
    transition: transform .3s cubic-bezier(.34,1.56,.64,1), opacity .22s ease;
    background-image: linear-gradient(
        to bottom,
        rgba(11,122,117,.07) 0%,
        transparent 60px
    );
}

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

/* Header */
.afc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 18px;
    background: linear-gradient(135deg, rgba(11,122,117,.22) 0%, rgba(15,169,159,.08) 100%);
    border-bottom: 1px solid var(--afc-border);
    flex-shrink: 0;
    position: relative;
}

.afc-header::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(11,122,117,.5), transparent);
}

.afc-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.afc-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: linear-gradient(145deg, #0b7a75, #0fa99f);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 16px; color: #fff;
    box-shadow: 0 0 18px rgba(11,122,117,.45);
    position: relative;
    flex-shrink: 0;
}

.afc-avatar::after {
    content: '';
    position: absolute;
    bottom: 2px; right: 2px;
    width: 10px; height: 10px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid var(--afc-bg);
    box-shadow: 0 0 6px rgba(34,197,94,.6);
}

.afc-header-name {
    font-weight: 600;
    color: var(--afc-text);
    font-size: 14.5px;
    letter-spacing: .01em;
}

.afc-header-status {
    font-size: 11.5px;
    color: #22c55e;
    display: flex; align-items: center; gap: 5px;
    margin-top: 1px;
}

.afc-header-status::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: #22c55e;
    display: inline-block;
    box-shadow: 0 0 5px rgba(34,197,94,.7);
    animation: afc-blink 2s ease-in-out infinite;
}

@keyframes afc-blink {
    0%,100% { opacity: 1; } 50% { opacity: .4; }
}

.afc-close-btn {
    width: 32px; height: 32px;
    border-radius: 8px;
    background: rgba(255,255,255,.05);
    border: 1px solid var(--afc-border);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--afc-text-dim);
    transition: background .15s, color .15s;
    flex-shrink: 0;
}

.afc-close-btn:hover {
    background: rgba(255,255,255,.12);
    color: var(--afc-text);
}

/* Messages */
.afc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 16px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

.afc-messages::-webkit-scrollbar { width: 3px; }
.afc-messages::-webkit-scrollbar-track { background: transparent; }
.afc-messages::-webkit-scrollbar-thumb { background: rgba(11,122,117,.3); border-radius: 2px; }

/* Message rows */
.afc-msg {
    display: flex;
    gap: 9px;
    animation: afc-msg-in .28s ease;
    align-items: flex-end;
}

.afc-msg.user { flex-direction: row-reverse; }

@keyframes afc-msg-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.afc-msg-avatar {
    width: 26px; height: 26px;
    border-radius: 50%;
    background: linear-gradient(145deg, #0b7a75, #0fa99f);
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; color: #fff;
    flex-shrink: 0;
}

.afc-msg.user .afc-msg-avatar {
    background: linear-gradient(145deg, #075f5b, #0b7a75);
}

.afc-bubble {
    max-width: 80%;
    padding: 10px 13px;
    border-radius: 15px;
    font-size: 13px;
    line-height: 1.55;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.afc-msg.bot .afc-bubble {
    background: rgba(11,122,117,.13);
    border: 1px solid rgba(11,122,117,.18);
    border-bottom-left-radius: 4px;
    color: var(--afc-text);
}

.afc-msg.user .afc-bubble {
    background: linear-gradient(145deg, rgba(11,122,117,.42), rgba(15,169,159,.28));
    border: 1px solid rgba(11,122,117,.28);
    border-bottom-right-radius: 4px;
    color: var(--afc-text);
}

/* Typing indicator */
.afc-typing .afc-bubble {
    padding: 13px 16px;
}

.afc-dots {
    display: flex; gap: 4px; align-items: center;
    height: 14px;
}

.afc-dots span {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: rgba(11,122,117,.7);
    animation: afc-dot 1.3s ease-in-out infinite;
}

.afc-dots span:nth-child(2) { animation-delay: .22s; }
.afc-dots span:nth-child(3) { animation-delay: .44s; }

@keyframes afc-dot {
    0%,80%,100% { transform: translateY(0); opacity: .45; }
    40%          { transform: translateY(-6px); opacity: 1; }
}

/* Input bar */
.afc-input-bar {
    padding: 12px 14px;
    border-top: 1px solid var(--afc-border);
    display: flex;
    gap: 9px;
    align-items: center;
    background: rgba(0,0,0,.18);
    flex-shrink: 0;
}

.afc-input {
    flex: 1;
    background: rgba(255,255,255,.06);
    border: 1px solid var(--afc-border);
    border-radius: 11px;
    padding: 10px 13px;
    color: var(--afc-text);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

.afc-input::placeholder { color: var(--afc-text-dim); }

.afc-input:focus {
    border-color: rgba(11,122,117,.5);
    box-shadow: 0 0 0 3px rgba(11,122,117,.1);
}

.afc-send-btn {
    width: 40px; height: 40px;
    border-radius: 11px;
    background: linear-gradient(145deg, #0b7a75, #0fa99f);
    border: none;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: transform .15s, box-shadow .15s, opacity .15s;
    box-shadow: 0 2px 14px rgba(11,122,117,.4);
}

.afc-send-btn:hover:not(:disabled) {
    transform: scale(1.08);
    box-shadow: 0 4px 22px rgba(11,122,117,.55);
}

.afc-send-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

/* Footer */
.afc-footer {
    padding: 7px 16px 9px;
    text-align: center;
    font-size: 11px;
    color: rgba(224,247,246,.28);
    border-top: 1px solid rgba(11,122,117,.08);
    flex-shrink: 0;
}

.afc-footer a {
    color: rgba(15,169,159,.55);
    text-decoration: none;
}

.afc-footer a:hover { color: rgba(15,169,159,.85); }

/* ── Responsive ───────────────────────── */
@media (max-width: 480px) {
    #afeto-chat-root {
        bottom: 16px;
        right: 16px;
    }

    .afc-panel {
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
        transform-origin: bottom center;
    }

    .afc-panel.open {
        transform: scale(1) translateY(0);
    }

    /* Esconde o botão flutuante quando o painel está aberto em mobile
       para não sobrepor o botão de enviar */
    #afeto-chat-root.afc-open .afc-launcher {
        display: none;
    }
}

@media (max-width: 360px) {
    .afc-btn { width: 54px; height: 54px; }
    .afc-pulse-ring { inset: -4px; }
}
