/* ===========================================
   CONSULTOR DIGITAL - PABLO MACIEL
   Premium Floating Chat Widget (Glassmorphism)
   Cross-browser: Chrome, Firefox, Safari, Edge
   =========================================== */

#consultor-chat-widget {
    position: fixed;
    bottom: calc(30px + env(safe-area-inset-bottom, 0px));
    right: 30px;
    z-index: 1100;
    font-family: 'Manrope', sans-serif;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    -webkit-box-align: end;
    -ms-flex-align: end;
    align-items: flex-end;
    /* Essencial: não bloqueia cliques fora do widget (ex: botão WhatsApp) */
    pointer-events: none;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== BOTÃO TOGGLE (SEMPRE CLICÁVEL) ===== */
.chat-toggle-btn {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: var(--primary-navy);
    border: 1.5px solid var(--accent-gold);
    color: var(--accent-gold);
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 10px 40px rgba(16, 35, 59, 0.4);
    -webkit-transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    position: relative;
    z-index: 10001;
    overflow: hidden;
    /* Restaura cliques neste elemento */
    pointer-events: auto;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.chat-toggle-btn:hover {
    -webkit-transform: scale(1.1) rotate(5deg);
    transform: scale(1.1) rotate(5deg);
    background: var(--primary-navy-deep);
    box-shadow: 0 15px 50px rgba(198, 161, 91, 0.35);
}

.chat-icon-container {
    width: 100%;
    height: 100%;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
}

.chat-toggle-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    border: 2px solid #D4AF37;
    background-color: #001529;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    -webkit-transition: -webkit-transform 0.4s ease;
    transition: transform 0.4s ease;
}

.chat-toggle-btn:hover .chat-toggle-img {
    -webkit-transform: scale(1.08);
    transform: scale(1.08);
}

/* ===== BADGE DE NOTIFICAÇÃO — ELEGANTE ===== */
.chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    background: #e74c3c;
    color: white;
    font-size: 11px;
    font-weight: 800;
    font-family: 'Manrope', sans-serif;
    border-radius: 9px;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    border: 2px solid #fff;
    line-height: 1;
    letter-spacing: -0.3px;
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.45);
    -webkit-animation: pulseBadge 2.5s ease-in-out infinite;
    animation: pulseBadge 2.5s ease-in-out infinite;
    pointer-events: none;
}

@-webkit-keyframes pulseBadge {
    0%, 100% { -webkit-transform: scale(1); transform: scale(1); box-shadow: 0 2px 8px rgba(231, 76, 60, 0.45); }
    50%       { -webkit-transform: scale(1.15); transform: scale(1.15); box-shadow: 0 4px 14px rgba(231, 76, 60, 0.6); }
}
@keyframes pulseBadge {
    0%, 100% { -webkit-transform: scale(1); transform: scale(1); box-shadow: 0 2px 8px rgba(231, 76, 60, 0.45); }
    50%       { -webkit-transform: scale(1.15); transform: scale(1.15); box-shadow: 0 4px 14px rgba(231, 76, 60, 0.6); }
}

/* ===== JANELA DO CHAT ===== */
.chat-window {
    width: 380px;
    height: 580px;
    max-height: calc(100vh - 120px);
    background: rgba(11, 27, 46, 0.97);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(198, 161, 91, 0.3);
    border-radius: 20px;
    overflow: hidden;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6);
    margin-bottom: 16px;
    -webkit-transform: translateY(20px) scale(0.97);
    transform: translateY(20px) scale(0.97);
    opacity: 0;
    visibility: hidden;
    -webkit-transition: opacity 0.4s cubic-bezier(0.165, 0.84, 0.44, 1),
                        -webkit-transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1),
                        visibility 0.4s;
    transition: opacity 0.4s cubic-bezier(0.165, 0.84, 0.44, 1),
                transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1),
                visibility 0.4s;
    position: relative;
    z-index: 1101;
    /* Restaura cliques quando visível */
    pointer-events: none;
}

.chat-window.active {
    -webkit-transform: translateY(0) scale(1);
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Vídeo de fundo */
.chat-bg-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.12;
    z-index: 0;
    pointer-events: none;
    mix-blend-mode: luminosity;
}

/* ===== CABEÇALHO ===== */
.chat-header {
    padding: 30px 20px 20px;
    background: -webkit-linear-gradient(top, #0B1B2E 40%, transparent);
    background: linear-gradient(to bottom, #0B1B2E 40%, transparent);
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    text-align: center;
    position: relative;
    z-index: 10;
}

.chat-header-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2px solid #D4AF37;
    background-color: #001529;
    box-shadow: 0 8px 20px rgba(0,0,0,0.4);
    object-fit: cover;
    -ms-flex-negative: 0;
    flex-shrink: 0;
    margin-bottom: 12px;
}

.chat-header-info {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
}

.chat-header-title {
    color: #fff;
    font-size: 1.1rem;
    font-weight: 800;
    margin: 0 0 5px 0;
    letter-spacing: 0.5px;
}

.chat-header-status {
    color: var(--accent-gold);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    gap: 8px;
}

.chat-header-status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #27ae60;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 10px #27ae60;
    -webkit-animation: statusPulse 2s ease-in-out infinite;
    animation: statusPulse 2s ease-in-out infinite;
}

