/* Variables globales y Sistema de Diseño */
:root {
  --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  
  /* Paleta de Colores Principal (Dark Theme Premium) */
  --bg-app: #08080d;
  --bg-card: rgba(22, 22, 33, 0.65);
  --bg-card-hover: rgba(28, 28, 42, 0.8);
  --border-color: rgba(255, 255, 255, 0.07);
  --border-color-active: rgba(37, 211, 102, 0.4);
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  /* Acentos */
  --whatsapp-green: #25d366;
  --whatsapp-green-hover: #1ebd58;
  --whatsapp-green-translucent: rgba(37, 211, 102, 0.1);
  
  --accent-blue: #3b82f6;
  --accent-blue-hover: #2563eb;
  
  --accent-red: #ef4444;
  --accent-red-hover: #dc2626;
  
  --accent-warning: #f59e0b;
  --accent-warning-bg: rgba(245, 158, 11, 0.1);
  --accent-warning-border: rgba(245, 158, 11, 0.3);
  
  /* Sombras y Efectos */
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --glow-green: 0 0 15px rgba(37, 211, 102, 0.25);
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset de Estilos */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-app);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 20px;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(37, 211, 102, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(59, 130, 246, 0.05) 0%, transparent 45%);
  overflow-x: hidden;
}

/* Contenedor Principal */
.app-container {
  width: 100%;
  max-width: 1200px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Header */
.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px border-color var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-shadow);
  border: 1px solid var(--border-color);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  color: var(--whatsapp-green);
  width: 32px;
  height: 32px;
  filter: drop-shadow(0 0 8px rgba(37, 211, 102, 0.4));
}

.logo-area h1 {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.5px;
}

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

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-blue);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
}

.user-email {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.logout-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-family: var(--font-main);
  transition: var(--transition);
}

.logout-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

/* Grid de Contenido */
.main-content {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

@media (min-width: 768px) {
  .main-content {
    grid-template-columns: 350px 1fr;
  }
}

/* Componente: Tarjeta (Card) */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-shadow);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  transition: var(--transition);
}

.card-header h2 {
  font-size: 1.2rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
}

/* Gestión de Sesiones */
.sessions-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 100px;
  align-content: flex-start;
}

.sessions-loading {
  color: var(--text-muted);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

/* Botones de Pestañas de Sesiones (Pills) */
.session-pill {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 30px;
  padding: 8px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: var(--transition);
  user-select: none;
}

.session-pill:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.session-pill.active {
  background: var(--whatsapp-green-translucent);
  border-color: var(--whatsapp-green);
  color: var(--whatsapp-green);
  box-shadow: var(--glow-green);
}

/* Luces de Estado */
.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.status-indicator.connected {
  background: var(--whatsapp-green);
  box-shadow: 0 0 8px var(--whatsapp-green);
}

.status-indicator.qr, .status-indicator.connecting {
  background: var(--accent-warning);
  box-shadow: 0 0 8px var(--accent-warning);
  animation: pulse 1.5s infinite;
}

.status-indicator.disconnected {
  background: var(--accent-red);
}

/* Formulario Añadir Sesión */
.add-session-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
}

.add-session-form input {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition);
}

.add-session-form input:focus {
  border-color: var(--whatsapp-green);
  box-shadow: 0 0 10px rgba(37, 211, 102, 0.1);
}

/* Botones */
.btn {
  font-family: var(--font-main);
  font-weight: 500;
  font-size: 0.9rem;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
}

.btn-primary {
  background: var(--whatsapp-green);
  color: #040d06;
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--whatsapp-green-hover);
  transform: translateY(-1px);
}

.btn-success {
  background: var(--whatsapp-green);
  color: #040d06;
  font-weight: 600;
}

.btn-success:hover {
  background: var(--whatsapp-green-hover);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid var(--accent-red);
  color: var(--accent-red);
}

.btn-danger:hover {
  background: var(--accent-red);
  color: white;
}

.btn-large {
  padding: 14px 28px;
  font-size: 1rem;
  width: 100%;
}

/* Detalle de Sesión */
.detail-body {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.state-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  gap: 16px;
  text-align: center;
}

/* Spinner */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.05);
  border-top-color: var(--whatsapp-green);
  border-radius: 50%;
  animation: spin 1s infinite linear;
}

