/* =====================================================================
   BrevoComposer — a bespoke Brevo-style drag-and-drop email editor UI.
   Self-contained, forced-light (like Brevo), scoped under .bvc-root.
   The editor runs full-screen fixed on <body> ABOVE the app sidebar.
   ===================================================================== */

.bvc-root {
  /* GOTCHA #1: fixed on body, above the app sidebar. A transform on any
     ancestor traps position:fixed, so this MUST be a direct child of <body>. */
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  background: #f5f6f8;
  color: #1f2b3d;
  font-family: 'Lexend Deca', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  color-scheme: light;
  -webkit-font-smoothing: antialiased;
}
.bvc-root *, .bvc-root *::before, .bvc-root *::after { box-sizing: border-box; }
.bvc-root button { font-family: inherit; cursor: pointer; }

/* ---- Brevo palette tokens ----
   Defined on :root (NOT just .bvc-root) so body-appended elements — the drag
   ghost, popup menus, modals, toasts — which live OUTSIDE .bvc-root still
   resolve these variables. (The --bvc- prefix avoids clashing with the app.) */
:root, .bvc-root {
  --bvc-blue: #0b6ff5;
  --bvc-blue-d: #0a5fd0;
  --bvc-green: #16a34a;
  --bvc-ink: #1f2b3d;
  --bvc-muted: #67758a;
  --bvc-line: #e2e6ec;
  --bvc-line-2: #eef1f5;
  --bvc-panel: #ffffff;
  --bvc-canvas: #eceff3;
  --bvc-hover: #f2f5f9;
  --bvc-sel: #0b6ff5;
  --bvc-radius: 8px;
  --bvc-shadow: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.06);
  --bvc-shadow-lg: 0 12px 32px rgba(16,24,40,.18);
}

