/* Amigo Invisível. Cores e medidas de docs/design.md.
   CSS escrito primeiro para o celular; @media (min-width: 768px) ajusta o notebook.
   Use sempre as variáveis de cor, nunca o código da cor direto. */

/* ---------- Cores: modo claro (padrão) ---------- */
:root,
:root[data-theme="light"] {
  --bg: #FAF7F2;
  --surface: #FFFFFF;
  --surface-2: #F2ECE3;
  --text: #241F1C;
  --text-muted: #675E57;
  --border: #E3DACE;
  --border-strong: #8C8177;
  --primary: #1F6B52;
  --primary-hover: #18553F;
  --on-primary: #FFFFFF;
  --accent: #A8233A;
  --success: #1E7145;
  --warning: #855500;
  --danger: #B3261E;
  --card-shadow: 0 1px 3px rgb(36 31 28 / 0.08), 0 4px 12px rgb(36 31 28 / 0.06);
  color-scheme: light;
}

/* ---------- Cores: modo escuro ---------- */
:root[data-theme="dark"] {
  --bg: #171513;
  --surface: #211E1B;
  --surface-2: #2C2824;
  --text: #F3EEE8;
  --text-muted: #B5ABA1;
  --border: #3A342E;
  --border-strong: #7D7268;
  --primary: #5CC8A1;
  --primary-hover: #7AD6B5;
  --on-primary: #0E2A20;
  --accent: #F08CA0;
  --success: #6FD19A;
  --warning: #E9B95C;
  --danger: #F28B82;
  --card-shadow: none;
  color-scheme: dark;
}

/* Sem JavaScript, segue o tema do aparelho */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #171513;
    --surface: #211E1B;
    --surface-2: #2C2824;
    --text: #F3EEE8;
    --text-muted: #B5ABA1;
    --border: #3A342E;
    --border-strong: #7D7268;
    --primary: #5CC8A1;
    --primary-hover: #7AD6B5;
    --on-primary: #0E2A20;
    --accent: #F08CA0;
    --success: #6FD19A;
    --warning: #E9B95C;
    --danger: #F28B82;
    --card-shadow: none;
    color-scheme: dark;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  overflow-wrap: break-word;
}

h1 {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 16px;
}

h2 {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.3;
  margin: 0 0 8px;
}

p {
  margin: 0 0 16px;
}

a {
  color: var(--primary);
}

a:hover {
  color: var(--primary-hover);
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.icon {
  flex: none;
  vertical-align: middle;
}

.muted {
  color: var(--text-muted);
  font-size: 14px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 8px;
  z-index: 10;
}

.skip-link:focus {
  left: 16px;
}

/* ---------- Larguras ---------- */
main {
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.narrow {
  max-width: 640px;
}

.wide {
  max-width: 960px;
}

/* ---------- Cabeçalho ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.site-header__inner {
  margin: 0 auto;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 60px;
}

.site-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 700;
  font-size: 18px;
  text-decoration: none;
  min-height: 44px;
}

.site-name .icon {
  color: var(--accent);
}

.site-name:hover {
  color: var(--text);
}

.site-header__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.site-header__actions form {
  margin: 0;
}

/* ---------- Escolha do tema: Claro | Escuro ---------- */
.theme-switch {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  overflow: hidden;
}

.theme-switch__option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.theme-switch__option + .theme-switch__option {
  border-left: 1px solid var(--border-strong);
}

.theme-switch__option:hover {
  background: var(--surface-2);
}

/* A opção escolhida fica destacada */
.theme-switch__option[aria-pressed="true"] {
  background: var(--primary);
  color: var(--on-primary);
}

.theme-switch__option:focus-visible {
  outline-offset: -3px;
}

/* No painel, em celular estreito, ficam só os ícones para caber o botão Sair */
.site-header--admin .theme-switch__label {
  display: none;
}

.site-name span {
  white-space: nowrap;
}

.site-header--admin .site-name {
  font-size: 16px;
}

@media (min-width: 420px) {
  .site-header--admin .site-name {
    font-size: 18px;
  }
}

@media (min-width: 420px) {
  .site-header--admin .theme-switch__label {
    display: inline;
  }
}

/* ---------- Cartões ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  padding: 24px 16px;
  margin-bottom: 16px;
}

.card--center {
  text-align: center;
}

/* ---------- Formulários ---------- */
.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
}

.field input {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  font: inherit;
  font-size: 16px; /* abaixo de 16px o iPhone aproxima a tela */
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
}

.field input:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.field--code input {
  font-size: 24px;
  letter-spacing: 0.3em;
  text-align: center;
}

.field__help {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
}

/* ---------- Botões ---------- */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 10px 20px;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
}

.button--primary {
  background: var(--primary);
  color: var(--on-primary);
}

.button--primary:hover {
  background: var(--primary-hover);
  color: var(--on-primary);
}

.button--secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}

.button--secondary:hover {
  background: var(--surface-2);
  color: var(--text);
}

.button--danger {
  background: var(--danger);
  color: var(--on-primary);
}

.button--small {
  width: auto;
  padding: 8px 12px;
  font-size: 14px;
}

/* ---------- Mensagens ---------- */
.message {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  background: var(--surface);
}

.message .icon {
  margin-top: 2px;
}

.message--error {
  border-left-color: var(--danger);
}

.message--error .icon {
  color: var(--danger);
}

.message--success {
  border-left-color: var(--success);
}

.message--success .icon {
  color: var(--success);
}

.message--info .icon {
  color: var(--primary);
}

/* ---------- Listas simples ---------- */
.list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.list li {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.list li:last-child {
  border-bottom: 0;
}

/* ---------- Notebook e tablet ---------- */
@media (min-width: 768px) {
  main {
    padding-top: 40px;
  }

  .card {
    padding: 32px;
  }

  .button {
    width: auto;
  }

  .narrow {
    max-width: 640px;
  }

  .wide {
    max-width: 960px;
  }
}

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