/* ============================================
   ESTILOS DE INTERFAZ (UI, CHAT, LOGIN, MENÃšS)
   ============================================ */

@charset "utf-8";

body {
  margin: 0;
  padding: 0;
  font-family: Arial, sans-serif;
  background: #ece5dd;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ============================================
   LOGIN
   ============================================ */
#login {
  padding: 15px;
  border-bottom: 1px solid #ddd;
  flex-shrink: 0;
}

#login h3 {
  text-align: center;
  margin-bottom: 20px;
  color: #333;
}

#loginForm input {
  width: 100%;
  padding: 10px;
  margin: 8px 0;
  border: 1px solid #ccc;
  border-radius: 6px;
  box-sizing: border-box;
}

#loginForm button {
  width: 100%;
  padding: 10px;
  background: #25d366;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
}

#loginForm button:hover {
  background: #1da851;
}

.mensaje {
  margin-top: 10px;
  font-size: 14px;
  color: red;
  text-align: center;
}

#mensaje {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  background: #f9f9f9;
  border-radius: 0 0 10px 10px;
}

/* ============================================
   CHAT FLOTANTE
   ============================================ */
.chat-flotante {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 360px;
  max-width: 95vw;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 0 20px rgba(0,0,0,0.3);
  z-index: 2000;
  display: flex;
  flex-direction: column;
}

.input-area {
  display: flex;
  align-items: center;
  padding: 10px;
  background: #f0f0f0;
}

.input-area input {
  flex: 1;
  padding: 8px;
  border: none;
  border-radius: 20px;
  outline: none;
  margin-right: 8px;
}

.input-area button {
  background: #25d366;
  border: none;
  color: #fff;
  padding: 10px;
  border-radius: 50%;
  cursor: pointer;
  margin-left: 5px;
}

.input-area button:hover {
  background: #20b858;
}

.message {
  margin: 5px 0;
  padding: 8px 12px;
  background: #dcf8c6;
  border-radius: 8px;
  max-width: 70%;
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background: #ffffff;
  border-right: 1px solid #ccc;
  box-shadow: 2px 0 8px rgba(0,0,0,0.2);
  padding: 20px;
  overflow-y: auto;
  z-index: 1;
  transition: transform 0.3s ease;
}

.sidebar h3 {
  margin-top: 0;
  color: #25d366;
  text-align: center;
}

/* ============================================
   BOTONES GENERALES UI
   ============================================ */
.submit {
    background-color: #4CAF50;
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

#submit:hover {
    background-color: #45a049;
}

#submit:active {
    transform: scale(0.95);
}

/* ============================================
   BOTÃ“N CERRAR
   ============================================ */
.cerrar {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: #999;
    font-size: 14px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 10;
    line-height: 1;
}

.cerrar:hover {
    background: rgba(255, 80, 80, 0.15);
    border-color: rgba(255, 80, 80, 0.4);
    color: #ff5050;
    transform: scale(1.05);
}

.cerrar:active {
    transform: scale(0.92);
}

/* ============================================
   PANELES FLOTANTES (Login y Chat)
   ============================================ */
.login-flotante, .inputArea {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #ffffff;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0,0,0,0.3);
    width: 220px;
    height: 320px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;  
    overflow-x: hidden; 
    padding: 10px;     
}

.inputArea{
    width:330px;
    height:400px;
}

.login-flotante { z-index: 1000; }
.inputArea { z-index: 1001; background: #f9f9f9; }

/* ============================================
   PIN DE ACCESO
   ============================================ */
#escribePin {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 10px;
    gap: 15px;
}
#escribePin h3 { margin: 0 0 10px 0; color: #333; }
#escribePin .cajasTexto { width: 80%; }

/* ============================================
   INPUTS Y BOTONES GENERALES (UI)
   ============================================ */
