/* ==========================================================================
   Componentes reutilizáveis
   ========================================================================== */

/* ---------- Botões ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 13px;
  line-height: 1;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease);
  white-space: nowrap;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn--primary {
  background: var(--faj-blue);
  color: var(--white);
}
.btn--primary:hover:not(:disabled) { background: var(--faj-blue-700); }

.btn--secondary {
  background: var(--white);
  color: var(--gray-800);
  border-color: var(--border-strong);
}
.btn--secondary:hover:not(:disabled) { background: var(--gray-50); border-color: var(--gray-400); }

.btn--ghost {
  background: transparent;
  color: var(--gray-700);
}
.btn--ghost:hover:not(:disabled) { background: var(--gray-100); color: var(--gray-900); }

.btn--danger {
  background: var(--danger-600);
  color: var(--white);
}
.btn--danger:hover:not(:disabled) { background: var(--danger-700); }

.btn--sm { padding: 6px 10px; font-size: 12px; }
.btn--lg { padding: 11px 20px; font-size: 14px; }
.btn--icon { padding: 8px; width: 36px; height: 36px; }
.btn--full { width: 100%; }

/* Link-style button (texto) */
.btn-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--faj-blue-500);
  font-size: 13px;
  font-weight: 600;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
}
.btn-link:hover { color: var(--faj-blue-700); }

/* Ícone-só */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--radius);
  color: var(--gray-500);
  background: transparent;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.icon-btn:hover { background: var(--gray-100); color: var(--gray-800); }

/* ---------- Card ---------- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
}
.card--tight { padding: 16px; }
.card--flush { padding: 0; overflow: hidden; }

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card__title { font-size: 15px; font-weight: 600; color: var(--gray-900); }
.card__subtitle { font-size: 12px; color: var(--gray-500); margin-top: 2px; }
.card__body { padding: 20px; }

/* ---------- Avatar ---------- */
.avatar {
  --avatar-size: 44px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: var(--avatar-size);
  height: var(--avatar-size);
  border-radius: 50%;
  overflow: hidden;
  background: var(--faj-blue-50);
  color: var(--faj-blue);
  font-weight: 700;
  font-size: calc(var(--avatar-size) * 0.36);
  letter-spacing: 0.02em;
  line-height: 1;
  user-select: none;
  vertical-align: middle;
}
.avatar__img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}
.avatar__initials { position: relative; z-index: 0; }
.avatar.is-broken .avatar__initials { z-index: 1; }
.avatar--xs { --avatar-size: 24px; font-size: 10px; font-weight: 700; }
.avatar--sm { --avatar-size: 32px; font-size: 12px; }
.avatar--md { --avatar-size: 40px; font-size: 13px; }
.avatar--lg { --avatar-size: 72px; font-size: 22px; }
.avatar--xl { --avatar-size: 96px; font-size: 30px; }

/* ---------- KPI strip (faixa editorial em vez de cards) ---------- */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--white);
  overflow: hidden;
}
.kpi-strip__item {
  padding: 18px 22px;
  display: flex; flex-direction: column;
  gap: 2px;
  border-right: 1px solid var(--border);
  position: relative;
}
.kpi-strip__item:last-child { border-right: none; }
.kpi-strip__label {
  font-size: 11px;
  color: var(--gray-500);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.kpi-strip__value {
  font-size: 28px;
  font-weight: 800;
  color: var(--gray-900);
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.kpi-strip__value--muted { color: var(--gray-600); }
.kpi-strip__value--success { color: var(--success-700); }
.kpi-strip__value--warning { color: var(--warning-700); }
.kpi-strip__value--accent  { color: var(--faj-blue); }
.kpi-strip__hint {
  font-size: 11px;
  color: var(--gray-500);
  margin-top: 4px;
}
.kpi-strip__hint-bar {
  height: 4px;
  border-radius: 999px;
  background: var(--gray-100);
  margin-top: 8px;
  overflow: hidden;
}
.kpi-strip__hint-bar > span {
  display: block; height: 100%;
  background: var(--faj-blue);
  transition: width var(--dur) var(--ease);
}
@media (max-width: 640px) {
  .kpi-strip { grid-template-columns: repeat(2, 1fr); }
  .kpi-strip__item { border-right: none; border-bottom: 1px solid var(--border); }
  .kpi-strip__item:nth-child(odd) { border-right: 1px solid var(--border); }
  .kpi-strip__item:nth-last-child(-n+2) { border-bottom: none; }
}

/* Stat (mantido como legado, mas evitar usar) */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}
.stat {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat__label { font-size: 12px; color: var(--gray-500); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.stat__value { font-size: 26px; font-weight: 800; color: var(--gray-900); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat__meta { font-size: 12px; color: var(--gray-500); display: flex; align-items: center; gap: 6px; }
.stat__meta .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gray-300); }

/* ---------- Badge / status inline ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  border: 1px solid transparent;
  line-height: 1.5;
  white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--neutral  { background: var(--gray-100);   color: var(--gray-700);   border-color: var(--gray-200); }
.badge--success  { background: var(--success-50); color: var(--success-700); border-color: var(--success-100); }
.badge--warning  { background: var(--warning-50); color: var(--warning-700); border-color: var(--warning-100); }
.badge--danger   { background: var(--danger-50);  color: var(--danger-700);  border-color: var(--danger-100); }
.badge--info     { background: var(--info-50);    color: var(--info-700);    border-color: var(--info-100); }
.badge--brand    { background: var(--faj-blue-50); color: var(--faj-blue-700); border-color: var(--faj-blue-100); }

/* Status inline (● + texto), forma discreta preferida na lista */
.status-dot {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--gray-700); font-weight: 500;
  white-space: nowrap;
}
.status-dot::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--gray-400);
  box-shadow: 0 0 0 2px rgba(0,0,0,0);
}
.status-dot--success { color: var(--success-700); }
.status-dot--success::before { background: var(--success-600); }
.status-dot--warning { color: var(--warning-700); }
.status-dot--warning::before { background: var(--warning-600); }
.status-dot--info    { color: var(--info-700); }
.status-dot--info::before    { background: var(--info-600); }
.status-dot--neutral::before { background: var(--gray-400); }

