/* ==========================================================================
  SISTEMA DE DISEÑO Y CONFIGURACIÓN GLOBAL
   ========================================================================== */
:root {
  /* Paleta de Colores (Diseño Oscuro Premium) */
  --bg-primary: #24252e;
  --card-bg: rgba(255, 255, 255, 0.03);
  --card-border: rgba(255, 255, 255, 0.07);
  --card-glow: rgba(99, 102, 241, 0.05);

  --primary: hsl(245, 82%, 67%);
  --primary-hover: hsl(245, 82%, 73%);
  --primary-glow: rgba(99, 102, 241, 0.3);

  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-inverse: #080911;

  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.2);
  --error: #ef4444;
  --error-glow: rgba(239, 68, 68, 0.2);
  --warning: #f59e0b;

  /* Fuentes y Efectos */
  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s ease;
  --blur-amount: 20px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  position: relative;
}

/* ==========================================================================
  FONDO ANIMADO PREMIUM
   ========================================================================== */
.bg-animation {
  display: none;
}

.circle {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.45;
  animation: float 20s infinite alternate ease-in-out;
}

.circle-1 {
  top: -10%;
  left: -10%;
  width: 50vw;
  height: 50vw;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.6) 0%, rgba(168, 85, 247, 0) 70%);
  animation-duration: 25s;
}

.circle-2 {
  bottom: -20%;
  right: -10%;
  width: 60vw;
  height: 60vw;
  background: radial-gradient(circle, rgba(236, 72, 153, 0.4) 0%, rgba(99, 102, 241, 0) 70%);
  animation-duration: 30s;
  animation-delay: -5s;
}

.circle-3 {
  top: 40%;
  left: 35%;
  width: 35vw;
  height: 35vw;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.4) 0%, rgba(16, 185, 129, 0) 70%);
  animation-duration: 18s;
  animation-delay: -2s;
}

@keyframes float {
  0% {
    transform: translate(0, 0) scale(1) rotate(0deg);
  }

  50% {
    transform: translate(5%, 8%) scale(1.08) rotate(180deg);
  }

  100% {
    transform: translate(-3%, -5%) scale(0.95) rotate(360deg);
  }
}

/* ==========================================================================
  CONTENEDOR DE TARJETA (GLASSMORPHISM)
   ========================================================================== */
.glass-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  padding: 40px;
  backdrop-filter: blur(var(--blur-amount));
  -webkit-backdrop-filter: blur(var(--blur-amount));
  box-shadow:
    0 4px 30px rgba(0, 0, 0, 0.4),
    0 1px 3px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 0 0 40px var(--card-glow);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.4s ease;
  margin: 20px;
}

.glass-card:hover {
  box-shadow:
    0 30px 60px rgba(0, 0, 0, 0.6),
    0 1px 5px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    inset 0 0 50px rgba(99, 102, 241, 0.08);
}


/* ==========================================================================
  CABECERA Y TÍTULOS
   ========================================================================== */
.card-section {
  width: 100%;
  animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.card-header {
  text-align: center;
  margin-bottom: 32px;
}

.logo-container {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 60px;
  height: 60px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary) 0%, #a855f7 100%);
  margin-bottom: 20px;
  color: #fff;
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
}

/* Logo imagen (reemplaza el SVG) */
.logo-img-container {
  background: none;
  box-shadow: none;
  width: auto;
  height: auto;
  border-radius: 0;
}

.logo-img {
  width: 180px;
  height: auto;
  object-fit: contain;
  transition: opacity 0.3s ease;
}

.logo {
  width: 32px;
  height: 32px;
}

h1,
h2 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #d1d5db 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ==========================================================================
  FORMULARIOS Y CAMPOS DE ENTRADA
   ========================================================================== */
form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.input-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrapper input {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 14px 16px 14px 44px;
  color: #fff;
  font-family: var(--font-family);
  font-size: 15px;
  outline: none;
  transition: var(--transition-smooth);
}

.input-wrapper input:focus {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-glow);
}

.input-wrapper input::placeholder {
  color: rgba(255, 255, 255, 0.25);
}

.input-icon {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
  transition: var(--transition-fast);
}

.input-wrapper input:focus~.input-icon {
  color: var(--primary);
}

/* Mostrar/Ocultar contraseña */
.btn-toggle-password {
  position: absolute;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  transition: var(--transition-fast);
}

.btn-toggle-password:hover {
  color: #fff;
}

.icon-eye {
  width: 18px;
  height: 18px;
}

/* ==========================================================================
   BOTONES
   ========================================================================== */
