/* ─── Admin layout ───────────────────────────────────────────── */
.page-admin { display: block; }

.admin-layout {
  display: flex;
  min-height: calc(100vh - 57px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: .625rem;
  flex-shrink: 0;
}

.panel-badge {
  font-size: .75rem;
  font-weight: 600;
  padding: .15rem .5rem;
  border-radius: 5px;
  background: var(--color-bg);
  color: var(--color-muted);
  border: 1px solid var(--color-border);
  white-space: nowrap;
}

/* ─── Sidebar ────────────────────────────────────────────────── */
.admin-sidebar {
  width: 180px;
  flex-shrink: 0;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  padding: 1.25rem .75rem;
  display: flex;
  flex-direction: column;
  gap: .25rem;
}

.nav-item {
  width: 100%;
  text-align: left;
  padding: .5rem .75rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-size: .9rem;
  cursor: pointer;
  color: var(--color-muted);
  transition: background .12s, color .12s;
}

.nav-item:hover  { background: var(--color-bg); color: var(--color-text); }
.nav-item.active { background: var(--color-primary); color: #fff; }

/* ─── Content ────────────────────────────────────────────────── */
.admin-content {
  flex: 1;
  padding: 1.5rem;
  overflow-x: auto;
}

.admin-section { }

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

.section-header h2 {
  font-size: 1.125rem;
  font-weight: 600;
}

/* ─── Buttons ────────────────────────────────────────────────── */
.btn-primary {
  padding: .45rem 1rem;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity .15s;
}
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-ghost {
  padding: .45rem 1rem;
  background: transparent;
  border: 1.5px solid var(--color-border);
  border-radius: 6px;
  font-size: .875rem;
  cursor: pointer;
  color: var(--color-muted);
  transition: border-color .15s;
}
.btn-ghost:hover { border-color: var(--color-text); color: var(--color-text); }

.btn-action {
  padding: .25rem .625rem;
  background: transparent;
  border: 1.5px solid var(--color-border);
  border-radius: 5px;
  font-size: .8125rem;
  cursor: pointer;
  color: var(--color-muted);
  white-space: nowrap;
  transition: all .12s;
}
.btn-action:hover        { border-color: var(--color-primary); color: var(--color-primary); }
.btn-action.danger:hover { border-color: var(--color-danger);  color: var(--color-danger);  }

/* ─── Data table ─────────────────────────────────────────────── */
.data-table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

.data-table th {
  text-align: left;
  padding: .625rem .75rem;
  border-bottom: 2px solid var(--color-border);
  color: var(--color-muted);
  font-weight: 600;
  white-space: nowrap;
}

.data-table td {
  padding: .625rem .75rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td      { background: #f8fafc; }

.row-actions { display: flex; gap: .375rem; }

.owner-cell {
  font-size: .75rem;
  color: var(--color-muted);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Status badges ──────────────────────────────────────────── */
.status-badge {
  display: inline-block;
  padding: .125rem .5rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 500;
}

.status-badge.active          { background: #d1fae5; color: #065f46; }
.status-badge.inactive        { background: #fee2e2; color: #991b1b; }
.status-badge.draft           { background: #fef3c7; color: #92400e; }
.status-badge.pending_review  { background: #dbeafe; color: #1e40af; }

/* ─── [M05] Indicador compacto de revisão (tabela) ───────────── */
.btn-review-indicator { background: none; border: none; padding: 0; font-size: .72rem; color: #b45309; cursor: pointer; font-weight: 500; display: block; margin-top: .2rem; line-height: 1.4; }
.btn-review-indicator:hover { text-decoration: underline; }

/* ─── [M05] Modal de histórico de revisões ───────────────────── */
.review-entry { padding: .75rem 0; border-bottom: 1px solid #e5e7eb; }
.review-entry:last-child { border-bottom: none; padding-bottom: 0; }
.review-entry-row { display: flex; gap: 1rem; margin-bottom: .25rem; font-size: .875rem; line-height: 1.4; }
.review-entry-label { font-weight: 600; min-width: 80px; color: #6b7280; flex-shrink: 0; }
.review-entry-comment { flex-direction: column; margin-top: .125rem; }
.review-entry-comment .review-entry-label { margin-bottom: .125rem; }
.review-entry-comment p { margin: 0; white-space: pre-wrap; word-break: break-word; }

/* ─── Role badge ─────────────────────────────────────────────── */
.role-badge {
  font-size: .75rem;
  padding: .125rem .5rem;
  border-radius: 999px;
  background: #e0e7ff;
  color: #3730a3;
  font-weight: 600;
}

/* ─── Form dialog ────────────────────────────────────────────── */
.form-dialog {
  border: none;
  border-radius: var(--radius);
  box-shadow: 0 8px 40px rgba(0,0,0,.18);
  padding: 1.75rem;
  width: min(480px, 95vw);
  /* Centralização explícita — corrige posicionamento no canto */
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  max-height: 90vh;
  overflow-y: auto;
}

.form-dialog::backdrop {
  background: rgba(0,0,0,.4);
}

.form-dialog h3 {
  font-size: 1.0625rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  margin-bottom: 1rem;
}

.field span {
  font-size: .8125rem;
  font-weight: 500;
  color: var(--color-muted);
}

.field input[type="text"],
.field input[type="number"],
.field textarea,
.field select {
  padding: .5rem .75rem;
  border: 1.5px solid var(--color-border);
  border-radius: 6px;
  font-size: .9rem;
  font-family: inherit;
  background: var(--color-surface);
  color: var(--color-text);
  outline: none;
  transition: border-color .15s;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus { border-color: var(--color-primary); }

.field-inline {
  flex-direction: row;
  align-items: center;
  gap: .5rem;
}

.dialog-actions {
  display: flex;
  gap: .625rem;
  margin-top: 1.25rem;
}

/* ─── Users table extras ─────────────────────────────────────── */
.role-select {
  padding: .25rem .5rem;
  border: 1.5px solid var(--color-border);
  border-radius: 5px;
  font-size: .8125rem;
  cursor: pointer;
}

.toggle { display: flex; align-items: center; gap: .375rem; cursor: pointer; font-size: .8125rem; }

/* ─── Empty state ────────────────────────────────────────────── */
.empty-msg { color: var(--color-muted); padding: 1.5rem 0; font-size: .9rem; }

/* ─── Knowledge files section (M16) ─────────────────────────── */
.files-section {
  border-top: 1px solid var(--color-border);
  margin-top: 1rem;
  padding-top: 1rem;
}

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

.files-title {
  font-size: .875rem;
  font-weight: 600;
  color: var(--color-text);
}

.btn-file-upload {
  padding: .3rem .75rem;
  background: transparent;
  border: 1.5px solid var(--color-primary);
  border-radius: 6px;
  font-size: .8125rem;
  font-weight: 500;
  color: var(--color-primary);
  cursor: pointer;
  transition: background .12s;
}
.btn-file-upload:hover { background: #eff6ff; }

.files-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  min-height: 1.5rem;
}

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .5rem .75rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  gap: .75rem;
}

.file-info {
  display: flex;
  flex-direction: column;
  gap: .125rem;
  min-width: 0;
}

.file-name {
  font-size: .875rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-meta {
  font-size: .75rem;
  color: var(--color-muted);
}

.files-empty,
.files-loading {
  font-size: .8125rem;
  color: var(--color-muted);
}

.files-total {
  font-size: .75rem;
  color: var(--color-muted);
  margin-top: .375rem;
  text-align: right;
}

.file-upload-error {
  font-size: .8125rem;
  color: var(--color-danger);
  margin-bottom: .5rem;
}
