/* ==========================================================================
   Gemini EduTutor - Estilos Principales
   ========================================================================== */

/* Contenedor principal del chat */
#chat-container {
    max-width: 800px;
    margin: 20px auto;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #ffffff;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 70vh; /* Ocupa el 70% del alto de la pantalla */
    min-height: 500px;
}

/* Área donde aparecen los mensajes */
#chat-box {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
    background-color: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 15px;
    scroll-behavior: smooth;
}

/* ==========================================================================
   Estructura de los Mensajes (Clases dinámicas inyectadas por JS)
   ========================================================================== */

.message-row {
    display: flex;
    width: 100%;
    align-items: flex-end;
}

/* Alineación Usuario vs IA */
.justify-end { justify-content: flex-end; }
.justify-start { justify-content: flex-start; }
.text-right { text-align: right; }
.text-left { text-align: left; }

/* Burbujas de chat */
.message-bubble {
    padding: 12px 16px;
    border-radius: 12px;
    display: inline-block;
    max-width: 80%;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    line-height: 1.5;
    font-size: 15px;
    word-wrap: break-word;
}

/* Colores de las burbujas */
.bg-blue-100 { 
    background-color: #dbeafe; 
    color: #1e3a8a; 
    border-bottom-right-radius: 2px; /* Efecto de cola de globo de texto */
}
.bg-gray-100 { 
    background-color: #ffffff; 
    color: #374151; 
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 2px;
}

/* Avatares */
.w-8 { width: 32px; }
.h-8 { height: 32px; }
.rounded-full { border-radius: 50%; object-fit: cover; }
.mr-2 { margin-right: 8px; }
.ml-2 { margin-left: 8px; }

/* Animación de "Pensando..." */
#ag-loading {
    font-style: italic;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .5; }
}

/* ==========================================================================
   Elementos Markdown dentro de las respuestas de Gemini
   ========================================================================== */

.message-bubble h1, 
.message-bubble h2, 
.message-bubble h3 {
    margin-top: 10px;
    margin-bottom: 10px;
    font-weight: 600;
    color: #111827;
}

.message-bubble h1 { font-size: 1.25rem; }
.message-bubble h2 { font-size: 1.1rem; }

.message-bubble ul, .message-bubble ol {
    margin-left: 20px;
    margin-top: 10px;
    margin-bottom: 10px;
}

.message-bubble li {
    margin-bottom: 5px;
}

/* Formato para tablas de Markdown */
.message-bubble table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    font-size: 14px;
}

.message-bubble th, .message-bubble td {
    border: 1px solid #d1d5db;
    padding: 8px 12px;
}

.message-bubble th {
    background-color: #f3f4f6;
    font-weight: bold;
}

/* Bloques de código (para los juegos o snippets) */
.message-bubble pre {
    background-color: #1f2937;
    color: #e5e7eb;
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    margin-top: 10px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 13px;
}

.message-bubble code {
    background-color: rgba(0,0,0,0.05);
    padding: 2px 5px;
    border-radius: 4px;
    font-family: monospace;
}

.message-bubble pre code {
    background-color: transparent;
    padding: 0;
}

/* ==========================================================================
   Controles del Usuario (Input y Botones)
   ========================================================================== */

#input-container {
    display: flex;
    padding: 15px;
    background-color: #ffffff;
    border-top: 1px solid #e5e7eb;
    gap: 10px;
    align-items: flex-end;
}

#user-input {
    flex-grow: 1;
    min-height: 50px;
    max-height: 120px;
    resize: none; /* Evita que el usuario rompa el diseño arrastrando la esquina */
    border: 1px solid #d1d5db;
    border-radius: 10px;
    padding: 12px 15px;
    font-size: 15px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#user-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* Botones principales de acción */
#angloGPTsend, #read-aloud-btn {
    background-color: #6366f1; /* Azul índigo moderno */
    color: white;
    border: none;
    border-radius: 10px;
    width: 50px;
    height: 50px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s;
    flex-shrink: 0; /* Evita que se encojan si el textarea crece */
}

#angloGPTsend:hover {
    background-color: #4f46e5;
    transform: translateY(-1px);
}

#read-aloud-btn {
    background-color: #10b981; /* Verde esmeralda para voz */
}

#read-aloud-btn:hover {
    background-color: #059669;
    transform: translateY(-1px);
}

/* Botón inyectado para jugar/ver simulaciones */
.play-game-btn {
    background-color: #10b981;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    margin-top: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
}

.play-game-btn:hover {
    background-color: #059669;
    box-shadow: 0 4px 6px rgba(16, 185, 129, 0.3);
    transform: translateY(-1px);
}