/**
 * ═══════════════════════════════════════════════════════════════════════════════
 * Widget CSS - Chatbot RAG SINTRACON v2.0 (Fiel ao Mockup)
 * ═══════════════════════════════════════════════════════════════════════════════
 */

:root {
    --chat-blue: #224187;
    --chat-blue-light: #2d56a8;
    --chat-yellow: #ffda01;
    --chat-grey-bg: #e2e8f0;
    --chat-text-dark: #1e293b;
    --chat-text-light: #ffffff;
    --chat-bubble-bot: #d1d5db;
    --chat-bubble-user: #224187;
    --chat-green: #22c55e;
    --chat-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    --chat-radius: 20px;

    /* Typography Defaults */
    --chat-font-family: 'Inter', sans-serif;
    --chat-font-size: 15px;
    --chat-font-weight: 400;
    --chat-line-height: 1.4;
}

/* ============================================================================
   Toggle Button & Initial Bubble
   ============================================================================ */
.sintracon-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 10000;
    font-family: var(--chat-font-family);
}

/* ============================================================================
   Toggle Button & Initial Bubble (Novo Design de Animação)
   ============================================================================ */
.widget-launcher {
    position: relative;
    display: flex;
    align-items: center;
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    outline: none;

    /* Configurações de Tamanho Base */
    width: 18rem;
    /* Largura expandida inicial */
    height: 4.5rem;

    will-change: width;
    transition: width 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* --- CAMADA 1: AVATAR (Deslize) --- */
.avatar-layer {
    position: absolute;
    left: 0;
    top: 0;
    width: 4.5rem;
    height: 4.5rem;
    background: transparent;
    /* sem border-radius/overflow: o mascote pode ter elementos (ex: balaozinho) que extrapolam o circulo */
    overflow: visible;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;

    /* Estado Inicial: Deslizado para a esquerda para acompanhar a barra aberta */
    transform: translateX(-1.2rem) scale(1.1);

    will-change: transform;
    transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.avatar-img {
    width: 100%;
    height: 100%;
    /* Sem border-radius e usando contain: a propria imagem ja desenha o circulo
       (PNG transparente ou SVG inline). Permite que elementos como um balaozinho
       de fala extrapolem o circulo sem serem cortados. */
    object-fit: contain;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
}

/* Dot vermelho no launcher quando ha conversa ativa em background
   (ex: usuario navegou para outra pagina ou recarregou — historico persistido). */
.widget-launcher.has-active-chat .avatar-layer::after {
    content: '';
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ef4444;
    border: 2px solid #ffffff;
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6);
    animation: chatDotPulse 1.8s ease-in-out infinite;
    z-index: 11;
}

@keyframes chatDotPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); }
    50%      { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

/* --- CAMADA 2: BARRA DE TEXTO (Expansão) --- */
.content-layer {
    position: absolute;
    left: 2.2rem;
    /* Ponto de ancoragem */
    top: 50%;
    transform: translateY(-50%);

    height: 3.5rem;
    background: #ffffff;
    border-top-right-radius: 3rem;
    border-bottom-right-radius: 3rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    z-index: 1;
    overflow: hidden;

    /* Estado Inicial: Aberta */
    width: 14.5rem;
    /* Aumentado de 13.5rem para caber o chevron */
    opacity: 1;

    will-change: width, opacity;
    transition: width 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94),
        opacity 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);

    display: flex;
    align-items: center;
    padding-left: 2.5rem;
    /* Reduzido de 2.8rem para aproximar o texto ainda mais do ícone */
    white-space: nowrap;
}

.text-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin-right: 1.5rem;
    text-align: left;
    transition: opacity 0.3s ease-in;
    opacity: 1;
}

.text-group .title {
    font-weight: 700;
    color: #0b3d91;
    font-size: 1rem;
    line-height: 1.1;
}

.text-group .subtitle {
    font-weight: 400;
    color: #64748b;
    font-size: 0.75rem;
}

