/* =============================================================================
   ARCHIVO: css/styles.css
   OBJETIVO: Estilos visuales del Front-End (Tema oscuro, responsivo y moderno).
   CARACTERÍSTICAS:
     - Variables CSS (:root) para consistencia en la paleta de colores.
     - Diseño responsivo mediante Flexbox y CSS Grid.
     - Estados interactivos (hover, active, focus, disabled).
     - Componentes: Navbar, Tarjetas, Tablas estilizadas, Modales y Toasts.
============================================================================= */

:root {
  /* Paleta de colores principales */
  --primary: #10b981;              /* Verde esmeralda (acciones principales) */
  --primary-hover: #059669;
  --primary-light: rgba(16, 185, 129, 0.12);
  --bg: #0f172a;                   /* Fondo oscuro (slate 900) */
  --surface: #1e293b;              /* Fondo de tarjetas y tablas (slate 800) */
  --surface-border: #334155;       /* Bordes sutiles (slate 700) */
  --text: #f8fafc;                 /* Texto blanco principal */
  --text-muted: #94a3b8;           /* Texto secundario / gris */
  --danger: #ef4444;               /* Rojo para eliminar y errores */
  --danger-bg: rgba(239, 68, 68, 0.15);
  --success: #22c55e;              /* Verde para confirmaciones */
  --success-bg: rgba(34, 197, 94, 0.15);
  --warning: #f59e0b;
  --radius: 12px;
  --radius-sm: 8px;
  --transition: all 0.2s ease;
}

/* Reset básico */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
}

/* =============================================================================
   PANTALLA DE LOGIN (login.html)
============================================================================= */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  /* Fondo con degradado radial sutil */
  background-image: 
    radial-gradient(at 0% 0%, rgba(16, 185, 129, 0.12) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(59, 130, 246, 0.12) 0px, transparent 50%);
}

.login-card-container {
  width: 100%;
  max-width: 440px;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--primary-light);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: var(--primary);
  padding: 0.35rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 0.85rem;
}

.brand-header {
  text-align: center;
  margin-bottom: 2rem;
}

.brand-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.brand-subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 0.4rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  padding: 2.25rem 2rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
}

/* =============================================================================
   FORMULARIOS Y CAMPOS DE ENTRADA
============================================================================= */
.form-group {
  margin-bottom: 1.25rem;
}

label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #cbd5e1;
  margin-bottom: 0.4rem;
}

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

.input-icon {
  position: absolute;
  left: 1rem;
  color: var(--text-muted);
  pointer-events: none;
  display: flex;
  align-items: center;
}

input[type="email"],
input[type="password"],
input[type="text"],
input[type="number"],
select {
  width: 100%;
  background: #0f172a;
  border: 1px solid var(--surface-border);
  color: var(--text);
  padding: 0.75rem 1rem 0.75rem 2.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  transition: var(--transition);
  outline: none;
  font-family: inherit;
}

select, input.no-icon {
  padding-left: 1rem;
}

input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.toggle-pass {
  position: absolute;
  right: 0.85rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.3rem;
  display: flex;
  align-items: center;
  transition: var(--transition);
}

.toggle-pass:hover, .toggle-pass.active {
  color: var(--primary);
}

/* =============================================================================
   BOTONES
============================================================================= */
.btn {
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  text-decoration: none;
  border: 1px solid transparent;
  outline: none;
  font-family: inherit;
}

.btn-primary {
  background: var(--primary);
  color: #042f2e;
  font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
  background: #34d399;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--surface-border);
  color: var(--text);
}

.btn-secondary:hover {
  background: #334155;
  color: #fff;
}

.btn-danger-outline {
  background: transparent;
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

.btn-danger-outline:hover {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: #fff;
}

.btn-block {
  width: 100%;
  padding: 0.85rem;
  margin-top: 1.25rem;
}

.btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

/* =============================================================================
   ALERTAS
============================================================================= */
.alert {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  margin-bottom: 1.25rem;
  display: none;
  line-height: 1.4;
}

.alert-danger {
  background: var(--danger-bg);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

.alert-success {
  background: var(--success-bg);
  border: 1px solid rgba(34, 197, 94, 0.4);
  color: #86efac;
}

/* Botón de credenciales de demostración */
.quick-credentials {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--surface-border);
  text-align: center;
}

.quick-credentials-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.btn-quick-fill {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--surface-border);
  color: #cbd5e1;
  padding: 0.5rem 0.85rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-quick-fill:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: #64748b;
  color: #fff;
}

/* Spinner animado */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(4, 47, 46, 0.3);
  border-top-color: #042f2e;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* =============================================================================
   BARRA SUPERIOR (NAVBAR)
============================================================================= */
.navbar {
  background: rgba(30, 41, 59, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--surface-border);
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 0.85rem 1.5rem;
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text);
}

.brand-icon {
  font-size: 1.5rem;
}

.brand-info h1 {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.2;
}

.brand-info span {
  font-size: 0.75rem;
  color: var(--primary);
  font-weight: 500;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-pill {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  padding: 0.35rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.8125rem;
  color: #cbd5e1;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.user-dot {
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
}

/* =============================================================================
   PANEL PRINCIPAL (DASHBOARD)
============================================================================= */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  flex: 1;
  width: 100%;
}

/* Banner de Token JWT Activo */
.token-banner {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, rgba(30, 41, 59, 0.8) 100%);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 2rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.token-banner-info h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.token-banner-info p {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.token-box {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  background: #0f172a;
  border: 1px solid var(--surface-border);
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  color: #94a3b8;
  max-width: 380px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Estadísticas */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.stat-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-value {
  font-size: 1.85rem;
  font-weight: 700;
  color: #fff;
}

/* Pestañas */
.tabs-header {
  display: flex;
  border-bottom: 1px solid var(--surface-border);
  margin-bottom: 1.5rem;
  gap: 0.5rem;
}

.tab-btn {
  background: none;
  border: none;
  padding: 0.75rem 1.25rem;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--primary);
  font-weight: 600;
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary);
}

.tab-badge {
  background: #334155;
  color: #f1f5f9;
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 600;
}

/* =============================================================================
   TABLAS DE DATOS
============================================================================= */
.table-card {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

th {
  background: rgba(15, 23, 42, 0.6);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--surface-border);
}

td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--surface-border);
  color: #e2e8f0;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.tag-team {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  display: inline-block;
}

.tag-free {
  background: rgba(148, 163, 184, 0.1);
  border: 1px solid rgba(148, 163, 184, 0.2);
  color: #94a3b8;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-style: italic;
  display: inline-block;
}

.actions-cell {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-icon {
  padding: 0.4rem;
  background: transparent;
  border: 1px solid var(--surface-border);
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
}

.btn-icon:hover {
  background: #334155;
  color: #fff;
}

.btn-icon-danger:hover {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: #fca5a5;
}

/* =============================================================================
   VENTANAS MODALES
============================================================================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 500px;
  padding: 2rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.5rem;
  line-height: 1;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.75rem;
}

.empty-state {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: #1e293b;
  border: 1px solid var(--surface-border);
  padding: 0.85rem 1.25rem;
  border-radius: 8px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
  display: none;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  z-index: 200;
}
