/* =========================================
   ESTILOS GENERALES Y RESETS
   ========================================= */
body, html {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    /* Evita scroll horizontal no deseado */
    overflow-x: hidden; 
}

/* Evita que el body se desplace cuando el chat modal está abierto en móviles */
body.chat-open {
    overflow: hidden !important;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* =========================================
   ESTILOS DE LA PÁGINA (CONTENIDO)
   ========================================= */

/* Submenú principal */
.acciones-container {
    text-align: center;
    margin: 20px auto;
    padding: 0 15px; /* Padding de seguridad para móviles */
}

.logo-cesop {
    width: 150px;
    margin-bottom: 20px;
}

.acciones-botones {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.accion-btn {
    background: #ffffff;
    border: 2px solid #ccc;
    border-radius: 12px;
    padding: 15px;
    width: 130px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.accion-btn img {
    width: 60px;
    height: 60px;
    object-fit: contain;
    margin-bottom: 10px;
}

.accion-btn span {
    font-weight: bold;
    color: #333;
}

.accion-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

/* Estilo del Submenú */
.menu-container {
    text-align: center;
    padding: 30px;
    background: #f6f9fc;
}

.titulo-menu {
    font-size: 24px;
    margin-bottom: 30px;
    color: #222;
    font-weight: bold;
}

.menu-grid {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
}

.menu-card {
    position: relative; /* Necesario para el pseudo-elemento ::after */
    background: white;
    width: 260px;
    border-radius: 16px;
    padding: 20px;
    text-decoration: none;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-sizing: border-box; /* Asegura padding correcto */
}

.menu-card img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin-bottom: 15px;
    transition: transform 0.3s ease;
}

.menu-card h3 {
    font-size: 20px;
    color: #1a73e8;
    margin-bottom: 10px;
    transition: color 0.3s ease;
}

.menu-card p {
    font-size: 14px;
    color: #444;
}

/* ⚡ EFECTO HOVER PREMIUM (Elevación suave y cambio de color) */
.menu-card:hover {
    transform: translateY(-6px); /* Elevación controlada */
    border-color: rgba(16, 185, 129, 0.3); 
    box-shadow: 0 15px 35px rgba(16, 185, 129, 0.08); 
}

/* Animación del ícono al pasar el mouse */
.menu-card:hover img {
    transform: scale(1.08);
}

/* El título cambia al verde interactivo de la cooperativa */
.menu-card:hover h3 {
    color: #10b981;
}

/* Línea decorativa inferior sutil */
.menu-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 4px;
    background: linear-gradient(90deg, #10b981, #facc15); 
    transition: all 0.4s ease;
    transform: translateX(-50%);
    border-radius: 2px 2px 0 0;
}

.menu-card:hover::after {
    width: 45%; 
}

/* Clase genérica para deshabilitar elementos */
.disabled {
    pointer-events: none;
    opacity: 0.5;
    filter: grayscale(100%);
}

/* =========================================
   ESTILOS DEL CHAT (ESCRITORIO)
   ========================================= */

/* BOTÓN FLOTANTE (solo visible cuando chat está cerrado) */
#chatFloatingBtn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #10b981, #facc15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
    z-index: 9999;
    transition: all 0.3s ease;
    animation: pulse 2s infinite;
}

#chatFloatingBtn.hidden {
    display: none !important;
}

#chatFloatingBtn:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.5);
}

@keyframes pulse {
    0% { box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4); }
    70% { box-shadow: 0 6px 30px rgba(16, 185, 129, 0.6); }
    100% { box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4); }
}

/* CHAT FLOTANTE CONTENEDOR PRINCIPAL */
#chatBot {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    height: 620px;
    max-height: 620px;
    border-radius: 20px;
    box-shadow: 0 12px 35px rgba(0,0,0,0.18);
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    z-index: 9998;
    background: white;
    border: 1px solid #e2e8f0;
    display: none; /* Oculto por defecto */
    flex-direction: column;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Clase para abrir el chat desde JS */
#chatBot.active {
    display: flex;
}

/* HEADER DEL CHAT */
#chatHeader {
    background: linear-gradient(135deg, #10b981, #facc15);
    color: white;
    padding: 16px;
    text-align: center;
    font-weight: 600;
    font-size: 17px;
    user-select: none;
    box-shadow: 0 2px 10px rgba(16,185,129,0.3);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

#chatHeader span {
    flex: 1;
    text-align: center;
}

/* BOTÓN X PARA CERRAR CHAT */
#closeChatBtn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10000;
}

#closeChatBtn:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: translateY(-50%) scale(1.1);
}

/* CUERPO DEL CHAT (Contenedor de mensajes + inputs) */
#chatBody {
    display: flex;
    flex-direction: column;
    /* Ajuste de altura para escritorio */
    height: calc(100% - 53px); /* Resta la altura del header */
    background: #f8fafc;
}

/* Área de Mensajes (Scrolleable) */
#messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: white;
    display: flex;
    flex-direction: column; /* Asegura orden de arriba a abajo */
}

