/* style.css — Estilos globales de Cónclave */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --fondo-principal: #0d0d0d;
  --fondo-sidebar: #111118;
  --fondo-chat: #0d0d0d;
  --burbuja-usuario: #2d2d5b;
  --burbuja-agente: #1a1a2e;
  --acento: #7c6af7;
  --acento-hover: #9d8fff;
  --acento-dim: rgba(124, 106, 247, 0.15);
  --texto: #e8e8f0;
  --texto-secundario: #8888a8;
  --texto-apagado: #555570;
  --borde: #222232;
  --borde-activo: #333350;
  --input-fondo: #18181f;
  --danger: #e05c6e;
  --danger-dim: rgba(224, 92, 110, 0.15);
  --success: #4caf8a;
  --radio: 12px;
  --radio-msg: 16px;
  --fuente: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --sombra: 0 4px 24px rgba(0,0,0,0.5);
}

html, body {
  height: 100%;
  font-family: var(--fuente);
  background: var(--fondo-principal);
  color: var(--texto);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ──────────────── LOGIN ──────────────── */
.pantalla-login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.caja-login {
  background: var(--fondo-sidebar);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  padding: 48px 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--sombra);
}

.logo-login {
  text-align: center;
  margin-bottom: 32px;
}

.logo-login h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--acento);
  letter-spacing: -0.5px;
}

.logo-login p {
  color: var(--texto-secundario);
  font-size: 13px;
  margin-top: 6px;
}

.campo-form {
  margin-bottom: 16px;
}

.campo-form label {
  display: block;
  font-size: 13px;
  color: var(--texto-secundario);
  margin-bottom: 6px;
  font-weight: 500;
}

.campo-form input {
  width: 100%;
  padding: 12px 14px;
  background: var(--input-fondo);
  border: 1px solid var(--borde);
  border-radius: 8px;
  color: var(--texto);
  font-size: 15px;
  font-family: var(--fuente);
  outline: none;
  transition: border-color 0.2s;
}

.campo-form input:focus {
  border-color: var(--acento);
}

.btn-primario {
  width: 100%;
  padding: 13px;
  background: var(--acento);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--fuente);
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  margin-top: 8px;
}

.btn-primario:hover { background: var(--acento-hover); }
.btn-primario:active { transform: scale(0.98); }
.btn-primario:disabled { opacity: 0.6; cursor: not-allowed; }

.error-login {
  color: var(--danger);
  font-size: 13px;
  text-align: center;
  margin-top: 12px;
  min-height: 20px;
}

/* ──────────────── LAYOUT PRINCIPAL ──────────────── */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ──────────────── SIDEBAR ──────────────── */
.sidebar {
  width: 260px;
  min-width: 220px;
  max-width: 320px;
  background: var(--fondo-sidebar);
  border-right: 1px solid var(--borde);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-cabecera {
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--borde);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-cabecera h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--acento);
  letter-spacing: -0.3px;
}

.btn-icono {
  background: none;
  border: none;
  color: var(--texto-secundario);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: background 0.2s, color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
}

.btn-icono:hover {
  background: var(--acento-dim);
  color: var(--acento);
}

.lista-agentes {
  flex: 1;
  overflow-y: auto;
  padding: 8px 8px;
}

.lista-agentes::-webkit-scrollbar { width: 4px; }
.lista-agentes::-webkit-scrollbar-track { background: transparent; }
.lista-agentes::-webkit-scrollbar-thumb { background: var(--borde-activo); border-radius: 2px; }

.agente-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  gap: 10px;
  position: relative;
}

.agente-item:hover { background: var(--acento-dim); }
.agente-item.activo { background: var(--acento-dim); }
.agente-item.activo .agente-nombre { color: var(--acento); }

.agente-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--acento-dim);
  border: 1px solid var(--acento);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  color: var(--acento);
  font-weight: 700;
}

.agente-info {
  flex: 1;
  min-width: 0;
}

