:root {
  --navy: #071726;
  --navy-2: #102c42;
  --blue: #116eaa;
  --blue-2: #0c5689;
  --paper: #f4f7fa;
  --surface: #ffffff;
  --line: rgba(15, 39, 58, .11);
  --muted: #697c8b;
  --text: #183246;
  --success: #16724d;
  --danger: #9b3041;
  --shadow: 0 18px 48px rgba(7, 23, 38, .12);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  overflow: hidden;
  color: var(--text);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 3px solid rgba(17, 110, 170, .25);
  outline-offset: 2px;
}

.editorShell { height: 100vh; display: grid; grid-template-rows: 68px 1fr; }
.editorTopbar {
  position: relative;
  z-index: 30;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(250px, 1fr) auto auto minmax(280px, 1fr);
  align-items: center;
  gap: 14px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 8px 30px rgba(7, 23, 38, .06);
  backdrop-filter: blur(18px);
}
.editorBrand { min-width: 0; display: flex; align-items: center; gap: 10px; }
.editorLogo { width: 38px; height: 38px; object-fit: contain; border-radius: 10px; background: #fff; }
.editorBrand > div { min-width: 0; display: grid; gap: 1px; }
.editorBrand span { color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .045em; text-transform: uppercase; }
.editorBrand strong { overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.backButton, .iconButton {
  width: 36px; height: 36px; display: inline-grid; place-items: center;
  border: 1px solid var(--line); border-radius: 11px; color: var(--text); background: #fff;
  text-decoration: none; cursor: pointer; transition: transform .18s ease, border-color .18s ease, background .18s ease;
}
.backButton:hover, .iconButton:hover { transform: translateY(-1px); border-color: rgba(17, 110, 170, .3); background: #f8fbfd; }
.editorHistory { display: flex; gap: 5px; }
.deviceSwitch { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: #f5f8fa; }
.deviceButton {
  min-height: 32px; border: 0; border-radius: 8px; padding: 0 10px; color: #536b7c; background: transparent;
  font-size: 11px; font-weight: 800; cursor: pointer;
}
.deviceButton.active { color: var(--navy); background: #fff; box-shadow: 0 4px 12px rgba(7, 23, 38, .08); }
.topbarActions { display: flex; justify-content: flex-end; gap: 7px; }
.button {
  min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid transparent; border-radius: 11px; padding: 0 14px; font-size: 12px; font-weight: 800;
  text-decoration: none; cursor: pointer; transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.button:hover { transform: translateY(-1px); }
.buttonPrimary { color: #fff; background: linear-gradient(135deg, var(--blue), #1487c5); box-shadow: 0 9px 22px rgba(17, 110, 170, .22); }
.buttonPrimary:hover { background: linear-gradient(135deg, var(--blue-2), var(--blue)); }
.buttonGhost { border-color: var(--line); color: #385267; background: #fff; }
.button[disabled] { opacity: .52; cursor: not-allowed; transform: none; }

.editorWorkspace { min-height: 0; display: grid; grid-template-columns: 220px minmax(0, 1fr) 290px; }
.blocksPanel, .propertiesPanel { min-height: 0; overflow: auto; background: #fbfcfd; }
.blocksPanel { border-right: 1px solid var(--line); }
.propertiesPanel { border-left: 1px solid var(--line); }
.panelTitle { display: grid; gap: 1px; padding: 18px 16px 12px; }
.panelTitle span, .eyebrow { color: var(--blue); font-size: 10px; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
.panelTitle strong { font-size: 16px; letter-spacing: -.02em; }
.panelTip { margin: 14px; display: flex; gap: 9px; padding: 11px; border-radius: 12px; color: #577083; background: #edf4f8; font-size: 11px; line-height: 1.45; }
.panelTip span { flex: 0 0 21px; width: 21px; height: 21px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--blue); font-weight: 850; }
.panelTip p { margin: 0; }

.canvasArea { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #e9eef2; }
#gjs { height: 100%; min-height: 0; border: 0; }
.editorState {
  position: absolute; inset: 0; z-index: 15; display: grid; place-content: center; justify-items: center; gap: 7px;
  color: #4a6477; background: #edf2f5; text-align: center;
}
.editorState[hidden] { display: none; }
.editorState strong { font-size: 15px; }
.editorState small { color: #7b8d9a; font-size: 11px; }
.loadingMark { width: 26px; height: 26px; border: 3px solid rgba(17, 110, 170, .16); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* GrapesJS: mantemos o motor, mas não a aparência genérica. */
.gjs-one-bg { background-color: #fbfcfd !important; }
.gjs-two-color { color: #526a7b !important; }
.gjs-three-bg { background-color: var(--blue) !important; color: #fff !important; }
.gjs-four-color, .gjs-four-color-h:hover { color: var(--blue) !important; }
.gjs-cv-canvas { width: 100% !important; height: 100% !important; top: 0 !important; background: #e9eef2; }
.gjs-frame-wrapper { box-shadow: 0 12px 42px rgba(7, 23, 38, .10); }
.gjs-blocks-c { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 12px 12px; }
.gjs-block {
  width: auto !important; min-height: 78px; margin: 0 !important; padding: 11px 7px !important;
  border: 1px solid var(--line) !important; border-radius: 12px !important; color: #375267 !important; background: #fff !important;
  box-shadow: none !important; transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.gjs-block:hover { transform: translateY(-2px); border-color: rgba(17, 110, 170, .3) !important; box-shadow: 0 8px 20px rgba(7, 23, 38, .08) !important; }
.gjs-block-label { font-size: 10px; font-weight: 800; line-height: 1.25; }
.gjs-block__media { margin-bottom: 5px; font-size: 23px; }
.gjs-sm-sector { border-bottom: 1px solid var(--line) !important; box-shadow: none !important; }
.gjs-sm-sector-title { padding: 11px 13px !important; background: #f7f9fb !important; }
.gjs-sm-properties { padding: 8px !important; }
.gjs-sm-property { padding: 5px !important; }
.gjs-field { border: 1px solid var(--line) !important; border-radius: 8px !important; background: #fff !important; }
.gjs-layer { font-size: 11px; }
.gjs-layer-title { border-bottom: 1px solid rgba(15, 39, 58, .05); background: transparent !important; }
.gjs-trt-trait { padding: 6px 8px !important; }

.propertiesTabs { position: sticky; top: 0; z-index: 4; display: grid; grid-template-columns: 1fr 1fr; padding: 8px; border-bottom: 1px solid var(--line); background: rgba(251, 252, 253, .95); backdrop-filter: blur(12px); }
.propertyTab { min-height: 34px; border: 0; border-radius: 9px; color: #667b8a; background: transparent; font-size: 11px; font-weight: 800; cursor: pointer; }
.propertyTab.active { color: var(--navy); background: #fff; box-shadow: 0 4px 12px rgba(7, 23, 38, .07); }
.propertyPane { display: none; }
.propertyPane.active { display: block; }
.emptyProperty { display: grid; justify-items: center; gap: 6px; padding: 34px 20px; color: #748794; text-align: center; }
.emptyProperty > span { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 12px; color: var(--blue); background: #eaf3f8; }
.emptyProperty strong { color: #3c566a; font-size: 12px; }
.emptyProperty p { margin: 0; max-width: 220px; font-size: 11px; line-height: 1.5; }
.emptyProperty.hidden { display: none; }

.statusToast {
  position: fixed; right: 18px; bottom: 18px; z-index: 1000; max-width: min(420px, calc(100vw - 36px));
  padding: 12px 15px; border-radius: 13px; color: #fff; background: var(--navy-2); box-shadow: var(--shadow);
  font-size: 12px; font-weight: 750; opacity: 0; transform: translateY(12px); pointer-events: none; transition: .22s ease;
}
.statusToast.show { opacity: 1; transform: none; }
.statusToast.success { background: var(--success); }
.statusToast.error { background: var(--danger); }

.editorDialog { width: min(92vw, 510px); border: 0; border-radius: 22px; padding: 0; background: transparent; box-shadow: 0 34px 90px rgba(7, 23, 38, .3); }
.editorDialog::backdrop { background: rgba(4, 15, 25, .6); backdrop-filter: blur(7px); }
.dialogCard { padding: 26px; border-radius: 22px; background: #fff; }
.dialogHeading { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.dialogIcon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; color: #fff; background: linear-gradient(135deg, var(--navy), var(--blue)); font-size: 18px; }
.dialogHeading h2, .previewHeader h2 { margin: 2px 0 0; color: var(--navy); font-size: 20px; letter-spacing: -.03em; }
.dialogCard > p { color: var(--muted); font-size: 12px; line-height: 1.55; }
.dialogCard label:not(.rememberRow) { display: grid; gap: 6px; margin-top: 16px; color: #3e5668; font-size: 11px; font-weight: 800; }
.dialogCard input[type="password"] { min-height: 42px; border: 1px solid var(--line); border-radius: 10px; padding: 0 11px; color: var(--text); background: #f8fafb; }
.rememberRow { margin-top: 12px; display: flex; align-items: center; gap: 8px; color: #5f7382; font-size: 11px; }
.dialogStatus { min-height: 18px; margin-bottom: 0 !important; color: var(--danger) !important; }
.dialogActions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.previewDialog { width: min(96vw, 1360px); max-width: none; height: min(92vh, 920px); }
.previewCard { height: 100%; display: grid; grid-template-rows: 58px 1fr; overflow: hidden; border-radius: 20px; background: #fff; }
.previewHeader { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 13px 8px 18px; border-bottom: 1px solid var(--line); }
#previewFrame { width: 100%; height: 100%; border: 0; background: #fff; }

@media (max-width: 1180px) {
  .editorTopbar { grid-template-columns: minmax(210px, 1fr) auto minmax(230px, 1fr); }
  .editorHistory { display: none; }
  .editorWorkspace { grid-template-columns: 190px minmax(0, 1fr) 250px; }
  .deviceButton { padding-inline: 7px; }
}
@media (max-width: 900px) {
  .editorTopbar { grid-template-columns: 1fr auto; }
  .deviceSwitch { display: none; }
  .topbarActions .hideSmall { display: none; }
  .editorWorkspace { grid-template-columns: 150px minmax(0, 1fr); }
  .propertiesPanel { display: none; }
  .gjs-blocks-c { grid-template-columns: 1fr; }
  .editorBrand span { display: none; }
}
@media (max-width: 640px) {
  .editorShell { grid-template-rows: 60px 1fr; }
  .editorTopbar { padding: 7px 8px; gap: 7px; }
  .editorLogo, .editorBrand > div { display: none; }
  .editorBrand { width: 40px; }
  .topbarActions { gap: 4px; }
  .topbarActions .button { min-height: 36px; padding-inline: 10px; }
  .editorWorkspace { grid-template-columns: 92px minmax(0, 1fr); }
  .panelTitle { padding: 12px 8px 8px; }
  .panelTitle strong { font-size: 13px; }
  .panelTip { display: none; }
  .gjs-blocks-c { padding-inline: 6px; gap: 5px; }
  .gjs-block { min-height: 64px; padding: 7px 4px !important; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
