/* ===== Web Page Editor — app chrome =====
   This styles the editor tool itself (menu, panes, splitter), not the
   children's pages. Their pages render inside the preview iframe. */

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  font-family: system-ui, sans-serif;
  color: #1d2733;
  background: #f3f5f7;
}

/* ----- Top menu bar ----- */
.menubar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 8px 16px;
  background: #1d3b53;
  color: white;
}

.app-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

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

.actions button {
  font: inherit;
  font-size: 0.95rem;
  padding: 7px 14px;
  border: 0;
  border-radius: 8px;
  background: #2f6f97;
  color: white;
  cursor: pointer;
}

.actions button:hover { background: #3a83b0; }

/* A clear, visible focus ring for keyboard users. */
:focus-visible {
  outline: 3px solid #ffd24a;
  outline-offset: 2px;
}

/* ----- Two-pane workspace ----- */
.workspace {
  flex: 1;
  display: flex;
  min-height: 0;            /* lets the panes scroll instead of growing the page */
}

.pane {
  min-width: 120px;        /* neither pane can be dragged shut */
  height: 100%;
  overflow: hidden;
}

.editor-pane { flex: 0 0 50%; }   /* starting split; JS updates this */
.preview-pane {
  flex: 1 1 0;
  background: white;
  border-left: 1px solid #d4dae0;
}

/* CodeMirror needs an explicit height to fill the pane. */
.editor-pane .CodeMirror {
  height: 100%;
  font-size: 14px;
}

#preview {
  width: 100%;
  height: 100%;
  border: 0;
  background: white;
}

/* ----- Splitter ----- */
.splitter {
  flex: 0 0 10px;
  background: #d4dae0;
  cursor: col-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;       /* so dragging works on touchscreens */
}

.splitter:hover { background: #b9c3cc; }

.splitter-grip {
  width: 2px;
  height: 28px;
  background: #7d8a96;
  border-radius: 2px;
}

/* While dragging we add this to the body to stop the iframe stealing the mouse. */
body.dragging { cursor: col-resize; user-select: none; }
body.dragging #preview { pointer-events: none; }

/* ----- Template picker dialog ----- */
.dialog {
  border: 0;
  border-radius: 12px;
  padding: 0;
  max-width: 440px;
  width: calc(100% - 32px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}

.dialog::backdrop { background: rgba(0, 0, 0, 0.4); }

.dialog-body { padding: 20px 22px; }
.dialog-body h2 { margin: 0 0 4px; }
.dialog-note { margin: 0 0 16px; color: #51606e; font-size: 0.9rem; }

.template-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: grid;
  gap: 8px;
}

.template-list button {
  font: inherit;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border: 1px solid #c8d0d8;
  border-radius: 8px;
  background: #f7f9fb;
  cursor: pointer;
}

.template-list button:hover {
  background: #eaf1f6;
  border-color: #2f6f97;
}

.dialog-buttons {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: flex-end;
}

.dialog-buttons {
  gap: 8px;
}

.dialog-buttons button {
  font: inherit;
  padding: 8px 16px;
  border: 1px solid #c8d0d8;
  border-radius: 8px;
  background: white;
  cursor: pointer;
}

/* The Save button is the main action — make it stand out. */
.dialog-buttons button[value="save"] {
  background: #2f6f97;
  border-color: #2f6f97;
  color: white;
}

/* ----- Add picture dialog ----- */
.image-section { margin: 0 0 18px; }
.image-section h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.source-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.source-list a {
  display: inline-block;
  padding: 7px 12px;
  border: 1px solid #c8d0d8;
  border-radius: 999px;
  background: #f7f9fb;
  color: #1d3b53;
  text-decoration: none;
  font-size: 0.95rem;
}

.source-list a:hover {
  background: #eaf1f6;
  border-color: #2f6f97;
}

.url-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.url-row input {
  flex: 1;
  font: inherit;
  padding: 8px 10px;
  border: 1px solid #c8d0d8;
  border-radius: 8px;
  min-width: 0;
}

.url-row button {
  font: inherit;
  padding: 8px 14px;
  border: 0;
  border-radius: 8px;
  background: #2f6f97;
  color: white;
  cursor: pointer;
  white-space: nowrap;
}

.image-section > #image-upload {
  font: inherit;
  padding: 8px 14px;
  border: 1px solid #c8d0d8;
  border-radius: 8px;
  background: white;
  cursor: pointer;
}

.image-error {
  margin: 8px 0 0;
  color: #a02020;
  font-size: 0.9rem;
}

.save-label {
  display: block;
  margin: 0 0 6px;
  font-size: 0.95rem;
}

.save-ext { color: #51606e; }
