/* ============================================================================
   Coreshift Live Edit — overlay styles
   Scoped under [data-cs] / .cs-* so it never collides with the host site's CSS.
   Ships with the site (served as 'self') so it is CSP-clean.
   ============================================================================ */

/* --- Edit-mode affordances on the host page ------------------------------- */
html.cs-editing [data-cs-edit],
html.cs-editing [data-cs-edit-img],
html.cs-editing [data-cs-edit-link] {
  outline: 1.5px dashed rgba(99, 102, 241, .55);
  outline-offset: 3px;
  border-radius: 3px;
  cursor: text;
  transition: outline-color .12s ease, background-color .12s ease;
}
html.cs-editing [data-cs-edit-img],
html.cs-editing [data-cs-edit-link] { cursor: pointer; }

html.cs-editing [data-cs-edit]:hover,
html.cs-editing [data-cs-edit-img]:hover,
html.cs-editing [data-cs-edit-link]:hover {
  outline-color: rgba(99, 102, 241, 1);
  background-color: rgba(99, 102, 241, .06);
}

html.cs-editing [data-cs-edit][contenteditable="true"] {
  outline: 2px solid #6366f1;
  background-color: rgba(99, 102, 241, .08);
  cursor: text;
}

/* A node with a pending (unpublished) draft edit */
html.cs-editing [data-cs-dirty] {
  outline-color: #f59e0b !important;
}

/* Section wrapper controls */
html.cs-editing [data-cs-section] {
  position: relative;
}
html.cs-editing [data-cs-section]::before {
  content: "";
  position: absolute; inset: 0;
  outline: 1.5px dashed rgba(16, 185, 129, .45);
  outline-offset: -2px;
  pointer-events: none;
  border-radius: 4px;
  opacity: 0; transition: opacity .12s ease;
}
html.cs-editing [data-cs-section]:hover::before { opacity: 1; }

