/* =========================================
   1. VARIABLES Y RESETEO GLOBAL
   ========================================= */
:root {
    --bg-dark: #050b14;
    --bg-gradient: radial-gradient(circle at top, #0b192c, #000000);
    --teal: #008080;
    --cyan: #00e5ff;
    --text-main: #ffffff;
    --text-muted: #8892b0;
    --glass-bg: rgba(11, 25, 44, 0.7);
    --glass-border: rgba(0, 229, 255, 0.15);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', sans-serif; background: var(--bg-gradient); color: var(--text-main); height: 100vh; display: flex; flex-direction: column; overflow: hidden; }

.glass-panel { background: var(--glass-bg); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border: 1px solid var(--glass-border); box-shadow: var(--shadow); }
.hidden-screen { display: none !important; }
.active-screen { display: flex; }
.mt-10 { margin-top: 10px; }

#global-avisos-banner { width: 100%; display: flex; flex-direction: column; z-index: 1000; }
.aviso-item { background: rgba(255, 170, 0, 0.15); border-bottom: 1px solid rgba(255, 170, 0, 0.5); color: #ffcc00; padding: 10px 20px; font-size: 13px; font-weight: 600; text-align: center; display: flex; justify-content: space-between; align-items: center; }
.btn-delete-aviso { background: rgba(255,0,0,0.2); border: 1px solid red; color: red; border-radius: 4px; padding: 3px 8px; font-size: 11px; cursor: pointer; transition: 0.3s; }
.btn-delete-aviso:hover { background: red; color: white; }

#login-screen { flex-direction: column; padding: 45px 40px; border-radius: 20px; width: 100%; max-width: 380px; margin: auto; text-align: center; position: relative; overflow: hidden; box-shadow: 0 20px 50px rgba(0,0,0,0.8), 0 0 0 1px var(--glass-border); }
.login-glow { position: absolute; top: -50px; left: 50%; transform: translateX(-50%); width: 200px; height: 100px; background: var(--cyan); filter: blur(70px); opacity: 0.2; z-index: 0; pointer-events: none; }
.logo { font-size: 28px; font-weight: 800; letter-spacing: -1px; margin-bottom: 5px; color: var(--text-main); position: relative; z-index: 2; }
.logo span { color: var(--cyan); text-shadow: 0 0 12px rgba(0, 229, 255, 0.6); }
.small-logo { font-size: 20px; margin-bottom: 0; }
.subtitle { color: var(--text-muted); font-size: 11px; margin-bottom: 30px; letter-spacing: 1.5px; text-transform: uppercase; position: relative; z-index: 2;}

.input-group { position: relative; margin-bottom: 20px; width: 100%; display: flex; align-items: center; z-index: 2; }
.input-icon { position: absolute; left: 16px; color: var(--text-muted); transition: 0.3s; z-index: 2; pointer-events: none; }
.input-group:focus-within .input-icon { color: var(--cyan); filter: drop-shadow(0 0 5px rgba(0,229,255,0.4)); }
input { width: 100%; padding: 14px 16px 14px 48px; background: rgba(0, 0, 0, 0.6); border: 1px solid rgba(0, 128, 128, 0.5); color: #fff; border-radius: 12px; font-size: 14px; outline: none; transition: 0.3s; }
input:focus { border-color: var(--cyan); box-shadow: 0 0 12px rgba(0, 229, 255, 0.2); background: rgba(0,0,0,0.8); }

.pwd-container .toggle-pwd { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); cursor: pointer; color: var(--text-muted); display: flex; align-items: center; justify-content: center; transition: 0.3s; z-index: 3;}
.pwd-container .toggle-pwd:hover { color: var(--cyan); }
.error-msg { color: #ff4d4d; font-size: 13px; height: 18px; margin-bottom: 15px; font-weight: 500; position: relative; z-index: 2;}

button { width: 100%; padding: 14px; border: none; border-radius: 12px; font-size: 14px; font-weight: 600; cursor: pointer; transition: 0.3s; display: flex; justify-content: center; align-items: center; z-index: 2; }
.btn-primary { background: linear-gradient(135deg, var(--teal), var(--cyan)); color: #000; font-weight: 800; box-shadow: 0 4px 15px rgba(0, 229, 255, 0.3); }
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0, 229, 255, 0.5); }
.btn-primary:disabled { background: #333; color: #888; box-shadow: none; cursor: not-allowed; }
.btn-secondary { background: transparent; border: 1px solid var(--cyan); color: var(--cyan); }
.btn-secondary:hover { background: rgba(0, 229, 255, 0.1); }
.btn-warning { background: transparent; border: 1px solid #ffcc00; color: #ffcc00; }
.btn-warning:hover { background: rgba(255, 204, 0, 0.1); }

#app-screen { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.navbar { padding: 15px 30px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--glass-border); z-index: 10; }
.user-controls { display: flex; align-items: center; gap: 20px; }
.user-badge { font-size: 13px; color: var(--text-muted); }
#display-user { color: var(--cyan); font-weight: 600; }
.btn-logout { width: auto; padding: 6px 12px; background: transparent; border: 1px solid #ff4d4d; color: #ff4d4d; border-radius: 8px; font-size: 12px; }
.btn-logout:hover { background: rgba(255, 77, 77, 0.1); }

.app-body { display: flex; flex: 1; overflow: hidden; }
.chat-section { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.typewriter-container { text-align: center; padding: 25px 20px 5px; min-height: 75px; }
#typewriter-text { font-size: 28px; font-weight: 800; background: linear-gradient(90deg, #fff, var(--cyan)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.cursor { font-size: 28px; color: var(--cyan); animation: blink 0.8s infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

.chat-container { flex: 1; overflow-y: auto; padding: 30px 50px; display: flex; flex-direction: column; gap: 20px; scroll-behavior: smooth; }
.chat-container::-webkit-scrollbar { width: 5px; }
.chat-container::-webkit-scrollbar-thumb { background: rgba(0, 229, 255, 0.3); border-radius: 10px; }
.mensaje { max-width: 70%; padding: 16px 22px; font-size: 14.5px; line-height: 1.6; border-radius: 18px; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.msg-user { align-self: flex-end; background: linear-gradient(135deg, #008080 0%, #00b4d8 100%); color: #ffffff; border-bottom-right-radius: 4px; box-shadow: 0 4px 20px rgba(0, 229, 255, 0.3); font-weight: 500; }
.msg-ai { align-self: flex-start; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--glass-border); color: #e0e6ed; border-bottom-left-radius: 4px; }

.thinking-indicator { display: flex; gap: 5px; padding: 5px; align-items: center; }
.dot { width: 7px; height: 7px; background: var(--cyan); border-radius: 50%; animation: bounce 1.4s infinite ease-in-out; }
.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }

.input-area { padding: 25px 50px; border-top: 1px solid var(--glass-border); background: #02060c; flex-shrink: 0; }
.input-wrapper { display: flex; gap: 12px; max-width: 900px; margin: 0 auto; position: relative; }
.input-wrapper input { border-radius: 30px; padding: 18px 28px; padding-right: 65px; background: rgba(0,0,0,0.5); border: 1px solid rgba(0, 229, 255, 0.2); }

/* AQUÍ ESTÁ LA MAGIA DEL BOTÓN PERFECTAMENTE ALINEADO */
.input-wrapper button { 
    position: absolute; 
    right: 8px; 
    top: 50%; 
    transform: translateY(-50%); 
    width: 48px; 
    height: 48px; 
    padding: 0; 
    border-radius: 50%; 
}

#admin-panel { width: 350px; border-left: 1px solid var(--glass-border); padding: 25px; overflow-y: auto; background: rgba(0,0,0,0.3); flex-shrink: 0; }
.admin-title { color: var(--cyan); margin-bottom: 25px; font-size: 15px; font-weight: 700; text-transform: uppercase; letter-spacing: 2px; }
.admin-section { margin-bottom: 25px; background: rgba(255, 255, 255, 0.03); padding: 20px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.05); }
.admin-section h4 { font-size: 11px; color: var(--text-muted); margin-bottom: 15px; text-transform: uppercase; letter-spacing: 1px; }
.modern-select { width: 100%; padding: 12px; background: #050b14; color: #fff; border: 1px solid var(--teal); border-radius: 8px; outline: none; }
.custom-file-upload { display: flex; align-items: center; justify-content: center; padding: 18px; background: rgba(0, 229, 255, 0.05); border: 1px dashed var(--cyan); border-radius: 10px; cursor: pointer; transition: 0.3s; }
.custom-file-upload:hover { background: rgba(0, 229, 255, 0.1); border-style: solid; }
.custom-file-upload input[type="file"] { display: none; }
.file-text { font-size: 13px; color: var(--cyan); font-weight: 600; text-align: center; }
.status-text { font-size: 12px; margin-top: 10px; text-align: center; font-weight: 500; }
.historial-container { margin-top: 15px; max-height: 250px; overflow-y: auto; }
.chat-log-item { background: rgba(0, 0, 0, 0.5); padding: 15px; border-radius: 8px; margin-bottom: 12px; border-left: 3px solid var(--cyan); }
.chat-log-meta { font-size: 11px; color: var(--text-muted); margin-bottom: 6px; }
.chat-log-q { font-size: 13px; font-weight: 600; color: #fff; margin-bottom: 4px; }
.chat-log-a { font-size: 12px; color: #aaa; }

@media (max-width: 1000px) {
    /* Tu regla original para ocultar el panel admin en pantallas medias */
    #admin-panel { position: fixed; right: -100%; top: 0; height: 100%; z-index: 100; transition: 0.4s; }
    .chat-container { padding: 20px; }
    .input-area { padding: 20px; }
}

/* =========================================
   📱 ADAPTACIÓN ESTRICTA PARA MÓVILES (TU DISEÑO)
   ========================================= */

@media screen and (max-width: 768px) {
    /* Ajustes del login */
    #login-screen { padding: 30px 20px; }
    .logo { font-size: 24px; }
    
    /* Cuerpo de la app: aseguramos que no haga scroll la pantalla entera */
    .app-body { flex-direction: column; overflow: hidden; }
    
    .typewriter-container { padding: 15px 15px 0; min-height: 50px; }
    #typewriter-text, .cursor { font-size: 20px; }

    .chat-container { padding: 15px; }
    .mensaje { max-width: 90%; font-size: 13.5px; padding: 12px 16px; }

    /* ANCLAJE DEL INPUT: Nunca se sale de la pantalla */
    .input-area { 
        padding: 15px; 
        flex-shrink: 0; /* Prohíbe que el chat lo aplaste */
        padding-bottom: 25px; /* Un poco de margen inferior para los dedos */
    }
    
    .input-wrapper input { 
        padding: 14px 20px; 
        padding-right: 55px; /* Espacio exacto para el botón */
    }
    
    .input-wrapper button { 
        width: 40px; 
        height: 40px; 
        right: 5px; 
    }

    /* El admin panel se coloca debajo de forma natural si estuviera visible */
    #admin-panel { 
        position: relative; 
        right: 0; 
        width: 100%; 
        border-left: none; 
        border-top: 1px solid var(--glass-border); 
        height: auto; 
    }
}