/* =========================================================
   Shrine · editor (barra, painel e marcações de edição)
   ========================================================= */
.editor-page { --site-top: 56px; --panel-w: 380px; }
.editor-page #scene { top: var(--site-top); width: calc(100% - var(--panel-w)); height: calc(100% - var(--site-top)); }
.editor-page .cs-site { margin-right: var(--panel-w); padding-top: var(--site-top); }
.editor-page .cs-wa { right: calc(var(--panel-w) + 22px); }
.editor-page .ed-toast { left: calc((100% - var(--panel-w)) / 2); }

/* ---------- barra ---------- */
.ed-bar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--site-top); z-index: 60;
  display: flex; align-items: center; gap: 16px; padding: 0 16px;
  background: rgba(6, 8, 16, .92); border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.ed-bar .logo small { color: var(--muted); font-size: 11px; font-weight: 400; margin-left: 2px; letter-spacing: 0; }
.ed-status { flex: 1; min-width: 0; color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ed-actions { display: flex; align-items: center; gap: 8px; }
.ed-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, .04); color: var(--fg); font: inherit; font-size: 13px;
  white-space: nowrap; transition: border-color .3s, color .3s;
}
.ed-btn:hover { border-color: var(--accent); color: var(--accent); }
.ed-btn.wide { width: 100%; margin-top: 14px; padding: 12px; }
.ed-bar .btn-small { padding: 10px 18px; }
.only-mobile { display: none; }

/* ---------- painel ---------- */
.ed-panel {
  position: fixed; top: var(--site-top); right: 0; bottom: 0; width: var(--panel-w); z-index: 50;
  overflow-y: auto; overscroll-behavior: contain; padding: 18px 18px 40px;
  display: grid; align-content: start; gap: 16px;
  background: rgba(8, 10, 20, .95); border-left: 1px solid var(--line);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); scrollbar-width: thin; overflow-x: hidden;
}
.ed-panel > *, .ed-pane > * { min-width: 0; }
.ed-hint { font-size: 13px; color: var(--muted); line-height: 1.5; padding: 12px 14px; border: 1px dashed color-mix(in srgb, var(--accent) 45%, transparent); border-radius: 12px; }
.ed-hint b { color: var(--fg); font-weight: 600; }
.ed-tabs {
  position: sticky; top: -18px; z-index: 5; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 4px;
  border-radius: 12px; background: rgba(6, 8, 16, .96); border: 1px solid var(--line);
}
.ed-tab { padding: 9px 2px; border: 0; border-radius: 9px; background: none; color: var(--muted); font: inherit; font-size: 13px; transition: background .3s, color .3s; }
.ed-tab:hover { color: var(--fg); }
.ed-tab[aria-selected="true"] { background: var(--accent); color: var(--bg); font-weight: 600; }
.ed-pane { display: grid; gap: 22px; }
.ed-pane[hidden] { display: none; }
.ed-panel .field input:is([type="text"], [type="tel"], [type="email"]) { padding: 13px 14px; font-size: 15px; }
.range-row { display: grid; gap: 8px; margin: 0 0 14px !important; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

.sec-list { list-style: none; display: grid; gap: 8px; }
.sec-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: rgba(0, 0, 0, .25); }
.sec-name { flex: 1; font-size: 15px; }
.sec-row.off .sec-name { color: var(--muted); }
.sec-name-input { width: 0; min-width: 0; padding: 4px 8px; border: 1px dashed var(--line); border-radius: 8px; background: transparent; color: var(--fg); font: inherit; font-size: 15px; }
.sec-name-input:focus { outline: none; border-color: var(--accent); }

