/* =========================================================
   MENTES ALTUS IA - BLACK & WHITE ELEGANT (Gemini Style)
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;800&display=swap');

:root {
    --bg-main: #ffffff;
    --bg-sidebar: #f9f9f9;
    --text-main: #111111;
    --text-muted: #666666;
    --border-light: #e5e5e5;
    --border-dark: #000000;
    --accent: #000000;
    --ai-bg: #ffffff;
    --user-bg: #f4f4f4;
}

* { box-sizing: border-box; font-family: 'Inter', sans-serif; }
body, html { margin: 0; padding: 0; height: 100%; background: var(--bg-main); color: var(--text-main); }
.hidden { display: none !important; }

/* LAYOUT */
.app-layout { display: flex; height: 100vh; overflow: hidden; }

/* SIDEBAR */
.sidebar { 
    width: 280px; background: var(--bg-sidebar); 
    border-right: 1px solid var(--border-light); 
    display: flex; flex-direction: column; padding: 20px; 
}
.logo-area { font-size: 20px; font-weight: 800; margin-bottom: 30px; display: flex; align-items: center; gap: 10px; }
.new-chat-btn { 
    background: transparent; border: 1px solid var(--border-light); 
    padding: 12px; border-radius: 50px; cursor: pointer; 
    font-size: 14px; font-weight: 600; transition: 0.2s; 
    display: flex; align-items: center; justify-content: center; gap: 10px;
}
.new-chat-btn:hover { background: #eeeeee; }
.history-list { flex: 1; overflow-y: auto; margin-top: 30px; }
.history-label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; margin-bottom: 15px; }
.logout-link { color: var(--text-muted); text-decoration: none; padding-top: 20px; font-size: 14px; }
.logout-link:hover { color: var(--text-main); }

/* CHAT AREA PRINCIPAL */
.chat-area { flex: 1; display: flex; flex-direction: column; position: relative; }
#chat-window { 
    flex: 1; padding: 40px 20px 150px 20px; 
    overflow-y: auto; display: flex; flex-direction: column; gap: 40px; 
    max-width: 900px; margin: 0 auto; width: 100%;
}

.msg { display: flex; width: 100%; gap: 15px; }
.msg.user { flex-direction: row-reverse; }
.avatar { width: 35px; height: 35px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: #000; color: #fff; font-size: 14px; flex-shrink: 0; }
.msg.user .avatar { background: var(--border-light); color: var(--text-main); }

.bubble { 
    max-width: 85%; line-height: 1.7; font-size: 16px; 
    padding: 15px 20px; border-radius: 20px; 
}
.msg.ai .bubble { background: transparent; padding: 5px 0; }
.msg.user .bubble { background: var(--user-bg); }

/* INPUT FLOTANTE (ESTILO GEMINI) */
.floating-input-wrapper {
    position: absolute; bottom: 0; left: 0; width: 100%;
    background: linear-gradient(to top, rgba(255,255,255,1) 70%, rgba(255,255,255,0));
    padding: 20px; display: flex; flex-direction: column; align-items: center;
}
.tool-selector { display: flex; gap: 10px; margin-bottom: 10px; }
.tool-btn { 
    padding: 6px 15px; border: 1px solid var(--border-light); 
    background: white; border-radius: 20px; cursor: pointer; 
    font-size: 13px; color: var(--text-muted); transition: 0.2s; 
}
.tool-btn.active, .tool-btn:hover { background: var(--text-main); color: white; border-color: var(--text-main); }

.input-box {
    width: 100%; max-width: 850px; background: #f4f4f4; 
    border-radius: 30px; display: flex; align-items: flex-end; 
    padding: 10px 15px; transition: 0.3s; border: 1px solid transparent;
}
.input-box:focus-within { background: #ffffff; border-color: var(--border-light); box-shadow: 0 5px 20px rgba(0,0,0,0.05); }
#user-input { 
    flex: 1; height: 45px; max-height: 150px; background: transparent; border: none; 
    padding: 12px 10px; outline: none; font-size: 16px; resize: none; 
}
#send-btn { 
    width: 40px; height: 40px; background: var(--text-main); color: white; 
    border: none; border-radius: 50%; cursor: pointer; margin-bottom: 2px;
    display: flex; align-items: center; justify-content: center; font-size: 16px;
}
#send-btn:hover { background: #333333; }
.disclaimer { font-size: 11px; color: var(--text-muted); margin-top: 15px; text-align: center; }

/* =========================================================
   COMPONENTES INTERACTIVOS (FIXED FLASHCARDS)
   ========================================================= */

