/* ═══════════════════════════════════════════════════
   DIC Admin · Militares (usuarios.css)
   Complementa dashboard.css — não duplica estilos base.
   ═══════════════════════════════════════════════════ */

/* ════════════════════════════════════════
   TOOLBAR (filtros)
   ════════════════════════════════════════ */
.usr-toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Tabs de status */
.usr-tabs {
  display: flex;
  gap: 4px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 10px;
  padding: 4px;
  width: fit-content;
}

.usr-tab {
  padding: 6px 14px;
  border-radius: 7px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.77rem;
  font-weight: 600;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.14s, color 0.14s;
}

.usr-tab:hover { background: hsl(var(--muted)); color: hsl(var(--foreground)); }

.usr-tab--active {
  background: hsl(var(--primary));
  color: #fff;
}

.usr-tab--active:hover {
  background: hsl(var(--primary));
  color: #fff;
}

/* Linha de filtros adicionais + busca */
.usr-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.usr-select {
  height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  font-family: inherit;
  font-size: 0.77rem;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: border-color 0.14s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

.usr-select:hover   { border-color: hsl(var(--primary) / 0.5); }
.usr-select:focus   { border-color: hsl(var(--primary)); }

/* Campo de busca */
.usr-search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  color: hsl(var(--muted-foreground));
  min-width: 220px;
  max-width: 320px;
  flex: 1;
  transition: border-color 0.14s;
}

.usr-search:focus-within {
  border-color: hsl(var(--primary));
  color: hsl(var(--foreground));
}

.usr-search input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.8rem;
  color: hsl(var(--foreground));
  outline: none;
}

.usr-search input::placeholder { color: hsl(var(--muted-foreground)); }

.usr-search__clear {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  border-radius: 4px;
  padding: 0;
  transition: color 0.14s;
  flex-shrink: 0;
}

.usr-search__clear:hover { color: hsl(var(--foreground)); }

/* ════════════════════════════════════════
   CONTAGEM
   ════════════════════════════════════════ */
.usr-count {
  font-size: 0.75rem;
  font-weight: 600;
  color: hsl(var(--muted-foreground));
  letter-spacing: 0.03em;
}

/* ════════════════════════════════════════
   TABELA
   ════════════════════════════════════════ */
.usr-table-wrap {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 12px;
  overflow: hidden;
  overflow-x: auto;
}

.usr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  min-width: 800px;
}

.usr-table thead {
  background: hsl(var(--muted));
}

.usr-table th {
  padding: 11px 14px;
  text-align: left;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: hsl(var(--muted-foreground));
  white-space: nowrap;
  border-bottom: 1px solid hsl(var(--border));
}

.usr-table td {
  padding: 12px 14px;
  vertical-align: middle;
  border-bottom: 1px solid hsl(var(--border));
  color: hsl(var(--foreground));
}

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

.usr-table tbody tr:hover { background: hsl(var(--muted) / 0.5); }

/* Colunas */
.col-id      { width: 48px; text-align: center; color: hsl(var(--muted-foreground)); font-size: 0.75rem; }
.col-ip      { color: hsl(var(--muted-foreground)); }
.col-acoes   { white-space: nowrap; }

/* Célula de nick com avatar */
.usr-nick-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.usr-avatar-wrap {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  background: hsl(var(--muted));
  flex-shrink: 0;
}

.usr-avatar {
  width: 100%;
  height: auto;
  display: block;
  transform: translateY(-8px); /* ← sobe/desce o boneco: negativo = sobe, positivo = desce */
}

/* Estados de carregamento / vazio */
.usr-table__loading-row td,
.usr-table__empty {
  text-align: center;
  padding: 48px 24px;
  color: hsl(var(--muted-foreground));
  font-size: 0.82rem;
}

/* ════════════════════════════════════════
   BADGES
   ════════════════════════════════════════ */
.usr-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

/* Status */
.usr-badge--ativo   { background: hsl(142 55% 42% / 0.15); color: hsl(142 55% 50%); }
.usr-badge--inativo { background: hsl(220 15% 50% / 0.15); color: hsl(220 10% 55%); }
.usr-badge--muted   { background: hsl(var(--muted));        color: hsl(var(--muted-foreground)); }

/* Situação */
.usr-badge--sit-em-servico  { background: hsl(142 55% 42% / 0.15); color: hsl(142 55% 50%); }
.usr-badge--sit-de-licenca  { background: hsl(213 80% 55% / 0.15); color: hsl(213 80% 60%); }
.usr-badge--sit-banido      { background: hsl(  0 70% 50% / 0.15); color: hsl(  0 70% 58%); }
.usr-badge--sit-demitido    { background: hsl(  0 55% 40% / 0.15); color: hsl(  0 55% 52%); }
.usr-badge--sit-dispensado  { background: hsl( 28 90% 52% / 0.15); color: hsl( 28 90% 58%); }
.usr-badge--sit-aposentado  { background: hsl(220 12% 52% / 0.15); color: hsl(220 10% 58%); }
.usr-badge--sit-reformado   { background: hsl(270 60% 55% / 0.15); color: hsl(270 60% 65%); }
.usr-badge--sit-pendente    { background: hsl( 43 95% 50% / 0.15); color: hsl( 43 95% 54%); }
.usr-badge--sit-muted       { background: hsl(var(--muted));        color: hsl(var(--muted-foreground)); }

