/*
 * ESTILOS CSS PARA EL CHATBOT FLOTANTE CECS AI
 * Basado en la paleta de colores institucional (Azul Oscuro, Dorado/Amarillo, Blanco).
 * VERSION RESPONSIVA
 */

/* --- 1. ESTILOS DEL CONTENEDOR FLOTANTE Y EL BOTÓN --- */

/* Botón Activador (Flotante) */
#chat-toggle-button {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: #87342e;
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    font-size: 24px;
    line-height: 60px;
    text-align: center;
    z-index: 10000 !important;
    transition: transform 0.2s ease;
}

#chat-toggle-button:hover {
    transform: scale(1.05);
}

#chat-toggle-button #chat-icon {
    pointer-events: none; 
}

/* Contenedor Principal del Chat */
#cecs-chat-container {
    position: fixed;
    bottom: 90px;
    left: 20px;
    width: 350px;
    max-width: calc(100vw - 40px); /* Previene que se salga de la pantalla */
    max-height: 80vh;
    height: 500px;
    background-color: white;
    border: 1px solid #ccc;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    font-family: Arial, sans-serif;
    overflow: hidden;
}

/* --- 2. ESTILOS DE ENCABEZADO Y ÁREA DE CHAT --- */

#cecs-chat-header {
    background-color: #87342e;
    color: white;
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    flex-shrink: 0;
}

#header-title {
    font-size: 16px;
    font-weight: 600;
}

#close-chat-button {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0 5px;
    min-width: 30px;
    min-height: 30px;
}

#cecs-chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 15px;
    background-color: #f4f4f4;
    word-wrap: break-word;
}

/* --- 3. ESTILOS DE MENSAJES --- */

.message {
    margin-bottom: 15px;
    padding: 10px 15px;
    border-radius: 20px;
    max-width: 85%;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.bot-message {
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    margin-right: auto;
    text-align: left;
    color: #333;
}

.user-message {
    background-color: #ffc107;
    color: #000;
    margin-left: auto;
    text-align: right;
}

/* --- 4. ESTILOS DEL ÁREA DE INPUT --- */

#cecs-chat-input-area {
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-top: 1px solid #e0e0e0;
    background-color: #ffffff;
    flex-shrink: 0;
}

#user-input {
    flex-grow: 1;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 20px;
    font-size: 14px;
    min-width: 0; /* Permite que se encoja en pantallas pequeñas */
}

#send-button {
    background-color: #87342e;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#send-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Estilo para el spinner de carga */
.spinner {
    margin-left: 5px;
    font-size: 12px;
    color: #87342e;
}

/* --- 5. MEDIA QUERIES PARA RESPONSIVIDAD --- */

/* Tablets en orientación vertical y dispositivos medianos (768px o menos) */
@media screen and (max-width: 768px) {
    #cecs-chat-container {
        width: 320px;
        height: 450px;
        max-height: 70vh;
    }
    
    #chat-toggle-button {
        width: 55px;
        height: 55px;
        font-size: 22px;
        line-height: 55px;
    }
    
    .message {
        max-width: 90%;
        font-size: 14px;
    }
}

/* Smartphones (480px o menos) */
@media screen and (max-width: 480px) {
    #chat-toggle-button {
        bottom: 15px;
        left: 15px;
        width: 50px;
        height: 50px;
        font-size: 20px;
        line-height: 50px;
    }
    
    #cecs-chat-container {
        bottom: 75px;
        left: 10px;
        right: 10px;
        width: auto;
        max-width: calc(100vw - 20px);
        height: 400px;
        max-height: 65vh;
        border-radius: 8px;
    }
    
    #cecs-chat-header {
        padding: 10px 12px;
        border-top-left-radius: 8px;
        border-top-right-radius: 8px;
    }
    
    #header-title {
        font-size: 14px;
    }
    
    #close-chat-button {
        font-size: 18px;
    }
    
    #cecs-chat-messages {
        padding: 10px;
    }
    
    .message {
        padding: 8px 12px;
        font-size: 13px;
        max-width: 90%;
    }
    
    #cecs-chat-input-area {
        padding: 8px;
        gap: 6px;
    }
    
    #user-input {
        padding: 8px 10px;
        font-size: 13px;
    }
    
    #send-button {
        width: 36px;
        height: 36px;
        min-width: 36px;
        min-height: 36px;
        font-size: 14px;
    }
}

/* Pantallas muy pequeñas (320px o menos) */
@media screen and (max-width: 320px) {
    #cecs-chat-container {
        height: 350px;
        max-height: 60vh;
    }
    
    .message {
        font-size: 12px;
        padding: 7px 10px;
    }
    
    #user-input {
        font-size: 12px;
    }
}

/* Orientación horizontal en móviles */
@media screen and (max-height: 500px) and (orientation: landscape) {
    #cecs-chat-container {
        height: 300px;
        max-height: 85vh;
        bottom: 60px;
    }
    
    #chat-toggle-button {
        bottom: 10px;
        width: 45px;
        height: 45px;
        font-size: 18px;
        line-height: 45px;
    }
    
    #cecs-chat-messages {
        padding: 8px;
    }
}

/* Pantallas grandes (Desktop) */
@media screen and (min-width: 1024px) {
    #cecs-chat-container {
        width: 380px;
        height: 550px;
    }
    
    #chat-toggle-button:hover {
        transform: scale(1.1);
    }
    
    #send-button:hover {
        background-color: #6d2a25;
    }
}