.agente-nombre {
  font-size: 14px;
  font-weight: 600;
  color: var(--texto);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agente-desc {
  font-size: 12px;
  color: var(--texto-secundario);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge-permanente {
  font-size: 9px;
  background: var(--acento-dim);
  color: var(--acento);
  border-radius: 4px;
  padding: 1px 5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.sidebar-pie {
  padding: 12px 16px;
  border-top: 1px solid var(--borde);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.version-info {
  font-size: 11px;
  color: var(--texto-apagado);
  cursor: default;
}

.btn-salir {
  background: none;
  border: none;
  color: var(--texto-apagado);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
  font-family: var(--fuente);
}

.btn-salir:hover { color: var(--danger); background: var(--danger-dim); }

/* ──────────────── ÁREA DE CHAT ──────────────── */
.area-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--fondo-chat);
}

.chat-cabecera {
  padding: 16px 24px;
  border-bottom: 1px solid var(--borde);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 65px;
  flex-shrink: 0;
}

.chat-cabecera-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-nombre {
  font-size: 16px;
  font-weight: 700;
  color: var(--texto);
}

.chat-desc {
  font-size: 12px;
  color: var(--texto-secundario);
}

.acciones-agente {
  display: flex;
  gap: 6px;
}

.chat-vacio {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--texto-apagado);
  gap: 12px;
}

.chat-vacio-icono {
  font-size: 48px;
  opacity: 0.3;
}

.chat-vacio-texto {
  font-size: 14px;
}

/* ──────────────── MENSAJES ──────────────── */
.contenedor-mensajes {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.contenedor-mensajes::-webkit-scrollbar { width: 6px; }
.contenedor-mensajes::-webkit-scrollbar-track { background: transparent; }
.contenedor-mensajes::-webkit-scrollbar-thumb { background: var(--borde-activo); border-radius: 3px; }

.mensaje {
  display: flex;
  flex-direction: column;
  max-width: 75%;
}

.mensaje.usuario {
  align-self: flex-end;
  align-items: flex-end;
}

.mensaje.agente {
  align-self: flex-start;
  align-items: flex-start;
}

.burbuja {
  padding: 12px 16px;
  border-radius: var(--radio-msg);
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
}

.mensaje.usuario .burbuja {
  background: var(--burbuja-usuario);
  border-bottom-right-radius: 4px;
  color: var(--texto);
}

.mensaje.agente .burbuja {
  background: var(--burbuja-agente);
  border-bottom-left-radius: 4px;
  color: var(--texto);
  border: 1px solid var(--borde);
}

.mensaje-hora {
  font-size: 11px;
  color: var(--texto-apagado);
  margin-top: 4px;
  padding: 0 4px;
}

.cursor-escritura {
  display: inline-block;
  width: 8px;
  height: 14px;
  background: var(--acento);
  margin-left: 2px;
  animation: parpadear 1s step-end infinite;
  border-radius: 1px;
  vertical-align: middle;
}

@keyframes parpadear {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ──────────────── INPUT DE MENSAJE ──────────────── */
.zona-input {
  padding: 16px 24px;
  border-top: 1px solid var(--borde);
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-shrink: 0;
}

.input-mensaje {
  flex: 1;
  background: var(--input-fondo);
  border: 1px solid var(--borde);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--texto);
  font-size: 14px;
  font-family: var(--fuente);
  resize: none;
  outline: none;
  min-height: 48px;
  max-height: 200px;
  transition: border-color 0.2s;
  line-height: 1.5;
}

.input-mensaje:focus { border-color: var(--acento); }
.input-mensaje::placeholder { color: var(--texto-apagado); }

.btn-enviar {
  background: var(--acento);
  border: none;
  border-radius: 10px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  flex-shrink: 0;
  color: white;
  font-size: 18px;
}

.btn-enviar:hover { background: var(--acento-hover); }
.btn-enviar:active { transform: scale(0.95); }
.btn-enviar:disabled { opacity: 0.5; cursor: not-allowed; }

/* ──────────────── MODAL ──────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
  backdrop-filter: blur(4px);
}

.modal-overlay.oculto { display: none; }

.modal {
  background: var(--fondo-sidebar);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  padding: 32px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--sombra);
}

.modal h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--texto);
}

.modal .campo-form { margin-bottom: 14px; }

.modal textarea {
  width: 100%;
  padding: 12px 14px;
  background: var(--input-fondo);
  border: 1px solid var(--borde);
  border-radius: 8px;
  color: var(--texto);
  font-size: 14px;
  font-family: var(--fuente);
  resize: vertical;
  min-height: 80px;
  outline: none;
  transition: border-color 0.2s;
  line-height: 1.5;
}

.modal textarea:focus { border-color: var(--acento); }

.modal-acciones {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

.btn-secundario {
  padding: 10px 18px;
  background: none;
  border: 1px solid var(--borde);
  border-radius: 8px;
  color: var(--texto-secundario);
  font-size: 14px;
  font-family: var(--fuente);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.btn-secundario:hover { border-color: var(--borde-activo); color: var(--texto); }

.btn-peligro {
  padding: 10px 18px;
  background: var(--danger-dim);
  border: 1px solid var(--danger);
  border-radius: 8px;
  color: var(--danger);
  font-size: 14px;
  font-family: var(--fuente);
  cursor: pointer;
  transition: background 0.2s;
}

.btn-peligro:hover { background: rgba(224, 92, 110, 0.3); }

.btn-modal-ok {
  padding: 10px 20px;
  background: var(--acento);
  border: none;
  border-radius: 8px;
  color: white;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--fuente);
  cursor: pointer;
  transition: background 0.2s;
}

.btn-modal-ok:hover { background: var(--acento-hover); }
.btn-modal-ok:disabled { opacity: 0.5; cursor: not-allowed; }

/* ──────────────── NOTIFICACIONES TOAST ──────────────── */
.contenedor-toasts {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
}

.toast {
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--sombra);
  animation: entrarToast 0.3s ease;
  max-width: 320px;
}

.toast.exito {
  background: rgba(76, 175, 138, 0.15);
  border: 1px solid var(--success);
  color: var(--success);
}

.toast.error {
  background: var(--danger-dim);
  border: 1px solid var(--danger);
  color: var(--danger);
}

@keyframes entrarToast {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ──────────────── UTILIDADES ──────────────── */
.oculto { display: none !important; }

/* ──────────────── RESPONSIVE BÁSICO ──────────────── */
@media (max-width: 768px) {
  /* Layout: sidebar oculta por defecto, overlay al abrir */
  .app { position: relative; overflow: hidden; }

  .sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100%;
    width: 80vw;
    max-width: 300px;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,0.5);
  }
  .sidebar.abierta { transform: translateX(0); }

  /* Overlay oscuro al abrir sidebar */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 199;
  }
  .sidebar-overlay.visible { display: block; }

  /* Area de chat: ocupa toda la pantalla */
  .area-chat {
    width: 100%;
    height: 100%;
    position: relative;
  }

  /* Botón hamburguesa para abrir sidebar */
  .btn-hamburguesa {
    display: flex !important;
  }

  /* Cabecera chat con botón hamburguesa */
  .chat-cabecera {
    padding: 12px 12px;
    gap: 8px;
  }

  /* Input pegado al fondo, con padding para teclado virtual */
  .zona-input {
    padding: 10px 12px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }

  .input-mensaje { font-size: 16px; } /* evita zoom en iOS */

  .contenedor-mensajes { padding: 12px; }
  .mensaje { max-width: 90%; }
  .burbuja img.imagen-mensaje { max-width: 200px; }
}

