/**
 * CSS do Chat Widget - Trafego e Cloud WhatsApp Chat
 * Botão flutuante + container do chat conversacional
 */

/* ===== RESET ===== */
.trafego-wa-floating-button,
.trafego-wa-floating-button *,
.trafego-wa-chat-container,
.trafego-wa-chat-container * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ===== BOTÃO FLUTUANTE ===== */
.trafego-wa-floating-button {
    position: fixed;
    z-index: 999998;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    animation: trfWASlideIn 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.trafego-wa-button-bottom-right {
    bottom: 20px;
    right: 20px;
}

.trafego-wa-button-bottom-left {
    bottom: 20px;
    left: 20px;
}

/* Botão principal */
#trafego-wa-floating-button .trafego-wa-btn-main {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    line-height: 1 !important;
    text-transform: none !important;
    text-decoration: none !important;
    border: none !important;
    border-radius: 50px !important;
    position: relative !important;
    overflow: hidden !important;
    cursor: pointer !important;
    padding: 20px !important;
    min-width: 60px !important;
    min-height: 60px !important;
    background-color: var(--button-bg-color, #25D366) !important;
    color: var(--button-icon-color, #FFFFFF) !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2) !important;
    transition: all 0.3s ease !important;
}

.trafego-wa-btn-main:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.25);
    filter: brightness(0.92);
}

.trafego-wa-btn-main:active {
    transform: translateY(-1px) scale(1.02);
}

.trafego-wa-icon {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    fill: currentColor;
}

/* Notification dot */
.trafego-wa-notification-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 12px;
    height: 12px;
    background: #ff4757;
    border: 2px solid white;
    border-radius: 50%;
    animation: trfWAPulse 2s infinite;
    display: none;
}

/* Tooltip */
.trafego-wa-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--button-bg-color, rgba(0, 0, 0, 0.8));
    color: var(--button-icon-color, #FFFFFF);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    margin-bottom: 10px;
    pointer-events: none;
}

.trafego-wa-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--button-bg-color, rgba(0, 0, 0, 0.8));
}

.trafego-wa-floating-button:hover .trafego-wa-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-5px);
}

/* Efeito ripple no clique */
.trafego-wa-btn-main::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: all 0.5s ease;
}

.trafego-wa-btn-main:active::before {
    width: 300px;
    height: 300px;
    animation: trfWARipple 0.6s ease-out;
}

/* ===== CHAT CONTAINER ===== */
.trafego-wa-chat-container {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 360px;
    max-width: calc(100vw - 24px);
    height: 500px;
    max-height: calc(100vh - 110px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
    z-index: 999997;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    animation: trfWAChatSlideUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.trafego-wa-chat-container.trf-wa-open {
    display: flex;
}

/* Chat posicionado à esquerda (quando botão está no canto esquerdo) */
.trafego-wa-position-bottom-left .trafego-wa-chat-container,
body.trafego-wa-position-bottom-left .trafego-wa-chat-container {
    right: auto;
    left: 20px;
}

/* ===== HEADER DO CHAT ===== */
.trafego-wa-chat-header {
    background: var(--chat-header-bg, #128C7E);
    background-image: linear-gradient(135deg, var(--chat-header-bg, #128C7E) 0%, #25D366 100%);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    color: #fff;
}

.trafego-wa-chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.trafego-wa-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
    overflow: hidden;
}

/* Foto do atendente */
.trafego-wa-avatar-img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.trafego-wa-chat-header-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.trafego-wa-chat-header-text strong {
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
}

/* Status base */
.trafego-wa-online-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.85);
}

.trafego-wa-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
}

/* Online */
.trafego-wa-status-online .trafego-wa-status-dot {
    background: #9effa0;
    box-shadow: 0 0 0 2px rgba(158, 255, 160, 0.35);
    animation: trfWAPulse 2s ease-in-out infinite;
}

/* Offline / Indisponível */
.trafego-wa-status-offline {
    color: rgba(255, 255, 255, 0.6);
}

.trafego-wa-status-offline .trafego-wa-status-dot {
    background: rgba(255, 255, 255, 0.4);
}

@keyframes trfWAPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(158, 255, 160, 0.5); }
    50%       { box-shadow: 0 0 0 4px rgba(158, 255, 160, 0); }
}

