@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
    --color-primary: #65BAAF;
    --color-primary-light: #C4D4A4;
    --color-secondary: #ADC988;
    --color-accent: #F7C48A;
    --color-accent-dark: #d3b088;
    --color-text-dark: #54565A;
    --color-bg: #f8faf9;
    --color-surface: #ffffff;
    --radius-xl: 1.5rem;
    --font-main: 'Manrope', sans-serif;
}

#chat-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
    font-family: var(--font-main);
}

/* Ventana del Chat */
#chat-window {
    width: 380px;
    height: 600px;
    max-height: 80vh;
    background-color: var(--color-bg);
    border-radius: var(--radius-xl);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(84, 86, 90, 0.15);
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

/* Header Estilo Concierge */
#chat-header {
    background: linear-gradient(135deg, var(--color-accent-dark), var(--color-accent));
    padding: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: white;
}

#chat-header .title-area {
    display: flex;
    flex-direction: column;
}

#chat-header b {
    font-size: 1rem;
    font-weight: 700;
}

#chat-header span {
    font-size: 0.65rem;
    text-transform: uppercase;
    opacity: 0.9;
    letter-spacing: 0.05em;
}

#close-chat {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 32px; /* Un poquito más grande para atinarle mejor con el dedo */
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    flex-shrink: 0; /* <--- LA MAGIA: Evita que se haga óvalo */
    padding: 0;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* Cuerpo del Chat */
#chat-content {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#chat-question {
    background: white;
    padding: 1rem;
    border-radius: 1rem;
    border-bottom-left-radius: 0.25rem;
    color: var(--color-text-dark);
    box-shadow: 0 2px 10px rgba(0,0,0,0.02);
    border: 1px solid rgba(173, 201, 136, 0.2);
    line-height: 1.5;
    font-size: 0.95rem;
}

/* Footer de Acciones */
.chat-footer-actions {
    padding: 1.25rem;
    background-color: var(--color-surface);
    border-top: 1px solid rgba(173, 201, 136, 0.1);
}

#chat-options {
    display: flex;
    gap: 0.75rem;
}

/* Botones */
.btn-init, .btn-opt, .btn-whatsapp {
    width: 100%;
    padding: 0.9rem;
    border-radius: 0.75rem;
    border: none;
    font-family: var(--font-main);
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    text-decoration: none;
    display: block;
}

.btn-init {
    background-color: var(--color-accent-dark);
    color: white;
}

.btn-opt:first-child { /* Botón SÍ */
    background-color: var(--color-secondary);
    color: white;
}

.btn-opt:last-child { /* Botón NO */
    background-color: var(--color-text-dark);
    color: white;
}

.btn-whatsapp {
    background-color: var(--color-secondary);
    color: white;
}

.btn-init:hover, .btn-opt:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

/* La Burbuja Flotante */
#chat-bubble {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--color-accent), var(--color-primary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    box-shadow: 0 10px 25px rgba(101, 186, 175, 0.3);
    float: right;
}

.hidden { display: none !important; }


/* --- ESTILOS DE LOS MENSAJES (HISTORIAL) --- */
.message {
    display: flex;
    flex-direction: column;
    margin-bottom: 12px;
    width: 100%;
    animation: fadeIn 0.3s ease-out forwards;
}

.message-header {
    font-size: 0.75rem;
    font-weight: 700;
    margin-bottom: 0.3rem;
    color: var(--color-text-dark);
    opacity: 0.7;
    margin-left: 5px;
}

.bubble {
    padding: 1rem;
    border-radius: 1rem;
    line-height: 1.4;
    font-size: 0.95rem;
    max-width: 85%;
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
}

/* Mensaje del Asistente (Izquierda) */
.bot-message { align-items: flex-start; }
.bot-message .bubble {
    background-color: var(--color-surface);
    color: var(--color-text-dark);
    border-bottom-left-radius: 0.25rem;
    border: 1px solid rgba(173, 201, 136, 0.3);
}

/* Mensaje del Usuario (Derecha) */
.user-message { align-items: flex-end; }
.user-message .bubble {
    background-color: var(--color-primary);
    color: white;
    border-bottom-right-radius: 0.25rem;
}

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

/* --- ADAPTACIÓN PARA MÓVILES --- */
@media (max-width: 600px) {
    #chat-window {
        position: fixed; /* Lo despegamos de la esquina */
        top: 8dvh;
        bottom: 2dvh;
        left: 7vw;
        width: 90vw;
        height: 90dvh; 
        max-height: 100dvh;
        
        border-radius: var(--radius-xl);
        margin: 0;
        z-index: 10000;
    }

    #chat-header {
        padding: 1rem;
    }

    #chat-bubble {
        /* Mantiene la burbuja en su esquina inferior derecha cuando el chat está cerrado */
        position: fixed;
        bottom: 30px;
        right: 20px;
    }
}

.btn-opt:disabled {
    opacity: 0.6; /* Lo hace un poco transparente */
    transform: none; 
    filter: none;
}