.mini-btn { flex: none; width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: rgba(255, 255, 255, .04); color: var(--fg); font: inherit; font-size: 13px; }
.mini-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.mini-btn:disabled { opacity: .3; cursor: default; }
.mini-btn.danger:hover:not(:disabled) { border-color: #ff4d6d; color: #ff4d6d; }

.ff-list { list-style: none; display: grid; gap: 10px; }
.ff { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: rgba(0, 0, 0, .25); }
.ff-top, .ff-row { display: flex; align-items: center; gap: 6px; }
.ff-row { gap: 12px; }
.ff :is(.ff-label, .ff-type, .ff-opts) {
  min-width: 0; padding: 9px 10px; border-radius: 9px; border: 1px solid var(--line); background: rgba(0, 0, 0, .35);
  color: var(--fg); font: inherit; font-size: 14px; outline: none;
}
.ff .ff-label { flex: 1; }
.ff .ff-type { flex: 1; }
.ff .ff-type option { background: #0b0e19; }
.ff .ff-opts { width: 100%; resize: vertical; }
.ff :is(.ff-label, .ff-type, .ff-opts):focus { border-color: var(--accent); }
.ff-req { display: flex !important; align-items: center; gap: 6px; margin: 0 !important; font-size: 13px !important; color: var(--muted) !important; text-transform: none !important; letter-spacing: 0 !important; white-space: nowrap; }
.ff-req input { accent-color: var(--accent); width: 16px; height: 16px; }

/* ---------- marcações de edição no site ---------- */
.editor-page:not(.ed-preview) [contenteditable="true"] {
  outline: 1px dashed transparent; outline-offset: 4px; border-radius: 4px; transition: outline-color .2s, background .2s;
}
.editor-page:not(.ed-preview) [contenteditable="true"]:hover { outline-color: color-mix(in srgb, var(--accent) 70%, transparent); }
.editor-page:not(.ed-preview) [contenteditable="true"]:focus { outline: 2px solid var(--accent); background: rgba(255, 255, 255, .05); }
.editor-page [data-ph]:empty::before { content: attr(data-ph); color: var(--muted); opacity: .6; }
.cs-btn [contenteditable="true"]:focus { background: rgba(0, 0, 0, .15); }
.cs-tools { position: absolute; top: 10px; right: 10px; z-index: 2; display: flex; gap: 4px; opacity: 0; transition: opacity .2s; }
:is(.cs-card, .cs-quote, .cs-qa):hover .cs-tools, .cs-tools:focus-within { opacity: 1; }
.cs-tools button { width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line); background: rgba(6, 8, 16, .9); color: var(--fg); font-size: 12px; }
.cs-tools button:hover { border-color: var(--accent); color: var(--accent); }
.cs-tools button[data-act="del"]:hover { border-color: #ff4d6d; color: #ff4d6d; }
.cs-add { margin-top: 14px; padding: 12px 18px; border-radius: 12px; border: 1px dashed color-mix(in srgb, var(--accent) 60%, transparent); background: none; color: var(--accent); font: inherit; font-size: 14px; }
.cs-add:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.editor-page:not(.ed-preview) .cs-tile:hover { outline: 2px dashed var(--accent); outline-offset: 3px; }
.cs-tile-del { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line); background: rgba(6, 8, 16, .9); color: var(--fg); }

/* ---------- ver como visitante ---------- */
.editor-page.ed-preview { --site-top: 0px; --panel-w: 0px; }
.editor-page.ed-preview :is(.ed-bar, .ed-panel) { display: none; }
.ed-back { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 70; }
.ed-back[hidden] { display: none; }

/* menu do site do cliente some quando a área de visualização fica estreita */
@media (max-width: 1320px) { .editor-page:not(.ed-preview) .cs-menu { display: none; } }

/* ---------- telas menores: painel vira gaveta ---------- */
@media (max-width: 900px) {
  .editor-page { --panel-w: 0px; }
  .only-mobile { display: inline-flex; }
  .ed-btn span, .ed-status { display: none; }
  .ed-bar { gap: 8px; padding: 0 10px; }
  .ed-actions { margin-left: auto; gap: 6px; }
  .ed-btn { padding: 9px 11px; }
  .ed-panel {
    top: auto; width: 100%; height: 72vh; border-left: 0; border-top: 1px solid var(--line); border-radius: 18px 18px 0 0;
    transform: translateY(100%); transition: transform .35s var(--ease);
  }
  .panel-open .ed-panel { transform: none; }
}

/* ---------- assistente virtual ---------- */
.ai-fab {
  position: fixed; left: 20px; bottom: 20px; z-index: 65; display: inline-flex; align-items: center; gap: 8px;
  padding: 13px 20px; border-radius: 999px; border: 1px solid var(--accent); background: rgba(8, 10, 20, .92);
  color: var(--fg); font: 600 14px "Space Grotesk", sans-serif; box-shadow: 0 10px 34px -12px var(--accent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); transition: transform .3s var(--ease), box-shadow .3s;
}
.ai-fab:hover { transform: translateY(-2px); box-shadow: 0 14px 40px -10px var(--accent); }
.ai-fab[aria-expanded="true"] { background: var(--accent); color: var(--bg); }
.ai-chat {
  position: fixed; left: 20px; bottom: 80px; z-index: 66; width: min(380px, calc(100% - 40px)); height: min(540px, calc(100vh - 160px));
  display: flex; flex-direction: column; border-radius: 20px; border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  background: rgba(8, 10, 20, .97); box-shadow: 0 24px 70px -20px rgba(0, 0, 0, .8), 0 0 40px -18px var(--accent);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); overflow: hidden;
}
.ai-chat[hidden] { display: none; }
.ai-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.ai-head b { font-size: 15px; }
.ai-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; scrollbar-width: thin; }
.ai-msg { max-width: 88%; padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.ai-msg.assistant { align-self: flex-start; background: rgba(255, 255, 255, .06); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.ai-msg.user { align-self: flex-end; background: color-mix(in srgb, var(--accent) 22%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); border-bottom-right-radius: 4px; }
.ai-msg.typing { color: var(--muted); animation: ai-pulse 1.2s ease-in-out infinite; }
@keyframes ai-pulse { 50% { opacity: .45; } }
.ai-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); font-size: 12px; color: var(--accent); }
.ai-meta button { border: 1px solid var(--line); background: none; color: var(--fg); border-radius: 8px; padding: 4px 8px; font: inherit; font-size: 12px; }
.ai-meta button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.ai-meta button:disabled { opacity: .5; }
.ai-sac { margin: 0; padding: 0 12px 10px; font-size: 12px; color: var(--muted); text-align: center; }
.ai-sac a { color: var(--fg); text-underline-offset: 3px; }
.ai-sac a:hover { color: var(--accent); }
.ai-limit { padding-bottom: 2px; opacity: .8; }
.ai-suggest { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 12px; }
.ai-suggest[hidden] { display: none; }
.ai-suggest .chip { font-size: 12px; padding: 7px 11px; }
.ai-form { display: flex; gap: 8px; align-items: flex-end; padding: 12px; border-top: 1px solid var(--line); }
.ai-form textarea {
  flex: 1; min-width: 0; resize: none; max-height: 120px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(0, 0, 0, .35); color: var(--fg); font: 14px "Space Grotesk", sans-serif; outline: none;
}
.ai-form textarea:focus { border-color: var(--accent); }
.ai-form .btn:disabled { opacity: .5; }
.editor-page.ed-preview :is(.ai-fab, .ai-chat) { display: none; }
@media (max-width: 900px) {
  .ai-fab { bottom: 16px; left: 12px; padding: 11px 16px; }
  .ai-fab span { display: none; }
  .ai-chat { left: 10px; right: 10px; width: auto; bottom: 70px; height: min(70vh, 540px); }
}

