/* ═══════════════════════════════════════════
   Hero Hub · Panel de Gestión de Roles
   Estilos específicos del tab "Roles" en admin.html
   Usa las variables CSS del styles.css principal.
   ═══════════════════════════════════════════ */

/* Header del panel con botón agregar */
.ra-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

/* ═══ Cards de estadísticas ═══ */
.ra-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.ra-stat-card {
  background: var(--card, #fff);
  border: 1px solid var(--border, #e8e8e8);
  border-radius: 12px;
  padding: 14px 16px;
}

.ra-stat-card.ra-stat-total {
  background: linear-gradient(135deg, #06a3b6, #048395);
  border-color: #048395;
  color: #fff;
}

.ra-stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted, #777);
  margin-bottom: 6px;
  font-weight: 700;
}

.ra-stat-card.ra-stat-total .ra-stat-label {
  color: rgba(255, 255, 255, 0.85);
}

.ra-stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text, #1a1a1a);
  line-height: 1;
}

.ra-stat-card.ra-stat-total .ra-stat-value {
  color: #fff;
}

/* ═══ Barra de búsqueda ═══ */
.ra-toolbar {
  margin-bottom: 14px;
}

/* Reusa .search-wrap del CSS principal, pero si no está disponible:*/
.ra-toolbar .search-wrap {
  position: relative;
  max-width: 420px;
}
.ra-toolbar .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--muted, #777);
  pointer-events: none;
}
.ra-toolbar input[type="text"] {
  width: 100%;
  padding: 10px 12px 10px 38px;
  border: 1px solid var(--border, #e8e8e8);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  background: var(--card, #fff);
  color: var(--text, #1a1a1a);
}
.ra-toolbar input[type="text"]:focus {
  outline: none;
  border-color: #06a3b6;
  box-shadow: 0 0 0 3px rgba(6, 163, 182, 0.15);
}

/* ═══ Filtros por rol (chips) ═══ */
.ra-filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.ra-filter-chip {
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--card, #fff);
  border: 1px solid var(--border, #e8e8e8);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2, #444);
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.ra-filter-chip:hover {
  border-color: #06a3b6;
  color: #06a3b6;
}

.ra-filter-chip.active {
  background: #06a3b6;
  border-color: #06a3b6;
  color: #fff;
}

/* ═══ Tabla ═══ */
.ra-table-wrap {
  background: var(--card, #fff);
  border: 1px solid var(--border, #e8e8e8);
  border-radius: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  box-shadow: 0 2px 8px rgba(6, 163, 182, 0.04);

  /* Scrollbar estilizada */
  scrollbar-width: thin;
  scrollbar-color: #06a3b6 #f0f4f8;
}

/* Scrollbar en navegadores WebKit (Chrome, Safari, Edge) */
.ra-table-wrap::-webkit-scrollbar {
  height: 10px;
}
.ra-table-wrap::-webkit-scrollbar-track {
  background: #f0f4f8;
  border-radius: 0 0 12px 12px;
}
.ra-table-wrap::-webkit-scrollbar-thumb {
  background: #06a3b6;
  border-radius: 5px;
  border: 2px solid #f0f4f8;
}
.ra-table-wrap::-webkit-scrollbar-thumb:hover {
  background: #048395;
}

.ra-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 14px;
  table-layout: fixed;
}

/* Anchos explícitos de cada columna */
.ra-table th:nth-child(1),
.ra-table td:nth-child(1) { width: auto; min-width: 280px; }
.ra-table th:nth-child(2),
.ra-table td:nth-child(2) { width: 180px; }
.ra-table th:nth-child(3),
.ra-table td:nth-child(3) { width: 110px; }
.ra-table th:nth-child(4),
.ra-table td:nth-child(4) { width: 90px; }

.ra-table thead {
  background: #f0f4f8;
}

.ra-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted, #777);
  border-bottom: 1px solid var(--border, #e8e8e8);
}

.ra-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border, #e8e8e8);
  vertical-align: middle;
}

.ra-table tbody tr:last-child td {
  border-bottom: none;
}

.ra-table tbody tr:hover {
  background: #f9fafb;
}

.ra-table td.empty {
  text-align: center;
  color: var(--muted, #777);
  padding: 40px 16px;
  font-style: italic;
}

/* ═══ Celda de usuario (avatar + nombre + email) ═══ */
.ra-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.ra-avatar-initials {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #06a3b6, #048395);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ra-user-name {
  font-weight: 600;
  color: var(--text, #1a1a1a);
  font-size: 14px;
  line-height: 1.2;
}

.ra-user-email {
  font-size: 12px;
  color: var(--muted, #777);
  font-family: 'JetBrains Mono', monospace;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ra-user-cell {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.ra-user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.ra-me-tag {
  display: inline-block;
  background: #06a3b6;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
  letter-spacing: 0.5px;
}

/* ═══ Dropdown de rol en la tabla ═══ */
.ra-role-select {
  padding: 6px 10px;
  border: 1px solid var(--border, #e8e8e8);
  border-radius: 6px;
  background: var(--card, #fff);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text, #1a1a1a);
  cursor: pointer;
  transition: border-color 0.15s;
}

.ra-role-select:hover {
  border-color: #06a3b6;
}

/* ═══════════════════════════════════════════
   TABULATOR — Mount + ajustes de celda
   El tema general (header cyan, paginación, etc.) lo
   define audit-panel.css (afecta a .tabulator global).
   ═══════════════════════════════════════════ */
#ra-table {
  background: var(--card, #fff);
  border: 1px solid var(--border, #e8e8e8);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

/* Asegurar que las celdas con flex-content respiren */
#ra-table .tabulator-cell { padding: 10px 14px; }

#ra-table .ra-user-cell {
  display: flex; align-items: center; gap: 12px;
  min-width: 0;
}
#ra-table .ra-avatar,
#ra-table .ra-avatar-initials { flex-shrink: 0; }
#ra-table .ra-user-info { min-width: 0; flex: 1; }
#ra-table .ra-user-name,
#ra-table .ra-user-email {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

#ra-table .ra-updated {
  display: flex; flex-direction: column; gap: 2px;
  line-height: 1.2;
}
#ra-table .ra-updated-date {
  font-family: var(--mono, "JetBrains Mono", monospace);
  font-size: 12px;
  color: var(--text, #1a1a1a);
  font-weight: 600;
}
#ra-table .ra-updated-by {
  font-size: 10.5px;
  color: var(--muted, #94a3b8);
}
#ra-table .ra-no-date {
  color: var(--muted, #94a3b8);
  font-style: italic;
}

#ra-table .ra-act-btn.ra-del {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted, #64748b);
  font-size: 14px; font-weight: 700;
  cursor: pointer;
  transition: all .15s;
}
#ra-table .ra-act-btn.ra-del:hover {
  background: #fee2e2; color: #b91c1c;
  border-color: #fecaca;
}

#ra-table .ra-protected {
  font-size: 18px; opacity: .7;
}

/* ═══════════════════════════════════════════
   Modal sl-dialog "Agregar usuario"
   ═══════════════════════════════════════════ */
.ra-add-dialog::part(panel) {
  border-radius: 16px;
  max-width: 480px;
}
.ra-add-dialog::part(header) {
  background: linear-gradient(135deg, #06a3b6, #057b8c);
  color: #fff;
}
.ra-add-dialog::part(title) {
  font-family: var(--display, "Bricolage Grotesque", "Inter"), sans-serif;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.3px;
}
.ra-add-dialog::part(close-button) {
  color: rgba(255,255,255,.85);
}
.ra-add-dialog::part(close-button):hover {
  color: #fff;
}

.ra-add-dialog .ra-add-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.ra-add-dialog .ra-add-form sl-input,
.ra-add-dialog .ra-add-form sl-select {
  display: block;
}
.ra-add-dialog .ra-suggestions-note {
  margin: -6px 0 0;
}
.ra-add-dialog .ra-role-hint {
  margin: 0;
}

.ra-role-select:focus {
  outline: none;
  border-color: #06a3b6;
  box-shadow: 0 0 0 3px rgba(6, 163, 182, 0.15);
}

/* ═══ Columna de fecha (compacta) ═══ */
.ra-updated {
  font-size: 12px;
  color: var(--text-2, #444);
  line-height: 1.3;
  white-space: nowrap;
}

.ra-updated-date {
  font-weight: 500;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
}

.ra-updated-by {
  font-size: 10.5px;
  color: var(--muted, #777);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100px;
}

/* ═══ Acciones ═══ */
.ra-actions {
  text-align: center;
  white-space: nowrap;
  padding-right: 12px !important;
}

.ra-act-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--border, #e8e8e8);
  background: var(--card, #fff);
  color: var(--muted, #777);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1;
  padding: 0;
}

.ra-act-btn:hover {
  background: #fdedec;
  border-color: #c0392b;
  color: #c0392b;
}

.ra-protected {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  font-size: 18px;
  color: #06a3b6;
  opacity: 0.7;
}

/* ═══ Modal de agregar usuario ═══ */
.ra-suggestions-note {
  font-size: 12px;
  color: var(--muted, #777);
  margin-top: -10px;
  margin-bottom: 14px;
  background: rgba(6, 163, 182, 0.06);
  padding: 8px 12px;
  border-radius: 6px;
  border-left: 3px solid #06a3b6;
}

.ra-role-hint {
  font-size: 12px;
  color: var(--muted, #777);
  background: var(--bg, #f0f4f8);
  padding: 10px 12px;
  border-radius: 6px;
  margin: 8px 0 14px;
  font-style: italic;
  line-height: 1.5;
  min-height: 20px;
}

/* ═══ Status bar flotante ═══ */
.ra-status {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #22a06b;
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(34, 160, 107, 0.35);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 9999;
  max-width: 90vw;
}

.ra-status.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ═══ Responsive ═══ */
@media (max-width: 700px) {
  .ra-header {
    flex-direction: column;
    align-items: stretch;
  }

  .ra-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .ra-table th,
  .ra-table td {
    padding: 10px 8px;
    font-size: 13px;
  }

  .ra-user-email {
    max-width: 160px;
    font-size: 11px;
  }

  .ra-avatar,
  .ra-avatar-initials {
    width: 32px;
    height: 32px;
  }

  .ra-updated-by {
    display: none;
  }
}

/* ═══════════════════════════════════════════
   DARK MODE — overrides puntuales
   (el resto del archivo ya usa var(--card), var(--border)
   etc., por lo que la sobreescritura de variables en
   styles.css lo cubre automáticamente)
   ═══════════════════════════════════════════ */
body[data-theme="dark"] .ra-act-btn:hover,
body[data-theme="dark"] #ra-table .ra-act-btn.ra-del:hover {
  background: rgba(244, 63, 94, .15);
  border-color: rgba(244, 63, 94, .45);
  color: #f87171;
}
body[data-theme="dark"] .ra-role-select {
  color-scheme: dark;
}
body[data-theme="dark"] .ra-suggestions-note {
  background: rgba(6, 163, 182, .10);
  color: var(--text-2);
  border-left-color: var(--cyan);
}
body[data-theme="dark"] .ra-role-hint {
  background: var(--paper-2);
  color: var(--text-2);
}
