/* ============================================================
   INFOR-MAR CONTÁBIL — Widget de Chat Interativo Estilo WhatsApp
   ============================================================ */

:root {
    --wa-green: #25D366;
    --wa-green-hover: #1EBE5D;
    --wa-dark-green: #075E54;
    --wa-teal: #128C7E;
    --wa-light-green: #D9FDD3;
    --wa-chat-bg: #ECE5DD;
    --wa-bubble-white: #FFFFFF;
    --wa-gray-text: #667781;
    --wa-dark-text: #111B21;
    --wa-blue-check: #53BDEB;
}

/* ============ BOTÃO FLUTUANTE (LAUNCHER) ============ */
.wa-widget-launcher {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.wa-widget-launcher:hover {
    transform: scale(1.05);
}

/* Tooltip / Balão de chamada */
.wa-launcher-prompt {
    background: #FFFFFF;
    color: var(--wa-dark-text);
    padding: 10px 16px;
    border-radius: 24px;
    font-size: 0.88rem;
    font-weight: 600;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: wa-float-bob 3s ease-in-out infinite;
    position: relative;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.wa-launcher-prompt::after {
    content: '';
    position: absolute;
    right: -7px;
    top: 50%;
    transform: translateY(-50%);
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-left: 8px solid #FFFFFF;
}

.wa-launcher-prompt .wa-pulse-dot {
    width: 8px;
    height: 8px;
    background: var(--wa-green);
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.7);
    animation: wa-pulse-ring 2s infinite;
}

/* Botão circular */
.wa-launcher-btn {
    width: 62px;
    height: 62px;
    background: linear-gradient(135deg, #25D366 0%, #1EBE5D 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFFFFF;
    font-size: 2rem;
    box-shadow: 0 8px 24px rgba(37, 211, 102, 0.45);
    border: none;
    outline: none;
    cursor: pointer;
    position: relative;
    transition: all 0.3s ease;
}

.wa-launcher-btn:hover {
    box-shadow: 0 10px 30px rgba(37, 211, 102, 0.65);
}

.wa-launcher-btn i {
    transition: transform 0.3s ease;
}

.wa-widget-launcher.is-open .wa-launcher-btn {
    background: #4B5563;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
    transform: rotate(90deg);
}

/* Badge de notificação */
.wa-launcher-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    background: #E53E3E;
    color: #FFFFFF;
    font-size: 0.72rem;
    font-weight: 700;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #FFFFFF;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    animation: wa-badge-pop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* ============ JANELA DE CHAT (CONTAINER) ============ */
.wa-chat-window {
    position: fixed;
    bottom: 104px;
    right: 30px;
    width: 375px;
    max-width: calc(100vw - 32px);
    height: 570px;
    max-height: calc(100vh - 125px);
    background: var(--wa-chat-bg);
    border-radius: 18px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom right;
    transition: all 0.32s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.wa-chat-window.is-active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* ============ CABEÇALHO (HEADER) ============ */
.wa-chat-header {
    background: linear-gradient(135deg, var(--wa-dark-green) 0%, var(--wa-teal) 100%);
    color: #FFFFFF;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
    position: relative;
    z-index: 2;
}

.wa-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.wa-avatar-wrap {
    position: relative;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

.wa-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--wa-dark-green);
    font-size: 1.3rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.wa-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.wa-status-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 11px;
    height: 11px;
    background: #25D366;
    border: 2px solid #FFFFFF;
    border-radius: 50%;
}

.wa-header-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.wa-header-title {
    font-size: 0.98rem;
    font-weight: 700;
    color: #FFFFFF;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wa-header-title .wa-badge-verified {
    color: #4ADE80;
    font-size: 0.8rem;
}

.wa-header-subtitle {
    font-size: 0.76rem;
    color: rgba(255, 255, 255, 0.88);
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.wa-header-subtitle .wa-online-pulse {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #4ADE80;
    display: inline-block;
    animation: wa-pulse-ring 1.8s infinite;
}

.wa-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.wa-header-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.85);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.95rem;
    transition: background 0.2s, color 0.2s;
}

.wa-header-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #FFFFFF;
}

