:root {
    --bg-main: #1e1e24;
    --bg-surface: #2a2a3231;
    --accent: #FF5722;
    --hover: #67200b;
    --text-main: #f4f4f6;
    --text-muted: #a0a0aa;
    --chat-width: 340px;
}


/* Botón disparador */
.chat-trigger {
    position: fixed;
    bottom: 5%;
    right: 5%;
    background-color: var(--accent);
    color: #fff;
    border: none;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, background-color 0.2s;
    z-index: 9999;
}

.chat-trigger:hover {
    transform: scale(1.05);
    background-color: var(--hover);
}

/* Contenedor del Chat */
.chat-container {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: var(--chat-width);
    height: 450px;
    background-color: var(--bg-main);
    border-radius: 16px;
    box-shadow: 0 8px 24px #0d1111f2;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 9999;
}

.chat-container.hidden {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
}

/* Cabecera */
.chat-header {
    background-color: var(--bg-surface);
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #3a3a45;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 36px;
    height: 36px;
    background-color: var(--accent);
    border-radius: 50%;
    background-image: url('../image/avatar.png');
    background-size: cover;
}

.user-info h4 {
    margin: 0;
    color: var(--text-main);
    font-size: 14px;
}

.status {
    font-size: 11px;
    color: #4ade80;
    display: flex;
    align-items: center;
    gap: 4px;
}

.status::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background-color: #4ade80;
    border-radius: 50%;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
}

/* Cuerpo */
.chat-body {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background-color: #17171c;
}

.message {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.4;
}

.message.incoming {
    background-color: var(--bg-surface);
    color: var(--text-main);
    align-self: flex-start;
    border-bottom-left-radius: 2px;
}

/* Pie / Input */
.chat-footer {
    padding: 12px;
    background-color: var(--bg-surface);
    display: flex;
    gap: 8px;
    border-top: 1px solid #3a3a45;
}

.chat-footer input {
    flex: 1;
    background-color: var(--bg-main);
    border: 1px solid #3a3a45;
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text-main);
    font-size: 13px;
    outline: none;
}

.chat-footer input:focus {
    border-color: var(--accent);
}

.chat-footer button {
    background-color: var(--accent);
    color: white;
    border: none;
    padding: 0 12px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-footer button:hover {
    background-color: var(--hover);
}


/* Contenedor del formulario dentro del chat */
.chat-form-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background-color: var(--bg-surface);
    padding: 14px;
    border-radius: 14px;
    border-top-left-radius: 2px; /* Simula que es una respuesta o tarjeta del bot */
    border: 1px solid #3a3a452e;
    margin-bottom: 8px;
}

/* Grupos de campos */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Inputs internos estilizados */
.form-group input {
    background-color: var(--bg-main);
    border: 1px solid #3a3a45;
    border-radius: 8px;
    padding: 8px 12px;
    color: var(--text-main);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus {
    border-color: var(--accent);
}

/* Burbuja de aviso final (Éxito) */
#chatStatusMessage{
   display: flex;
    justify-content: flex-end;
}
.message.system-notice {
    background-color: #5d5d5d24;
    border: 0px solid #3b3b3b;
    color: #4ade80;
    align-self: center;
    text-align: right;
    font-size: 12px;
    border-radius: 8px;
    padding: 10px;
    width: 90%;
    margin-top: 10px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}


/* Animación de los puntitos "escribiendo..." */
.typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background-color: var(--text-muted, #a0a0aa);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Contenedor de Botones de Servicios */
.services-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
    animation: fadeIn 0.4s ease forwards;
}

.service-btn {
    background-color: var(--bg-surface, #2a2a32);
    color: var(--accent, #00b4d8);
    border: 0px solid var(--accent, #00b4d8);
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 300;
    text-align: left;
    transition: background-color 0.2s, color 0.2s, transform 0.1s;
    text-decoration: none;
    display: block;
}

.service-btn:hover {
    color: #ffffff;
}

/* Input Bloqueado */
.chat-footer input:disabled {
    background-color: #17171c;
    color: #52525b;
    cursor: not-allowed;
    border-color: #27272a;
}

.chat-footer button:disabled {
    background-color: #27272a;
    color: #52525b;
    cursor: not-allowed;
}
 #chatTrigger {
        position: fixed !important;
        /* Usamos svh para asegurar que con las barras visibles no se esconda */
        bottom: 4%; 
        right: 4%;
        z-index: 2147483647 !important;
        /* Evita saltos extraños en Safari */
        transform: translate3d(0, 0, 0); 
    }

@media (max-width: 768px) {
    /* Forzamos a que el contenedor del pie pase por encima de todo */
    #pie {
        
        z-index: 2147483647 !important;
    }

    /* El botón flotante de la burbuja (Asegúrate de usar su ID o clase correcta) */
    #chatTrigger {
        position: fixed !important;
        /* Usamos svh para asegurar que con las barras visibles no se esconda */
        bottom: 9%; 
        right: 9%;
        z-index: 2147483647 !important;
        /* Evita saltos extraños en Safari */
        transform: translate3d(0, 0, 0); 
    }

    /* Cuando el chat NO tiene la clase .hidden, se adueña de la pantalla de forma dinámica */
    #chatContainer:not(.hidden) {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
        
        /* SOLUCIÓN AL ALTO: dvh se adapta en tiempo real cuando la barra del navegador se oculta */
        height: 100dvh !important;
        max-height: 100dvh !important;
        
        background-color: #1b1b1b;
        border-radius: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;   
        z-index: 2147483647 !important;
    }

    /* Oculta el botón de la burbuja naranja mientras el chat está fullscreen */
    #chatContainer:not(.hidden) ~ #chatTrigger,
    #chatContainer:not(.hidden) + #chatTrigger {
        display: none !important;
    }
}