.icon-arrow {
    width: 0.6rem;
    height: 0.6rem;
    border-top: 2px solid #0b3d91;
    border-right: 2px solid #0b3d91;
    transform: rotate(45deg);
    margin-right: 1.5rem;
    opacity: 1;
    transition: opacity 0.3s ease-in;
    margin-left: auto;
}

/* ============================================================================
   ESTADOS DE ANIMAÇÃO (Hover e Auto-Collapse)
   ============================================================================ */

/* 1. Estado Recolhido (JS adiciona .collapsed após 10s) */
.widget-launcher.collapsed {
    width: 4.5rem;
}

.widget-launcher.collapsed .avatar-layer {
    transform: translateX(0) scale(1);
    animation: wiggle 4s ease-in-out infinite;
    /* Mantém a tremidinha charmosa */
}

.widget-launcher.collapsed .content-layer {
    width: 0;
    opacity: 0;
}

.widget-launcher.collapsed .text-group,
.widget-launcher.collapsed .icon-arrow {
    opacity: 0;
}

/* 2. Hover (Expande novamente) */
.widget-launcher:hover {
    width: 18rem;
}

.widget-launcher:hover .avatar-layer {
    transform: translateX(-1.2rem) scale(1.1);
    animation: none;
}

.widget-launcher:hover .content-layer {
    width: 14.5rem;
    opacity: 1;
}

.widget-launcher:hover .text-group,
.widget-launcher:hover .icon-arrow {
    opacity: 1;
    transition-delay: 0.1s;
}

@keyframes wiggle {

    0%,
    90%,
    100% {
        transform: rotate(0deg);
    }

    92% {
        transform: rotate(-8deg);
    }

    94% {
        transform: rotate(6deg);
    }

    96% {
        transform: rotate(-4deg);
    }

    98% {
        transform: rotate(2deg);
    }
}

/* ============================================================================
   Chat Window
   ============================================================================ */
.widget-window {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 410px;
    height: calc(100vh - 60px);
    max-height: calc(100vh - 60px);
    background: #f1f5f9;
    border-radius: var(--chat-radius);
    box-shadow: var(--chat-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    /* Estado fechado: fora da tela, à direita */
    transform: translateX(calc(100% + 60px));
    transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1),
                opacity   0.3s ease,
                visibility 0s linear 0.45s;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.widget-window.open {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
    transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1),
                opacity   0.3s ease,
                visibility 0s linear 0s;
}

.widget-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 30px;
    height: 30px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* Welcome / Pre-chat Screen */
.screen-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 15px 10px;
    text-align: center;
    background: white;
}

.welcome-media {
    width: 280px;
    height: 350px;
    border-radius: 20px;
    background: #ffffff;
    margin-bottom: 15px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.welcome-media video,
.welcome-media img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.welcome-text {
    width: 280px;
    font-size: var(--chat-font-size);
    color: var(--chat-text-dark);
    margin-bottom: 15px;
    line-height: var(--chat-line-height);
    font-weight: var(--chat-font-weight);
}

.btn-start {
    width: 280px;
    background: var(--chat-blue);
    color: white;
    border: none;
    padding: 15px 0;
    border-radius: 30px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    transition: all 0.3s ease;
    text-transform: uppercase;
}

.btn-start:disabled {
    background: #94a3b8;
    cursor: not-allowed;
    opacity: 0.7;
}

.btn-start .btn-icon {
    background: rgba(255, 255, 255, 0.2);
    width: 35px;
    height: 35px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Chat Screen */
.screen-chat {
    display: none;
    flex-direction: column;
    height: 100%;
}

.chat-header-img {
    width: calc(100% - 40px);
    height: 200px;
    margin: 20px auto 10px;
    background: transparent;
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
    border: none;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-header-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: opacity 0.5s ease;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: #f1f5f9;
    scrollbar-color: var(--chat-blue) transparent;
    scrollbar-width: thin;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--chat-blue);
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--chat-blue-light);
}

.msg {
    max-width: 85%;
    padding: 12px 18px;
    border-radius: 20px;
    font-size: var(--chat-font-size);
    line-height: var(--chat-line-height);
    font-weight: var(--chat-font-weight);
    position: relative;
    word-wrap: break-word;
}

