/* Painel do site: claro, legível e com botões sempre escritos.
   Fonte Atkinson Hyperlegible (feita para facilitar a leitura). */
@font-face { font-family: "Atkinson"; src: url("fonts/atkinson-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Atkinson"; src: url("fonts/atkinson-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --ink: #12303d;
  --ink-soft: #46616d;
  --line: #d5e2e8;
  --line-strong: #a9c1cc;
  --bg: #f3f7f9;
  --surface: #ffffff;
  --blue: #0079a6;
  --blue-bright: #00a1d8;
  --blue-soft: #e3f4fb;
  --coral: #c71f00;
  --coral-soft: #fdebe7;
  --ok: #1f7a4d;
  --ok-soft: #e5f5ec;
  --warn-soft: #fff5d6;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(18, 48, 61, .06), 0 6px 18px rgba(18, 48, 61, .07);
  --focus: 0 0 0 3px #ffbf47, 0 0 0 5px #12303d;
  --top-h: 58px;
  --side-w: 214px;
  --editor-w: clamp(400px, 34vw, 520px);
  font-family: "Atkinson", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 40px; padding: .45rem 1rem;
  border: 2px solid var(--blue); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--blue); font-weight: 700; cursor: pointer;
  transition: background-color .15s, color .15s, border-color .15s, transform .1s;
}
.btn:hover:not(:disabled) { background: var(--blue-soft); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--primary { background: var(--blue); color: #fff; }
.btn--primary:hover:not(:disabled) { background: #00648a; border-color: #00648a; }
.btn--ghost { border-color: var(--line-strong); color: var(--ink); }
.btn--ghost:hover:not(:disabled) { background: #eaf1f4; }
.btn--danger { border-color: var(--coral); background: var(--coral); color: #fff; }
.btn--danger:hover:not(:disabled) { background: #a51a00; }
.btn--lg { min-height: 50px; padding: .7rem 1.4rem; font-size: 1.05rem; }
.btn--small { min-height: 34px; padding: .3rem .75rem; font-size: .92rem; }
.btn--tiny { min-height: 30px; padding: .15rem .55rem; font-size: .85rem; border-width: 1px; border-color: var(--line-strong); color: var(--ink); }
.btn--danger-text { color: var(--coral); }
.btn--danger-text:hover:not(:disabled) { background: var(--coral-soft); border-color: var(--coral); }
.btn--add { margin-top: .5rem; border-style: dashed; }
.btn--add-block { width: 100%; min-height: 52px; margin: .75rem 0 2rem; border-style: dashed; font-size: 1.02rem; }
.link-back { border: 0; background: none; padding: 0; color: var(--blue); font-weight: 700; cursor: pointer; margin-bottom: .35rem; }
.link-back:hover { text-decoration: underline; }

/* ---------- carregando e tela inicial ---------- */
.boot { min-height: 100vh; display: grid; place-items: center; padding: 2rem; }
.boot__msg { font-size: 1.1rem; color: var(--ink-soft); max-width: 36rem; text-align: center; }
.boot__msg--error { color: var(--coral); font-weight: 700; }
.start {
  min-height: 100vh; display: grid; place-items: center; padding: 2rem;
  background: radial-gradient(circle at 15% 20%, #d9f1fa 0, transparent 45%), radial-gradient(circle at 85% 80%, #fde3dc 0, transparent 40%), var(--bg);
}
.start__card { width: min(520px, 100%); background: var(--surface); border-radius: 18px; padding: 2.5rem; box-shadow: var(--shadow); text-align: center; }
.start__logo { height: 70px; width: auto; }
.start h1 { margin: .75rem 0 .25rem; font-size: 1.8rem; }
.start__lead { color: var(--ink-soft); margin: 0 0 1.5rem; }
.start__actions { display: grid; gap: .65rem; }
.start__note { margin: 1.25rem 0 0; font-size: .92rem; color: var(--ink-soft); }
.start__note a { color: var(--blue); font-weight: 700; }
.start__form { display: grid; gap: .55rem; text-align: left; }
.start__form label { font-weight: 700; }
.start__form .btn { margin-top: .4rem; }
.start__form .start__check { display: flex; gap: .5rem; align-items: flex-start; font-weight: 400; font-size: .92rem; color: var(--ink-soft); }
.start__check input { margin-top: .2rem; }

/* ---------- moldura do painel ---------- */
.app {
  height: 100vh; display: grid;
  grid-template-columns: var(--side-w) var(--editor-w) 1fr;
  grid-template-rows: var(--top-h) 1fr;
  grid-template-areas: "top top top" "side editor preview";
}
.top {
  grid-area: top; display: flex; align-items: center; gap: 1rem; padding: 0 1rem;
  background: var(--surface); border-bottom: 1px solid var(--line); z-index: 2;
}
.top__brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; width: calc(var(--side-w) - 1rem); }
.top__lang { display: flex; gap: 2px; background: #e6eef2; padding: 3px; border-radius: 999px; }
.top__lang button {
  border: 0; background: transparent; padding: .3rem .8rem; border-radius: 999px; font-weight: 700; cursor: pointer; color: var(--ink-soft);
}
.top__lang button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.top__lang button:disabled { opacity: .35; cursor: not-allowed; }
.top__actions { margin-left: auto; display: flex; align-items: center; gap: .6rem; }
.top__status { font-size: .92rem; color: var(--ok); display: inline-flex; align-items: center; gap: .4rem; }
.top__status::before { content: ""; width: .6rem; height: .6rem; border-radius: 50%; background: currentColor; }
.top__status.is-dirty { color: #a35a00; }

.side { grid-area: side; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--line); padding: .75rem .6rem; display: flex; flex-direction: column; }
.nav__title { margin: 1rem .5rem .35rem; font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); }
.nav__title:first-child { margin-top: .25rem; }
.nav__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.nav__item {
  width: 100%; display: flex; align-items: center; gap: .4rem; text-align: left;
  border: 0; background: transparent; padding: .5rem .6rem; border-radius: var(--radius-sm); cursor: pointer; font-size: .95rem;
}
.nav__item:hover { background: #eef4f7; }
.nav__item.is-active { background: var(--blue-soft); color: #005a7c; font-weight: 700; box-shadow: inset 3px 0 0 var(--blue-bright); }
.nav__count { margin-left: auto; font-size: .8rem; color: var(--ink-soft); background: #eef4f7; border-radius: 999px; padding: 0 .45rem; }
.nav__foot { margin-top: auto; padding: 1rem .5rem 0; font-size: .82rem; color: var(--ink-soft); }
.nav__logout { display: none; }
.dirty-dot { width: .55rem; height: .55rem; border-radius: 50%; background: #e08a00; flex: none; }
.nav__item .dirty-dot { margin-left: .25rem; }

.editor { grid-area: editor; overflow-y: auto; padding: 1.25rem 1.25rem 3rem; border-right: 1px solid var(--line); outline: none; }

.preview { grid-area: preview; display: flex; flex-direction: column; min-width: 0; background: #dde7ec; }
.preview__bar { display: flex; align-items: center; gap: .75rem; padding: .5rem .9rem; background: #eef3f6; border-bottom: 1px solid var(--line); }
.preview__title { font-weight: 700; font-size: .92rem; }
.preview__open { margin-left: auto; font-size: .9rem; color: var(--blue); font-weight: 700; text-decoration: none; }
.preview__open:hover { text-decoration: underline; }
.seg { display: flex; gap: 2px; background: #dbe5ea; padding: 3px; border-radius: 8px; }
.seg button { border: 0; background: transparent; padding: .25rem .7rem; border-radius: 6px; cursor: pointer; font-size: .88rem; }
.seg button[aria-pressed="true"] { background: var(--surface); font-weight: 700; box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.preview__stage { position: relative; flex: 1; overflow: hidden; }
.preview__stage iframe { position: absolute; top: 0; border: 0; background: #fff; transform-origin: 0 0; box-shadow: 0 0 0 1px rgba(0,0,0,.06); }

/* ---------- cabeçalho das telas ---------- */
.view__head { margin-bottom: 1rem; }
.view__title-row { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
.view__title { margin: 0; font-size: 1.45rem; line-height: 1.25; }
.view__sub { margin: .3rem 0 0; color: var(--ink-soft); font-size: .95rem; }
.view__actions { margin-top: .8rem; }
.view__h2 { font-size: 1.1rem; margin: 1.5rem 0 .6rem; }
.notice { background: var(--warn-soft); border-left: 4px solid #e0a800; padding: .6rem .8rem; border-radius: var(--radius-sm); font-size: .95rem; }
.badge { display: inline-block; font-size: .78rem; font-weight: 700; padding: .05rem .5rem; border-radius: 999px; vertical-align: middle; }
.badge--muted { background: #e8eef1; color: var(--ink-soft); }

.panel-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 1rem; }
.panel-box > summary { padding: .8rem 1rem; font-weight: 700; cursor: pointer; list-style-position: inside; }
.panel-box__body { padding: 0 1rem 1rem; }
.panel-box--flat { padding: .25rem 1rem 1rem; }
.panel-box--flat > .view__h2 { margin-top: .75rem; }

/* ---------- blocos da página ---------- */
.blocks { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.block { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); transition: border-color .15s, box-shadow .15s; }
.block:hover { border-color: var(--line-strong); }
.block.is-open { border-color: var(--blue-bright); box-shadow: 0 0 0 2px var(--blue-soft); }
.block.is-hidden { background: repeating-linear-gradient(-45deg, #fafcfd 0 10px, #f1f5f7 10px 20px); }
.block__toggle { width: 100%; min-width: 0; text-align: left; border: 0; background: none; padding: .6rem .8rem; border-radius: var(--radius); cursor: pointer; display: grid; }
.block__toggle:hover { background: #f2f7f9; }
.block__label { font-weight: 700; display: flex; align-items: center; gap: .4rem; }
.block__label::before { content: "▸"; color: var(--ink-soft); transition: transform .15s; }
.block.is-open .block__label::before { transform: rotate(90deg); }
.block__sum { color: var(--ink-soft); font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.block__tools { display: flex; gap: 4px; flex-wrap: wrap; padding: 0 1rem .6rem; }
.block__body { padding: .25rem 1rem 1rem; border-top: 1px solid var(--line); }

/* ---------- campos ---------- */
.field { margin: .9rem 0; }
.field-heading { margin: 1.4rem 0 .2rem; font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; color: var(--blue); }
.field__label { display: block; font-weight: 700; margin-bottom: .25rem; }
.field__sub { display: block; font-size: .88rem; font-weight: 700; margin: .4rem 0 .2rem; color: var(--ink-soft); }
.req { color: var(--coral); }
.hint { margin: .1rem 0 .4rem; font-size: .88rem; color: var(--ink-soft); }
.hint--kids { margin-top: .5rem; font-size: .84rem; }
input[type="text"], input[type="password"], input[type="search"], input[type="email"], input[type="url"], input[type="tel"], input[type="date"], input[type="time"], select, textarea {
  width: 100%; padding: .55rem .7rem; border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm); background: #fff; min-height: 42px;
}
textarea { resize: vertical; line-height: 1.5; }
input:hover, select:hover, textarea:hover { border-color: #7fa3b2; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); }
.field--error input, .field--error textarea, .field--error select, input[aria-invalid] { border-color: var(--coral); background: #fffafa; }
.field__error { margin: .3rem 0 0; color: var(--coral); font-size: .9rem; font-weight: 700; }
.field__error::before { content: "⚠ "; }
.check { display: flex; align-items: flex-start; gap: .55rem; cursor: pointer; }
.check input { width: 1.2rem; height: 1.2rem; margin-top: .15rem; accent-color: var(--blue); flex: none; }
.field--bool { background: #f6fafb; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .6rem .75rem; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem .75rem; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.group { margin: 1rem 0; padding: .4rem .9rem .7rem; border-left: 3px solid var(--blue-soft); background: #fafcfd; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.group__title { font-weight: 700; padding: .3rem 0; }
.count { font-weight: 400; color: var(--ink-soft); font-size: .9rem; }

.strings__row { margin: .35rem 0; }
.strings__line { display: flex; gap: .4rem; align-items: center; }
.strings__line input { flex: 1; }
.item__tools { display: flex; gap: 4px; flex: none; }

.items { display: grid; gap: .4rem; }
.item { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; }
.item[open] { border-color: var(--line-strong); }
.item__head { display: flex; gap: .5rem; align-items: baseline; padding: .55rem .75rem; cursor: pointer; }
.item__n { font-weight: 700; white-space: nowrap; }
.item__sum { min-width: 0; color: var(--ink-soft); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item__body { padding: .25rem .75rem .75rem; border-top: 1px solid var(--line); }
.item__body > .item__tools { justify-content: flex-end; margin: .4rem 0 0; }

.photo { display: grid; grid-template-columns: 120px 1fr; gap: .8rem; align-items: start; }
.photo__preview { width: 120px; aspect-ratio: 4 / 3; border-radius: var(--radius-sm); overflow: hidden; background: #e8eff2; display: grid; place-items: center; border: 1px solid var(--line); }
.photo__img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo__empty { color: var(--ink-soft); font-size: .85rem; }
.photo__buttons { display: flex; flex-wrap: wrap; gap: .35rem; }
.photo__name, .file__name { margin: .35rem 0 0; font-size: .82rem; color: var(--ink-soft); word-break: break-all; }
.photo__alt input { min-height: 38px; }

/* ---------- listas de passeios e artigos ---------- */
.search { margin-bottom: .75rem; }
.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.row {
  width: 100%; display: flex; align-items: center; gap: .75rem; text-align: left;
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: .45rem .6rem; cursor: pointer;
}
.row:hover { border-color: var(--blue-bright); background: #fbfeff; }
.row__img { width: 64px; height: 48px; border-radius: 6px; object-fit: cover; flex: none; background: #e3ecf0; }
.row__main { display: grid; min-width: 0; flex: 1; }
.row__main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__main span { font-size: .86rem; color: var(--ink-soft); }

.danger { margin-top: 2.5rem; padding-top: 1rem; border-top: 2px dashed #f0c8bf; }

/* ---------- janelas ---------- */
.dialog { border: 0; border-radius: 14px; padding: 0; width: min(520px, calc(100vw - 2rem)); box-shadow: 0 20px 60px rgba(0,0,0,.25); color: var(--ink); }
.dialog--wide { width: min(880px, calc(100vw - 2rem)); }
.dialog::backdrop { background: rgba(12, 32, 41, .55); }
.dialog__form { padding: 1.4rem 1.5rem; max-height: calc(100vh - 3rem); display: flex; flex-direction: column; }
.dialog__title { margin: 0 0 .6rem; font-size: 1.3rem; }
.dialog__body { overflow-y: auto; }
.dialog__body p { margin: 0 0 .6rem; }
.dialog__actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.picker__group h3 { margin: 1rem 0 .4rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--blue); }
.picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .5rem; }
.picker__item { display: grid; gap: .2rem; text-align: left; border: 1.5px solid var(--line); background: #fff; border-radius: var(--radius); padding: .7rem .8rem; cursor: pointer; }
.picker__item:hover { border-color: var(--blue-bright); background: #fbfeff; }
.picker__item span { font-size: .86rem; color: var(--ink-soft); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .5rem; }
.gallery__item { display: grid; gap: .25rem; border: 1.5px solid var(--line); border-radius: var(--radius-sm); padding: .3rem; background: #fff; cursor: pointer; text-align: left; }
.gallery__item:hover { border-color: var(--blue-bright); }
.gallery__item img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 5px; }
.gallery__item span { font-size: .75rem; color: var(--ink-soft); word-break: break-all; }
.errors { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.errors li { display: flex; gap: .75rem; align-items: center; justify-content: space-between; padding: .6rem .75rem; background: var(--coral-soft); border-radius: var(--radius-sm); }
.errors p { margin: .15rem 0 0; color: var(--coral); font-weight: 700; font-size: .92rem; }
.errors li > button { flex: none; }

/* ---------- avisos ---------- */
.toasts { position: fixed; right: 1rem; bottom: 1rem; display: grid; gap: .5rem; z-index: 50; width: min(420px, calc(100vw - 2rem)); }
.toast { display: flex; gap: .75rem; align-items: flex-start; padding: .75rem .9rem; border-radius: var(--radius); background: var(--ink); color: #fff; box-shadow: var(--shadow); animation: toast-in .2s ease-out; }
.toast--ok { background: var(--ok); }
.toast--error { background: var(--coral); }
.toast span { flex: 1; }
.toast__close { border: 0; background: none; color: inherit; font-size: 1.3rem; line-height: 1; cursor: pointer; padding: 0 .2rem; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- telas menores ---------- */
@media (max-width: 1100px) {
  :root { --side-w: 180px; --editor-w: 400px; }
}
/* Celular e tablet em pé: menu vira gaveta e editor/prévia viram abas embaixo */
.top__menu, .side-backdrop, .panes { display: none; }
@media (max-width: 860px) {
  .app {
    height: 100vh; height: 100dvh;
    grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: "top" "main" "panes";
  }
  .top { flex-wrap: wrap; gap: .45rem .5rem; padding: .45rem .6rem; }
  .top::after { content: ""; order: 6; flex-basis: 100%; } /* quebra: idioma e status na 2ª linha */
  .top__actions { display: contents; }
  .top__menu { display: inline-flex; order: 1; }
  .top .btn { min-height: 40px; padding: .35rem .7rem; }
  .top__brand { order: 2; width: auto; }
  .top__brand span { display: none; }
  #undo { order: 3; margin-left: auto; }
  #save { order: 4; }
  #logout { display: none; } /* no celular, o Sair fica no fim do Menu */
  .top__lang { order: 7; }
  .top__status { order: 8; margin-left: auto; font-size: .85rem; }

  .side {
    position: fixed; inset: 0 auto 0 0; z-index: 30; width: min(300px, 86vw);
    transform: translateX(-102%); transition: transform .22s ease-out; box-shadow: 0 0 40px rgba(0,0,0,.2);
    padding-top: 1rem;
  }
  .app.is-menu-open .side { transform: none; }
  .side-backdrop { display: block; position: fixed; inset: 0; z-index: 29; background: rgba(12, 32, 41, .45); }
  .side-backdrop[hidden] { display: none; }
  .nav__item { min-height: 44px; font-size: 1rem; }
  .nav__logout { display: inline-flex; margin-top: .6rem; }
  .item__head { flex-wrap: wrap; row-gap: .35rem; }
  .item__tools { flex-wrap: wrap; }
  .strings__line { flex-wrap: wrap; }
  .strings__line input { flex-basis: 100%; }

  .editor, .preview { grid-area: main; min-height: 0; min-width: 0; }
  .editor { border-right: 0; padding: 1rem .9rem 2.5rem; }
  .app:not([data-pane="preview"]) .preview, .app[data-pane="preview"] .editor { display: none; }
  .preview__bar { flex-wrap: wrap; }

  .panes {
    grid-area: panes; display: grid; grid-template-columns: 1fr 1fr; gap: .4rem;
    padding: .45rem .6rem calc(.45rem + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line);
  }
  .panes button { min-height: 44px; border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm); background: #fff; font: inherit; font-weight: 700; color: var(--ink-soft); cursor: pointer; }
  .panes button[aria-pressed="true"] { background: var(--blue); border-color: var(--blue); color: #fff; }

  /* 16px evita o zoom automático do iPhone ao tocar num campo */
  input, select, textarea { font-size: 16px; }
  .btn--small, .btn--tiny { min-height: 40px; }
  .photo { grid-template-columns: 1fr; }
  .pair, .checks { grid-template-columns: 1fr; }
  .picker { grid-template-columns: 1fr; }
  .gallery { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .errors li { flex-direction: column; align-items: stretch; }
  .dialog__form { padding: 1.1rem 1rem; max-height: calc(100dvh - 2rem); }
  .dialog__actions .btn { flex: 1 1 auto; }
  .toasts { left: .6rem; right: .6rem; bottom: calc(4.2rem + env(safe-area-inset-bottom)); width: auto; }
  .start { padding: 1rem; }
  .start__card { padding: 1.6rem 1.2rem; }
}
