/* Estilos Generales y de Página */
html, body {
    height: 100%;
    margin: 0;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
}

.page-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background-color: #f0f4f8;
}

header {
    padding: 12px 20px;
    border-bottom: 1px solid #e2e8f0;
    text-align: center;
    background-color: #fff;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

header h1 {
    color: #2d3748;
    font-size: 1.3rem;
    margin: 0;
}

header .model-info {
    font-size: 0.75rem;
    color: #718096;
    margin-top: 2px;
}

.main-content {
    display: flex;
    flex-direction: row;
    flex-grow: 1;
    overflow: hidden;
    background-color: #e9eef2;
}

/* Contenedor Principal del Chat */
#chatInterfaceContainer {
    flex-basis: 0;
    flex-grow: 3;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background-color: #ffffff;
}

/* Barra Lateral (Sidebar) */
#sidebar {
    flex-basis: 0;
    flex-grow: 1;
    background-color: #fdfdff;
    border-left: 1px solid #dde2e7;
    padding: 15px;
    overflow-y: auto;
    display: none;
    font-size: 0.85rem;
    min-height: 0;
}

#sidebar h4 {
    margin-top: 0;
    color: #1a2533;
    border-bottom: 1px solid #dde2e7;
    padding-bottom: 10px;
    margin-bottom: 12px;
    font-size: 0.95rem;
    font-weight: 600;
}

#sidebar h4 i {
    margin-right: 5px;
}

#sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0 0 15px 0;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    /*overflow: hidden; /* Clave para la animación de max-height */
}

#availableSessionsList {
    transition: opacity 0.4s ease, max-height 0.4s ease, transform 0.4s ease, margin-bottom 0.4s, border-width 0.2s;
    transform-origin: top;
    max-height: 280px; /* Altura máxima visible */
    opacity: 1;
    transform: scaleY(1);
    overflow-y: auto;
}

#availableSessionsList.oculto {
    opacity: 0;
    max-height: 0;
    transform: scaleY(0.95);
    pointer-events: none; /* Evita interacciones mientras está oculto */
    margin-bottom: 0;
    border-width: 0;
}

#sidebar li a,
#sidebar .available-session-item {
    text-decoration: none;
    color: #3182ce;
    display: block;
    padding: 8px 10px;
    border-bottom: 1px solid #eef2f7;
    font-size: 0.8rem;
    transition: background-color 0.2s, color 0.2s;
}

#sidebar li:last-child a,
#sidebar .available-session-item:last-child {
    border-bottom: none;
}

#sidebar li a:hover,
#sidebar .available-session-item:hover {
    color: #2b6cb0;
    background-color: #e9eef2;
    cursor: pointer;
}

#sidebar .available-session-item strong {
    display: block;
    font-size: 0.82rem;
    color: #2d3748;
}

#sidebar .available-session-item small {
    color: #718096;
    font-size: 0.75rem;
    display: block;
    margin-top: 2px;
}

#searchAvailableSessions {
    width: calc(100% - 22px);
    padding: 8px 10px;
    margin-bottom: 10px;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    font-size: 0.85rem;
    transition: background-color 0.3s;
}

#searchAvailableSessions:disabled {
    background-color: #e9ecef;
    cursor: not-allowed;
}

/* Sección de Login */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    height: calc(100vh - 50px);
    flex-grow: 1;
}

.login-container {
    padding: 30px;
    text-align: center;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    width: 320px;
}

.login-container input[type="text"] {
    font-size: 1rem;
    padding: 12px;
    text-align: center;
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 15px;
}

.login-container button {
    font-size: 1rem;
    width: 100%;
}