.msg-info {
    font-size: 11px;
    color: #94a3b8;
}

.msg-text {
    /* container do texto da mensagem (separado do footer com replay+horario) */
}

.msg-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 6px;
}

.msg-user .msg-info {
    color: rgba(255, 218, 1, 0.65);
}

.msg-sources {
    display: none;
}

/* Card de redirecionamento para atendimento humano (suporte) */
.support-card {
    background: linear-gradient(135deg, var(--chat-blue) 0%, #1a3268 100%) !important;
    color: #fff !important;
    font-weight: 600 !important;
    align-self: stretch !important;
    max-width: 100% !important;
    border-top-left-radius: 16px !important;
}

.support-card-header {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--chat-yellow);
    line-height: 1.3;
}

.support-card-btns {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.support-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.95);
    color: var(--chat-blue);
    text-decoration: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 13px;
    transition: transform 0.15s, background 0.15s;
}

.support-btn:hover {
    background: var(--chat-yellow);
    transform: translateX(2px);
}

.support-btn i {
    font-size: 16px;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

/* Link inline para a página da fonte (top similarity) — aparece dentro do balão do bot */
.msg-page-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 6px 10px;
    background: rgba(34, 65, 135, 0.12);
    color: var(--chat-blue);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 10px;
    border: 1px solid rgba(34, 65, 135, 0.25);
    transition: background 0.15s, transform 0.15s;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.msg-page-link:hover {
    background: rgba(34, 65, 135, 0.22);
    transform: translateY(-1px);
}

.msg-page-link i {
    font-size: 11px;
    flex-shrink: 0;
}

.msg-sources i {
    margin-right: 4px;
    opacity: 0.7;
}

.msg-source-link {
    color: #2563eb;
    text-decoration: none;
    border-bottom: 1px dotted #2563eb;
}
.msg-source-link:hover {
    text-decoration: underline;
}
.msg-source-link i {
    font-size: 9px;
    margin-left: 2px;
    opacity: 0.6;
}

/* ── Avatar: animações CSS fallback (quando não há vídeo configurado) ──── */
/* Aplicado no .chat-header-img enquanto os videos estão vazios.            */
/* O state machine seta data-avatar-state no header.                         */
.chat-header-img[data-avatar-state] #header-static-img {
    will-change: transform, filter;
}

/* idle: float sutil (-2px / +2px) */
.chat-header-img[data-avatar-state="idle"] #header-static-img {
    animation: avatarFloat 3.5s ease-in-out infinite;
}
@keyframes avatarFloat {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-3px); }
}

/* searching: pulse com leve tint (busca) */
.chat-header-img[data-avatar-state="searching"] #header-static-img {
    animation: avatarSearch 1.2s ease-in-out infinite;
}
@keyframes avatarSearch {
    0%, 100% { transform: scale(1)      rotate(0deg);   filter: hue-rotate(0deg)   brightness(1); }
    25%      { transform: scale(1.03)   rotate(-2deg);  filter: hue-rotate(-15deg) brightness(1.05); }
    75%      { transform: scale(1.03)   rotate(2deg);   filter: hue-rotate(15deg)  brightness(1.05); }
}

/* talking: scale ritmico imitando boca (sem sincronia real, generico) */
.chat-header-img[data-avatar-state="talking"] #header-static-img {
    animation: avatarTalk 0.32s ease-in-out infinite;
}
@keyframes avatarTalk {
    0%, 100% { transform: scaleY(1)    translateY(0); }
    50%      { transform: scaleY(0.96) translateY(1px); }
}

/* Header com avatar desabilitado (off via toggle ou persona.avatar_enabled=false) */
.chat-header-img.avatar-off {
    display: none !important;
}

/* Botão de toggle de áudio no header — ao lado do toggle de avatar */
.btn-audio-toggle {
    position: absolute;
    top: 8px;
    right: 44px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(4px);
    color: #475569;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    transition: background 0.2s, color 0.2s;
}
.btn-audio-toggle:hover {
    background: rgba(255, 255, 255, 0.95);
    color: #1e293b;
}
.btn-audio-toggle.is-off {
    background: rgba(15, 23, 42, 0.85);
    color: #f1f5f9;
}

