@import url("./tokens.css");

*,
*::before,
*::after {
  box-sizing: border-box;
}

body.admin-body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.admin-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.admin-sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand a {
  color: inherit;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.sidebar-brand span {
  display: block;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
  margin-top: 0.15rem;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.65rem 0.875rem;
  border-radius: var(--radius);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.925rem;
  transition: background 0.15s, color 0.15s;
}

.sidebar-link:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.sidebar-link.active {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent);
  font-weight: 600;
}

.sidebar-badge {
  background: var(--danger);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  min-width: 1.25rem;
  text-align: center;
}

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
}

.sidebar-footer a {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-decoration: none;
}

.sidebar-footer a:hover {
  color: var(--text);
}

.admin-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 20, 25, 0.6);
  backdrop-filter: blur(8px);
}

.admin-topbar h1 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

.admin-content {
  padding: 1.5rem;
  flex: 1;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.page-header-text h2 {
  margin: 0 0 0.35rem;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
}

.page-header-text p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  max-width: 55ch;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.15rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  font-family: inherit;
  text-decoration: none;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--surface-hover);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.825rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-body {
  padding: 1.25rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.stat-card strong {
  display: block;
  font-size: 1.75rem;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
}

.stat-card span {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.table-wrap {
  overflow-x: auto;
}

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

table.data-table th,
table.data-table td {
  padding: 0.875rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

table.data-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

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

table.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.table-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}

.empty-state p {
  margin: 0 0 1rem;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-warning {
  background: rgba(234, 179, 8, 0.15);
  color: #facc15;
}

.badge-success {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
}

.badge-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

.badge-info {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 200;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 2px);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  margin: 0;
  font-size: 1.15rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
}

.form-grid {
  display: grid;
  gap: 1rem;
}

.form-grid.two-col {
  grid-template-columns: 1fr 1fr;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.35rem;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.65rem 0.875rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
}

.form-section-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0.5rem 0 0;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.875rem 1.25rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  opacity: 0;
  transform: translateY(120%);
  transition: transform 0.3s, opacity 0.3s;
  pointer-events: none;
  z-index: 300;
}

.toast.visible {
  transform: translateY(0);
  opacity: 1;
}

.alert-item {
  display: flex;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}

.alert-item:last-child {
  border-bottom: none;
}

.alert-item.unread {
  background: rgba(239, 68, 68, 0.06);
}

.alert-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.1rem;
}

.alert-content h4 {
  margin: 0 0 0.25rem;
  font-size: 0.95rem;
}

.alert-content p {
  margin: 0 0 0.35rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.alert-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ── RELATÓRIOS ── */
.section-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0 0 0.75rem;
}

.pendentes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.pendente-card {
  background: var(--surface);
  border: 1px solid rgba(234, 179, 8, 0.35);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.pendente-card-info h4 {
  margin: 0 0 0.2rem;
  font-size: 0.975rem;
}

.pendente-card-info p {
  margin: 0;
  font-size: 0.825rem;
  color: var(--text-muted);
}

.relatorio-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.25rem;
}

.relatorio-meta strong {
  color: var(--text);
}

/* ── Checklist — partilhado ── */
.rcl-list {
  display: flex;
  flex-direction: column;
}

.rcl-item {
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
}

.rcl-item:last-child {
  border-bottom: none;
}

.rcl-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.rcl-icon {
  font-size: 1.1rem;
  line-height: 1;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
}

.rcl-label {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 500;
}

.rcl-expand {
  margin-top: 0.6rem;
}

.rcl-expand textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  resize: vertical;
  box-sizing: border-box;
}

.rcl-expand textarea:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── Checklist — leitura (enviado) ── */
.rcl-value {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
}

.rcl-yes  { color: #4ade80; }
.rcl-no   { color: var(--text-muted); }

.rcl-detail {
  margin-top: 0.4rem;
  padding: 0.5rem 0.75rem;
  background: rgba(234, 179, 8, 0.07);
  border-left: 2px solid rgba(234, 179, 8, 0.4);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.rcl-text-block {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ── Checklist — edição (pendente) ── */
/* Botões Sim/Não em par */
.rcl-opt-pair {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

/* Grupo de pílulas para select */
.rcl-opt-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.5rem 0 0.25rem 2rem;
}

/* Base: todas as opções ficam transparentes */
.rcl-opt {
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font: 600 0.8rem var(--font);
  cursor: pointer;
  opacity: 0.35;
  transition: opacity 0.15s, background 0.15s, color 0.15s, border-color 0.15s;
}

.rcl-opt:hover {
  opacity: 0.65;
}

/* Opção selecionada: opacidade total + cor */
.rcl-opt.active {
  opacity: 1;
}

.rcl-opt-yes.active {
  background: rgba(34, 197, 94, 0.12);
  color: #4ade80;
  border-color: rgba(34, 197, 94, 0.4);
}

.rcl-opt-no.active {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border-color: var(--border);
}

.rcl-opt-select.active {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border-color: rgba(59, 130, 246, 0.4);
}

/* Coluna resumo na tabela */
.hist-summary {
  color: var(--text-muted);
  font-size: 0.85rem;
  max-width: 220px;
}

/* ── FILTROS ── */
.filter-bar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.filter-input-name {
  flex: 1;
  min-width: 180px;
  padding: 0.6rem 0.875rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
}

.filter-input-date {
  padding: 0.6rem 0.875rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  color-scheme: dark;
}

.filter-input-name:focus,
.filter-input-date:focus {
  outline: none;
  border-color: var(--accent);
}

.filter-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.825rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

/* ── PAGINAÇÃO ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.pg-pages {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.pg-btn {
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font: 500 0.85rem var(--font);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  line-height: 1.4;
}

.pg-btn:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text);
}

.pg-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.pg-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.pg-ellipsis {
  color: var(--text-muted);
  padding: 0 0.2rem;
  font-size: 0.85rem;
  line-height: 1;
  user-select: none;
}

.coming-soon {
  text-align: center;
  padding: 4rem 2rem;
}

.coming-soon h3 {
  margin: 0 0 0.5rem;
}

.coming-soon p {
  color: var(--text-muted);
  margin: 0;
  max-width: 40ch;
  margin-inline: auto;
}

@media (max-width: 900px) {
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    position: relative;
    height: auto;
  }

  .form-grid.two-col {
    grid-template-columns: 1fr;
  }
}