/* ── Adjuntar archivos ──────────────────────────────────────────────────────── */
.btn-adjuntar {
  background: transparent;
  border: none;
  border-radius: 10px;
  width: 40px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 20px;
  opacity: 0.6;
  transition: opacity 0.2s;
  flex-shrink: 0;
}
.btn-adjuntar:hover { opacity: 1; }

.preview-archivo {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--superficie);
  border-radius: 8px;
  margin: 0 16px 8px;
  font-size: 13px;
  color: var(--texto-apagado);
  border: 1px solid var(--borde);
}
.preview-archivo img {
  max-height: 60px;
  max-width: 80px;
  border-radius: 6px;
  object-fit: cover;
}
.preview-archivo .nombre-archivo {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--texto);
}
.preview-archivo .btn-quitar {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--texto-apagado);
  font-size: 16px;
  padding: 0 4px;
  opacity: 0.7;
}
.preview-archivo .btn-quitar:hover { opacity: 1; color: #e05a5a; }

.burbuja img.imagen-mensaje {
  max-width: 280px;
  max-height: 200px;
  border-radius: 8px;
  display: block;
  margin-top: 6px;
  cursor: pointer;
}
.burbuja .enlace-archivo {
  display: inline-block;
  margin-top: 6px;
  color: var(--acento);
  text-decoration: none;
  font-size: 13px;
}
.enlace-archivo:hover { text-decoration: underline; }

/* ── Hamburguesa (solo móvil) ───────────────────────────────────────────────── */
.btn-hamburguesa {
  display: none;
  background: none;
  border: none;
  color: var(--texto-secundario);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 20px;
  flex-shrink: 0;
  transition: color 0.2s;
}
.btn-hamburguesa:hover { color: var(--acento); }