/* ============ CORPO DE MENSAGENS (BODY) ============ */
.wa-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background-color: var(--wa-chat-bg);
    background-image: radial-gradient(rgba(0, 0, 0, 0.04) 1px, transparent 1px);
    background-size: 16px 16px;
    scroll-behavior: smooth;
}

/* Custom Scrollbar */
.wa-chat-body::-webkit-scrollbar {
    width: 5px;
}
.wa-chat-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.18);
    border-radius: 10px;
}

/* Data / Divisor */
.wa-date-divider {
    align-self: center;
    background: rgba(255, 255, 255, 0.85);
    color: var(--wa-gray-text);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 10px;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    margin: 4px 0 6px;
}

/* Alerta de Criptografia / Confiança */
.wa-crypto-badge {
    align-self: center;
    background: #FFEECD;
    color: #5E523A;
    font-size: 0.74rem;
    line-height: 1.35;
    text-align: center;
    padding: 8px 12px;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    margin-bottom: 6px;
    max-width: 94%;
    display: flex;
    align-items: center;
    gap: 6px;
}

.wa-crypto-badge i {
    color: #8C7443;
    font-size: 0.8rem;
    flex-shrink: 0;
}

/* ============ BALÕES DE MENSAGEM ============ */
.wa-msg {
    display: flex;
    flex-direction: column;
    max-width: 86%;
    animation: wa-msg-slide 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.wa-msg-bot {
    align-self: flex-start;
}

.wa-msg-user {
    align-self: flex-end;
}

.wa-bubble {
    padding: 9px 12px 6px;
    border-radius: 10px;
    font-size: 0.875rem;
    line-height: 1.4;
    position: relative;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
    word-break: break-word;
}

.wa-msg-bot .wa-bubble {
    background: var(--wa-bubble-white);
    color: var(--wa-dark-text);
    border-top-left-radius: 2px;
}

.wa-msg-user .wa-bubble {
    background: var(--wa-light-green);
    color: var(--wa-dark-text);
    border-top-right-radius: 2px;
}

.wa-bubble-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 3px;
    font-size: 0.68rem;
    color: var(--wa-gray-text);
    user-select: none;
}

.wa-bubble-footer .wa-checks {
    color: var(--wa-blue-check);
    font-size: 0.72rem;
    margin-left: 2px;
}

/* ============ BOTÕES DE SELEÇÃO DE DEPARTAMENTO ============ */
.wa-departments-grid {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-top: 6px;
    animation: wa-msg-slide 0.35s ease;
}