/* Replay button discreto em mensagens do bot, alinhado com o timestamp */
.btn-replay-audio {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    font-size: 11px;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}
.btn-replay-audio:hover {
    background: rgba(34, 65, 135, 0.12);
    color: var(--chat-blue);
}

/* Botão de microfone dentro do input */
.btn-mic {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: #ffffff;
    color: var(--chat-blue);
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s, transform 0.15s;
    margin-right: 4px;
}
.btn-mic:hover {
    background: #f1f5f9;
    color: var(--chat-blue);
    transform: scale(1.05);
}
.btn-mic.listening {
    background: rgba(220, 38, 38, 0.15);
    color: #dc2626;
    animation: micPulse 1.2s ease-in-out infinite;
}
@keyframes micPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.5); }
    50%      { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
}

/* Botão de toggle de avatar no header — discreto, top-right */
.btn-avatar-toggle {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(4px);
    color: #475569;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    transition: background 0.2s, color 0.2s;
}
.btn-avatar-toggle:hover {
    background: rgba(255, 255, 255, 0.95);
    color: #1e293b;
}
.btn-avatar-toggle.is-off {
    background: rgba(15, 23, 42, 0.85);
    color: #f1f5f9;
}

/* Reaparição do avatar quando o usuário liga de novo */
.btn-avatar-restore {
    position: absolute;
    bottom: 10px;
    right: 10px;
    z-index: 6;
    background: rgba(15, 23, 42, 0.85);
    color: #f1f5f9;
    border: none;
    border-radius: 14px;
    padding: 4px 10px;
    font-size: 11px;
    cursor: pointer;
    display: none;
}
.btn-avatar-restore.visible {
    display: inline-block;
}

/* Aviso LGPD discreto — agora abaixo do campo de input */
.lgpd-notice {
    font-size: 10px;
    color: #94a3b8;
    text-align: center;
    padding: 8px 12px 4px;
    line-height: 1.3;
}
.lgpd-notice i {
    margin-right: 4px;
    opacity: 0.6;
}

/* Cursor piscando enquanto o bot ainda está streamando tokens */
.streaming-cursor {
    display: inline-block;
    margin-left: 1px;
    opacity: 0.6;
    animation: streamingBlink 1s steps(2, start) infinite;
}

@keyframes streamingBlink {
    to { visibility: hidden; }
}

.msg-bot {
    background: var(--chat-yellow);
    color: var(--chat-blue);
    font-weight: 700;
    align-self: flex-start;
    border-top-left-radius: 2px;
}

.msg-bot .msg-info {
    color: rgba(34, 65, 135, 0.7);
}

.msg-bot .btn-replay-audio {
    color: var(--chat-blue);
}
.msg-bot .btn-replay-audio:hover {
    background: rgba(34, 65, 135, 0.18);
    color: var(--chat-blue);
}

.msg-user {
    background: var(--chat-bubble-user);
    color: var(--chat-yellow);
    font-weight: 700;
    align-self: flex-end;
    border-top-right-radius: 2px;
}

/* Input Area */
.chat-input-container {
    padding: 12px 20px 20px;
    background: #f1f5f9;
    display: flex;
    flex-direction: column;
}