@-webkit-keyframes statusPulse {
    0%, 100% { box-shadow: 0 0 6px #27ae60; }
    50%       { box-shadow: 0 0 14px #27ae60; }
}
@keyframes statusPulse {
    0%, 100% { box-shadow: 0 0 6px #27ae60; }
    50%       { box-shadow: 0 0 14px #27ae60; }
}

/* ===== HERO AVATAR (intro destaque) ===== */
.chat-hero-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    margin: 10px auto 20px auto;
    border: 3px solid var(--accent-gold);
    box-shadow: 0 0 25px rgba(198, 161, 91, 0.5), 0 10px 30px rgba(0,0,0,0.3);
    position: relative;
    z-index: 1;
    display: block;
    object-fit: cover;
    background: #FFFFFF;
    -webkit-animation: slideDownHero 0.8s cubic-bezier(0.165, 0.84, 0.44, 1);
    animation: slideDownHero 0.8s cubic-bezier(0.165, 0.84, 0.44, 1);
}

@-webkit-keyframes slideDownHero {
    from { opacity: 0; -webkit-transform: translateY(-30px) scale(0.9); transform: translateY(-30px) scale(0.9); }
    to   { opacity: 1; -webkit-transform: translateY(0) scale(1); transform: translateY(0) scale(1); }
}
@keyframes slideDownHero {
    from { opacity: 0; transform: translateY(-30px) scale(0.9); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== CORPO DO CHAT ===== */
.chat-body {
    -webkit-box-flex: 1;
    -ms-flex-positive: 1;
    flex-grow: 1;
    padding: 20px 15px;
    overflow-y: auto;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    gap: 15px;
    scroll-behavior: smooth;
    position: relative;
    z-index: 10;
}

.chat-body::-webkit-scrollbar { width: 4px; }
.chat-body::-webkit-scrollbar-track { background: rgba(255,255,255,0.05); }
.chat-body::-webkit-scrollbar-thumb { background: var(--accent-gold); border-radius: 10px; }
/* Firefox */
.chat-body { scrollbar-width: thin; scrollbar-color: var(--accent-gold) rgba(255,255,255,0.05); }

/* ===== BUBBLES ===== */
.chat-bubble {
    max-width: 85%;
    padding: 14px 18px;
    border-radius: 15px;
    font-size: 14px;
    line-height: 1.6;
    position: relative;
    word-wrap: break-word;
    word-break: break-word;
}

.chat-bubble-ai {
    -ms-flex-item-align: start;
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.1);
    color: #FFFFFF;
    border-bottom-left-radius: 3px;
    border-left: 3px solid var(--accent-gold);
}

.chat-bubble-user {
    -ms-flex-item-align: end;
    align-self: flex-end;
    background: var(--accent-gold);
    color: var(--primary-navy-deep);
    font-weight: 600;
    border-bottom-right-radius: 3px;
}

/* ===== BOTÕES DE OPÇÃO ===== */
.chat-options {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    gap: 10px;
    margin-top: 5px;
    -webkit-animation: fadeIn 0.5s ease forwards;
    animation: fadeIn 0.5s ease forwards;
}

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

.chat-option-btn {
    background: rgba(198, 161, 91, 0.1);
    border: 1.5px solid var(--accent-gold);
    color: #FFFFFF;
    padding: 12px 15px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    cursor: pointer;
    -webkit-transition: all 0.3s ease;
    transition: all 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

.chat-option-btn:hover,
.chat-option-btn:focus {
    background: var(--accent-gold);
    color: var(--primary-navy-deep);
    -webkit-transform: translateX(5px);
    transform: translateX(5px);
    outline: none;
}

/* ===== FORMULÁRIO ===== */
.chat-form {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    gap: 12px;
    margin-top: 10px;
}

.chat-input-group {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    gap: 5px;
}

.chat-input-group label {
    font-size: 11px;
    color: var(--accent-gold);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chat-field {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(198, 161, 91, 0.3);
    padding: 12px;
    border-radius: 6px;
    color: white;
    font-size: 14px;
    outline: none;
    -webkit-transition: border-color 0.3s;
    transition: border-color 0.3s;
    /* Firefox fix */
    -moz-appearance: none;
    appearance: none;
}

.chat-field:focus {
    border-color: var(--accent-gold);
    background: rgba(255,255,255,0.09);
}

.chat-field::-webkit-input-placeholder { color: rgba(255,255,255,0.35); }
.chat-field::-moz-placeholder           { color: rgba(255,255,255,0.35); opacity: 1; }
.chat-field:-ms-input-placeholder       { color: rgba(255,255,255,0.35); }
.chat-field::placeholder                { color: rgba(255,255,255,0.35); }

.chat-submit-btn {
    background: var(--accent-gold);
    color: var(--primary-navy-deep);
    border: none;
    padding: 15px;
    border-radius: 8px;
    font-weight: 800;
    font-size: 14px;
    cursor: pointer;
    margin-top: 10px;
    -webkit-transition: all 0.3s ease;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    -webkit-tap-highlight-color: transparent;
}

.chat-submit-btn:hover,
.chat-submit-btn:focus {
    -webkit-transform: translateY(-2px);
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(198, 161, 91, 0.45);
    outline: none;
}

/* ===== RODAPÉ / INPUT ===== */
.chat-footer {
    padding: 15px 20px 25px;
    background: rgba(16, 35, 59, 0.55);
    border-top: 1px solid rgba(198, 161, 91, 0.2);
    position: relative;
    z-index: 10;
}

.chat-input-container {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    background: rgba(255,255,255,0.08);
    border-radius: 30px;
    padding: 5px 15px;
    border: 1px solid rgba(255,255,255,0.1);
}

.chat-input-container input {
    -webkit-box-flex: 1;
    -ms-flex-positive: 1;
    flex-grow: 1;
    background: transparent;
    border: none;
    padding: 10px;
    color: white;
    font-size: 14px;
    outline: none;
    /* Firefox */
    -moz-appearance: none;
    appearance: none;
}

.chat-input-container input::-webkit-input-placeholder { color: rgba(255,255,255,0.4); }
.chat-input-container input::-moz-placeholder           { color: rgba(255,255,255,0.4); opacity: 1; }
.chat-input-container input:-ms-input-placeholder       { color: rgba(255,255,255,0.4); }
.chat-input-container input::placeholder                { color: rgba(255,255,255,0.4); }

.chat-send-btn {
    background: transparent;
    border: none;
    color: var(--accent-gold);
    cursor: pointer;
    padding: 5px;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    -webkit-transition: -webkit-transform 0.2s;
    transition: transform 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.chat-send-btn:hover,
.chat-send-btn:focus {
    -webkit-transform: scale(1.2) translateX(2px);
    transform: scale(1.2) translateX(2px);
    outline: none;
}

/* ===== TYPING INDICATOR ===== */
.typing-indicator {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    gap: 5px;
    padding: 12px 16px;
    background: rgba(255,255,255,0.06);
    border-radius: 12px;
    width: -webkit-fit-content;
    width: -moz-fit-content;
    width: fit-content;
    -ms-flex-item-align: start;
    align-self: flex-start;
    border-left: 3px solid var(--accent-gold);
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--accent-gold);
    border-radius: 50%;
    opacity: 0.4;
    -webkit-animation: typing 1.5s infinite ease-in-out;
    animation: typing 1.5s infinite ease-in-out;
}

.typing-dot:nth-child(2) { -webkit-animation-delay: 0.2s; animation-delay: 0.2s; }
.typing-dot:nth-child(3) { -webkit-animation-delay: 0.4s; animation-delay: 0.4s; }

@-webkit-keyframes typing {
    0%, 100% { -webkit-transform: translateY(0); transform: translateY(0); opacity: 0.4; }
    50%       { -webkit-transform: translateY(-5px); transform: translateY(-5px); opacity: 1; }
}
@keyframes typing {
    0%, 100% { transform: translateY(0); opacity: 0.4; }
    50%       { transform: translateY(-5px); opacity: 1; }
}

/* ===== RESPONSIVO ===== */
@media (max-width: 480px) {
    #consultor-chat-widget {
        bottom: calc(20px + env(safe-area-inset-bottom, 0px));
        right: 20px;
    }
    .chat-window {
        width: calc(100vw - 40px);
        height: -webkit-min(580px, calc(100vh - 110px));
        height: min(580px, calc(100vh - 110px));
        border-radius: 16px;
    }
    .chat-toggle-btn {
        width: 58px;
        height: 58px;
    }
    .chat-header {
        padding: 20px 16px 14px;
    }
    .chat-header-avatar {
        width: 50px;
        height: 50px;
    }
    .chat-header-title {
        font-size: 0.95rem;
    }
}

@media (max-width: 360px) {
    .chat-window {
        width: calc(100vw - 24px);
    }
    #consultor-chat-widget {
        right: 12px;
    }
}