.cs-section-tools {
  position: absolute;
  top: 8px; right: 8px;
  z-index: 2147483000;
  display: none;
  gap: 4px;
  background: #0b0b0f;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
html.cs-editing [data-cs-section]:hover > .cs-section-tools { display: flex; }
.cs-section-tools button {
  all: unset;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  color: #e5e7eb; font-size: 13px; line-height: 1;
  border-radius: 6px; cursor: pointer;
}
.cs-section-tools button:hover { background: rgba(255,255,255,.12); }
.cs-section-tools button.cs-danger:hover { background: #dc2626; color: #fff; }

/* "Add section here" insert bar between sections */
.cs-insert {
  position: relative;
  height: 0;
  z-index: 2147482000;
}
html.cs-editing .cs-insert { height: 22px; }
.cs-insert button {
  all: unset;
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  display: none;
  align-items: center; gap: 6px;
  background: #6366f1; color: #fff;
  font: 600 12px/1 ui-sans-serif, system-ui, sans-serif;
  padding: 6px 12px; border-radius: 999px;
  cursor: pointer; white-space: nowrap;
  box-shadow: 0 4px 14px rgba(99,102,241,.5);
}
html.cs-editing .cs-insert:hover button,
html.cs-editing .cs-insert button:focus-visible { display: inline-flex; }

/* ============================================================================
   Widget chrome (toolbar, popovers, modals) — all namespaced .cs-*
   ============================================================================ */
.cs-ui { font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; }

.cs-toolbar {
  position: fixed;
  bottom: 20px; left: 50%;
  transform: translateX(-50%);
  z-index: 2147483600;
  display: flex; align-items: center; gap: 10px;
  background: rgba(11,11,15,.92);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
  color: #e5e7eb;
}
.cs-toolbar .cs-brand {
  display: flex; align-items: center; gap: 7px;
  font-weight: 700; font-size: 13px; letter-spacing: .01em;
  padding-right: 10px; margin-right: 2px;
  border-right: 1px solid rgba(255,255,255,.12);
}
.cs-toolbar .cs-dot { width: 8px; height: 8px; border-radius: 50%; background: #6366f1; box-shadow: 0 0 10px #6366f1; }
.cs-toolbar button {
  all: unset;
  font: 600 13px/1 inherit;
  padding: 8px 12px; border-radius: 9px;
  cursor: pointer; color: #e5e7eb;
  display: inline-flex; align-items: center; gap: 6px;
}
.cs-toolbar button:hover { background: rgba(255,255,255,.1); }
.cs-toolbar button.cs-primary { background: #6366f1; color: #fff; }
.cs-toolbar button.cs-primary:hover { background: #4f46e5; }
.cs-toolbar button.cs-primary:disabled { opacity: .4; cursor: not-allowed; background: #6366f1; }
.cs-toolbar button.cs-ghost:hover { background: rgba(255,255,255,.1); }
.cs-toolbar .cs-count {
  font-size: 12px; color: #f59e0b; font-weight: 700;
  min-width: 74px; text-align: center;
}
.cs-toolbar .cs-count.cs-clean { color: #6b7280; }

/* Floating rich-text format bar */
.cs-format {
  position: absolute;
  z-index: 2147483600;
  display: none;
  gap: 2px;
  background: #0b0b0f;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 9px; padding: 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
}
.cs-format.cs-show { display: flex; }
.cs-format button {
  all: unset; color: #e5e7eb; cursor: pointer;
  padding: 5px 9px; border-radius: 6px; font: 600 13px/1 ui-sans-serif, system-ui, sans-serif;
}
.cs-format button:hover { background: rgba(255,255,255,.12); }

/* Popover (image / link editors) */
.cs-pop {
  position: absolute;
  z-index: 2147483600;
  width: 320px; max-width: calc(100vw - 24px);
  background: #0b0b0f; color: #e5e7eb;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 12px; padding: 14px;
  box-shadow: 0 16px 48px rgba(0,0,0,.55);
}
.cs-pop h4 { margin: 0 0 10px; font-size: 13px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; color: #9ca3af; }
.cs-pop label { display: block; font-size: 12px; color: #9ca3af; margin: 8px 0 4px; }
.cs-pop input[type=text], .cs-pop input[type=url] {
  width: 100%; box-sizing: border-box;
  background: #16161d; border: 1px solid rgba(255,255,255,.14);
  color: #f3f4f6; border-radius: 8px; padding: 8px 10px; font-size: 13px;
}
.cs-pop input:focus { outline: 2px solid #6366f1; border-color: #6366f1; }
.cs-pop .cs-pop-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.cs-pop button {
  all: unset; font: 600 13px/1 ui-sans-serif, system-ui, sans-serif;
  padding: 8px 14px; border-radius: 8px; cursor: pointer; color: #e5e7eb;
}
.cs-pop button:hover { background: rgba(255,255,255,.1); }
.cs-pop button.cs-primary { background: #6366f1; color: #fff; }
.cs-pop button.cs-primary:hover { background: #4f46e5; }
.cs-pop .cs-uploadrow { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.cs-pop .cs-thumb { width: 100%; height: 120px; object-fit: cover; border-radius: 8px; margin-top: 8px; background: #16161d; }

/* Section picker modal */
.cs-modal-backdrop {
  position: fixed; inset: 0; z-index: 2147483500;
  background: rgba(0,0,0,.6); backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 24px;
}
.cs-modal {
  width: 720px; max-width: 100%; max-height: 82vh; overflow: auto;
  background: #0b0b0f; color: #e5e7eb;
  border: 1px solid rgba(255,255,255,.14); border-radius: 16px; padding: 20px;
  box-shadow: 0 24px 70px rgba(0,0,0,.6);
}
.cs-modal h3 { margin: 0 0 4px; font-size: 18px; }
.cs-modal p.cs-sub { margin: 0 0 16px; color: #9ca3af; font-size: 13px; }
.cs-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cs-card {
  border: 1px solid rgba(255,255,255,.12); border-radius: 12px; padding: 14px;
  cursor: pointer; transition: border-color .12s ease, background-color .12s ease;
}
.cs-card:hover { border-color: #6366f1; background: rgba(99,102,241,.08); }
.cs-card .cs-card-title { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.cs-card .cs-card-desc { font-size: 12px; color: #9ca3af; }
.cs-card .cs-card-tag { display: inline-block; font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: #6366f1; margin-top: 8px; font-weight: 700; }
.cs-modal .cs-modal-close { float: right; cursor: pointer; color: #9ca3af; font-size: 20px; line-height: 1; }

/* Toast */
.cs-toast {
  position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%);
  z-index: 2147483600;
  background: #10b981; color: #04231a; font-weight: 700; font-size: 13px;
  padding: 10px 16px; border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
  opacity: 0; transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
}
.cs-toast.cs-show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