/* Permissão */
.usr-badge--perm-admin     { background: hsl(var(--primary) / 0.15); color: hsl(var(--primary)); }
.usr-badge--perm-moderador { background: hsl(270 60% 55% / 0.15);   color: hsl(270 60% 65%);    }
.usr-badge--perm-usuario   { background: hsl(220 12% 52% / 0.15);   color: hsl(220 10% 58%);    }
.usr-badge--perm-grupo     { background: hsl(195 70% 42% / 0.14);   color: hsl(195 65% 40%);    }

html.light .usr-badge--perm-grupo { background: hsl(195 70% 42% / 0.12); color: hsl(195 65% 32%); }

/* ════════════════════════════════════════
   BOTÕES DE AÇÃO
   ════════════════════════════════════════ */
.usr-actions-lock {
  color: hsl(var(--muted-foreground));
  font-size: 0.8rem;
}

.usr-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 7px;
  border: none;
  font-family: inherit;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.14s, opacity 0.14s;
}

.usr-btn + .usr-btn { margin-left: 6px; }

.usr-btn--edit {
  background: hsl(213 80% 55% / 0.14);
  color: hsl(213 80% 62%);
}
.usr-btn--edit:hover { background: hsl(213 80% 55% / 0.25); }

.usr-btn--delete {
  background: hsl(0 70% 50% / 0.14);
  color: hsl(0 70% 60%);
}
.usr-btn--delete:hover { background: hsl(0 70% 50% / 0.25); }

/* ════════════════════════════════════════
   MODAIS
   ════════════════════════════════════════ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 14px;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  transform: translateY(12px);
  transition: transform 0.18s ease;
}

.modal-backdrop.open .modal { transform: translateY(0); }

.modal--sm { max-width: 380px; }

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid hsl(var(--border));
  border-radius: 14px 14px 0 0;
}

.modal__title {
  font-size: 0.92rem;
  font-weight: 700;
}

.modal__title--danger { color: hsl(0 70% 58%); }

.modal__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.14s, color 0.14s;
}

.modal__close:hover { background: hsl(var(--muted)); color: hsl(var(--foreground)); }

.modal__body {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.modal__field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.modal__label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: hsl(var(--muted-foreground));
}

.modal__input,
.modal__select {
  height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: inherit;
  font-size: 0.82rem;
  outline: none;
  transition: border-color 0.14s;
}

.modal__input:focus,
.modal__select:focus { border-color: hsl(var(--primary)); }

.modal__input--readonly {
  color: hsl(var(--muted-foreground));
  cursor: default;
  background: hsl(var(--muted));
}

.modal__select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  cursor: pointer;
}

.modal__warn-text {
  font-size: 0.83rem;
  color: hsl(var(--foreground));
  line-height: 1.6;
}

.modal__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px 18px;
  border-top: 1px solid hsl(var(--border));
  border-radius: 0 0 14px 14px;
}

.modal__btn {
  height: 36px;
  padding: 0 18px;
  border-radius: 8px;
  border: none;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.14s;
}

.modal__btn:disabled { opacity: 0.6; cursor: not-allowed; }

.modal__btn--secondary {
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
}
.modal__btn--secondary:hover:not(:disabled) { opacity: 0.8; }

.modal__btn--primary {
  background: hsl(var(--primary));
  color: #fff;
}
.modal__btn--primary:hover:not(:disabled) { opacity: 0.88; }

.modal__btn--danger {
  background: hsl(0 70% 50%);
  color: #fff;
}
.modal__btn--danger:hover:not(:disabled) { opacity: 0.88; }

/* ════════════════════════════════════════
   TOAST
   ════════════════════════════════════════ */
.usr-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 600;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  white-space: nowrap;
  max-width: 90vw;
  text-align: center;
}

.usr-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.usr-toast--success {
  background: hsl(142 55% 42%);
  color: #fff;
}

.usr-toast--error {
  background: hsl(0 70% 50%);
  color: #fff;
}

/* ════════════════════════════════════════
   ABAS DO MODAL DE EDIÇÃO
   ════════════════════════════════════════ */
.modal--tabs { max-width: 500px; }

.modal__tabs {
  display: flex;
  align-items: center;
  border-bottom: 1px solid hsl(var(--border));
  padding: 0 8px;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.modal__tabs::-webkit-scrollbar { display: none; }

.modal__tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: transparent;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 0.14s, border-color 0.14s;
}

.modal__tab:hover { color: hsl(var(--foreground)); }

.modal__tab--active {
  color: hsl(var(--foreground));
  border-bottom-color: hsl(var(--primary));
}