.cajasTexto {
    width: 100%;
    padding: 12px 14px;
    background: #ffffff;
    border: 1px solid #d0d0d0;
    border-radius: 8px;
    color: #1a1a1a;
    font-family: inherit;
    font-size: 14px;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s;
}
.cajasTexto:focus { border-color: #e07a3a; }

.cajasTexto::placeholder {
    color: #aaa;
}

/* ============================================
   ESTRUCTURA INTERNA DEL CHAT (Flexbox)
   ============================================ */
.chat_header {
    padding: 12px;
    background: #fff;
    font-size: 15px;
    font-weight: 700;
    color: #1a1a1a;
    border-bottom: 1px solid #e5e5e5;
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#conversacionPIN {
    padding: 10px;
    background: #fff;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-buttons {
    display: flex;
    gap: 6px;
}
.chat-buttons button {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid #d0d0d0;
    border-radius: 8px;
    color: #777;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
}
.chat-buttons button:hover {
    background: #f5f5f5;
    color: #1a1a1a;
    border-color: #e07a3a;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #f9f9f9;
    width: 430px;
}

.editionArea {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

.editionArea:focus-within {
  border-color: #0078d7;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(0,120,215,0.2);
}

.editionArea textarea {
    width: 100%;
    height: 350px;
    padding: 12px;
    background: #ffffff;
    border: 1px solid #d0d0d0;
    border-radius: 8px;
    color: #1a1a1a;
    font-family: inherit;
    font-size: 13px;
    outline: none;
    resize: vertical;
    box-sizing: border-box;
}

.editionArea textarea:focus {
    border-color: #e07a3a;
}

#textoIaCopiado {
    flex: 1;
    width: 100%;
    font-size: 15px;
    font-family: 'Segoe UI', sans-serif;
    padding: 15px;
    border: none;
    outline: none;
    resize: none;
    background: #fff;
    color: #333;
    box-sizing: border-box;
}

/* ============================================
   MENSAJES DE IA 
   ============================================ */
/* (Arriba ya estÃ¡ .message del chat, este es para sobreescribir si es necesario) */

/* ============================================
   BOTONES DE LA CABECERA (Minimizar/Cerrar)
   ============================================ */
.chat-header-botones {
    display: flex;
    gap: 5px;
}

.chat-header-botones button {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #666;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.chat-header-botones button:hover {
    background: #f0f0f0;
    color: #333;
}

/* ============================================
   BOTÃ“N MINIMIZAR / MAXIMIZAR
   ============================================ */
.btn-minimizar {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    color: #888;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 20;
}

.btn-minimizar:hover {
    background: #f0f0f0;
    color: #333;
    border-color: #aaa;
}

.btn-minimizar:active {
    transform: scale(0.9);
}

.inputArea.minimizado .btn-minimizar {
    right: 50%;
    transform: translateX(50%);
    top: 50%;
    margin-top: -15px;
}

.loginBox.minimizado .btn-minimizar:hover {
    transform: translateX(50%) scale(1.05);
}

#iconoMinimizar {
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.inputArea.minimizado #iconoMinimizar {
    transform: rotate(180deg);
}

.loginBox.minimizado #iconoMinimizar {
    transform: rotate(180deg);
}

/* ============================================
   ESTADO MINIMIZADO (Burbujas y Transiciones)
   ============================================ */
.inputArea.minimizado {
    width: 50px;
}

.inputArea.minimizado .chat_header,
.inputArea.minimizado .chat-container,
.inputArea.minimizado .messages,
.inputArea.minimizado .editionArea {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.05s ease;
}

.loginBox.minimizado .chat_header,
.loginBox.minimizado .chat-container,
.loginBox.minimizado .messages,
.loginBox.minimizado .editionArea {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.05s ease;
}

.chat_header,
.chat-container,
.messages,
.editionArea {
    opacity: 1;
    transition: opacity 0.15s ease 0.05s;
}

.login-flotante.minimizado, 
.inputArea.minimizado {
    width: 60px !important;
    height: 60px !important;
    border-radius: 50% !important;
    bottom: 20px !important;
    right: 20px !important;
    top: auto !important;
    left: auto !important;
    transform: none !important;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    background: #4CAF50 !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.login-flotante.minimizado > *, 
.inputArea.minimizado > * {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.1s;
}

.login-flotante.minimizado::after, 
.inputArea.minimizado::after {
    content: 'ðŸ’¬';
    font-size: 28px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 1;
}

.login-flotante.minimizado {
    width: 20px;
}
.login-flotante.minimizado #login,
.login-flotante.minimizado #mensaje {
    opacity: 0;
    pointer-events: none;
}

.login-flotante.minimizado {
    width: 60px;
    height: 60px;
    border-radius: 50%;
}
.login-flotante.minimizado #cerrarinputArea {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* ============================================
   VENTANA DE DESCARGAS
   ============================================ */
