/* =====================================================================
   Eskambo · base compartilhada (site, área do usuário, painel)
   Tokens, reset, botões, formulários, alertas, badges e cards.
   As cores/fonte/raio são sobrescritas pelo painel (partials/theme.php).
   ===================================================================== */

:root {
  --primary: #0E7C66;
  --ink: #14213D;
  --accent: #FFC83D;
  --radius: 14px;
  --font-body: "Instrument Sans", system-ui, sans-serif;
  --font-display: "Bricolage Grotesque", var(--font-body);

  --paper: #FFFFFF;
  --surface: #F5F7F4;
  --line: #E4E8E3;
  --line-strong: #CDD4CC;
  --muted: #5B6475;
  --soft: #8A93A3;
  --danger: #C8372D;
  --success: #18794E;
  --warning: #A15C07;

  --primary-soft: color-mix(in srgb, var(--primary) 9%, white);
  --primary-strong: color-mix(in srgb, var(--primary) 82%, black);
  --accent-soft: color-mix(in srgb, var(--accent) 22%, white);
  --radius-sm: calc(var(--radius) * .6);
  --radius-lg: calc(var(--radius) * 1.6);
  --shadow-sm: 0 1px 2px rgba(20, 33, 61, .06);
  --shadow: 0 1px 2px rgba(20, 33, 61, .05), 0 8px 24px -12px rgba(20, 33, 61, .16);
  --shadow-lg: 0 2px 4px rgba(20, 33, 61, .04), 0 24px 48px -20px rgba(20, 33, 61, .28);
  --container: 1200px;
  --header-h: 64px;
  --bottom-nav-h: 68px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
img { height: auto; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { margin: 0; line-height: 1.15; font-weight: 700; letter-spacing: -.01em; }
p { margin: 0; }
.icon { flex-shrink: 0; }
[hidden] { display: none !important; }

:focus-visible { outline: 2.5px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--accent); color: var(--ink); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 10px; }
.skip-link:focus { top: 12px; }

.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 16px; }
.display { font-family: var(--font-display); font-optical-sizing: auto; letter-spacing: -.025em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.stack > * + * { margin-top: var(--stack, 1rem); }

/* ---------------------------------------------------------------------
   Botões
   --------------------------------------------------------------------- */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 44px; padding: 0 1.1rem;
  border: 1px solid transparent; border-radius: 999px;
  background: var(--btn-bg); color: var(--btn-fg);
  font-weight: 600; font-size: .95rem; white-space: nowrap;
  transition: transform .15s var(--ease), background-color .15s, box-shadow .15s, border-color .15s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { --btn-bg: var(--primary); --btn-fg: #fff; box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--primary) 70%, transparent); }
.btn-primary:hover { --btn-bg: var(--primary-strong); }
.btn-ink { --btn-bg: var(--ink); --btn-fg: #fff; }
.btn-ghost { --btn-bg: transparent; }
.btn-ghost:hover { --btn-bg: var(--surface); }
.btn-outline { --btn-bg: var(--paper); border-color: var(--line-strong); }
.btn-outline:hover { border-color: var(--ink); }
.btn-lg { min-height: 52px; padding: 0 1.5rem; font-size: 1rem; }
.btn-sm { min-height: 36px; padding: 0 .85rem; font-size: .875rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; pointer-events: none; }

/* ---------------------------------------------------------------------
   Alertas / toasts
   --------------------------------------------------------------------- */
.toasts { position: fixed; z-index: 90; top: calc(var(--header-h) + 8px); left: 16px; right: 16px; display: grid; gap: 8px; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: var(--radius); background: var(--ink); color: #fff;
  box-shadow: var(--shadow-lg); font-size: .925rem; animation: toast-in .35s var(--ease);
}
.toast .icon { margin-top: 1px; }
.toast-success .icon { color: #5EE0A8; }
.toast-error .icon { color: #FF8F87; }
.toast-warning .icon, .toast-info .icon { color: var(--accent); }
.toast button { margin-left: auto; background: none; border: 0; color: rgba(255,255,255,.7); padding: 0 0 0 8px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

.alert { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); font-size: .925rem; }
.alert-warning { background: #FFF7E6; border-color: #F6DDA4; color: #6B4204; }
.alert-error { background: #FDF0EF; border-color: #F3C9C5; color: #8A231B; }
.alert-success { background: #EEF8F3; border-color: #BFE3D0; color: #0F5132; }

/* ---------------------------------------------------------------------
   Formulários
   --------------------------------------------------------------------- */
/* align-content: start → um campo mais alto (com ajuda/erro embaixo) não estica nem desalinha o vizinho da mesma linha */
.field { display: grid; gap: 6px; align-content: start; }
.field + .field, .field-row + .field, .field + .field-row, .field-row + .field-row { margin-top: 16px; }
.field-row > .field + .field { margin-top: 0; }
.field-row { display: grid; gap: 16px; align-items: start; }
.address-fields + .field, .field + .address-fields, .field + div > .address-fields { margin-top: 16px; }
.cep-status:empty { display: none; }
/* Botão do campo de arquivo no mesmo estilo dos botões do site */
input[type="file"] { font: inherit; font-size: .875rem; color: var(--muted); max-width: 100%; }
input[type="file"]::file-selector-button {
  margin-right: 12px; padding: 9px 16px; border: 1px solid var(--line-strong); border-radius: 999px;
  background: var(--paper); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; transition: border-color .15s, background-color .15s;
}
input[type="file"]::file-selector-button:hover { border-color: var(--ink); background: var(--surface); }
.label { font-size: .875rem; font-weight: 600; }
.label .opt { font-weight: 400; color: var(--soft); }
.input, .select, .textarea {
  width: 100%; min-height: 48px; padding: 12px 14px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--paper);
  transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 110px; resize: vertical; }
.select { appearance: none; padding-right: 40px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%235B6475' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--soft); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger); }
.field-error { font-size: .825rem; color: var(--danger); font-weight: 500; }
.help { font-size: .825rem; color: var(--soft); }
.input-wrap { position: relative; }
.input-wrap .toggle-pass { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 38px; height: 38px; display: grid; place-items: center; border: 0; background: none; color: var(--soft); border-radius: 8px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .9rem; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--primary); flex-shrink: 0; }
.check a { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Autocomplete de cidade */
.autocomplete { position: relative; }
.autocomplete-list { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 6px; list-style: none; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); max-height: 240px; overflow: auto; }
.autocomplete-list li { padding: 9px 10px; border-radius: 8px; cursor: pointer; font-size: .925rem; }
.autocomplete-list li[aria-selected="true"], .autocomplete-list li:hover { background: var(--surface); }

/* Marca, avatar, botões de ícone e menus */
.brand { display: inline-flex; align-items: center; gap: .55rem; font-family: var(--font-display); font-weight: 800; font-size: 1.3rem; letter-spacing: -.03em; }
.brand img { max-height: 34px; width: auto; }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px;
  border-radius: 11px; background: var(--ink); color: var(--accent);
  transform: rotate(-6deg);
}
.brand:hover .brand-mark { transform: rotate(6deg); transition: transform .3s var(--ease); }
.icon-btn { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 999px; border: 0; background: transparent; position: relative; }
.icon-btn:hover { background: var(--surface); }
.icon-btn .dot { position: absolute; top: 9px; right: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 2px var(--paper); }
.avatar {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary-strong); font-weight: 700; font-size: .8rem; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.2rem; }
.menu a, .menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; background: none; border-radius: var(--radius-sm); font-size: .925rem; text-align: left; }
.menu a:hover, .menu button:hover { background: var(--surface); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.menu-head { padding: 10px 12px 8px; }
.menu-head strong { display: block; font-size: .95rem; }

/* Badges e cards */
.badge { --badge: #64748B; display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 700; color: color-mix(in srgb, var(--badge) 80%, black); background: color-mix(in srgb, var(--badge) 13%, white); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--badge); }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; }
.card-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }

@media (min-width: 560px) {
  .toasts { left: auto; width: 380px; }
  .field-row.cols-2 { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* Campos personalizados (formulário dinâmico por categoria) */
.cf-grid { display: grid; gap: 16px; }
.cf-grid .field + .field { margin-top: 0; }
.req { color: var(--danger); }
.cf-unit { display: flex; align-items: center; gap: 8px; }
.cf-unit span { font-size: .875rem; font-weight: 600; color: var(--muted); }
.choice-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-choice { position: relative; cursor: pointer; }
.chip-choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip-choice span { display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--paper); font-size: .9rem; font-weight: 500; transition: border-color .15s, background-color .15s, color .15s; }
.chip-choice:hover span { border-color: var(--ink); }
.chip-choice input:checked + span { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip-choice input:focus-visible + span { outline: 2.5px solid var(--primary); outline-offset: 2px; }
.chip-choice input:disabled + span { cursor: default; }
@media (min-width: 640px) {
  .cf-grid { grid-template-columns: 1fr 1fr; }
  .cf-grid .cf-wide { grid-column: 1 / -1; }
}

/* Formulário de anúncio: cards e gerenciador de fotos (site e painel) */
.form-card { padding: 20px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--paper); }
.form-card + .form-card { margin-top: 14px; }
.form-card[hidden] { display: none; }
.form-card > header { margin-bottom: 16px; }
.form-card > header h2 { font-size: 1.1rem; font-weight: 700; }
.form-card > header p { margin-top: 4px; font-size: .85rem; color: var(--muted); }
.counter-help { display: flex; justify-content: space-between; gap: 12px; }
.counter-help span:last-child { font-variant-numeric: tabular-nums; white-space: nowrap; }
.money-input { display: flex; align-items: center; max-width: 260px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--paper); }
.money-input:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.money-input span { padding: 0 4px 0 14px; font-weight: 600; color: var(--muted); }
.money-input .input { border: 0; box-shadow: none !important; }
.toggles { display: grid; gap: 10px; }

.photo-grid { list-style: none; margin: 0 0 8px; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.photo, .photo-add { position: relative; aspect-ratio: 1 / 1; border-radius: var(--radius); overflow: hidden; }
.photo { background: var(--surface); border: 1px solid var(--line); }
.photo img { width: 100%; height: 100%; object-fit: cover; }
.photo.is-removed { display: none; }
.photo.is-cover::after { content: "Capa"; position: absolute; left: 8px; top: 8px; padding: 2px 8px; border-radius: 7px; background: var(--accent); color: var(--ink); font-size: .7rem; font-weight: 800; text-transform: uppercase; transform: rotate(-3deg); }
.photo-tools { position: absolute; inset: auto 6px 6px 6px; display: flex; gap: 4px; justify-content: flex-end; }
.photo-tools button, .photo-tools .photo-remove { display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 9px; background: rgba(255,255,255,.94); color: var(--ink); font-size: 1rem; font-weight: 700; line-height: 1; cursor: pointer; box-shadow: var(--shadow-sm); }
.photo-tools .photo-remove { color: var(--danger); }
.photo-tools .photo-remove input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.photo-add label { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; width: 100%; height: 100%; border: 1.5px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--muted); cursor: pointer; text-align: center; font-size: .8rem; transition: border-color .15s, color .15s, background-color .15s; }
.photo-add label strong { color: var(--ink); font-size: .85rem; }
.photo-add label:hover { border-color: var(--ink); color: var(--ink); background: var(--paper); }
.photo-add[hidden] { display: none; }
.photo-manager.is-enhanced .photo-input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.photo-manager.is-dragover .photo-grid { outline: 2px dashed var(--primary); outline-offset: 6px; border-radius: var(--radius); }
.photo-manager.is-busy .photo-add label { opacity: .6; pointer-events: none; }
.photo-manager:not(.is-enhanced) .photo-add { display: none; }
@media (min-width: 560px) { .photo-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 900px) { .photo-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

/* Endereço com CEP (público e painel) */
.address-fields { display: grid; gap: 16px; }
.cep-status { min-height: 1.3em; }
.cep-status.is-loading { color: var(--muted); }
.cep-status.is-ok { color: var(--primary); font-weight: 600; }
.cep-status.is-error { color: var(--danger); }
.address-fields.is-loading [data-cep-input] { background-image: linear-gradient(90deg, transparent, color-mix(in srgb, var(--primary) 12%, transparent), transparent); background-size: 200% 100%; animation: cep-load 1s linear infinite; }
@keyframes cep-load { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .address-fields.is-loading [data-cep-input] { animation: none; } }

/* ---------------------------------------------------------------------
   Verificador do servidor (painel e instalador)
   --------------------------------------------------------------------- */
.diag { display: grid; gap: 16px; }
.diag-summary {
  --tone: #16A34A; --tone-soft: #E7F5EE;
  display: grid; grid-template-columns: auto 1fr; gap: 14px 16px; align-items: start;
  padding: 20px; border-radius: var(--radius-lg); background: var(--paper);
  border: 1px solid var(--line); border-left: 5px solid var(--tone);
}
.diag-summary.is-warn { --tone: #D97706; --tone-soft: #FFF7E6; }
.diag-summary.is-fail { --tone: #DC2626; --tone-soft: #FDF0EF; }
.diag-verdict-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: var(--tone-soft); color: var(--tone); }
.diag-verdict h2 { font-family: var(--font-display); font-size: 1.35rem; font-weight: 800; letter-spacing: -.01em; line-height: 1.2; }
.diag-verdict > p { margin-top: 2px; font-size: .85rem; color: var(--muted); }
.diag-counts { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; padding: 0; list-style: none; }
.diag-counts li { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--surface); }
.diag-counts li::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.diag-counts .is-ok { color: #0F5132; } .diag-counts .is-warn { color: #8A5300; } .diag-counts .is-fail { color: #A61B1B; }
.diag-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; }
.diag-actions form { display: contents; }

.diag-group { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--paper); overflow: hidden; }
.diag-group h3 { display: flex; align-items: center; gap: 10px; padding: 14px 18px; font-size: .95rem; font-weight: 700; border-bottom: 1px solid var(--line); }
.diag-group-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--surface); color: var(--ink); }
.diag-pill { margin-left: auto; padding: 2px 9px; border-radius: 999px; font-size: .72rem; font-weight: 700; }
.diag-pill.is-ok { background: #E7F5EE; color: #0F5132; }
.diag-pill.is-warn { background: #FFF7E6; color: #8A5300; }
.diag-pill.is-fail { background: #FDF0EF; color: #A61B1B; }
.diag-list { list-style: none; margin: 0; padding: 0; }
.diag-list li { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 12px 18px; border-top: 1px solid var(--line); }
.diag-list li:first-child { border-top: 0; }
.diag-list li.is-fail { background: #FFF8F7; }
.diag-list strong { font-size: .9rem; }
.diag-list p { margin-top: 2px; font-size: .82rem; color: var(--muted); overflow-wrap: anywhere; }
.diag-list .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .78rem; color: var(--ink); background: var(--surface); padding: 6px 8px; border-radius: 8px; margin-top: 6px; }
.diag-fix { color: var(--ink) !important; }
.diag-fix b { font-weight: 700; }
.diag-dot { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; margin-top: 1px; }
.is-ok > .diag-dot { background: #E7F5EE; color: #16A34A; }
.is-warn > .diag-dot { background: #FFF7E6; color: #D97706; }
.is-fail > .diag-dot { background: #FDF0EF; color: #DC2626; }
.is-info > .diag-dot { background: var(--surface); color: var(--muted); }
@media (min-width: 768px) {
  .diag-summary { grid-template-columns: auto 1fr auto; align-items: center; }
  .diag-actions { grid-column: auto; justify-content: flex-end; max-width: 360px; }
}