/* ---------- Inputs ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-700);
}
.field__hint  { font-size: 11px; color: var(--gray-500); }
.field__error { font-size: 11px; color: var(--danger-700); }

.input, .select, .textarea {
  background: var(--white);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-size: 13px;
  color: var(--gray-800);
  width: 100%;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--gray-400); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--faj-blue-500);
  box-shadow: 0 0 0 3px rgba(28,69,144,0.12);
  outline: none;
}
.textarea { min-height: 88px; resize: vertical; line-height: 1.5; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%234d5566' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}

.input--search {
  padding-left: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23737b8b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 10px center;
}

/* ---------- Toolbar de filtros ---------- */
.filter-bar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(3, minmax(150px, 200px)) auto;
  gap: 8px;
  align-items: center;
}
.filter-bar .input, .filter-bar .select { padding-top: 7px; padding-bottom: 7px; }
@media (max-width: 900px) {
  .filter-bar { grid-template-columns: 1fr 1fr; }
  .filter-bar .btn { grid-column: 1 / -1; }
}
@media (max-width: 520px) {
  .filter-bar { grid-template-columns: 1fr; }
}

/* ---------- Tabela ---------- */
.table-wrap {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.table-wrap__scroll { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table thead th {
  text-align: left;
  padding: 10px 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-500);
  background: var(--gray-50);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table tbody td {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--gray-800);
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--dur-fast) var(--ease); }
.table tbody tr:hover { background: var(--gray-50); }

.table__cell-user {
  display: flex; align-items: center; gap: 12px;
}
.table__cell-user__meta { min-width: 0; }
.table__cell-user__name { font-weight: 600; color: var(--gray-900); font-size: 13px; line-height: 1.25; }
.table__cell-user__sub  { color: var(--gray-500); font-size: 12px; line-height: 1.25; margin-top: 1px; }

.table__actions {
  display: inline-flex;
  gap: 4px;
  justify-content: flex-end;
  align-items: center;
}

@media (max-width: 720px) {
  .table--stack-mobile thead { display: none; }
  .table--stack-mobile,
  .table--stack-mobile tbody,
  .table--stack-mobile tr,
  .table--stack-mobile td { display: block; width: 100%; }
  .table--stack-mobile tr {
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
  }
  .table--stack-mobile tr:last-child { border-bottom: none; }
  .table--stack-mobile td {
    padding: 4px 0;
    border-bottom: none;
    display: flex; justify-content: space-between; gap: 12px;
    align-items: center;
  }
  .table--stack-mobile td::before {
    content: attr(data-label);
    color: var(--gray-500);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
  }
  .table--stack-mobile .table__actions { justify-content: flex-end; }
}

