#smartchat-toggle{
    position:fixed;
    bottom:20px;
    right:20px;
    background:linear-gradient(135deg,#7b3fe4,#4a00e0);
    color:#fff;
    width:64px;
    height:64px;
    border-radius:50%;
    text-align:center;
    line-height:64px;
    font-size:26px;
    cursor:pointer;
    z-index:99999;
    box-shadow:0 10px 30px rgba(0,0,0,0.35);
}

#smartchat-box{
    display:none;
    position:fixed;
    bottom:100px;
    right:20px;
    width:360px;
    height:520px;
    background:#0f172a;
    border-radius:20px;
    box-shadow:0 25px 60px rgba(0,0,0,0.5);
    flex-direction:column;
    overflow:hidden;
    font-family:'Segoe UI',system-ui,sans-serif;
    z-index:99999;
}

#smartchat-header{
    background:linear-gradient(135deg,#7b3fe4,#4a00e0);
    color:#fff;
    padding:18px;
    font-weight:600;
    font-size:16px;
    display:flex;
    justify-content:space-between;
    align-items:center;
}

#smartchat-messages{
    flex:1;
    overflow-y:auto;
    padding:18px;
    background:#020617;
    display:flex;
    flex-direction:column;
    gap:8px;
}

.question-btn{
    background:#1e293b;
    color:#fff;
    padding:14px;
    border-radius:14px;
    cursor:pointer;
    font-size:14px;
    transition:0.2s;
}

.question-btn:hover{
    background:#334155;
}

.user{
    align-self:flex-end;
    background:linear-gradient(135deg,#7b3fe4,#4a00e0);
    color:#fff;
    padding:12px 16px;
    border-radius:18px 18px 4px 18px;
    max-width:85%;
    font-size:14px;
}

.bot{
    align-self:flex-start;
    background:#4a00e0;
    color:#fff;
    padding:12px 16px;
    border-radius:18px 18px 18px 4px;
    max-width:85%;
    font-size:14px;
}

#smartchat-box input{
    border:none;
    outline:none;
    padding:16px;
    width:70%;
    border-radius:12px;
    background:#020617;
    color:#fff;
    font-size:14px;
}

#smartchat-box button{
    border:none;
    background:linear-gradient(135deg,#7b3fe4,#4a00e0);
    color:#fff;
    padding:16px 18px;
    border-radius:12px;
    font-weight:600;
    cursor:pointer;
    transition:0.2s;
}

#smartchat-box button:hover{
    transform:scale(1.05);
}

#smartchat-box > div:last-child{
    padding:14px;
    background:#0f172a;
    display:flex;
    gap:10px;
    border-top:1px solid rgba(255,255,255,0.05);
}

.whatsapp-btn{
    display:inline-flex;
    align-items:center;
    gap:8px;
    margin-top:10px;
    padding:12px 18px;
    background:linear-gradient(135deg,#25D366,#128C7E);
    color:#fff !important;
    font-weight:600;
    font-size:14px;
    border-radius:12px;
    text-decoration:none !important;
    box-shadow:0 6px 20px rgba(0,0,0,0.25);
    transition:all .2s ease;
}

.whatsapp-btn:hover{
    transform:scale(1.05);
    box-shadow:0 10px 30px rgba(0,0,0,0.35);
}

.whatsapp-btn img{
    width:20px;
    height:20px;
}

.menu-principal{
    margin-top:50px;
    text-align:center;
}

.menu-principal button{
    background:#1e293b;
    color:#fff;
    border:none;
    padding:10px 14px;
    border-radius:10px;
    font-size:13px;
    cursor:pointer;
    transition:.2s;
}

.menu-principal button:hover{
    background:#334155;
}

/* ====================================================================== */
/* =========================   MOBILE RESPONSIVO   ======================= */
/* ====================================================================== */

@media (max-width: 480px) {

    #smartchat-toggle{
        width:54px;
        height:54px;
        line-height:54px;
        font-size:22px;
        bottom:15px;
        right:15px;
    }

    #smartchat-box{
        width:92vw;
        height:78vh;
        bottom:80px;
        right:4vw;
        border-radius:18px;
    }

    #smartchat-header{
        font-size:15px;
        padding:16px;
    }

    #smartchat-messages{
        padding:14px;
        gap:6px;
    }

    #smartchat-box input{
        width:65%;
        padding:14px;
        font-size:13px;
    }

    #smartchat-box button{
        padding:14px 16px;
        font-size:14px;
    }

    .user, .bot{
        max-width:90%;
        font-size:13px;
        padding:10px 14px;
        border-radius:16px;
    }

    .whatsapp-btn{
        width:100%;
        justify-content:center;
        font-size:13px;
        padding:12px;
    }
}


