/* RBAC STYLES & ROLES MANAGEMENT */
.rbac-role-badge {
  display: inline-flex !important;
  width: max-content;
  margin-top: 3px;
  padding: 3px 8px;
  border-radius: 999px;
  font: 700 9px var(--mono) !important;
  letter-spacing: .02em;
  background: #e2e8f0;
  color: #1e293b;
}

.rbac-role-owner { background: #fff0c2; color: #85620c; }
.rbac-role-shop_chief { background: #fee2e2; color: #991b1b; }
.rbac-role-receptionist { background: #e6f1ff; color: #28608f; }
.rbac-role-mechanic { background: #e8f5df; color: #4e7b33; }
.rbac-role-helper { background: #fef3c7; color: #92400e; }
.rbac-role-warehouse_manager { background: #ede9fe; color: #5b21b6; }

.rbac-summary-loading .admin-metric-grid { visibility: hidden; }
.rbac-team-nav { margin-top: 9px; border-top: 1px solid rgba(255, 255, 255, .08) !important; }
.rbac-team-icon { display: grid; place-items: center; width: 17px; font-size: 13px; }

.admin-content.rbac-team-open > *:not(.rbac-team-view) { display: none !important; }
.rbac-team-view { display: none !important; }
.admin-content.rbac-team-open > .rbac-team-view { display: block !important; animation: toolOrdersFadeIn 0.2s ease-out; }

.rbac-team-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.rbac-team-heading h1 {
  margin: 5px 0 7px;
  color: #0c2338;
  font-size: 32px;
  letter-spacing: -.04em;
}

.rbac-team-heading p { margin: 0; color: #64748b; font-size: 13px; }

/* TABS */
.rbac-tabs-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  border-bottom: 1px solid #dce4eb;
  padding-bottom: 1px;
}

.rbac-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: #64748b;
  font: 700 12px var(--sans);
  cursor: pointer;
  transition: all 0.15s ease;
}

.rbac-tab-btn.active {
  color: #0c2338;
  border-bottom-color: #0284c7;
}

.rbac-tab-count {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  font: 700 10px var(--mono);
}

.rbac-tab-btn.active .rbac-tab-count {
  background: #0284c7;
  color: #ffffff;
}

/* CARDS DE ROLES */
.rbac-roles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 16px;
}

.rbac-role-card {
  padding: 20px;
  display: flex;
  flex-direction: column;
  border-radius: 8px;
  border: 1px solid #dce4eb;
  background: #ffffff;
}

.rbac-role-card-inactive {
  background: #f8fafc;
  opacity: 0.7;
}

.rbac-role-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}

.rbac-role-card-top h3 {
  margin: 5px 0 3px;
  color: #0f172a;
  font-size: 17px;
  font-weight: 700;
}

.rbac-role-kind-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 3px;
  font: 800 8px var(--mono);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.rbac-role-kind-badge.system { background: #e0f2fe; color: #0369a1; }
.rbac-role-kind-badge.custom { background: #fef3c7; color: #b45309; }

.rbac-slug-tag {
  display: inline-block;
  color: #64748b;
  font: 600 10px var(--mono);
}

.rbac-role-desc {
  margin: 0 0 14px;
  color: #475569;
  font-size: 12px;
  line-height: 1.4;
  flex-grow: 1;
}

.rbac-role-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 14px;
  border-radius: 6px;
  background: #f8fafc;
  border: 1px solid #edf2f7;
}

.rbac-role-stats small {
  display: block;
  color: #64748b;
  font: 700 9px var(--mono);
  text-transform: uppercase;
}

.rbac-role-stats strong {
  color: #0f172a;
  font-size: 12px;
}

.rbac-role-modules-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 16px;
}

.rbac-pill-module {
  padding: 2px 7px;
  border-radius: 4px;
  background: #f1f5f9;
  color: #475569;
  font: 600 10px var(--mono);
}

.rbac-pill-more {
  padding: 2px 6px;
  color: #0284c7;
  font: 700 10px var(--mono);
}

.rbac-role-card-actions {
  display: flex;
  gap: 6px;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid #f1f5f9;
}

.rbac-role-card-actions button {
  flex: 1;
}

.rbac-role-card-actions .rbac-delete-role {
  flex: 0 0 40px;
  color: #dc2626 !important;
}

/* LISTA DE USUARIOS */
.rbac-team-card { overflow: hidden; border-radius: 8px; }
.rbac-team-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e6ebef;
  background: #f8fafc;
}

.rbac-user-list { display: flex; flex-direction: column; }
.rbac-user-row {
  display: grid;
  grid-template-columns: 42px minmax(160px, 1fr) 160px 100px auto;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid #edf0f2;
}

.rbac-user-row:last-child { border-bottom: 0; }
.rbac-user-inactive { background: #fafafa; opacity: .65; }

.rbac-user-avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #0f2b48;
  color: #a8df45;
  font: 700 12px var(--mono);
}

.rbac-user-name { display: flex; flex-direction: column; gap: 3px; }
.rbac-user-name strong { color: #0f172a; font-size: 13px; }
.rbac-user-name small { color: #64748b; font-size: 11px; }

.rbac-role-pill {
  width: max-content;
  padding: 4px 9px;
  border-radius: 999px;
  font: 700 10px var(--mono);
  background: #e2e8f0;
  color: #1e293b;
}

.rbac-user-status.status-active { color: #16a34a; font: 600 11px var(--mono); }
.rbac-user-status.status-inactive { color: #94a3b8; font: 600 11px var(--mono); }

/* MATRIZ DE PERMISOS EN EL MODAL DE ROL */
.rbac-role-form { width: min(840px, 100%) !important; }
.rbac-permissions-matrix-block {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
}

.rbac-matrix-header {
  padding: 14px 18px;
  background: #0b2847;
  color: #ffffff;
}

.rbac-matrix-header strong { display: block; font-size: 13px; font-weight: 700; }
.rbac-matrix-header small { color: #cbd5e1; font-size: 11px; }

.rbac-matrix-table-wrap {
  overflow-x: auto;
  max-height: 360px;
  overflow-y: auto;
}

.rbac-matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.rbac-matrix-table thead th {
  padding: 10px 12px;
  background: #f1f5f9;
  color: #334155;
  font: 700 10px var(--mono);
  text-transform: uppercase;
  border-bottom: 1px solid #cbd5e1;
  position: sticky;
  top: 0;
  z-index: 2;
}

.rbac-matrix-table tbody tr {
  border-bottom: 1px solid #edf2f7;
}

.rbac-matrix-table tbody tr:hover {
  background: #f8fafc;
}

.rbac-matrix-table td {
  padding: 10px 12px;
  vertical-align: middle;
}

.rbac-mod-col strong {
  display: block;
  color: #0f172a;
  font-size: 12px;
}

.rbac-mod-col small {
  color: #64748b;
  font-size: 10px;
}

.rbac-matrix-table input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #0284c7;
  cursor: pointer;
}

.rbac-capabilities-subblock {
  padding: 16px 18px;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
}

.rbac-capabilities-subblock strong {
  display: block;
  margin-bottom: 10px;
  color: #1e293b;
  font-size: 12px;
}

.rbac-capabilities-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.rbac-cap-label {
  display: flex !important;
  align-items: center !important;
  flex-direction: row !important;
  gap: 8px !important;
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #ffffff;
  color: #334155 !important;
  font-size: 11px !important;
  cursor: pointer;
}

.rbac-cap-label input {
  width: 15px !important;
  height: 15px !important;
  accent-color: #0284c7;
}

@media (max-width: 768px) {
  .rbac-team-heading { flex-direction: column; align-items: stretch; }
  .rbac-user-row { grid-template-columns: 38px 1fr auto; padding: 12px; }
  .rbac-role-pill { grid-column: 2; }
  .rbac-user-status { grid-column: 3; }
  .rbac-edit-user { grid-column: 2 / -1; width: 100%; }
  .rbac-capabilities-grid { grid-template-columns: 1fr; }
}