/* Barra Superior y Mensajes de Estado */
.top-bar {
    flex-shrink: 0;
    padding: 6px 15px;
    background-color: #fdfdff;
    border-bottom: 1px solid #eef2f7;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.top-bar-icons button,
.student-info-display-button {
    background: none;
    border: none;
    font-size: 1rem;
    color: #5a6ac5;
    cursor: pointer;
    padding: 6px;
    transition: color 0.2s;
    margin-left: 4px;
}

.top-bar-icons button:hover,
.student-info-display-button:hover {
    color: #3182ce;
}

.student-info-display-button {
    display: flex;
    align-items: center;
    font-size: 0.85em;
}

.student-info-display-button i {
    margin-right: 5px;
    font-size: 1em;
}

.status-messages-container {
    flex-shrink: 0;
    font-size: 0.8rem;
}

.status-area {
    padding: 7px 15px;
    margin: 0;
    text-align: center;
    display: none;
    border-bottom: 1px solid #e2e8f0;
}

.error-area { background-color: #fff0f3; color: #c53030; border-color: #f7d4d6; }
.learning-session-context-info { background-color: #e6fffa; color: #23766f; border-color: #a0f0dc; }
.notification-area { background-color: #ebf4ff; color: #2c5282; border-color: #bee5eb; }

/* Caja de Chat y Mensajes */
.chatbox {
    flex-grow: 1;
    overflow-y: auto;
    padding: 15px;
    background-color: #f0f4f8;
    min-height: 0;
}

.message {
    display: flex;
    align-items: flex-end;
    margin-bottom: 10px;
    max-width: 80%;
    clear: both;
}

.message .avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: white;
    flex-shrink: 0;
}

.message-bubble {
    padding: 10px 14px;
    border-radius: 18px;
    line-height: 1.5;
    box-shadow: 0 2px 5px rgba(0,0,0,0.08);
    position: relative;
}

.message.user { margin-left: auto; flex-direction: row-reverse; }
.message.user .avatar { background-color: #2563eb; margin-left: 8px; }
.message.user .message-bubble { background-color: #2563eb; color: white; border-bottom-right-radius: 5px; }

.message.assistant { margin-right: auto; }
.message.assistant .avatar { background-color: #059669; margin-right: 8px; }
.message.assistant .message-bubble { background-color: #ffffff; color: #1a202c; border: 1px solid #e2e8f0; border-bottom-left-radius: 5px; }

.avatar.speaking-leonorito {
    animation: speaking-pulse 0.8s ease-in-out infinite alternate;
}

@keyframes speaking-pulse {
    from { transform: scale(1); }
    to { transform: scale(1.08); }
}

.message .role {
    font-weight: 600;
    display: block;
    margin-bottom: 4px;
    font-size: 0.7rem;
    color: #4a5568;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Formulario de Envío */
.form-container {
    padding: 10px 15px;
    border-top: 1px solid #e2e8f0;
    background-color: #f8fafc;
    flex-shrink: 0;
}

textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    margin-bottom: 10px;
    border-radius: 20px;
    border: 1px solid #cbd5e0;
    min-height: 44px;
    max-height: 100px;
    font-size: 0.95rem;
    resize: vertical;
    transition: border-color 0.2s;
}

textarea:focus {
    border-color: #2563eb;
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

textarea[readonly] {
    background-color: #e9ecef;
    opacity: 0.7;
}

.buttons-container {
    display: flex;
    gap: 10px;
}

button {
    flex-grow: 1;
    background-color: #2563eb;
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background-color 0.2s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

button i { margin-right: 6px; }
button:hover { background-color: #1d4ed8; }
button:disabled { background-color: #94a3b8; cursor: not-allowed; }
button.new-chat-btn-js { background-color: #ef4444; }
button.new-chat-btn-js:hover { background-color: #dc2626; }

/* Modales */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    animation: fadeIn 0.3s;
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto;
    padding: 25px;
    border: 1px solid #888;
    width: 80%;
    max-width: 500px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    animation: slideIn 0.3s;
    position: relative;
}

.modal-close-button {
    color: #aaa;
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideIn { from { transform: translateY(-30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }


/* ================================= */
/* NUEVAS ANIMACIONES DE CARGA       */
/* ================================= */

/* Contenedor para la animación "Pensando..." */
.streaming-placeholder {
    display: flex;
    align-items: center;
    gap: 10px; /* Espacio entre el spinner y el texto */
}

/* El nuevo spinner circular */
.loader-spinner {
    width: 18px;
    height: 18px;
    border: 3px solid rgba(0, 0, 0, 0.1); /* Color base del círculo */
    border-top-color: #1a202c; /* Color del arco que gira */
    border-radius: 50%;
    animation: spinner-rotate 0.8s linear infinite;
}

/* Animación de rotación para el spinner */
@keyframes spinner-rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* El texto "Pensando" */
.loader-text {
    font-style: italic;
    color: #4a5568;
}

/* Animación para los puntos suspensivos */
.loader-text::after {
    content: '.';
    animation: ellipsis-anim 1.5s infinite;
}

@keyframes ellipsis-anim {
    0% { content: '.'; }
    33% { content: '..'; }
    66% { content: '...'; }
    100% { content: '.'; }
}

/* ================================= */
/* ESTILOS PARA MODAL DE CONFIRMACIÓN*/
/* ================================= */

.confirm-modal-content {
    max-width: 400px; /* Un poco más pequeño y centrado */
    text-align: center;
    padding: 30px;
}

.confirm-modal-header {
    margin-bottom: 15px;
}

.confirm-modal-header i {
    font-size: 2.5rem;
    color: #f8bb86; /* Un tono de advertencia suave */
}

.confirm-modal-header h2 {
    margin-top: 10px;
    margin-bottom: 5px;
    font-size: 1.4rem;
    color: #333;
    border-bottom: none;
}

#confirmModalText {
    color: #555;
    line-height: 1.6;
    margin-bottom: 25px;
}

.confirm-modal-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.modal-button {
    border: none;
    border-radius: 5px;
    padding: 10px 20px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.2s ease;
}

.modal-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.modal-button.cancel {
    background-color: #6c757d;
    color: white;
}

.modal-button.confirm {
    background-color: #d9534f; /* Rojo de confirmación/peligro */
    color: white;
}