/* ============================ TOP BAR ============================ */
.bvc-topbar {
  flex: 0 0 auto;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background: var(--bvc-panel);
  border-bottom: 1px solid var(--bvc-line);
  z-index: 2;
}
.bvc-tb-left, .bvc-tb-center, .bvc-tb-right { display: flex; align-items: center; gap: 8px; }
.bvc-tb-center { flex: 1 1 auto; min-width: 0; justify-content: center; }
.bvc-back {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 7px; border: 1px solid var(--bvc-line);
  background: #fff; font-size: 17px; color: var(--bvc-ink);
}
.bvc-back:hover { background: var(--bvc-hover); }
.bvc-title-wrap { display: flex; flex-direction: column; min-width: 0; max-width: 420px; }
.bvc-title {
  border: 1px solid transparent; background: transparent; font-weight: 600; font-size: 15px;
  color: var(--bvc-ink); padding: 5px 8px; border-radius: 6px; width: 340px; max-width: 46vw;
  text-overflow: ellipsis;
}
.bvc-title:hover { background: var(--bvc-hover); }
.bvc-title:focus { outline: none; background: #fff; border-color: var(--bvc-blue); }
.bvc-saved { font-size: 11.5px; color: var(--bvc-muted); padding-left: 8px; white-space: nowrap; }

.bvc-iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px; padding: 0 8px; border-radius: 7px;
  border: 1px solid var(--bvc-line); background: #fff; color: var(--bvc-ink); font-size: 15px;
}
.bvc-iconbtn:hover { background: var(--bvc-hover); }
.bvc-iconbtn:disabled { opacity: .4; cursor: default; }
.bvc-iconbtn.is-on { background: #e7f0ff; border-color: var(--bvc-blue); color: var(--bvc-blue); }

.bvc-device { display: inline-flex; border: 1px solid var(--bvc-line); border-radius: 7px; overflow: hidden; }
.bvc-device button { width: 40px; height: 34px; border: 0; background: #fff; color: var(--bvc-muted); font-size: 15px; }
.bvc-device button.is-on { background: #e7f0ff; color: var(--bvc-blue); }

.bvc-btn {
  height: 34px; padding: 0 14px; border-radius: 7px; border: 1px solid var(--bvc-line);
  background: #fff; color: var(--bvc-ink); font-weight: 600; font-size: 13px; white-space: nowrap;
}
.bvc-btn:hover { background: var(--bvc-hover); }
.bvc-btn-primary { background: var(--bvc-blue); border-color: var(--bvc-blue); color: #fff; }
.bvc-btn-primary:hover { background: var(--bvc-blue-d); }
.bvc-btn-green { background: var(--bvc-green); border-color: var(--bvc-green); color: #fff; }
.bvc-btn-green:hover { filter: brightness(.95); }

/* ============================ BODY LAYOUT ============================ */
.bvc-body { flex: 1 1 auto; display: flex; min-height: 0; overflow-x: auto; }

/* ---- Left palette ---- */
.bvc-left {
  flex: 0 0 280px; width: 280px; background: var(--bvc-panel);
  border-right: 1px solid var(--bvc-line); display: flex; flex-direction: column; min-height: 0;
}
.bvc-tabs { display: flex; border-bottom: 1px solid var(--bvc-line); flex: 0 0 auto; }
.bvc-tab {
  flex: 1; height: 44px; border: 0; background: transparent; color: var(--bvc-muted);
  font-weight: 600; font-size: 13px; border-bottom: 2px solid transparent;
}
.bvc-tab:hover { background: var(--bvc-hover); }
.bvc-tab.is-on { color: var(--bvc-blue); border-bottom-color: var(--bvc-blue); }
.bvc-tabpanes { flex: 1 1 auto; overflow-y: auto; }
.bvc-tabpane { display: none; padding: 12px; }
.bvc-tabpane.is-on { display: block; }
.bvc-pal-group-title { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--bvc-muted); margin: 4px 2px 8px; }
.bvc-pal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.bvc-block {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  height: 74px; border: 1px solid var(--bvc-line); border-radius: var(--bvc-radius); background: #fff;
  color: var(--bvc-ink); font-size: 11.5px; font-weight: 600; text-align: center; user-select: none;
}
.bvc-block:hover { border-color: var(--bvc-blue); background: #f7faff; box-shadow: var(--bvc-shadow); }
.bvc-block.bvc-dragging { opacity: .5; }
.bvc-block-ico { font-size: 20px; line-height: 1; color: var(--bvc-muted); }
.bvc-block:hover .bvc-block-ico { color: var(--bvc-blue); }

/* Sections (layouts) */
.bvc-sec { display: flex; gap: 4px; height: 46px; padding: 6px; border: 1px solid var(--bvc-line); border-radius: var(--bvc-radius); background: #fff; margin-bottom: 8px; }
.bvc-sec:hover { border-color: var(--bvc-blue); background: #f7faff; }
.bvc-sec > i { flex: 1; background: #dde3ec; border-radius: 3px; display: block; }

.bvc-empty-note { color: var(--bvc-muted); font-size: 12.5px; text-align: center; padding: 26px 12px; line-height: 1.6; }

/* ---- Center canvas ---- */
.bvc-center { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 360px; min-height: 0; background: var(--bvc-canvas); }
.bvc-notice { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: #fef3c7; border-bottom: 1px solid #fcd34d; color: #92400e; font-size: 12.5px; line-height: 1.5; }
.bvc-notice-ico { font-size: 15px; }
.bvc-notice-x { border: 0; background: transparent; color: #92400e; font-size: 15px; width: 26px; height: 26px; border-radius: 6px; flex: 0 0 auto; }
.bvc-notice-x:hover { background: rgba(146,64,14,.12); }

/* RTE formatting bar — GOTCHA #4: in-flow flex child at TOP (not absolute) */
.bvc-rte {
  flex: 0 0 auto; display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  padding: 6px 10px; background: var(--bvc-panel); border-bottom: 1px solid var(--bvc-line);
  min-height: 44px;
}
.bvc-rte.is-disabled { opacity: .45; pointer-events: none; }
.bvc-rte-sep { width: 1px; height: 22px; background: var(--bvc-line); margin: 0 4px; }
.bvc-rte-btn {
  min-width: 30px; height: 30px; padding: 0 7px; border: 1px solid transparent; border-radius: 6px;
  background: transparent; color: var(--bvc-ink); font-size: 14px; display: inline-flex; align-items: center; justify-content: center;
}
.bvc-rte-btn:hover { background: var(--bvc-hover); }
.bvc-rte-btn.is-on { background: #e7f0ff; color: var(--bvc-blue); }
.bvc-rte-btn b, .bvc-rte-btn i, .bvc-rte-btn u, .bvc-rte-btn s { pointer-events: none; }
.bvc-rte-select { height: 30px; border: 1px solid var(--bvc-line); border-radius: 6px; background: #fff; color: var(--bvc-ink); font-size: 12.5px; padding: 0 6px; }
.bvc-rte-color { position: relative; }
.bvc-rte-color input[type=color] { width: 30px; height: 30px; padding: 0; border: 1px solid var(--bvc-line); border-radius: 6px; background: #fff; cursor: pointer; }

/* Canvas area: relative box the GrapesJS editor fills ABSOLUTELY, so its iframe
   always gets a definite size (never collapses to 0 height/width). The dotted
   backdrop shows through the transparent canvas where there's no email. */
.bvc-canvas-area {
  flex: 1 1 auto; min-height: 0; min-width: 0; position: relative; overflow: hidden;
  background-color: var(--bvc-canvas);
  background-image: radial-gradient(circle, #c8d0db 1px, transparent 1px);
  background-size: 16px 16px;
}
#bvc-gjs { position: absolute; inset: 0; background: transparent; }

/* GrapesJS chrome suppression — the preset initializes the default panels
   (needed so it doesn't crash), but we hide ALL of them and drive our own UI. */
.bvc-root .gjs-pn-panels,
.bvc-root .gjs-pn-panel,
.bvc-root .gjs-pn-views-container,
.bvc-root .gjs-pn-views,
.bvc-root .gjs-pn-options,
.bvc-root .gjs-pn-commands,
.bvc-root .gjs-pn-devices-c { display: none !important; }
.bvc-root .gjs-cv-canvas { top: 0 !important; left: 0 !important; width: 100% !important; height: 100% !important; background: transparent !important; }
.bvc-root .gjs-editor, .bvc-root .gjs-editor-cont { height: 100% !important; }
.bvc-root .gjs-frame-wrapper { padding: 0; }
/* Keep GrapesJS's own RTE actionbar hidden (we render our own) */
.bvc-root .gjs-rte-toolbar, .bvc-root .gjs-rte-actionbar { display: none !important; }

/* ---- Right settings ---- */
.bvc-right {
  flex: 0 0 312px; width: 312px; background: var(--bvc-panel);
  border-left: 1px solid var(--bvc-line); display: flex; flex-direction: column; min-height: 0;
}
.bvc-right-head { flex: 0 0 auto; height: 46px; display: flex; align-items: center; gap: 8px; padding: 0 14px; border-bottom: 1px solid var(--bvc-line); font-weight: 700; font-size: 13px; }
.bvc-right-head .bvc-rh-ico { color: var(--bvc-blue); font-size: 16px; }
.bvc-right-body { flex: 1 1 auto; overflow-y: auto; }
.bvc-settings-empty { color: var(--bvc-muted); font-size: 12.5px; text-align: center; padding: 40px 20px; line-height: 1.7; }

.bvc-sect { border-bottom: 1px solid var(--bvc-line-2); }
.bvc-sect-head { display: flex; align-items: center; justify-content: space-between; padding: 11px 14px; font-weight: 600; font-size: 12.5px; cursor: pointer; user-select: none; }
.bvc-sect-head:hover { background: var(--bvc-hover); }
.bvc-sect-head .chev { color: var(--bvc-muted); transition: transform .15s; }
.bvc-sect.is-collapsed .chev { transform: rotate(-90deg); }
.bvc-sect-body { padding: 4px 14px 14px; display: block; }
.bvc-sect.is-collapsed .bvc-sect-body { display: none; }

.bvc-field { margin-bottom: 11px; }
.bvc-field > label { display: block; font-size: 11.5px; font-weight: 600; color: var(--bvc-muted); margin-bottom: 5px; }
.bvc-input, .bvc-select, .bvc-textarea {
  width: 100%; height: 34px; border: 1px solid var(--bvc-line); border-radius: 6px; background: #fff;
  color: var(--bvc-ink); font-size: 13px; padding: 0 9px; font-family: inherit;
}
.bvc-textarea { height: auto; min-height: 70px; padding: 8px 9px; resize: vertical; }
.bvc-input:focus, .bvc-select:focus, .bvc-textarea:focus { outline: none; border-color: var(--bvc-blue); }
.bvc-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.bvc-color-row { display: flex; align-items: center; gap: 8px; }
.bvc-color-row input[type=color] { width: 36px; height: 34px; border: 1px solid var(--bvc-line); border-radius: 6px; padding: 2px; background: #fff; }
.bvc-color-row .bvc-input { flex: 1; }

.bvc-seg { display: inline-flex; border: 1px solid var(--bvc-line); border-radius: 6px; overflow: hidden; width: 100%; }
.bvc-seg button { flex: 1; height: 32px; border: 0; border-right: 1px solid var(--bvc-line); background: #fff; color: var(--bvc-muted); font-size: 13px; }
.bvc-seg button:last-child { border-right: 0; }
.bvc-seg button.is-on { background: #e7f0ff; color: var(--bvc-blue); font-weight: 600; }

.bvc-stepper { display: flex; align-items: center; border: 1px solid var(--bvc-line); border-radius: 6px; overflow: hidden; }
.bvc-stepper button { width: 30px; height: 32px; border: 0; background: #fff; color: var(--bvc-muted); font-size: 15px; }
.bvc-stepper button:hover { background: var(--bvc-hover); }
.bvc-stepper input { flex: 1; width: 100%; height: 32px; border: 0; border-left: 1px solid var(--bvc-line); border-right: 1px solid var(--bvc-line); text-align: center; font-size: 13px; color: var(--bvc-ink); }
.bvc-dual { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.bvc-check { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--bvc-ink); margin-top: 4px; }
.bvc-checklist { max-height: 190px; overflow-y: auto; border: 1px solid var(--bvc-line); border-radius: 8px; padding: 4px; }
.bvc-check-row { display: flex; align-items: center; gap: 9px; padding: 7px 9px; border-radius: 6px; font-size: 13px; color: var(--bvc-ink); cursor: pointer; }
.bvc-check-row:hover { background: var(--bvc-hover); }
.bvc-check-row input { width: 16px; height: 16px; accent-color: var(--bvc-blue); }

/* ============================ POPOVER MENUS ============================ */
.bvc-menu {
  position: fixed; z-index: 1200; min-width: 210px; background: #fff; border: 1px solid var(--bvc-line);
  border-radius: 10px; box-shadow: var(--bvc-shadow-lg); padding: 6px; max-height: 60vh; overflow: auto;
}
.bvc-menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 7px;
  background: transparent; color: var(--bvc-ink); font-size: 13px; text-align: left;
}
.bvc-menu-item:hover { background: var(--bvc-hover); }
.bvc-menu-item .k { margin-left: auto; color: var(--bvc-blue); font-family: 'JetBrains Mono', monospace; font-size: 11.5px; }
.bvc-menu-sep { height: 1px; background: var(--bvc-line-2); margin: 5px 4px; }
.bvc-menu-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--bvc-muted); padding: 6px 10px 3px; font-weight: 700; }

/* ============================ MODALS ============================ */
.bvc-backdrop {
  position: fixed; inset: 0; z-index: 1300; background: rgba(16,24,40,.5);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.bvc-modal { background: #fff; border-radius: 14px; box-shadow: var(--bvc-shadow-lg); width: 100%; max-width: 720px; max-height: 88vh; display: flex; flex-direction: column; overflow: hidden; }
.bvc-modal.lg { max-width: 1040px; }
.bvc-modal-head { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--bvc-line); }
.bvc-modal-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.bvc-modal-body { flex: 1 1 auto; overflow: auto; padding: 20px; }
.bvc-modal-foot { flex: 0 0 auto; display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--bvc-line); background: #fafbfc; }
.bvc-x { width: 32px; height: 32px; border-radius: 7px; border: 0; background: transparent; font-size: 18px; color: var(--bvc-muted); }
.bvc-x:hover { background: var(--bvc-hover); }

/* Preview modal split */
.bvc-prev-tabs { display: inline-flex; border: 1px solid var(--bvc-line); border-radius: 8px; overflow: hidden; }
.bvc-prev-tabs button { padding: 7px 16px; border: 0; background: #fff; color: var(--bvc-muted); font-weight: 600; font-size: 13px; }
.bvc-prev-tabs button.is-on { background: #e7f0ff; color: var(--bvc-blue); }
.bvc-prev-stage { display: flex; justify-content: center; padding: 18px; background: var(--bvc-canvas); border-radius: 10px; }
.bvc-prev-frame { border: 1px solid var(--bvc-line); border-radius: 8px; background: #fff; width: 640px; max-width: 100%; height: 60vh; }
.bvc-prev-frame.mobile { width: 375px; }
.bvc-test-row { display: flex; gap: 10px; margin-top: 16px; }
.bvc-test-row .bvc-input { flex: 1; }

.bvc-toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 1400;
  background: #10233d; color: #fff; padding: 11px 18px; border-radius: 9px; font-size: 13px; font-weight: 500;
  box-shadow: var(--bvc-shadow-lg); opacity: 0; transition: opacity .18s, transform .18s; pointer-events: none;
}
.bvc-toast.is-on { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.bvc-toast.err { background: #991b1b; }

.bvc-hint { font-size: 11.5px; color: var(--bvc-muted); line-height: 1.5; }
.bvc-spin { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: bvc-spin .6s linear infinite; vertical-align: -2px; }
@keyframes bvc-spin { to { transform: rotate(360deg); } }

/* Drop indicator on canvas */
.bvc-drop-hint { outline: 2px dashed var(--bvc-blue) !important; outline-offset: -2px; }
/* NB: rendered on <body>, OUTSIDE .bvc-root — must use hard-coded colors, not
   CSS variables (they don't resolve here → the ghost was invisible). Looks like
   a mini palette card (icon + label) that follows the cursor while dragging. */
.bvc-drag-ghost {
  position: fixed; z-index: 1500; pointer-events: none;
  display: inline-flex; align-items: center; gap: 8px;
  background: #ffffff; color: #1f2b3d; border: 1.5px solid #0b6ff5;
  font-family: 'Lexend Deca', Arial, sans-serif; font-size: 12.5px; font-weight: 600;
  padding: 8px 14px; border-radius: 9px; box-shadow: 0 14px 34px rgba(11,111,245,.30);
  white-space: nowrap;
}
.bvc-drag-ghost-ico { font-size: 16px; line-height: 1; color: #0b6ff5; }
.bvc-canvas-area.bvc-drop-active { box-shadow: inset 0 0 0 3px var(--bvc-blue); }
.bvc-block.bvc-dragging { opacity: .5; }
/* Captures mouse events during a palette drag so they don't get swallowed by
   the canvas iframe (which would break the drop). */
.bvc-drag-overlay { position: fixed; inset: 0; z-index: 1450; cursor: grabbing; background: transparent; }
