/* =================================
   CECE CHATBOT PAGE - MOBILE FIRST
   ================================= */

/* --- ESTILOS BASE (Mobile) --- */

@media (max-width: 47.9375rem) {
    .main-header, .main-footer {
        display: none;
    }
    main {
        padding-top: 0;
    }
}

.cece-container {
    height: 100vh; 
    height: 100dvh; 
    width: 100%;
    margin: 0;
    background: var(--white-color);
    display: flex;
    flex-direction: column;
    box-shadow: none;
    border-radius: 0;
    overflow: hidden;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background-color: var(--light-gray);
    border-bottom: .0625rem solid var(--border-color);
    position: relative;
    flex-shrink: 0;
}

.chat-avatar {
    width: 3.125rem;
    height: 3.125rem;
    object-fit: contain;
}

.chat-title { flex-grow: 1; }
.chat-title h2 { margin: 0; font-size: 1.5rem; }
.chat-title p { margin: 0; opacity: 0.7; font-size: 0.9rem; }

.chat-history {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Los mensajes se apilan abajo */
.chat-history::before {
    content: '';
    /* Ocupa todo el espacio vacío disponible */
    flex-grow: 1; 
    /* Evita bugs de scroll en algunos navegadores */
    min-height: 0; 
}

/* --- BURBUJAS --- */
.message {
    max-width: 85%;
    padding: 0.8rem 1.2rem;
    border-radius: 1.25rem;
    line-height: 1.4;
    word-wrap: break-word;
    position: relative;
}

.message::after {
    content: '';
    position: absolute;
    top: 0;
    width: 0;
    height: 0;
    border-style: solid;
}

.cece-message {
    background-color: var(--primary-color);
    color: var(--white-color);
    border-top-left-radius: 0;
    align-self: flex-start;
    min-width: 3rem; /* Mínimo para que entren los puntos */
}
.cece-message::after {
    left: -.625rem;
    border-width: 0 .625rem .625rem .0625rem;
    border-color: transparent var(--primary-color) transparent transparent;
}

.user-message {
    background-color: var(--secondary-color);
    color: var(--white-color);
    border-top-right-radius: 0;
    align-self: flex-end;
}
.user-message::after {
    right: -.625rem;
    border-width: 0 0 .625rem .625rem;
    border-color: transparent transparent transparent var(--secondary-color);
}

.message.system-message {
    align-self: center;
    background-color: var(--color-fondo-claro, #f4f4f4);
    color: var(--color-texto-secundario, #555);
    max-width: 80%;
    padding: .375rem .75rem;
    border-radius: .5rem;
    font-size: 0.875rem;
    text-align: center;
    margin: .625rem 0;
    font-style: italic;
    border: .0625rem solid var(--color-bordes, #ddd);
    box-shadow: none;
}

/* --- INDICADOR DE TIPEANDO (Tipo WhatsApp) --- */
.typing-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 1rem 1.2rem; /* Un poco más alto para centrar */
    min-width: 4.5rem;
    height: 2.5rem;
}

.typing-dot {
    width: .3125rem;
    height: .3125rem;
    background-color: rgba(255, 255, 255, 0.7); /* Blancos semitransparentes */
    border-radius: 50%;
    animation: wave 1.3s linear infinite;
}

.typing-dot:nth-child(2) { animation-delay: -1.1s; }
.typing-dot:nth-child(3) { animation-delay: -0.9s; }

@keyframes wave {
    0%, 60%, 100% { transform: initial; }
    30% { transform: translateY(-0.4rem); } /* Salto del punto */
}

/* --- INPUT AREA --- */
.chat-input-form {
    display: flex;
    align-items: flex-end;
    padding: 1rem;
    border-top: .0625rem solid var(--border-color);
    background: var(--light-gray);
    flex-shrink: 0;
}

.input-wrapper {
    flex-grow: 1;
    display: flex;
    align-items: center;
    background: var(--white-color);
    border-radius: 1.5625rem;
    padding: .375rem;
    border: .0625rem solid var(--border-color);
}
.input-wrapper:focus-within { border-color: var(--primary-color); }

#user-input {
    flex-grow: 1;
    border: none;
    outline: none;
    resize: none;
    font-family: var(--font-family-main);
    padding-left: 1rem;
    font-size: 1rem;
    max-height: 6rem;
    background: transparent;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    fill: #888;
}
.icon-btn svg { width: 1.5rem; height: 1.5rem; }

.send-btn {
    background-color: var(--primary-color);
    border: none;
    border-radius: 50%;
    width: 3.5625rem;
    height: 3.5625rem;
    flex-shrink: 0; 
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    margin-left: 0.5rem;
    transition: background-color 0.3s;
}
.send-btn:hover { background-color: #00434b; }
.send-btn svg { fill: var(--white-color); width: 1.5625rem; height: 1.5625rem; }

.share-button-nav { display: none; }

/* --- ESTILOS DESKTOP (Overrides) --- */
@media (min-width: 48rem) {
    .cece-container {
        margin: 2rem auto;
        height: calc(100vh - var(--header-height) - 4rem);
        max-width: 50rem;
        border-radius: .625rem;
        box-shadow: 0 .3125rem 1.5625rem rgba(0,0,0,0.1);
    }
    .chat-header .nav-toggle, .chat-header .nav-menu { display: none; }
    .message { max-width: 75%; }
    .message.system-message { max-width: 60%; }

    .share-button-nav {
        display: flex;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: .125rem solid var(--secondary-color);
        color: var(--secondary-color);
        font-weight: 600;
        border-radius: 50%;
        width: 2.5rem;
        height: 2.5rem;
        cursor: pointer;
        transition: all 0.3s ease;
        padding: 0;
    }
    .share-button-nav svg { width: 1.25rem; height: 1.25rem; fill: var(--secondary-color); }
    .share-button-nav:hover {
        background-color: var(--secondary-color);
        color: var(--white-color);
        transform: translateY(-.125rem);
    }
    .share-button-nav:hover svg { fill: var(--white-color); }
    .share-menu-item { display: none; }
}

/* --- MODAL DE INTERACCIÓN (Agrega esto al final de cece.css) --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5); /* Fondo semitransparente */
    z-index: 2000; /* Por encima del header */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background-color: var(--white-color);
    padding: 2rem;
    border-radius: 1.25rem;
    text-align: center;
    max-width: 25rem;
    width: 100%;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    transform: translateY(0);
    transition: transform 0.3s ease;
}

.modal-overlay.hidden .modal-content {
    transform: translateY(20px);
}

.modal-icon {
    color: var(--secondary-color);
    margin-bottom: 1rem;
}

.modal-content h3 {
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.modal-content p {
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
    color: #666;
}

.modal-content button {
    width: 100%;
    padding: 0.8rem;
    font-size: 1rem;
}