.wa-dept-btn {
    background: #FFFFFF;
    border: 1.5px solid #E2E8F0;
    border-radius: 10px;
    padding: 9px 12px;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
    font-family: inherit;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.wa-dept-btn:hover {
    border-color: var(--wa-green);
    background: #F0FDF4;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(37, 211, 102, 0.2);
}

.wa-dept-icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: #F3F4F6;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--wa-teal);
    font-size: 1rem;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.wa-dept-btn:hover .wa-dept-icon {
    background: var(--wa-green);
    color: #FFFFFF;
}

.wa-dept-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.wa-dept-title {
    font-size: 0.86rem;
    font-weight: 700;
    color: var(--wa-dark-text);
    margin: 0;
    line-height: 1.2;
}

.wa-dept-desc {
    font-size: 0.72rem;
    color: var(--wa-gray-text);
    margin-top: 2px;
    line-height: 1.2;
}

/* ============ DIGITANDO (TYPING INDICATOR) ============ */
.wa-typing-indicator {
    display: none;
    align-self: flex-start;
    background: #FFFFFF;
    padding: 10px 14px;
    border-radius: 12px;
    border-top-left-radius: 2px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
    align-items: center;
    gap: 4px;
}

.wa-typing-indicator.is-visible {
    display: inline-flex;
    animation: wa-msg-slide 0.2s ease;
}

.wa-typing-dot {
    width: 7px;
    height: 7px;
    background: #9CA3AF;
    border-radius: 50%;
    animation: wa-typing-bounce 1.4s infinite ease-in-out both;
}

.wa-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.wa-typing-dot:nth-child(2) { animation-delay: -0.16s; }

/* ============ REDIRECIONAMENTO / SUCESSO ============ */
.wa-redirect-card {
    background: #FFFFFF;
    border-radius: 12px;
    padding: 14px;
    border-top: 3px solid var(--wa-green);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: center;
    animation: wa-msg-slide 0.35s ease;
}

.wa-redirect-card h4 {
    margin: 0;
    font-size: 0.94rem;
    color: var(--wa-dark-text);
    font-weight: 700;
}

.wa-redirect-card p {
    margin: 0;
    font-size: 0.78rem;
    color: var(--wa-gray-text);
    line-height: 1.4;
}

.wa-btn-open-whatsapp {
    background: #25D366;
    color: #FFFFFF;
    border: none;
    padding: 11px 16px;
    border-radius: 25px;
    font-weight: 700;
    font-size: 0.88rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    text-decoration: none;
    box-shadow: 0 4px 14px rgba(37, 211, 102, 0.4);
    transition: all 0.2s ease;
}

.wa-btn-open-whatsapp:hover {
    background: #1EBE5D;
    color: #FFFFFF;
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(37, 211, 102, 0.55);
}

.wa-btn-restart {
    background: transparent;
    border: none;
    color: var(--wa-gray-text);
    font-size: 0.74rem;
    cursor: pointer;
    text-decoration: underline;
    padding: 4px;
}

.wa-btn-restart:hover {
    color: var(--wa-dark-text);
}

/* ============ ÁREA DE INPUT (FOOTER) ============ */
.wa-chat-footer {
    background: #F0F2F5;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
    position: relative;
}

.wa-chat-footer.is-disabled {
    opacity: 0.6;
    pointer-events: none;
}

.wa-input-wrap {
    flex: 1;
    position: relative;
}

.wa-input-field {
    width: 100%;
    background: #FFFFFF;
    border: 1px solid #E5E7EB;
    border-radius: 22px;
    padding: 10px 16px;
    font-size: 0.88rem;
    color: var(--wa-dark-text);
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.wa-input-field:focus {
    border-color: var(--wa-teal);
    box-shadow: 0 0 0 2px rgba(18, 140, 126, 0.15);
}

.wa-input-field.has-error {
    border-color: #EF4444;
    background: #FEF2F2;
}

.wa-error-tooltip {
    position: absolute;
    top: -34px;
    left: 10px;
    background: #EF4444;
    color: #FFFFFF;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    white-space: nowrap;
    display: none;
    animation: wa-msg-slide 0.2s ease;
    z-index: 10;
}

.wa-error-tooltip::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 16px;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid #EF4444;
}

.wa-error-tooltip.is-visible {
    display: block;
}

.wa-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--wa-teal);
    color: #FFFFFF;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.wa-send-btn:hover {
    background: var(--wa-dark-green);
    transform: scale(1.06);
}

/* ============ KEYFRAMES ============ */
@keyframes wa-msg-slide {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes wa-typing-bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

@keyframes wa-pulse-ring {
    0% {
        box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.7);
    }
    70% {
        box-shadow: 0 0 0 8px rgba(37, 211, 102, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(37, 211, 102, 0);
    }
}

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

@keyframes wa-badge-pop {
    0% {
        transform: scale(0);
    }
    80% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

/* ============ RESPONSIVIDADE (MOBILE) ============ */
@media (max-width: 480px) {
    .wa-widget-launcher {
        bottom: 20px;
        right: 18px;
    }

    .wa-launcher-prompt {
        display: none; /* Em telas muito pequenas, foca no botão circular */
    }

    .wa-launcher-btn {
        width: 56px;
        height: 56px;
        font-size: 1.8rem;
    }

    .wa-chat-window {
        bottom: 86px;
        right: 16px;
        left: 16px;
        width: auto;
        height: calc(100vh - 110px);
        max-height: 540px;
        border-radius: 16px;
    }
}
