/* ==========================================================================
   FAGRON CHATBOT IA - HOJA DE ESTILOS PRINCIPAL
   Ubicación: page/css/chatbot_style.css
   Arquitectura: Flexbox para gestión de estados y responsividad.
   ========================================================================== */

:root {
    --fagron-red: #E30613;
    --fagron-red-hover: #c20510;
    --fagron-dark: #1D1D1B;
    --fagron-light-gray: #f8f9fa;
    --fagron-border: #e5e5e5;
    --fagron-text: #333333;
}

/* ==========================================================================
   0. RESET DE MODELO DE CAJA (Evita desbordamientos y recortes a la derecha)
   ========================================================================== */
.fagron-chatbot-container, 
.fagron-chatbot-container * {
    box-sizing: border-box;
}

/* ==========================================================================
   CLASE PARA DESTACAR EL BOTÓN PRINCIPAL
   ========================================================================== */
.fagron-btn-highlight {
    background-color: #fff3f3 !important;
    color: var(--fagron-red) !important;
    border: 2px solid var(--fagron-red) !important;
    font-weight: 700 !important;
    box-shadow: 0 4px 6px rgba(227, 6, 19, 0.12) !important;
    transform: translateY(-1px);
    transition: all 0.2s ease;
}
.fagron-btn-highlight:hover {
    background-color: #ffe6e6 !important;
    box-shadow: 0 6px 10px rgba(227, 6, 19, 0.18) !important;
    transform: translateY(-2px);
}

/* --------------------------------------------------------------------------
   1. CONTENEDOR PRINCIPAL Y ESTADOS DE VENTANA
   -------------------------------------------------------------------------- */
.fagron-chatbot-container {
    position: fixed;
    bottom: 20px;
    /* Eliminamos 'right: 20px;' para que lo controle la clase modificadora */
    width: 380px;
    height: 600px;
    max-height: 85vh;
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    z-index: 999999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    transition: all 0.3s ease;
    border: 1px solid var(--fagron-border);
}

/* Clases Modificadoras de Posición */
.fagron-pos-right {
    right: 20px;
    left: auto;
}

.fagron-pos-left {
    left: 20px;
    right: auto;
}

/* ESTADO: Widget Maximizado */
.fagron-window-expanded {
    width: 800px !important;
    max-width: 95vw !important;
    height: 85vh !important;
    max-height: 85vh !important;
    bottom: 50% !important;
    right: 50% !important;
    left: auto !important; /* Reset crucial para evitar conflicto si estaba a la izquierda */
    transform: translate(50%, 50%);
    border-radius: 12px !important;
}

/* --------------------------------------------------------------------------
   2. CABECERA (HEADER)
   -------------------------------------------------------------------------- */
.fagron-header {
    background-color: var(--fagron-red);
    color: #ffffff;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 16px;
    flex-shrink: 0; /* Evita que el header se encoja */
}
.fagron-header-actions button {
    background: none;
    border: none;
    color: #ffffff;
    cursor: pointer;
    font-size: 16px;
    margin-left: 10px;
    opacity: 0.8;
    transition: opacity 0.2s;
}
.fagron-header-actions button:hover {
    opacity: 1;
}

/* --------------------------------------------------------------------------
   3. CUERPO Y GESTIÓN DE PASOS (STEPS)
   -------------------------------------------------------------------------- */
.fagron-body {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Clave para que Flexbox anidado scrollee */
    background-color: var(--fagron-light-gray);
    position: relative;
}

.fagron-step {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    flex: 1 1 auto;
    background: #ffffff;
}

.hidden-step {
    display: none !important;
}

/* --------------------------------------------------------------------------
   4. ÁREA DE CHAT (MENSAJES)
   -------------------------------------------------------------------------- */
.fagron-chat-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background-color: var(--fagron-light-gray);
}

.chat-msg {
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 85%;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.ai-msg {
    background-color: var(--fagron-red);
    color: #ffffff;
    align-self: flex-start;
    border-top-left-radius: 4px;
}

.user-msg {
    background-color: #e0e0e0;
    color: var(--fagron-text);
    align-self: flex-end;
    border-top-right-radius: 4px;
}

/* --------------------------------------------------------------------------
   5. ÁREA DE INPUT (ESCRITURA)
   -------------------------------------------------------------------------- */
.fagron-chat-input-area {
    display: flex;
    padding: 15px;
    background: #ffffff;
    border-top: 1px solid var(--fagron-border);
    flex-shrink: 0;
    gap: 10px;
}
.fagron-chat-input-area input {
    flex: 1;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    outline: none;
    font-size: 14px;
    transition: border-color 0.2s;
}
.fagron-chat-input-area input:focus {
    border-color: var(--fagron-red);
}
.fagron-chat-input-area button {
    background-color: var(--fagron-red);
    color: #ffffff;
    border: none;
    width: 45px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.2s;
}
.fagron-chat-input-area button:hover {
    background-color: var(--fagron-red-hover);
}

/* --------------------------------------------------------------------------
   6. BOTONES Y FORMULARIOS COMPARTIDOS
   -------------------------------------------------------------------------- */
.fagron-btn-primary {
    background-color: var(--fagron-red);
    color: #ffffff;
    border: none;
    padding: 12px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    text-align: center;
    transition: background-color 0.2s;
}
.fagron-btn-primary:hover {
    background-color: var(--fagron-red-hover);
}

.fagron-btn-secondary {
    background-color: #ffffff;
    color: var(--fagron-red);
    border: 2px solid var(--fagron-red);
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    text-align: center;
    transition: all 0.2s;
}
.fagron-btn-secondary:hover {
    background-color: var(--fagron-light-gray);
}

/* Utilidades para la pantalla de cierre y carga */
.text-center { text-align: center; }
.fagron-text-sm { font-size: 13px; color: #666; }
.fagron-spinner { border: 4px solid rgba(0,0,0,0.1); width: 40px; height: 40px; border-radius: 50%; border-left-color: var(--fagron-red); animation: spin 1s linear infinite; margin: 0 auto 15px auto; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }