/* ==========================================================================
   SovereignChat - Premium Glassmorphism Design System
   Modo Oscuro Tailored HSL, Gradientes Fluídos y Micro-animaciones
   ========================================================================== */

/* 1. Definición de Variables de Diseño (Tokens) */
:root {
  --font-primary: 'Outfit', 'Plus Jakarta Sans', system-ui, sans-serif;
  
  /* Paleta de Colores HSL Tailored */
  --bg-dark: 230 25% 6%;
  --card-glass: 230 25% 10% / 0.45;
  --border-glass: 230 25% 100% / 0.08;
  
  --accent-purple: 265 85% 65%;
  --accent-purple-glow: 265 85% 65% / 0.3;
  --accent-blue: 200 95% 55%;
  --accent-blue-glow: 200 95% 55% / 0.3;
  
  --text-primary: 230 100% 98%;
  --text-secondary: 230 15% 70%;
  --text-muted: 230 10% 45%;
  
  --danger: 0 85% 60%;
  --success: 140 75% 50%;
  
  /* Transiciones y Sombras */
  --transition-smooth: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  --shadow-premium: 0 20px 40px -15px rgba(0, 0, 0, 0.7);
}

/* 2. Reseteo y Estilos Base */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-primary);
  background-color: hsl(var(--bg-dark));
  color: hsl(var(--text-primary));
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* 3. Fondo Aurora Animado */
.aurora-bg {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: -1;
  overflow: hidden;
  filter: blur(100px);
}

.blob {
  position: absolute;
  border-radius: 50%;
  mix-blend-mode: screen;
  opacity: 0.3;
  animation: float 25s infinite alternate;
}

.blob-purple {
  top: -10%;
  left: -10%;
  width: 55vw;
  height: 55vw;
  background: radial-gradient(circle, hsl(var(--accent-purple)) 0%, transparent 70%);
}

.blob-blue {
  bottom: -15%;
  right: -10%;
  width: 60vw;
  height: 60vw;
  background: radial-gradient(circle, hsl(var(--accent-blue)) 0%, transparent 70%);
  animation-delay: -5s;
}

@keyframes float {
  0% { transform: translate(0, 0) scale(1) rotate(0deg); }
  50% { transform: translate(50px, 30px) scale(1.1) rotate(180deg); }
  100% { transform: translate(-30px, -20px) scale(0.9) rotate(360deg); }
}

/* 4. Contenedor Principal Glassmorphism */
.glass-container {
  width: 95vw;
  max-width: 1100px;
  height: 85vh;
  min-height: 550px;
  background-color: hsl(var(--card-glass));
  border: 1px solid hsl(var(--border-glass));
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  border-radius: 24px;
  box-shadow: var(--shadow-premium);
  position: relative;
  overflow: hidden;
}

/* Pantallas y estados activos */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition-smooth);
  transform: scale(0.98);
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

/* 5. Estilos Pantalla de Autenticación */
#auth-screen {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 40px;
}

.auth-header {
  text-align: center;
  margin-bottom: 30px;
}

.logo-badge {
  font-size: 3rem;
  background: linear-gradient(135deg, hsl(var(--accent-purple)), hsl(var(--accent-blue)));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  display: inline-block;
  margin-bottom: 12px;
  filter: drop-shadow(0 0 15px hsl(var(--accent-purple-glow)));
}

.auth-header h1 {
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

.auth-header p {
  color: hsl(var(--text-secondary));
  font-size: 0.95rem;
}

/* Tabs */
.auth-tabs {
  display: flex;
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid hsl(var(--border-glass));
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 25px;
  width: 100%;
  max-width: 380px;
}

.tab-btn {
  flex: 1;
  background: none;
  border: none;
  color: hsl(var(--text-secondary));
  font-family: var(--font-primary);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 10px;
  border-radius: 9px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.tab-btn.active {
  background-color: rgba(255, 255, 255, 0.08);
  color: hsl(var(--text-primary));
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Formularios de Auth */
.auth-forms-container {
  width: 100%;
  max-width: 380px;
  position: relative;
  min-height: 240px;
}

.auth-form {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition-smooth);
  transform: translateY(10px);
}

.auth-form.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* Componentes de Entrada de Datos */
.input-group {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
}

.input-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: hsl(var(--text-secondary));
  margin-bottom: 6px;
}

.input-group input, .input-group select {
  font-family: var(--font-primary);
  background-color: rgba(255, 255, 255, 0.04);
  border: 1px solid hsl(var(--border-glass));
  color: hsl(var(--text-primary));
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 0.95rem;
  outline: none;
  transition: var(--transition-smooth);
}

.input-group input:focus, .input-group select:focus {
  border-color: hsl(var(--accent-purple));
  background-color: rgba(255, 255, 255, 0.07);
  box-shadow: 0 0 15px hsl(var(--accent-purple-glow));
}

.input-tip {
  font-size: 0.75rem;
  color: hsl(var(--text-muted));
  margin-top: 4px;
}

.hidden {
  display: none !important;
}

/* Botones */
.btn {
  font-family: var(--font-primary);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 12px 24px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: inline-flex;
  justify-content: center;
  align-items: center;
}

.btn-primary {
  background: linear-gradient(135deg, hsl(var(--accent-purple)), hsl(var(--accent-blue)));
  color: hsl(var(--text-primary));
  box-shadow: 0 8px 20px hsl(var(--accent-purple-glow));
  width: 100%;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 25px hsl(var(--accent-purple-glow));
}

.btn-secondary {
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid hsl(var(--border-glass));
  color: hsl(var(--text-primary));
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.btn-outline {
  background: none;
  border: 1px solid hsl(var(--border-glass));
  color: hsl(var(--text-secondary));
}

.btn-outline:hover {
  border-color: hsl(var(--text-primary));
  color: hsl(var(--text-primary));
}

.btn-full {
  width: 100%;
}

.btn-round {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* 6. Estilos de Pantalla del Chat Principal */
#chat-screen {
  display: flex;
  height: 100%;
}

/* Barra Lateral */
.sidebar {
  width: 320px;
  border-right: 1px solid hsl(var(--border-glass));
  display: flex;
  flex-direction: column;
  background-color: rgba(0, 0, 0, 0.1);
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid hsl(var(--border-glass));
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.user-profile-summary {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, hsl(var(--accent-purple)), hsl(var(--accent-blue)));
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.2rem;
  box-shadow: 0 0 10px hsl(var(--accent-purple-glow));
}

.user-info h3 {
  font-size: 0.9rem;
  font-weight: 600;
}

.user-info span {
  font-size: 0.75rem;
  color: hsl(var(--text-secondary));
}

.btn-icon {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  opacity: 0.7;
  transition: var(--transition-smooth);
}

.btn-icon:hover {
  opacity: 1;
  transform: scale(1.1);
}

.sidebar-search {
  padding: 15px 20px;
}

.rooms-list-container {
  flex: 1;
  overflow-y: auto;
}

.rooms-list {
  list-style: none;
}

.room-item {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: var(--transition-smooth);
  display: flex;
  align-items: center;
  gap: 14px;
}

.room-item:hover, .room-item.active {
  background-color: rgba(255, 255, 255, 0.04);
}

.room-item.active {
  border-left: 3px solid hsl(var(--accent-purple));
}

.room-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid hsl(var(--border-glass));
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.2rem;
}

.room-details {
  flex: 1;
  overflow: hidden;
}

.room-details h4 {
  font-size: 0.95rem;
  font-weight: 500;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-details p {
  font-size: 0.8rem;
  color: hsl(var(--text-muted));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-item.empty-state {
  justify-content: center;
  color: hsl(var(--text-muted));
  font-size: 0.85rem;
  padding: 40px 20px;
  text-align: center;
  cursor: default;
}

.room-item.empty-state:hover {
  background: none;
}

/* Área de Chat Activa */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.chat-header {
  padding: 20px 30px;
  border-bottom: 1px solid hsl(var(--border-glass));
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: rgba(0, 0, 0, 0.05);
}

.active-room-summary h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.active-room-summary span {
  font-size: 0.8rem;
  color: hsl(var(--text-secondary));
}

.btn-sm {
  font-size: 0.8rem;
  padding: 6px 12px;
  border-radius: 8px;
}

/* Historial de Mensajes */
.messages-container {
  flex: 1;
  padding: 30px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Mensajes individuales */
.message {
  max-width: 65%;
  display: flex;
  flex-direction: column;
}

.message.received {
  align-self: flex-start;
}

.message.sent {
  align-self: flex-end;
}

.msg-sender {
  font-size: 0.75rem;
  color: hsl(var(--text-secondary));
  margin-bottom: 4px;
  margin-left: 12px;
}

.message.sent .msg-sender {
  align-self: flex-end;
  margin-right: 12px;
}

.msg-bubble {
  padding: 12px 18px;
  border-radius: 18px;
  font-size: 0.95rem;
  line-height: 1.4;
  word-break: break-word;
}

.message.received .msg-bubble {
  background-color: rgba(255, 255, 255, 0.04);
  border: 1px solid hsl(var(--border-glass));
  color: hsl(var(--text-primary));
  border-bottom-left-radius: 4px;
}

.message.sent .msg-bubble {
  background: linear-gradient(135deg, hsl(var(--accent-purple)), hsl(var(--accent-blue)));
  color: hsl(var(--text-primary));
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 15px hsl(var(--accent-purple-glow));
}

.msg-time {
  font-size: 0.7rem;
  color: hsl(var(--text-muted));
  margin-top: 4px;
  margin-left: 12px;
}

.message.sent .msg-time {
  align-self: flex-end;
  margin-right: 12px;
}

/* Bienvenida en el Chat */
.chat-welcome-state {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100%;
  text-align: center;
  padding: 40px;
  color: hsl(var(--text-secondary));
}

.welcome-icon {
  font-size: 4rem;
  margin-bottom: 20px;
  filter: drop-shadow(0 0 15px hsl(var(--accent-purple-glow)));
}

.chat-welcome-state h2 {
  font-size: 1.5rem;
  color: hsl(var(--text-primary));
  margin-bottom: 10px;
}

.chat-welcome-state p {
  font-size: 0.95rem;
  max-width: 450px;
  line-height: 1.5;
  margin-bottom: 25px;
}

.info-badges {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.badge {
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid hsl(var(--border-glass));
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  color: hsl(var(--text-secondary));
}

/* Área de Entrada */
.message-input-area {
  padding: 20px 30px;
  border-top: 1px solid hsl(var(--border-glass));
  display: flex;
  gap: 16px;
  background-color: rgba(0, 0, 0, 0.05);
}

.message-input-area input {
  flex: 1;
  font-family: var(--font-primary);
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid hsl(var(--border-glass));
  color: hsl(var(--text-primary));
  padding: 14px 20px;
  border-radius: 16px;
  outline: none;
  font-size: 0.95rem;
  transition: var(--transition-smooth);
}

.message-input-area input:focus {
  border-color: hsl(var(--accent-purple));
  background-color: rgba(255, 255, 255, 0.06);
  box-shadow: 0 0 15px hsl(var(--accent-purple-glow));
}

/* 7. Ventanas Modales */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition-smooth);
}

.modal.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  width: 90%;
  max-width: 440px;
  padding: 30px;
  border-radius: 24px;
  transform: translateY(20px);
  transition: var(--transition-smooth);
}

.modal.active .modal-content {
  transform: translateY(0);
}

.glass-card {
  background-color: hsl(var(--card-glass));
  border: 1px solid hsl(var(--border-glass));
  backdrop-filter: blur(25px);
  box-shadow: var(--shadow-premium);
}

.modal h2 {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.modal p {
  font-size: 0.85rem;
  color: hsl(var(--text-secondary));
  line-height: 1.4;
  margin-bottom: 20px;
}

.qr-container {
  display: flex;
  justify-content: center;
  margin: 20px 0;
}

.qr-code {
  background: white;
  padding: 16px;
  border-radius: 16px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
}

.mock-qr {
  width: 160px;
  height: 160px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 25px;
}

.modal-actions .btn {
  flex: 1;
}

/* 8. Ajustes Estilos para Dispositivos Móviles */
@media (max-width: 768px) {
  .glass-container {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    border: none;
  }
  
  #chat-screen {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    height: 40%;
    border-right: none;
    border-bottom: 1px solid hsl(var(--border-glass));
  }
  
  .chat-area {
    height: 60%;
  }
  
  .message {
    max-width: 80%;
  }
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.15);
}