.btn-primary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 14px 20px;
  color: #fff;
  font-family: var(--font-family);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: var(--transition-smooth);
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  margin-top: 10px;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.25);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 14px 20px;
  color: #fff;
  font-family: var(--font-family);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  transition: var(--transition-smooth);
  margin-top: 24px;
}

.btn-secondary:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.btn-outline {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 14px 20px;
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.25);
}

.btn-icon {
  width: 18px;
  height: 18px;
}

/* ==========================================================================
  ESTADO DE CARGA (SPINNER)
   ========================================================================== */
.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
  position: absolute;
}

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

.btn-primary.loading .btn-text {
  visibility: hidden;
  opacity: 0;
}

.btn-primary.loading .spinner {
  display: block !important;
}

/* ==========================================================================
  VISTA DE DASHBOARD
   ========================================================================== */
.avatar-container {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.avatar {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, #a855f7 100%);
  border: 3px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
  box-shadow: 0 10px 25px rgba(99, 102, 241, 0.35);
}

.user-details {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
}

.detail-label {
  color: var(--text-muted);
  font-weight: 400;
}

.detail-value {
  color: #fff;
  font-weight: 500;
  word-break: break-all;
  max-width: 60%;
  text-align: right;
}

.badge {
  background: var(--success-glow);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* ==========================================================================
  SISTEMA DE NOTIFICACIONES TOAST
   ========================================================================== */
@media (max-width: 480px) {
  .toast-container {
    bottom: 16px;
    right: 16px;
    left: 16px;
    max-width: none;
    width: auto;
  }
}

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 9999;
  max-width: 360px;
  width: 100%;
}

.toast {
  background: rgba(18, 19, 31, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 16px;
  border-radius: 14px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  animation: slideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: var(--transition-smooth);
}

@keyframes slideIn {
  from {
    transform: translateX(120%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.toast.removing {
  animation: slideOut 0.3s ease forwards;
}

@keyframes slideOut {
  to {
    transform: translateX(120%);
    opacity: 0;
  }
}

.toast-icon-wrapper {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
}

.toast-icon {
  width: 14px;
  height: 14px;
  color: #fff;
}

.toast-content {
  flex-grow: 1;
}

.toast-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
}

.toast-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Modificaciones según tipo de Toast */
.toast-success {
  border-left: 4px solid var(--success);
}

.toast-success .toast-icon-wrapper {
  background: var(--success);
}

.toast-error {
  border-left: 4px solid var(--error);
}

.toast-error .toast-icon-wrapper {
  background: var(--error);
}

.toast-info {
  border-left: 4px solid var(--primary);
}

.toast-info .toast-icon-wrapper {
  background: var(--primary);
}

/* ==========================================================================
  UTILIDADES Y TRANSICIONES DE PANTALLA
   ========================================================================== */
.hidden {
  display: none !important;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}


/* ==========================================================================
  ESTILOS DE HISTORIAL DE CONEXIONES
   ========================================================================== */
.login-history-container {
  margin-top: 24px;
  text-align: left;
}

.login-history-container h3 {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.history-list {
  max-height: 160px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
}

/* Scrollbar Personalizado */
.history-list::-webkit-scrollbar {
  width: 4px;
}

.history-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
  border-radius: 4px;
}

.history-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.history-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

.history-item {
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: var(--transition-fast);
}

.history-item:hover {
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(255, 255, 255, 0.06);
}

.history-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  color: #fff;
}

.history-item-device {
  display: flex;
  align-items: center;
  gap: 6px;
}

.history-item-ip {
  color: #a78bfa;
  font-family: monospace;
}

.history-item-meta {
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 11px;
}

.history-item-placeholder,
.history-item-empty {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 16px 0;
  background: rgba(0, 0, 0, 0.1);
  border: 1px dashed rgba(255, 255, 255, 0.05);
  border-radius: 10px;
}

/* Ajustes Responsive */
@media (max-width: 480px) {
  .glass-card {
    padding: 30px 20px;
    margin: 16px;
    border-radius: 20px;
  }

  .avatar {
    width: 60px;
    height: 60px;
    font-size: 24px;
  }
}

/* ==========================================================================
  TEMA CLARO (LIGHT THEME)
   ========================================================================== */
body.light-theme {
  --bg-primary: #f1f5f9;
  --card-bg: rgba(255, 255, 255, 0.65);
  --card-border: rgba(255, 255, 255, 0.9);
  --card-glow: rgba(99, 102, 241, 0.1);

  --primary: hsl(245, 82%, 55%);
  --primary-hover: hsl(245, 82%, 50%);
  --primary-glow: rgba(99, 102, 241, 0.4);

  --text-main: #334155;
  --text-muted: #64748b;
  --text-inverse: #ffffff;
}

body.light-theme h1,
body.light-theme h2 {
  background: none;
  -webkit-text-fill-color: #0f172a;
  color: #0f172a;
}

body.light-theme .input-wrapper input {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.1);
  color: #0f172a;
}

body.light-theme .input-wrapper input:focus {
  background: rgba(0, 0, 0, 0.05);
}

body.light-theme .input-wrapper input::placeholder {
  color: rgba(0, 0, 0, 0.4);
}

body.light-theme .btn-toggle-password:hover {
  color: #0f172a;
}

body.light-theme .btn-primary {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.1);
  color: #0f172a;
}

body.light-theme .btn-primary:hover {
  background: rgba(0, 0, 0, 0.08);
  border-color: rgba(0, 0, 0, 0.15);
}

body.light-theme .user-details {
  background: rgba(255, 255, 255, 0.5);
  border-color: rgba(0, 0, 0, 0.05);
}

body.light-theme .detail-value {
  color: #0f172a;
}

body.light-theme .history-list::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.03);
}