/* QUIZ */
.quiz-q { margin-bottom: 30px; }
.q-btn { 
    display: block; width: 100%; padding: 15px; margin: 8px 0; 
    border: 1px solid var(--border-light); background: white; border-radius: 12px; 
    cursor: pointer; text-align: left; font-size: 15px; transition: 0.2s; 
}
.q-btn:hover:not(:disabled) { border-color: var(--text-main); }
.q-btn[data-correct="true"].selected { background: #f4f4f4; border-color: var(--text-main); font-weight: bold; }
.q-btn[data-correct="false"].selected { background: #fff; color: #aaa; text-decoration: line-through; border-color: #eee; }

/* FLASHCARDS (SOLUCIONADO EL GIRO 3D) */
.flashcard-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; }
.flashcard { height: 180px; perspective: 1000px; cursor: pointer; }
.card-inner { 
    position: relative; width: 100%; height: 100%; 
    transition: transform 0.6s cubic-bezier(0.4, 0.2, 0.2, 1); 
    transform-style: preserve-3d;
}
.flashcard.flip .card-inner { transform: rotateY(180deg); }
.card-front, .card-back { 
    position: absolute; width: 100%; height: 100%; 
    backface-visibility: hidden; 
    display: flex; align-items: center; justify-content: center; 
    padding: 20px; text-align: center; border-radius: 16px;
    border: 1px solid var(--border-light); font-size: 15px;
}
.card-front { background: #ffffff; color: var(--text-main); }
.card-back { background: var(--text-main); color: #ffffff; transform: rotateY(180deg); }

/* ACORDEÓN */
.accordion { border: 1px solid var(--border-light); border-radius: 16px; overflow: hidden; }
.acc-header { background: #ffffff; padding: 18px 20px; cursor: pointer; font-weight: 600; display: flex; justify-content: space-between; border-bottom: 1px solid #f0f0f0; }
.acc-header:hover { background: #f9f9f9; }
.acc-body { padding: 20px; background: #fcfcfc; color: #444; border-bottom: 1px solid var(--border-light); line-height: 1.6; }

/* EVALUADOR */
.eval-box { border: 1px solid var(--border-light); padding: 25px; border-radius: 16px; }
.eval-text { background: #f9f9f9; padding: 20px; border-radius: 12px; margin-top: 15px; line-height: 1.8; }
.err { border-bottom: 2px dashed #000; padding: 0 2px; font-weight: 600; cursor: help; }

/* LOGIN */
.login-bg { height: 100vh; display: flex; justify-content: center; align-items: center; background: #ffffff; }
.login-box { width: 400px; text-align: center; }
.login-box h1 { font-size: 32px; font-weight: 800; margin: 0; }
.subtitle { color: var(--text-muted); margin-bottom: 40px; }
.login-box input { width: 100%; padding: 15px; margin: 10px 0; border: 1px solid var(--border-light); border-radius: 12px; outline: none; background: #f9f9f9; }
.login-box button { width: 100%; padding: 15px; background: var(--text-main); color: #fff; border: none; border-radius: 12px; font-weight: bold; cursor: pointer; margin-top: 10px; font-size: 16px; }

/* ESTILOS PARA LOS ITEMS DEL HISTORIAL */
.history-item {
    padding: 12px 15px;
    margin-bottom: 5px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border: 1px solid transparent;
    transition: 0.2s;
}

.history-item i { margin-right: 8px; }

.history-item:hover {
    background: #eeeeee;
    color: var(--text-main);
}

.history-item.active-chat {
    background: #ffffff;
    border-color: var(--border-light);
    color: var(--text-main);
    font-weight: 600;
}

/* =========================================================
   COMPATIBILIDAD MÓVIL Y RESPONSIVE
   ========================================================= */

.mobile-header {
    display: none; padding: 15px 20px; background: var(--bg-main);
    border-bottom: 1px solid var(--border-light);
    align-items: center; gap: 15px; font-weight: 600; font-size: 18px;
}
#menu-toggle {
    background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-main);
}

/* Reglas para pantallas pequeñas (Móviles y Tablets) */
@media (max-width: 768px) {
    .mobile-header { display: flex; }
    
    .sidebar {
        position: fixed; z-index: 1000; top: 0; left: -300px;
        height: 100vh; width: 280px;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 5px 0 20px rgba(0,0,0,0.1);
    }
    
    /* Clase que añadiremos con JS para abrir el menú */
    .sidebar.sidebar-open { left: 0; }
    
    #chat-window { padding: 20px 15px 150px 15px; }
    .floating-input-wrapper { padding: 10px; }
    .bubble { max-width: 95%; }
    .tool-selector { overflow-x: auto; padding-bottom: 10px; white-space: nowrap; }
}