/* Banners de Estado */
.instruction-banner {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.2);
  color: var(--accent-warning);
  padding: 12px 24px;
  border-radius: 30px;
  font-size: 0.95rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.success-banner {
  background: rgba(37, 211, 102, 0.08);
  border: 1px solid rgba(37, 211, 102, 0.2);
  color: var(--whatsapp-green);
  padding: 12px 24px;
  border-radius: 30px;
  font-size: 0.95rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--glow-green);
}

.error-banner {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--accent-red);
  padding: 12px 24px;
  border-radius: 30px;
  font-size: 0.95rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.success-status-text {
  font-size: 1.2rem;
  color: var(--text-secondary);
  font-weight: 300;
}

/* QR Code */
.qr-code-wrapper {
  background: white;
  padding: 16px;
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.5s ease-out;
}

.qr-code-wrapper img {
  display: block;
  max-width: 250px;
  width: 100%;
  height: auto;
}

/* Secciones de Detalle */
.details-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-top: 1px solid var(--border-color);
  padding-top: 20px;
}

.details-section h3 {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Bloque de Código (Terminal) */
.code-block-container {
  background: #040406;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  position: relative;
  overflow: hidden;
}

.code-block-container pre {
  font-family: "Courier New", Courier, monospace;
  font-size: 0.85rem;
  color: #38bdf8;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  padding-right: 32px;
  line-height: 1.5;
}

.copy-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.copy-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
}

/* Formulario Webhook */
.webhook-form-vertical {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.checkbox-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox-container input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--whatsapp-green);
  cursor: pointer;
}

.checkbox-container label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  font-weight: 500;
}

.webhook-input-group {
  display: flex;
  gap: 10px;
}

.webhook-input-group input {
  flex: 1;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition);
}

.webhook-input-group input:focus {
  border-color: var(--whatsapp-green);
}

/* Danger Zone */
.danger-zone {
  border-top: 1px solid var(--border-color);
  padding-top: 20px;
  margin-top: 10px;
}

/* No Session Selected Screen */
.no-session-selected {
  justify-content: center;
  align-items: center;
  min-height: 400px;
}

.no-session-body {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  max-width: 400px;
}

.no-session-icon {
  width: 64px;
  height: 64px;
  color: var(--text-muted);
}

.no-session-body h3 {
  font-size: 1.3rem;
  font-weight: 500;
  color: var(--text-primary);
}

.no-session-body p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Modales */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: var(--transition);
  animation: fadeIn 0.3s ease-out;
}

.modal-content {
  background: #12121e;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 500px;
  width: 90%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-icon-success {
  background: var(--whatsapp-green-translucent);
  border-radius: 50%;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-icon-success i {
  color: var(--whatsapp-green);
  width: 36px;
  height: 36px;
}

.modal-content h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
}

.api-key-box-wrapper {
  background: rgba(37, 211, 102, 0.05);
  border: 1.5px dashed var(--whatsapp-green);
  border-radius: var(--radius-md);
  padding: 16px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.api-key-text {
  font-family: "Courier New", Courier, monospace;
  font-size: 0.9rem;
  color: var(--whatsapp-green);
  word-break: break-all;
  text-align: left;
  line-height: 1.4;
}

.copy-key-btn {
  background: var(--whatsapp-green-translucent);
  border: 1px solid var(--whatsapp-green);
  color: var(--whatsapp-green);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
}

.copy-key-btn:hover {
  background: var(--whatsapp-green);
  color: #040d06;
}

.modal-warning {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid var(--accent-warning-border);
  color: var(--accent-warning);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  line-height: 1.5;
}

.modal-warning i {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}


/* Utilidades */
.hidden {
  display: none !important;
}

/* Login Screen Styles */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 80vh;
  width: 100%;
  animation: fadeIn 0.4s ease-out;
}

.login-card {
  max-width: 420px;
  width: 100%;
  padding: 40px !important;
  text-align: center;
  border: 1px solid var(--border-color);
  box-shadow: var(--glass-shadow);
}

/* Animaciones */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.1); }
  100% { opacity: 0.6; transform: scale(1); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Estilos para enlaces y transición de recuperación */
#go-forgot-btn:hover {
  text-decoration: underline !important;
  opacity: 0.9;
}

#go-login-btn-1:hover, #go-login-btn-2:hover {
  color: var(--text-primary) !important;
  text-decoration: underline !important;
}

/* Transiciones de opacidad para campos de formulario */
.login-card input {
  transition: all 0.2s ease-in-out;
}

.login-card input:focus {
  border-color: var(--whatsapp-green) !important;
  background: rgba(0, 0, 0, 0.4) !important;
  box-shadow: 0 0 8px rgba(37, 211, 102, 0.2);
}
