/* BRZ Services — Editor v2 (in-place HTML editor) */
:root {
  --ed-navy: #0a2540;
  --ed-navy-dark: #061a30;
  --ed-blue: #2563eb;
  --ed-blue-soft: rgba(37, 99, 235, 0.1);
  --ed-text: #1f2937;
  --ed-muted: #6b7280;
  --ed-border: #e5e7eb;
  --ed-bg: #f8fafc;
  --ed-bg-2: #f1f5f9;
  --ed-success: #10b981;
  --ed-warning: #f59e0b;
  --ed-danger: #ef4444;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--ed-bg);
  color: var(--ed-text);
  font-size: 14px;
  overflow: hidden;
}

/* === Topbar === */
.ed-topbar {
  display: flex;
  align-items: center;
  height: 56px;
  background: var(--ed-navy);
  color: #fff;
  padding: 0 16px;
  gap: 16px;
  position: relative;
  z-index: 10;
}

.ed-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #fff;
  font-weight: 700;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}
.ed-brand img { height: 28px; }
.ed-brand small {
  display: block;
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.6);
}

.ed-current {
  margin-left: 16px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: rgba(255,255,255,0.85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 400px;
}

.ed-status {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.7);
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  white-space: nowrap;
}
.ed-status.is-dirty { background: rgba(245,158,11,0.18); color: #fde68a; }
.ed-status.is-saved { background: rgba(16,185,129,0.18); color: #a7f3d0; }
.ed-status.is-error { background: rgba(239,68,68,0.18); color: #fca5a5; }

.ed-actions { margin-left: auto; display: flex; gap: 8px; }

.ed-btn {
  background: rgba(255,255,255,0.08);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.12);
  font: inherit;
  font-weight: 500;
  font-size: 0.8125rem;
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 150ms;
  white-space: nowrap;
}
.ed-btn:hover:not(:disabled) { background: rgba(255,255,255,0.16); }
.ed-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.ed-btn--ghost { background: transparent; }
.ed-btn--primary {
  background: var(--ed-blue);
  border-color: var(--ed-blue);
}
.ed-btn--primary:hover:not(:disabled) { background: #1d4ed8; }

/* === Main layout === */
.ed-main {
  display: grid;
  grid-template-columns: 240px 1fr 300px;
  height: calc(100vh - 56px);
}

/* === Left: page list === */
.ed-pages {
  background: #fff;
  border-right: 1px solid var(--ed-border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.ed-section {
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--ed-border);
}
.ed-section:last-child { border-bottom: none; }

.ed-section h3 {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ed-navy);
  margin: 0 0 10px;
}

.ed-hint {
  font-size: 0.8125rem;
  color: var(--ed-muted);
  line-height: 1.55;
  margin: 0 0 8px;
}
.ed-hint strong { color: var(--ed-text); }

.ed-page-list {
  padding: 8px 0;
  flex: 1;
  overflow-y: auto;
}

.ed-page-group {
  padding: 12px 18px 4px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ed-muted);
}

.ed-page-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  font-size: 0.8125rem;
  color: var(--ed-text);
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 120ms, border-color 120ms;
}
.ed-page-item:hover { background: var(--ed-bg-2); }
.ed-page-item.is-active {
  background: var(--ed-blue-soft);
  border-left-color: var(--ed-blue);
  color: var(--ed-navy);
  font-weight: 600;
}
.ed-page-item .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: transparent;
  flex-shrink: 0;
}
.ed-page-item.is-dirty .dot { background: var(--ed-warning); }

.ed-quickhelp ul {
  list-style: none;
  padding: 0;
  margin: 4px 0 0;
}
.ed-quickhelp li {
  padding: 6px 0;
  font-size: 0.8125rem;
  color: var(--ed-muted);
  border-bottom: 1px dashed var(--ed-border);
}
.ed-quickhelp li:last-child { border-bottom: none; }
kbd {
  background: var(--ed-bg-2);
  border: 1px solid var(--ed-border);
  border-radius: 3px;
  padding: 1px 6px;
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
}

/* === Canvas === */
.ed-canvas-wrap {
  background: #d8e0e8;
  position: relative;
  overflow: hidden;
}

.ed-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.ed-empty[hidden] { display: none; }