/* ---------- ajustes da revisão ---------- */
/* texto apagado continua clicável para editar de novo */
.editor-page:not(.ed-preview) [contenteditable="true"]:empty { display: inline-block; min-width: 3ch; min-height: 1em; }
.editor-page:not(.ed-preview) [contenteditable="true"]:empty:not([data-ph])::before { content: "✎"; opacity: .45; }
/* telas de toque: ferramentas dos cards sempre visíveis (sem hover) */
@media (hover: none) { .cs-tools { opacity: 1; } }
.cs-tools { pointer-events: none; }
:is(.cs-card, .cs-quote, .cs-qa):hover .cs-tools, .cs-tools:focus-within { pointer-events: auto; }
@media (hover: none) { .cs-tools { pointer-events: auto; } }
@media (max-width: 900px) {
  .ed-bar .logo small, #btn-finish i { display: none; }
  .ed-bar .logo { min-width: 0; }
  .ed-panel { padding-bottom: 90px; }
  .panel-open .ai-fab { display: none; }
}
@media (max-width: 480px) {
  .ed-bar .logo { font-size: 0; gap: 0; }
  .ed-bar .btn-small { padding: 9px 12px; font-size: 13px; }
  .ed-actions { gap: 4px; }
  .ed-btn { padding: 8px 9px; }
}

/* ---------- alterações de site já publicado (alterar.html) ---------- */
.alt-page { --panel-w: 400px; }
.alt-page .ed-panel { display: flex; flex-direction: column; gap: 0; padding: 0; overflow: hidden; }
.alt-info { display: grid; gap: 10px; padding: 16px; border-bottom: 1px solid var(--line); max-height: 50%; overflow-y: auto; scrollbar-width: thin; }
.alt-info:empty { display: none; }
.alt-state { margin: 0; font-size: 13px; line-height: 1.55; color: var(--muted); }
.alt-state b { color: var(--fg); font-weight: 600; }
.alt-note { margin: 0; font-size: 13px; line-height: 1.5; padding: 10px 12px; border-radius: 10px; border: 1px solid rgba(255, 77, 109, .45); color: #ffc2cd; background: rgba(255, 77, 109, .08); }
.alt-meter { height: 6px; border-radius: 99px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.alt-meter i { display: block; height: 100%; background: var(--accent); transition: width .4s; }
.alt-meter.over i { background: #ff4d6d; }
.alt-label { margin: 4px 0 0; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.alt-sum { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.alt-sum li::before { content: "• "; color: var(--accent); }
.alt-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.alt-actions .btn { flex: 1; justify-content: center; }
.alt-actions button:disabled { opacity: .45; cursor: not-allowed; }
.alt-photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.alt-photo { position: relative; aspect-ratio: 4 / 3; min-width: 0; }
.alt-photo > button:first-child {
  width: 100%; height: 100%; padding: 0; overflow: hidden; border-radius: 10px; border: 1px dashed var(--line);
  background: rgba(0, 0, 0, .3); color: var(--muted); font: inherit; font-size: 20px; cursor: pointer;
}
.alt-photo > button:first-child:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.alt-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.alt-photo.changed > button:first-child { border: 2px solid var(--accent); }
.alt-photo-del {
  position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 7px;
  border: 1px solid var(--line); background: rgba(6, 8, 16, .9); color: var(--fg); font-size: 11px;
}
.alt-photo-del:hover:not(:disabled) { border-color: #ff4d6d; color: #ff4d6d; }
.alt-photo button:disabled { opacity: .35; cursor: not-allowed; }
.alt-page .ai-log { min-height: 140px; }
.alt-page .ai-form textarea:disabled { opacity: .5; }
@media (max-width: 900px) {
  .alt-page { --panel-w: 0px; }
  .alt-page .ed-panel { height: 78vh; padding: 0; }
  .alt-info { max-height: 38%; }
}