.trafego-wa-chat-close {
    background: rgba(255, 255, 255, 0.2) !important;
    border: none !important;
    color: #fff !important;
    cursor: pointer !important;
    border-radius: 8px !important;
    padding: 6px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background 0.2s !important;
    flex-shrink: 0;
}

.trafego-wa-chat-close:hover {
    background: rgba(255, 255, 255, 0.35) !important;
}

/* ===== BODY (mensagens) ===== */
.trafego-wa-chat-body {
    flex: 1;
    overflow-y: auto;
    background: #f0f2f5;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scroll-behavior: smooth;
}

/* Scrollbar suave */
.trafego-wa-chat-body::-webkit-scrollbar {
    width: 4px;
}
.trafego-wa-chat-body::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}

/* ===== BOLHAS DE MENSAGENS ===== */
.trf-wa-bubble {
    max-width: 82%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.45;
    word-break: break-word;
    position: relative;
    animation: trfWABubbleIn 0.25s ease;
}

.trf-wa-bubble-bot {
    background: #fff;
    color: #1a1a1a;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.trf-wa-bubble-user {
    background: #dcf8c6;
    color: #1a1a1a;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* ===== TYPING INDICATOR ===== */
.trf-wa-typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 10px 14px;
    background: #fff;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    animation: trfWABubbleIn 0.25s ease;
}

.trf-wa-typing span {
    width: 7px;
    height: 7px;
    background: #aaa;
    border-radius: 50%;
    animation: trfWATyping 1.4s infinite ease-in-out;
}

.trf-wa-typing span:nth-child(1) { animation-delay: 0s; }
.trf-wa-typing span:nth-child(2) { animation-delay: 0.2s; }
.trf-wa-typing span:nth-child(3) { animation-delay: 0.4s; }

/* ===== FOOTER (input) ===== */
.trafego-wa-chat-footer {
    background: #f0f2f5;
    border-top: 1px solid #e5e7eb;
    padding: 10px 12px;
    flex-shrink: 0;
}

.trafego-wa-input-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* DDI select — inline, compacto */
.trafego-wa-ddi-wrapper {
    flex-shrink: 0;
}

.trafego-wa-ddi-select {
    width: 100%;
    padding: 10px;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    background: #fff;
    font-size: 13px;
    color: #374151;
    cursor: pointer;
    outline: none;
}

.trafego-wa-ddi-select:focus {
    border-color: #25D366;
    box-shadow: 0 0 0 2px rgba(37,211,102,0.2);
}

.trafego-wa-chat-input {
    flex: 1;
    padding: 9px 14px;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    background: #fff;
    font-size: 14px;
    color: #1a1a1a;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
}

.trafego-wa-chat-input::placeholder {
    color: #9ca3af;
}

.trafego-wa-chat-input:focus {
    border-color: #25D366;
    box-shadow: 0 0 0 2px rgba(37,211,102,0.2);
}

.trafego-wa-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: #25D366;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.15s;
}

.trafego-wa-send-btn:hover {
    background: #20c55e;
    transform: scale(1.08);
}

.trafego-wa-send-btn:active {
    transform: scale(0.95);
}

.trafego-wa-send-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
}

/* Honeypot oculto */
.trf-wa-hp-field {
    display: none !important;
    visibility: hidden !important;
    position: absolute !important;
    left: -9999px !important;
    height: 0 !important;
    overflow: hidden !important;
}