.chat-input-wrapper {
    background: var(--chat-blue);
    border-radius: 30px;
    padding: 5px 5px 5px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-input {
    flex: 1;
    background: none;
    border: none;
    color: #ffffff;
    padding: 10px 0;
    font-size: var(--chat-font-size);
    font-weight: 600;
    outline: none;
}

.chat-input::placeholder {
    color: rgba(255, 255, 255, 0.75);
    font-weight: 600;
}

/* Indicador de gravação (waveform tipo WhatsApp) — aparece quando .is-recording */
.recording-indicator {
    display: none;
    flex: 1;
    align-items: center;
    gap: 3px;
    padding: 10px 0;
}

.chat-input-wrapper.is-recording .chat-input {
    display: none;
}

.chat-input-wrapper.is-recording .recording-indicator {
    display: flex;
}

.recording-indicator > span:not(.recording-label) {
    width: 3px;
    height: 4px;
    background: var(--chat-yellow);
    border-radius: 2px;
    display: inline-block;
    animation: recWave 1s ease-in-out infinite;
}

.recording-indicator > span:nth-child(1) { animation-delay: 0.0s; }
.recording-indicator > span:nth-child(2) { animation-delay: 0.12s; }
.recording-indicator > span:nth-child(3) { animation-delay: 0.24s; }
.recording-indicator > span:nth-child(4) { animation-delay: 0.36s; }
.recording-indicator > span:nth-child(5) { animation-delay: 0.48s; }

.recording-label {
    color: var(--chat-yellow);
    font-size: 13px;
    font-weight: 600;
    font-style: italic;
    margin-left: 8px;
    letter-spacing: 0.02em;
}

@keyframes recWave {
    0%, 100% { height: 4px; }
    50%      { height: 22px; }
}

.chat-input-wrapper.is-recording .btn-mic {
    background: var(--chat-yellow);
    color: var(--chat-blue);
    animation: micRecording 1.2s ease-in-out infinite;
}

@keyframes micRecording {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 218, 1, 0.5); }
    50%      { box-shadow: 0 0 0 8px rgba(255, 218, 1, 0); }
}