.ed-empty-inner {
  text-align: center;
  max-width: 420px;
}
.ed-empty-inner svg { margin-bottom: 16px; }
.ed-empty-inner h2 {
  font-size: 1.25rem;
  color: var(--ed-navy);
  margin: 0 0 12px;
}
.ed-empty-inner p {
  color: var(--ed-muted);
  line-height: 1.65;
  margin: 0 0 12px;
}
.ed-empty-inner code {
  background: var(--ed-bg-2);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: ui-monospace, monospace;
  font-size: 0.8125rem;
  color: var(--ed-text);
}
.ed-empty-note {
  font-size: 0.75rem !important;
  color: var(--ed-muted) !important;
  margin-top: 24px !important;
}

#edFrame {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}
#edFrame[hidden] { display: none; }

/* === Right: Properties === */
.ed-props {
  background: #fff;
  border-left: 1px solid var(--ed-border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.ed-tagline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--ed-blue-soft);
  border-radius: 4px;
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ed-blue);
  margin-bottom: 12px;
}
.ed-tagline .crumbs {
  color: var(--ed-muted);
  font-weight: 400;
}

.ed-field {
  margin-bottom: 12px;
}
.ed-field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ed-text);
  margin-bottom: 4px;
}
.ed-field input[type="text"],
.ed-field input[type="number"],
.ed-field input[type="url"],
.ed-field input[type="color"],
.ed-field textarea,
.ed-field select {
  width: 100%;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 0.8125rem;
  border: 1px solid var(--ed-border);
  border-radius: 6px;
  background: #fff;
  color: var(--ed-text);
  transition: border-color 120ms;
}
.ed-field input:focus,
.ed-field textarea:focus,
.ed-field select:focus {
  outline: none;
  border-color: var(--ed-blue);
  box-shadow: 0 0 0 3px var(--ed-blue-soft);
}
.ed-field input[type="color"] { height: 36px; padding: 2px; cursor: pointer; }
.ed-field textarea { min-height: 80px; resize: vertical; }
.ed-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.ed-context {
  display: flex;
  gap: 6px;
  padding: 8px 0;
  border-top: 1px solid var(--ed-border);
  margin-top: 12px;
}
.ed-context button {
  flex: 1;
  padding: 6px 10px;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid var(--ed-border);
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
  color: var(--ed-text);
}
.ed-context button:hover { background: var(--ed-bg-2); }
.ed-context button.danger {
  color: #b91c1c;
  border-color: #fecaca;
}
.ed-context button.danger:hover { background: #fef2f2; }

/* Image picker grid */
.ed-images {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 4px;
}
.ed-images img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid var(--ed-border);
  transition: all 120ms;
}
.ed-images img:hover {
  border-color: var(--ed-blue);
  transform: scale(1.04);
}

/* === Modal === */
.ed-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.ed-modal[hidden] { display: none; }
.ed-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(10, 37, 64, 0.6);
  backdrop-filter: blur(4px);
}
.ed-modal-content {
  position: relative;
  background: #fff;
  border-radius: 12px;
  max-width: 800px;
  max-height: 80vh;
  width: 100%;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.ed-modal-content header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--ed-border);
}
.ed-modal-content header h3 { margin: 0; font-size: 1rem; color: var(--ed-navy); }
.ed-modal-content footer {
  display: flex;
  gap: 8px;
  padding: 16px 20px;
  border-top: 1px solid var(--ed-border);
}
.ed-modal-content footer input { flex: 1; }
.ed-icon-btn {
  width: 32px; height: 32px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 4px;
  font-size: 1rem;
  color: var(--ed-muted);
}
.ed-icon-btn:hover { background: var(--ed-bg-2); color: var(--ed-text); }

.ed-image-grid {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  align-content: start;
}
.ed-image-card {
  border: 2px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  background: var(--ed-bg-2);
  transition: all 150ms;
}
.ed-image-card.is-selected { border-color: var(--ed-blue); }
.ed-image-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.ed-image-card img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
}
.ed-image-card .name {
  font-size: 0.75rem;
  padding: 6px 8px;
  color: var(--ed-text);
  background: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Responsive */
@media (max-width: 1100px) {
  .ed-main { grid-template-columns: 200px 1fr 260px; }
}
@media (max-width: 860px) {
  .ed-main { grid-template-columns: 180px 1fr; }
  .ed-props { display: none; }
}