/* ===== ANIMAÇÕES ===== */
@keyframes trfWASlideIn {
    0%   { opacity: 0; transform: translateY(100px) scale(0.3); }
    50%  { opacity: 0.8; transform: translateY(-10px) scale(1.1); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes trfWAChatSlideUp {
    0%   { opacity: 0; transform: translateY(30px) scale(0.95); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes trfWABubbleIn {
    0%   { opacity: 0; transform: translateY(6px); }
    100% { opacity: 1; transform: translateY(0); }
}

@keyframes trfWAPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50%       { transform: scale(1.2); opacity: 0.7; }
}

@keyframes trfWARipple {
    0%   { transform: scale(0); opacity: 1; }
    100% { transform: scale(4); opacity: 0; }
}

@keyframes trfWATyping {
    0%, 60%, 100% { transform: translateY(0); }
    30%            { transform: translateY(-6px); }
}

/* ===== RESPONSIVO ===== */
@media (max-width: 768px) {
    .trafego-wa-floating-button {
        bottom: 15px;
    }
    .trafego-wa-button-bottom-right { right: 15px; }
    .trafego-wa-button-bottom-left  { left: 15px; }

    .trafego-wa-btn-main {
        border-radius: 50% !important;
        width: 56px !important;
        height: 56px !important;
        padding: 14px !important;
    }
    .trafego-wa-btn-text { display: none !important; }
    .trafego-wa-icon { width: 24px; height: 24px; }

    .trafego-wa-chat-container {
        bottom: 80px;
        right: 10px;
        left: 10px;
        width: auto;
        max-width: none;
        height: auto;
        max-height: 70vh;
        border-radius: 14px;
    }

    body.trafego-wa-position-bottom-left .trafego-wa-chat-container {
        left: 10px;
        right: 10px;
    }
}

@media (max-width: 480px) {
    .trafego-wa-floating-button { bottom: 12px; }
    .trafego-wa-button-bottom-right { right: 12px; }
    .trafego-wa-button-bottom-left  { left: 12px; }

    .trafego-wa-btn-main {
        width: 52px !important;
        height: 52px !important;
        padding: 12px !important;
    }
    .trafego-wa-icon { width: 22px; height: 22px; }

    .trafego-wa-chat-container {
        bottom: 74px;
    }
}

/* ===== ACESSIBILIDADE ===== */
.trafego-wa-btn-main:focus-visible {
    outline: 3px solid rgba(37, 211, 102, 0.6);
    outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
    .trafego-wa-floating-button,
    .trafego-wa-chat-container,
    .trf-wa-bubble,
    .trf-wa-typing { animation: none !important; }

    .trafego-wa-btn-main:hover { transform: none; }
}

@media (prefers-contrast: high) {
    .trafego-wa-btn-main {
        border: 2px solid white;
        box-shadow: 0 4px 8px rgba(0,0,0,0.5);
    }
}

/* ===================================================
   FORMULÁRIO DE CONTATO — [trafego_wa_form]
   =================================================== */

.trf-wa-contact-form-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.trf-wa-form-align-center { text-align: center; }
.trf-wa-form-align-right  { text-align: right; }
.trf-wa-form-align-left   { text-align: left; }

.trf-wa-contact-form {
    background: var(--trf-form-bg, #fff);
    border-radius: 12px;
    padding: 28px 32px;
    max-width: 560px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.07);
    text-align: left;
}

.trf-wa-form-align-center .trf-wa-contact-form,
.trf-wa-form-align-right  .trf-wa-contact-form {
    margin: 0 auto;
}

.trf-wa-form-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--trf-form-title, #111827);
    margin: 0 0 8px 0 !important;
    padding: 0 !important;
    border: none !important;
}

.trf-wa-form-description {
    margin: 0 0 20px 0 !important;
    padding: 0 !important;
    color: #6b7280;
    font-size: 14px;
    line-height: 1.55;
    border: none !important;
}

/* Quando há título + descrição, o espaço vem da descrição */
.trf-wa-form-title:last-of-type:not(:has(+ .trf-wa-form-description)) {
    margin-bottom: 20px !important;
}

/* Campos */
.trf-wa-form-field {
    margin-bottom: 16px;
}

.trf-wa-form-field label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--trf-form-label, #374151);
    margin-bottom: 6px;
}

.trf-wa-required {
    color: #ef4444;
    margin-left: 2px;
}

.trf-wa-optional {
    font-weight: 400;
    color: #9ca3af;
    font-size: 13px;
}

.trf-wa-form-input {
    display: block;
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    color: #1a1a1a;
    background: var(--trf-form-field-bg, #fff);
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.trf-wa-form-input::placeholder {
    color: var(--trf-form-placeholder, #9ca3af);
}

.trf-wa-form-input:focus {
    border-color: #25D366;
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.15);
}

.trf-wa-form-input.trf-wa-field-error {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

.trf-wa-form-textarea {
    resize: vertical;
    min-height: 100px;
    line-height: 1.5;
}

/* Linha DDI + Telefone */
.trf-wa-form-phone-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.trf-wa-form-ddi {
    flex-shrink: 0;
    width: auto;
    min-width: 90px;
    padding: 10px 8px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: var(--trf-form-field-bg, #fff);
    font-size: 14px;
    color: #374151;
    cursor: pointer;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
}

.trf-wa-form-ddi:focus {
    border-color: #25D366;
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.15);
}

.trf-wa-form-phone-row .trf-wa-form-input {
    flex: 1;
}

/* Botão de envio */
.trf-wa-form-submit-row {
    margin-top: 20px;
}

.trf-wa-form-submit {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.15s;
    text-decoration: none;
}

.trf-wa-form-submit:hover:not(:disabled) {
    opacity: 0.88;
    transform: translateY(-1px);
}

.trf-wa-form-submit:active:not(:disabled) {
    transform: translateY(0);
}

.trf-wa-form-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Feedback de sucesso/erro */
.trf-wa-form-feedback {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    display: none;
}

.trf-wa-form-feedback.trf-wa-feedback-success {
    display: block;
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}

.trf-wa-form-feedback.trf-wa-feedback-error {
    display: block;
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

/* Select de tipo de serviço */
.trf-wa-form-select {
    cursor: pointer;
    appearance: auto;
    -webkit-appearance: auto;
}

/* Fix: placeholder color em <select> (quando nenhuma opção real está selecionada) */
.trf-wa-form-select:required:invalid,
.trf-wa-form-select option[value=""] {
    color: var(--trf-form-placeholder, #9ca3af);
}

.trf-wa-form-select option:not([value=""]) {
    color: #1a1a1a;
}

/* Layout 2 colunas */
.trf-wa-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.trf-wa-form-row .trf-wa-form-field {
    margin-bottom: 0;
}

/* Responsivo */
@media (max-width: 540px) {
    .trf-wa-contact-form {
        padding: 20px 16px;
    }

    .trf-wa-form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .trf-wa-form-row .trf-wa-form-field {
        margin-bottom: 16px;
    }

    .trf-wa-form-phone-row {
        flex-direction: column;
        align-items: stretch;
    }

    .trf-wa-form-ddi {
        width: 100%;
    }
}

/* ===================================================
   CHIPS DE SERVIÇO — chat widget
   =================================================== */

.trf-wa-service-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 2px 0 8px 4px;
}

.trf-wa-service-chip {
    background: #ffffff;
    border: 1.5px solid #25D366;
    color: #128C7E;
    border-radius: 20px;
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    line-height: 1.4;
    transition: background 0.15s, color 0.15s, transform 0.1s;
}

.trf-wa-service-chip:hover,
.trf-wa-service-chip:focus {
    background: #25D366;
    color: #ffffff;
    transform: translateY(-1px);
    outline: none;
}
