/* Base da aplicação: tipografia, tela de acesso, formulários e os componentes
   compartilhados entre telas. Valores de cor, sombra, raio e duração vêm sempre
   de tokens.css. */

@font-face {
  font-family: ArtegraSans;
  src: url('/fonts/ArtegraSans-Regular.woff2') format('woff2'), url('/fonts/ArtegraSans-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: ArtegraSans;
  src: url('/fonts/ArtegraSans-Bold.woff2') format('woff2'), url('/fonts/ArtegraSans-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ---------- Base ---------- */

:root {
  font-family: ArtegraSans, Arial, sans-serif;
  color: var(--text-strong);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--surface-page);
  color: var(--text-strong);
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

/* Foco visível e consistente para navegação por teclado. :focus-visible não
   dispara em clique de mouse, então isso não polui a interação com ponteiro. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Tela de acesso ---------- */

.login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
}

.brand {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  padding: clamp(2rem, 7vw, 6rem);
  color: var(--text-on-inverse);
  background: var(--surface-inverse);
}

.brand::before {
  content: "";
  position: absolute;
  right: -12rem;
  top: -15rem;
  width: 42rem;
  height: 42rem;
  border-radius: 50%;
  background: var(--xia-gradient);
  transform: rotate(-20deg);
}

.brand > * { z-index: 1; }
.brand .eyebrow { color: rgba(255, 255, 255, 0.6); }

.brand h1 {
  max-width: 620px;
  margin: 0;
  font-size: clamp(2.5rem, 4.6vw, 5.2rem);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: -0.06em;
}

.brand p:not(.eyebrow) {
  max-width: 460px;
  color: rgba(255, 255, 255, 0.73);
  line-height: 1.6;
}

.login-side {
  display: grid;
  place-items: center;
  padding: 2rem;
  background: radial-gradient(circle at 95% 5%, var(--info-soft), transparent 30%), var(--surface-page);
}

.eyebrow {
  margin: 0 0 0.65rem;
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.card {
  width: min(420px, 100%);
  padding: 2.5rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  background: var(--surface-card);
  box-shadow: var(--shadow-lg);
}

.card h2 {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.lead {
  color: var(--text-muted);
  line-height: 1.55;
}

/* ---------- Formulários ---------- */

.field {
  display: grid;
  gap: 0.45rem;
  margin: 1rem 0;
}

.field label {
  font-size: 0.8rem;
  font-weight: 700;
}

.field input,
.field select,
.field textarea,
.search {
  width: 100%;
  padding: 0.82rem 0.9rem;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--surface-card);
  color: var(--text-strong);
  outline: none;
  transition: border-color var(--motion-fast) var(--ease), box-shadow var(--motion-fast) var(--ease);
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.error {
  min-height: 19px;
  color: var(--danger);
  font-size: 0.8rem;
}

/* ---------- Botões ---------- */

.btn {
  border: 0;
  border-radius: var(--radius-sm);
  padding: 0.84rem 1rem;
  font-weight: 700;
  transition: transform var(--motion-fast) var(--ease), filter var(--motion-fast) var(--ease), background var(--motion-fast) var(--ease);
}

.btn:hover {
  transform: translateY(-1px);
  filter: brightness(0.96);
}

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

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.btn.primary {
  color: var(--text-on-brand);
  background: var(--xia-gradient);
  box-shadow: var(--shadow-accent);
}

.btn.outline {
  border: 1px solid var(--border-default);
  background: var(--surface-card);
  color: var(--text-strong);
}

.btn.danger {
  color: #fff;
  background: var(--danger);
  box-shadow: 0 10px 20px var(--danger-soft);
}

.full {
  width: 100%;
  margin-top: 1rem;
}

/* ---------- Cartões e painéis ---------- */

.content {
  max-width: 1240px;
  margin: auto;
}

.stat {
  min-height: 120px;
  padding: 1.3rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--surface-card);
  box-shadow: var(--shadow-md);
}

.stat span,
.stat b { display: block; }

.stat span {
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.stat b {
  margin-top: 0.5rem;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.05em;
}

.panel {
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--surface-card);
  box-shadow: var(--shadow-md);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 1.35rem 1.5rem;
  border-bottom: 1px solid var(--border-default);
}

.panel-head h3 {
  margin: 0;
  font-weight: 700;
}

.panel-head p {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.search { max-width: 270px; }

/* ---------- Tabelas ---------- */

.table-wrap { overflow: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  padding: 0.82rem 1.5rem;
  color: var(--text-muted);
  background: var(--surface-subtle);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-align: left;
  text-transform: uppercase;
}

.table td {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.85rem;
}

.person {
  display: flex;
  gap: 0.7rem;
  align-items: center;
}

.avatar {
  width: 37px;
  height: 37px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--xia-gradient);
  color: var(--text-on-brand);
  font-size: 0.78rem;
  font-weight: 700;
}

.mini {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 700;
}

.name { font-weight: 700; }

.email {
  margin-top: 0.18rem;
  color: var(--text-muted);
  font-size: 0.76rem;
}

/* ---------- Selos, links e vazios ---------- */

/* O selo neutro é o padrão: sem ele, um status como "Inativo" ficava como texto
   solto ao lado de selos coloridos, parecendo um erro de renderização. */
.badge {
  display: inline-block;
  padding: 0.32rem 0.56rem;
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  background: var(--surface-skeleton);
  font-size: 0.67rem;
  font-weight: 700;
}

.admin {
  color: var(--badge-admin-text);
  background: var(--badge-admin-bg);
}

.common {
  color: var(--badge-common-text);
  background: var(--badge-common-bg);
}

.active {
  color: var(--success);
  background: var(--success-soft);
}

.link {
  border: 0;
  color: var(--accent);
  background: none;
  font-size: 0.78rem;
  font-weight: 700;
}

.link:hover { text-decoration: underline; }

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

/* ---------- Camadas sobrepostas ---------- */

.backdrop {
  position: fixed;
  z-index: 5;
  inset: 0;
  display: flex;
  justify-content: flex-end;
  background: var(--surface-overlay);
  backdrop-filter: blur(2px);
}

.drawer {
  width: min(570px, 100%);
  height: 100%;
  padding: 1.6rem;
  overflow: auto;
  background: var(--surface-card);
  box-shadow: var(--shadow-overlay);
}

.modal-backdrop {
  justify-content: center;
  align-items: center;
  padding: 1.5rem;
}

.modal-card {
  width: min(420px, 100%);
  height: auto;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-overlay);
}

.modal-card .lead { margin: 0.6rem 0 0; }

.drawer-top {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 1.5rem;
}

.drawer h2 {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.close {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  color: var(--text-body);
  background: var(--surface-page);
}

.close:hover { background: var(--surface-sunken); }

/* ---------- Permissões ---------- */

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1rem;
}

.wide { grid-column: 1 / -1; }

.permissions { margin-top: 1.4rem; }

.notice {
  padding: 0.8rem;
  border-radius: var(--radius-sm);
  color: var(--badge-admin-text);
  background: var(--info-soft);
  font-size: 0.78rem;
  line-height: 1.45;
}

.perm {
  margin-top: 0.7rem;
  padding: 1rem;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
}

.perm-top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.perm strong {
  font-size: 0.86rem;
  font-weight: 700;
}

.perm p {
  margin: 0.22rem 0;
  color: var(--text-muted);
  font-size: 0.74rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-top: 0.9rem;
  font-size: 0.76rem;
}

.actions label,
.check {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 1.5rem;
}

/* ---------- Avisos temporários ---------- */

#toast {
  position: fixed;
  z-index: 10;
  top: 1rem;
  right: 1rem;
  display: grid;
  gap: 0.5rem;
  justify-items: end;
  max-width: min(380px, calc(100vw - 2rem));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  color: #fff;
  background: var(--xia-ink);
  box-shadow: var(--shadow-overlay);
  font-size: 0.82rem;
  line-height: 1.4;
  animation: toast-in var(--motion-base) var(--ease);
}

.toast.bad { background: var(--danger); }

.toast .icon { flex: none; margin-top: 1px; }

.toast-close {
  flex: none;
  margin: -2px -4px 0 auto;
  padding: 2px;
  border: 0;
  border-radius: var(--radius-xs);
  color: inherit;
  background: transparent;
  opacity: 0.75;
}

.toast-close:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.16);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Ícones ---------- */

/* Os ícones são SVG Lucide inline com traço de 2px (ver docs/design-system.md).
   currentColor faz cada um herdar a cor do contexto em que está. */
.icon {
  width: 18px;
  height: 18px;
  display: inline-block;
  flex: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  vertical-align: -0.18em;
}

.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }

/* ---------- Responsivo ---------- */

@media (max-width: 840px) {
  .login { grid-template-columns: 1fr; }
  .brand { min-height: 330px; }
  .brand h1 { font-size: 2.7rem; }
  .panel-head { flex-direction: column; align-items: stretch; }
  .grid { grid-template-columns: 1fr; }
  .wide { grid-column: auto; }
  #toast { left: 1rem; justify-items: stretch; max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