.modal__tab-username {
  margin-left: auto;
  padding: 0 14px 0 8px;
  font-size: 0.78rem;
  font-weight: 700;
  color: hsl(var(--muted-foreground));
  white-space: nowrap;
  flex-shrink: 0;
}

.modal__tab-panel .modal__body { min-height: 196px; }

/* ════════════════════════════════════════
   AUTENTICAÇÃO DE 2 FATORES (ABA SEGURANÇA)
   ════════════════════════════════════════ */
.modal__twofa-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: hsl(var(--muted-foreground));
  font-size: 0.82rem;
  min-height: 80px;
}

.modal__twofa-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid hsl(var(--border));
  border-top-color: hsl(var(--primary));
  border-radius: 50%;
  animation: twofa-spin 0.7s linear infinite;
  flex-shrink: 0;
}

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

.modal__twofa-empty {
  display: flex;
  align-items: center;
  gap: 10px;
  color: hsl(var(--muted-foreground));
  font-size: 0.82rem;
  padding: 8px 0;
}

.modal__twofa-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: 10px;
  background: hsl(var(--muted));
  border: 1px solid hsl(var(--border));
  gap: 12px;
}

.modal__twofa-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.modal__twofa-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  truncate: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.modal__twofa-type {
  font-size: 0.7rem;
  color: hsl(var(--muted-foreground));
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.modal__twofa-disable-btn {
  height: 30px;
  padding: 0 14px;
  border-radius: 7px;
  border: none;
  font-family: inherit;
  font-size: 0.74rem;
  font-weight: 600;
  background: hsl(0 70% 50% / 0.12);
  color: hsl(0 70% 60%);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.14s;
}

.modal__twofa-disable-btn:hover:not(:disabled) { background: hsl(0 70% 50% / 0.24); }

.modal__twofa-disable-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Placeholder da aba Perfil */
.modal__placeholder-text {
  font-size: 0.82rem;
  color: hsl(var(--muted-foreground));
  text-align: center;
  padding: 36px 0;
}

/* ════════════════════════════════════════
   CUSTOM SELECT — overrides e extras
   (base em global.css seção 19)
   ════════════════════════════════════════ */

/* Panel fica absolute nesta página (sem positionPanel JS) */
.csel__panel {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
}

/* Rótulo de grupo dentro do painel */
.csel__group-label {
  padding: 10px 12px 4px;
  font-size: 0.67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: hsl(var(--muted-foreground));
  border-top: 1px solid hsl(var(--border));
  margin-top: 2px;
}

.csel__group-label:first-child {
  border-top: none;
  margin-top: 0;
}

/* ════════════════════════════════════════
   CSEL NO FILTRO (variante menor)
   ════════════════════════════════════════ */
.csel--filter .csel__trigger {
  height: 36px;
  font-size: 0.77rem;
  font-weight: 500;
  min-width: 130px;
  background: hsl(var(--card));
}

.csel--filter .csel__panel {
  min-width: 180px;
  background: hsl(var(--card));
}

.csel--filter .csel__item {
  background: hsl(var(--card));
}

.csel--filter .csel__item:hover {
  background: hsl(var(--muted));
}

.csel--filter .csel__item--selected {
  background: hsl(var(--primary) / 0.07);
}

.csel--filter .csel__item--selected:hover {
  background: hsl(var(--primary) / 0.13);
}

/* ════════════════════════════════════════
   MODO CLARO
   ════════════════════════════════════════ */
html.light .usr-table tbody tr:hover { background: hsl(var(--muted) / 0.8); }

html.light .modal {
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.14);
}

html.light .modal-backdrop {
  background: rgba(0, 0, 0, 0.35);
}

/* ════════════════════════════════════════
   PAGINAÇÃO
   ════════════════════════════════════════ */
.usr-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 4px 0 8px;
}

.usr-page-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s, opacity 0.14s;
  flex-shrink: 0;
}

.usr-page-arrow:hover:not(:disabled) {
  background: hsl(var(--muted));
  border-color: hsl(var(--primary) / 0.4);
}

.usr-page-arrow:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.usr-page-info {
  display: flex;
  align-items: center;
  gap: 8px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  padding: 0 14px;
  height: 36px;
}

.usr-page-input {
  width: 40px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  color: hsl(var(--foreground));
  text-align: center;
  outline: none;
  -moz-appearance: textfield;
}

.usr-page-input::-webkit-inner-spin-button,
.usr-page-input::-webkit-outer-spin-button { -webkit-appearance: none; }

.usr-page-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  white-space: nowrap;
}

/* ════════════════════════════════════════
   RESPONSIVO
   ════════════════════════════════════════ */
@media (max-width: 767px) {
  .usr-tabs      { flex-wrap: wrap; }
  .usr-filters   { flex-direction: column; align-items: stretch; }
  .usr-search    { max-width: 100%; }
  .modal__row    { grid-template-columns: 1fr; }
}