#descargas {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  border: 2px solid #ccc;
  border-radius: 8px;
  width: 400px;
  max-width: 90%;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  z-index: 1000;
}

.ventana-header {
  background: #0078d7;
  color: #fff;
  padding: 10px;
  cursor: move;
  border-radius: 6px 6px 0 0;
  font-weight: bold;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.close-btn {
  cursor: pointer;
  font-size: 18px;
  font-weight: bold;

  transition: color 0.3s;
}

.close-btn:hover {
  color: #ff4d4d;
}

#limitImg {
  padding: 15px;
}

#upload-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#upload-form input[type="text"],
#upload-form input[type="file"],
#upload-form input[type="submit"] {
  width: 100%;
  padding: 8px;
  border: 1px solid #aaa;
  border-radius: 5px;
  font-size: 14px;
  box-sizing: border-box;
}

#upload-form input[type="submit"] {
  background: #0078d7;
  color: #fff;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.3s;
}

#upload-form input[type="submit"]:hover {
  background: #005a9e;
}

.progress {
  width: 100%;
  height: 18px;
  border-radius: 5px;
  overflow: hidden;
  appearance: none;
}

.progress::-webkit-progress-bar {
  background-color: #eee;
}

.progress::-webkit-progress-value {
  background-color: #0078d7;
}

.progress::-moz-progress-bar {
  background-color: #0078d7;
}

/* ============================================
   LOGIN BOX
   ============================================ */
#loginBox {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #ffffff;
  padding: 25px;
  border-radius: 10px;
  box-shadow: 0 0 20px rgba(0,0,0,0.3);
  width: 320px;
  z-index: 1000;
  overflow: visible;
}

/* ============================================
   MENÃšS
   ============================================ */
ul.menu {
    list-style: none;
    padding: 0;
    margin: 0;
    background-color: #f0f0f0;
    display: flex;
    flex-wrap: wrap;
    z-index: 1000;
    position: relative;
}

ul.menu li.deli {
    position: relative;
    padding: 0;
    margin: 0;
}

.myButtonMenu {
  background: #ffffff;
  border: 2px solid #ccc;
  border-radius: 25px;
  padding: 8px 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 500;
  color: #333;
  transition: all 0.3s ease;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.myButtonMenu:hover {
  background: #f5f5f5;
  border-color: #999;
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.myButtonMenu:active {
  background: #e0e0e0;
  transform: scale(0.97);
}

ul.submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    display: none;
    position: absolute;
    left: 0;
    top: 100%;
    min-width: 200px;
    background-color: #fff;
    border: 1px solid #ccc;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
}

ul.submenu li {
    width: 100%;
    display: block;
}

ul.submenu ul.submenu {
    top: 0;
    left: 100%;
}

ul.menu li.has-submenu:hover > ul.submenu {
    display: block;
}

.has-submenu > button::after {
    content: " ?";
    font-size: 10px;
    margin-left: 5px;
    color: #666;
}

ul.submenu .has-submenu > button::after {
    content: " ?";
}

/* --- LÃ“GICA MÃ“VIL --- */
@media (max-width: 768px) {
  .chat-flotante {
    width: 95%;
    right: 2.5%;
    top: 10px;
  }

  ul.menu {
      flex-direction: column;
  }
  
  ul.submenu {
      position: static;
      box-shadow: none;
      border: none;
      background-color: #e0e0e0;
      width: 100%;
  }
  
  ul.submenu {
      display: none;
  }
  
  ul.submenu.show-submenu {
      display: block;
  }
}
/* 1. Forzar al contenedor a NO crecer y poner scroll si hay mucho texto */
.contenedor {
    height: 300px; /* El alto que ya tienes */
    overflow-y: auto; /* <-- ESTO ES CLAVE: pone scroll vertical y evita que se expanda */
    overflow-x: hidden;
    line-height: 1.5;
}

div[contenteditable="true"] img {
    max-width: 150px;   /* ancho máximo */
    max-height: 150px;  /* alto máximo */
    height: auto;       /* mantiene proporción */
    width: auto;        /* mantiene proporción */
    object-fit: contain; /* evita deformaciones */
}


/* Ocultar login flotante cuando la pantalla completa está activa */
#newLoginScreen.active ~ #loginBox {
  display: none !important;
}

/* Cuando se valide y se oculta newLoginScreen, el sistema ocupa todo */
#infoBox {
  min-height: 100vh;
  width: 100%;
 
}