/* ========================================================= */
/*  TABLETS (481px a 900px)                                  */
/* ========================================================= */
@media (min-width: 481px) and (max-width: 900px) {
    #smartchat-box{
        width:420px;
        height:600px;
        right:30px;
        bottom:90px;
    }

    #smartchat-toggle{
        width:70px;
        height:70px;
        line-height:70px;
        font-size:30px;
    }

    .user, .bot{
        max-width:88%;
        font-size:15px;
    }
}

/* ========================================================= */
/*  iOS SAFE AREA (iPhone com notch)                         */
/* ========================================================= */
@supports(padding: env(safe-area-inset-bottom)) {
    #smartchat-toggle{
        bottom:calc(20px + env(safe-area-inset-bottom));
    }

    #smartchat-box{
        bottom:calc(100px + env(safe-area-inset-bottom));
    }
}


/* ========================================================= */
/*  PERFORMANCE (scroll suave e GPU accelerate)              */
/* ========================================================= */
#smartchat-messages{
    -webkit-overflow-scrolling:touch;
    will-change:transform;
}

#smartchat-box{
    will-change:transform, opacity;
}

/* ========================================================= */
/*  ANIMAÇÃO DE DIGITAÇÃO DO BOT                             */
/* ========================================================= */

.typing-indicator {
    width: 50px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding:0 10px;
    background: #1e293b;
    border-radius: 20px;
    margin-bottom:10px;
}

.typing-indicator div {
    width: 6px;
    height: 6px;
    background: #fff;
    border-radius: 50%;
    animation: typing 1.5s infinite ease-in-out;
}

.typing-indicator div:nth-child(2){
    animation-delay: .2s;
}
.typing-indicator div:nth-child(3){
    animation-delay: .4s;
}

@keyframes typing {
    0%, 60%, 100% { opacity: .2; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-4px); }
}


/* ========================================================= */
/*  ANIMAÇÃO DE ENTRADA DAS MENSAGENS                        */
/* ========================================================= */

.bot, .user {
    animation: msgIn .35s ease forwards;
    opacity:0;
}

@keyframes msgIn {
    from { opacity:0; transform: translateY(10px); }
    to { opacity:1; transform:translateY(0); }
}


/* ========================================================= */
/*  EFEITO DE ONDA/PULSO NO BOTÃO DO CHAT                    */
/* ========================================================= */

#smartchat-toggle{
    animation:pulseButton 2.4s infinite ease-in-out;
}

@keyframes pulseButton {
    0% { box-shadow:0 0 0 0 rgba(123,63,228,0.6); }
    70% { box-shadow:0 0 0 20px rgba(123,63,228,0); }
    100% { box-shadow:0 0 0 0 rgba(123,63,228,0); }
}


/* ========================================================= */
/*  ANIMAÇÃO DE ABERTURA DO CHAT (suavidade extra)           */
/* ========================================================= */

#smartchat-box.smartchat-open{
    animation: slideUpFade .35s ease;
}

@keyframes slideUpFade {
    from { opacity:0; transform: translateY(40px) scale(.95); }
    to { opacity:1; transform: translateY(0) scale(1); }
}

/* ==========================
   FIX: centralizar #smartchat-box no MOBILE
   Colocar no final do CSS
   ========================== */

@media (max-width: 600px) {

  /* Força o smartchat-box a centralizar horizontalmente,
     mantendo a animação vertical existente. */
  #smartchat-box{
    left: 50% !important;      /* centraliza pelo lado esquerdo */
    right: auto !important;    /* remove qualquer offset por right */
    width: 92vw !important;    /* mantém largura responsiva */
    max-width: 480px !important;
    border-radius: 14px !important;
    transform: translateX(-50%) translateY(30px) !important; /* fechado: deslocado pra baixo */
    bottom: calc(80px + env(safe-area-inset-bottom)) !important;
    /* garante que o elemento apareça acima do teclado em iOS/Android */
    box-sizing: border-box !important;
    padding: 0 !important;
  }

  /* Quando aberto, mantém o translateX(-50%) e reseta o translateY/scale da animação */
  #smartchat-box.smartchat-open{
    transform: translateX(-50%) translateY(0) scale(1) !important;
  }

  /* Se você usa a classe para animar mensagens (msgIn), ajustar origem para o centro */
  .bot, .user {
    transform-origin: center center;
  }

  /* Ajuste de margem interna para evitar cortar em telas pequenas */
  #smartchat-messages{
    padding-left: 14px !important;
    padding-right: 14px !important;
  }
}