body.light-theme .history-list::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
}

body.light-theme .history-item {
  background: rgba(255, 255, 255, 0.7);
  border-color: rgba(0, 0, 0, 0.05);
}

body.light-theme .history-item:hover {
  background: rgba(255, 255, 255, 1);
  border-color: rgba(0, 0, 0, 0.1);
}

body.light-theme .history-item-header {
  color: #0f172a;
}

body.light-theme .history-item-placeholder,
body.light-theme .history-item-empty {
  background: rgba(0, 0, 0, 0.02);
  border-color: rgba(0, 0, 0, 0.08);
}

body.light-theme .toast {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  color: #0f172a;
}

/* ==========================================================================
  THEME SWITCH (TOP RIGHT)
   ========================================================================== */
.theme-switch-container {
  position: absolute;
  top: 60px;
  right: 24px;
  z-index: 1000;
  transition: var(--transition-smooth);
}

.theme-switch {
  display: inline-block;
  width: 66px;
  height: 32px;
  position: relative;
}

.theme-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.theme-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 34px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: 0.4s;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.theme-slider-circle {
  position: absolute;
  height: 24px;
  width: 24px;
  left: 3px;
  bottom: 3px;
  background-color: #fff;
  border-radius: 50%;
  transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55), background-color 0.4s;
  z-index: 2;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.theme-icons {
  display: flex;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: space-between;
  position: absolute;
  top: 0;
  left: 0;
  padding: 0 9px;
  z-index: 3;
  pointer-events: none;
}

.icon-sun-switch,
.icon-moon-switch {
  width: 14px;
  height: 14px;
  transition: 0.4s;
}

/* Modo oscuro (Luna activa, círculo a la derecha) */
body:not(.light-theme) .theme-slider-circle {
  transform: translateX(34px);
  background-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2), inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

body:not(.light-theme) .icon-sun-switch {
  color: #6b7280;
}

body:not(.light-theme) .icon-moon-switch {
  color: #e2e8f0;
}

/* Modo claro (Sol activo, círculo a la izquierda) */
body.light-theme .theme-slider {
  background-color: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

body.light-theme .theme-slider-circle {
  transform: translateX(0);
  background-color: #fff;
}

body.light-theme .icon-sun-switch {
  color: #d97706;
}

body.light-theme .icon-moon-switch {
  color: #9ca3af;
}

@media (max-width: 480px) {
  .theme-switch-container {
    top: 52px;
    right: 16px;
  }
}

/* Fix para botón secundario (Cerrar Sesión) en index.html modo claro */
body.light-theme .btn-secondary {
  color: #1e293b;
  border-color: rgba(0, 0, 0, 0.12);
  background: rgba(0, 0, 0, 0.05);
}

body.light-theme .btn-secondary:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #0f172a;
}

.btn-close-modal {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  transition: 0.2s;
  padding: 0;
}

.btn-close-modal:hover {
  color: #fff;
}

body.light-theme .btn-close-modal:hover {
  color: #000;
}

#btn-logout.btn-close-modal {
  position: absolute;
  top: 16px;
  right: 24px;
  font-size: 32px;
  line-height: 1;
  z-index: 1001;
}

@media (max-width: 480px) {
  #btn-logout.btn-close-modal {
    top: 12px;
    right: 16px;
  }
}