/* ---------- Progress ---------- */
.progress {
  width: 100%;
  height: 6px;
  background: var(--gray-100);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.progress__bar {
  height: 100%;
  background: var(--faj-blue);
  border-radius: inherit;
  transition: width var(--dur) var(--ease);
}
.progress--sm { height: 4px; }

.progress-inline {
  display: flex; align-items: center; gap: 10px;
  min-width: 140px;
}
.progress-inline .progress { flex: 1 1 auto; }
.progress-inline__value {
  font-variant-numeric: tabular-nums;
  font-weight: 600; color: var(--gray-700); font-size: 12px;
  min-width: 34px; text-align: right;
}

/* ---------- Rating scale ---------- */
.rating {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.rating__opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 84px;
  padding: 10px 8px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--gray-700);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
  text-align: center;
}
.rating__opt:hover {
  border-color: var(--faj-blue-500);
  background: var(--faj-blue-50);
  color: var(--faj-blue-700);
}
.rating__opt.is-selected {
  border-color: var(--faj-blue);
  background: var(--faj-blue);
  color: var(--white);
}
.rating__opt-num {
  font-size: 16px;
  font-weight: 800;
}
.rating__opt-label {
  font-size: 10px;
  font-weight: 500;
  line-height: 1.2;
  opacity: 0.9;
  letter-spacing: 0.01em;
}
@media (max-width: 600px) {
  .rating__opt { flex: 1 1 calc(50% - 6px); min-width: 0; }
}

/* ---------- Evidência ---------- */
.evidence {
  margin-top: 14px;
}
.evidence label { display: block; margin-bottom: 6px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.45);
  display: grid;
  place-items: center;
  z-index: 60;
  padding: 16px;
  animation: fadeIn var(--dur) var(--ease);
}
.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: min(560px, 100%);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex; flex-direction: column;
  max-height: calc(100vh - 40px);
  animation: pop var(--dur) var(--ease);
}
.modal--lg { width: min(760px, 100%); }
.modal__header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.modal__title { font-size: 15px; font-weight: 700; color: var(--gray-900); }
.modal__subtitle { font-size: 12px; color: var(--gray-500); margin-top: 2px; }
.modal__body { padding: 20px; overflow-y: auto; }
.modal__footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  background: var(--gray-50);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- Toast ---------- */
.toast-stack {
  position: fixed;
  right: 20px; bottom: 20px;
  z-index: 80;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--gray-900);
  color: var(--white);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 10px;
  animation: slideIn var(--dur) var(--ease);
  pointer-events: auto;
  min-width: 240px;
  max-width: 380px;
}
.toast--success { background: var(--success-700); }
.toast--warning { background: var(--warning-700); }
.toast--danger  { background: var(--danger-700);  }
.toast .icon { flex: 0 0 auto; opacity: 0.95; }
@keyframes slideIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Empty state ---------- */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-500);
}
.empty__title { color: var(--gray-800); font-weight: 600; font-size: 14px; margin-top: 12px; }
.empty__desc { margin-top: 4px; font-size: 13px; }
.empty .icon-wrap {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--gray-100); color: var(--gray-500);
  display: grid; place-items: center; margin: 0 auto;
}

/* ---------- Loading ---------- */
.spinner {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid var(--gray-200);
  border-top-color: var(--faj-blue);
  animation: spin 700ms linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Tabs discretos ---------- */
.tabs {
  display: inline-flex;
  border-bottom: 1px solid var(--border);
  gap: 0;
}
.tabs__btn {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-500);
  border: none;
  background: transparent;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs__btn:hover { color: var(--gray-800); }
.tabs__btn.is-active {
  color: var(--faj-blue);
  border-bottom-color: var(--faj-blue);
}

/* ---------- Chip ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 500;
  background: var(--faj-blue-50);
  color: var(--faj-blue-700);
  border: 1px solid var(--faj-blue-100);
}
.chip__x {
  width: 16px; height: 16px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: var(--faj-blue-700);
  background: transparent;
}
.chip__x:hover { background: var(--faj-blue-100); }

/* ---------- Alert / Callout ---------- */
.alert {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--info-100);
  background: var(--info-50);
  color: var(--info-700);
  font-size: 13px;
  line-height: 1.5;
}
.alert--warning { border-color: var(--warning-100); background: var(--warning-50); color: var(--warning-700); }
.alert--danger  { border-color: var(--danger-100);  background: var(--danger-50);  color: var(--danger-700); }
.alert__title { font-weight: 700; color: inherit; margin-bottom: 2px; }

/* ---------- Divider ---------- */
.divider { height: 1px; background: var(--border); border: none; margin: 0; }

/* ---------- Info list ---------- */
.info-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
}
.info-list__item .label {
  font-size: 11px;
  color: var(--gray-500);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}
.info-list__item .value {
  font-size: 14px;
  color: var(--gray-900);
  font-weight: 500;
}

/* ---------- Breadcrumb ---------- */
.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px;
  color: var(--gray-500);
}
.breadcrumb a { color: var(--gray-600); font-weight: 500; }
.breadcrumb a:hover { color: var(--faj-blue-700); }
.breadcrumb .sep { color: var(--gray-400); }
.breadcrumb .current { color: var(--gray-900); font-weight: 600; }