/* Burbujas de mensaje */
.msg {
    margin: 12px 0;
    padding: 14px 18px;
    border-radius: 20px;
    max-width: 85%;
    word-wrap: break-word;
    animation: fadeIn 0.3s ease-out;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    line-height: 1.5;
    box-sizing: border-box;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Mensajes del Usuario */
.msg.user {
    background: linear-gradient(135deg, #10b981, #facc15);
    color: white;
    align-self: flex-end;
    margin-left: auto;
    border-bottom-right-radius: 8px;
}

/* Mensajes del Bot */
.msg.bot {
    background: linear-gradient(135deg, #e6f9ea, #fef9d6);
    color: #155724;
    align-self: flex-start;
    border-bottom-left-radius: 8px;
}

.msg.bot strong { color: #0d5c36; }

/* Contenedor de Botones e inputs dinámicos del bot */
.bot-buttons {
    padding: 0 20px 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-self: flex-start;
}

/* Estilos para elementos interactivos del bot (botones, selects, inputs dinámicos) */
.bot-buttons button,
.bot-buttons select,
.bot-buttons input {
    background: white;
    color: #1e293b;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 10px 16px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    box-sizing: border-box;
    font-family: inherit;
}

/* Botones específicos de opción */
.bot-buttons button {
    background: #10b981;
    color: white;
    border: none;
    box-shadow: 0 2px 8px rgba(16,185,129,0.3);
}

.bot-buttons button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(16,185,129,0.4);
}

/* Formulario de envío (Parte inferior fija) */
#chatForm {
    display: flex;
    padding: 16px 20px;
    background: white;
    border-top: 1px solid #e5e7eb;
    gap: 12px;
    box-sizing: border-box;
    align-items: center; /* Alinea verticalmente input y botón */
}

/* Input de texto */
#chatForm input {
    flex: 1;
    padding: 14px 18px;
    border-radius: 25px;
    border: 2px solid #e5e7eb;
    outline: none;
    font-size: 15px;
    transition: all 0.2s;
    background: #fafbfc;
    font-family: inherit;
    box-sizing: border-box;
}

#chatForm input:focus {
    border-color: #10b981;
    background: white;
    box-shadow: 0 0 0 3px rgba(16,185,129,0.1);
}

/* Botón de enviar */
#chatForm button {
    padding: 14px 20px;
    border-radius: 25px;
    border: none;
    background: #10b981;
    color: white;
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
    transition: all 0.2s;
    min-width: 50px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
}

#chatForm button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(16,185,129,0.4);
}

#chatForm button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Indicador de escritura "DATA está respondiendo" */
.typing {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    color: #64748b;
    font-style: italic;
    background: linear-gradient(135deg, #e6f9f3, #fef9d6);
    border-radius: 20px;
    max-width: 85%;
    align-self: flex-start;
    border-bottom-left-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    box-sizing: border-box;
}

.typing-dots {
    display: flex;
    gap: 6px;
}

.typing-dots span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #10b981;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-10px); opacity: 1; }
}

/* Personalización del Scrollbar de mensajes */
#messages::-webkit-scrollbar { width: 6px; }
#messages::-webkit-scrollbar-track { background: #f1f5f9; border-radius: 10px; }
#messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
#messages::-webkit-scrollbar-thumb:hover { background: #94a3b8; }


/* =========================================
   MEDIA QUERIES - RESPONSIVE MÓVILES
   ========================================= */

/* Tablets y Móviles grandes en horizontal */
@media (max-width: 768px) {
    .menu-grid {
        gap: 20px;
    }
    .titulo-menu {
        font-size: 20px;
    }
}

/* Móviles pequeños (Vertical) - Cambios drásticos para CHAT FULLSCREEN */
@media (max-width: 480px) {
    /* CONTENIDO PÁGINA */
    .menu-container {
        padding: 20px 10px;
    }
    .menu-card {
        width: 100%; /* Tarjetas ocupan todo el ancho */
        max-width: 300px;
    }

    /* CHAT FLOTANTE - MODO FULLSCREEN */
    #chatBot {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        bottom: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: 100% !important; /* Fallback */
        height: 100dvh !important; /* Soporte para viewports dinámicos modernos */
        max-height: none !important;
        border-radius: 0px !important;
        border: none !important;
        box-shadow: none !important;
        transform: none !important;
        z-index: 13000 !important; /* Asegura estar sobre todo */
    }

    /* HEADER DEL CHAT MÓVIL */
    #chatHeader {
        border-radius: 0px !important;
        padding: 16px 14px !important;
        font-size: 17px !important;
        height: 56px; /* Altura fija para cálculos */
    }

    #closeChatBtn {
        display: flex !important;
        width: 36px !important;
        height: 36px !important;
        font-size: 20px !important;
        right: 10px;
    }

    /* CUERPO DEL CHAT MÓVIL - Cálculo preciso de altura */
    #chatBody {
        height: calc(100dvh - 56px) !important; /* Altura total menos header */
    }

    #messages {
        padding: 14px;
        font-size: 14.5px;
    }

    /* FORMULARIO MÓVIL - Más compacto */
    #chatForm {
        padding: 10px 12px !important;
        gap: 8px !important;
        height: 65px; /* Altura fija */
    }

    #chatForm input {
        font-size: 14px !important;
        padding: 11px 14px !important;
        border-radius: 22px !important;
        min-height: 42px;
    }

    #sendBtn {
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        padding: 0 !important;
        border-radius: 50% !important;
        font-size: 16px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    /* BOTÓN FLOTANTE MÓVIL - Ligeramente más pequeño */
    #chatFloatingBtn {
        display: flex !important; /* Asegura que exista si no tiene clase hidden */
        bottom: 15px;
        right: 15px;
        width: 55px; 
        height: 55px;
    }

    #chatFloatingBtn.hidden {
        display: none !important;
    }
}