.btn-send {
    width: 42px;
    height: 42px;
    background: var(--chat-yellow);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.btn-send:hover {
    transform: scale(1.1);
}

.btn-send svg {
    width: 20px;
    height: 20px;
    fill: var(--chat-blue);
}

/* Typing Indicator */
.typing-container {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 10px 18px !important;
}

.typing-text {
    font-size: 13px;
    font-style: italic;
    color: #64748b;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    animation: typingPulse 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) {
    animation-delay: 0s;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingPulse {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

/* Rodapé do Chat — 3 colunas: Encerrar | by vazto (centro) | engrenagem */
.chat-footer {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 6px 4px;
    font-size: 11px;
    gap: 8px;
}

.chat-footer .btn-end-mini { justify-self: start; }
.chat-footer .footer-credit { justify-self: center; }
.chat-footer .btn-settings { justify-self: end; }

.btn-end-mini {
    background: #ef4444;
    border: none;
    color: #ffffff;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 18px;
    border-radius: 100px;
    transition: background 0.2s, color 0.2s;
}

.btn-end-mini:hover {
    color: #ef4444;
    background: #e5e7eb;
}

/* Engrenagem de configurações — substitui os toggles do header */
.btn-settings {
    background: transparent;
    border: none;
    color: #64748b;
    font-size: 18px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s, transform 0.2s;
}
.btn-settings:hover {
    background: rgba(34, 65, 135, 0.08);
    color: var(--chat-blue);
    transform: rotate(45deg);
}

/* Crédito "by vazto" centralizado no footer */
.footer-credit {
    color: #9ca3af;
    font-size: 10px;
    text-decoration: none;
    transition: color 0.2s;
    text-align: center;
    line-height: 1;
}

.footer-credit:hover {
    color: #f97316;
}

.vazto-brand {
    color: #f97316;
    font-weight: 600;
}

/* Modal de Confirmação */
.widget-confirm-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
}

.confirm-content {
    background: #ffffff;
    padding: 25px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
    transform-origin: center;
    animation: zoomIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    min-width: 280px;
    max-width: 90%;
}

.confirm-content p {
    color: #374151;
    font-size: 15px;
    line-height: 1.5;
    margin-bottom: 20px;
    font-weight: 500;
}

.confirm-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-confirm {
    background: #ef4444;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-confirm:hover {
    background: #dc2626;
}

.btn-cancel {
    background: #f3f4f6;
    color: #4b5563;
    border: none;
    padding: 12px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-cancel:hover {
    background: #e5e7eb;
}

/* Modal de Configurações (áudio / avatar) */
.settings-title {
    color: var(--chat-blue);
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 16px;
    text-align: center;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 4px;
    border-bottom: 1px solid #f1f5f9;
}

.setting-row:last-of-type {
    border-bottom: none;
    margin-bottom: 10px;
}

.setting-row .setting-label {
    color: #374151;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.setting-row .setting-label i {
    color: var(--chat-blue);
    width: 18px;
    text-align: center;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #cbd5e1;
    border-radius: 24px;
    transition: background 0.2s;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    top: 3px;
    background: #ffffff;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--chat-blue);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ============================================================================
   MOBILE - Chat Fullscreen
   ============================================================================ */
@media (max-width: 480px) {

    /* Widget container - mantém posição fixed no canto */
    .sintracon-widget {
        bottom: 15px;
        right: 15px;
    }

    /* Launcher menor em mobile */
    .widget-launcher {
        height: 70px;
        min-width: 70px;
    }

    .launcher-avatar {
        width: 70px;
        height: 70px;
    }

    /* Esconde texto do launcher quando colapsado em mobile */
    .widget-launcher.collapsed .launcher-text-container {
        display: none;
    }

    /* ========== JANELA DO CHAT FULLSCREEN ========== */
    .widget-window {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        /* dvh: ajusta automaticamente quando a barra de endereco do mobile aparece/some.
           Fallback para --vh (JS) em browsers antigos sem suporte a dvh. */
        height: calc(var(--vh, 1vh) * 100) !important;
        height: 100dvh !important;
        max-width: none !important;
        max-height: none !important;
        min-width: 100vw !important;
        min-height: 100dvh !important;
        border-radius: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        /* Mobile: também desliza da direita para a esquerda */
        transform: translateX(100vw) !important;
        z-index: 999999 !important;
        overflow: hidden !important;
        display: flex !important;
        flex-direction: column !important;
    }

    /* Body com o widget aberto: trava o scroll para nao expor o site embedador atras */
    body.sintracon-chat-open {
        overflow: hidden !important;
        position: fixed !important;
        width: 100% !important;
    }

    .widget-window.open {
        opacity: 1 !important;
        visibility: visible !important;
        transform: translateX(0) !important;
    }

    /* Telas internas do chat */
    .screen-welcome,
    .screen-chat {
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    /* Container de input fixo na parte inferior */
    .chat-input-container {
        flex-shrink: 0 !important;
        position: relative !important;
    }

    /* Esconde botão X vermelho padrão em mobile */
    .widget-close-btn {
        display: none;
    }

    /* Botão de minimizar mobile - dentro da janela */
    .mobile-minimize-btn {
        position: absolute !important;
        top: 12px;
        right: 12px;
        width: 36px;
        height: 36px;
        background: rgba(0, 0, 0, 0.6);
        color: white;
        border: none;
        border-radius: 50%;
        cursor: pointer;
        z-index: 100;
        display: flex !important;
        align-items: center;
        justify-content: center;
        font-size: 18px;
        font-weight: bold;
    }

    .mobile-minimize-btn:active {
        background: rgba(0, 0, 0, 0.8);
    }

    /* Ajustes de conteúdo interno */
    .screen-welcome {
        padding: 20px;
    }

    .welcome-media {
        width: 90%;
        max-width: 280px;
        height: auto;
        max-height: 45vh;
    }

    .welcome-text {
        width: 90%;
        max-width: 280px;
        font-size: 14px;
    }

    .btn-start {
        width: 90%;
        max-width: 280px;
    }

    /* Header do chat com espaço para botão minimizar */
    .chat-header-img {
        margin-top: 50px;
        height: 150px;
        flex-shrink: 0;
    }

    .chat-messages {
        padding: 12px;
        flex: 1;
        overflow-y: auto;
        min-height: 0;
        /* Importante para flex scroll funcionar */
    }

    .chat-input-container {
        padding: 12px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .chat-input-wrapper {
        padding: 4px 4px 4px 15px;
    }

    .chat-input {
        font-size: 14px;
    }

    .btn-send {
        width: 38px;
        height: 38px;
    }
}

/* Botão minimizar - oculto por padrão (desktop) */
.mobile-minimize-btn {
    display: none;
}