/* ============================================================
   EDITOR CSS - Visual editor UI styles
   Only loaded when editor is present
   ============================================================ */

/* ---- EDITOR BAR ---- */
.editor-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(255,255,255,0.08);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 13px;
  color: #e2e8f0;
  gap: 12px;
}

.editor-bar__left,
.editor-bar__center,
.editor-bar__right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.editor-bar__center {
  flex: 1;
  justify-content: center;
}

.editor-bar__group {
  display: flex;
  align-items: center;
  gap: 2px;
  background: rgba(255,255,255,0.06);
  border-radius: 6px;
  padding: 2px;
}

.editor-bar__sep {
  width: 1px;
  height: 20px;
  background: rgba(255,255,255,0.1);
  margin: 0 4px;
}

.editor-bar__toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  color: #94a3b8;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
}
.editor-bar__toggle:hover {
  color: #e2e8f0;
  background: rgba(255,255,255,0.06);
}
.editor-bar__toggle--active {
  color: #22d3ee;
  background: rgba(34,211,238,0.1);
  border-color: rgba(34,211,238,0.2);
}

.editor-bar__btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 4px;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.editor-bar__btn:hover {
  color: #e2e8f0;
  background: rgba(255,255,255,0.08);
}
.editor-bar__btn:disabled {
  opacity: 0.3;
  cursor: default;
}
.editor-bar__btn--active {
  color: #22d3ee;
  background: rgba(34,211,238,0.12);
}

.editor-bar__btn--save {
  color: #e2e8f0;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  padding: 5px 14px;
  border-radius: 6px;
}
.editor-bar__btn--save:hover {
  background: rgba(255,255,255,0.12);
}

.editor-bar__btn--publish {
  color: #0f172a;
  background: #22d3ee;
  padding: 5px 14px;
  border-radius: 6px;
  font-weight: 600;
}
.editor-bar__btn--publish:hover {
  background: #06b6d4;
}

/* ---- EDITOR BAR PRESENT: give footer clearance ---- */
body:has(.editor-bar) .footer { padding-bottom: calc(var(--space-8, 32px) + 52px); }

/* ---- EDITOR ACTIVE STATE ---- */
body.editor-active {
  padding-bottom: 50px;
}

/* Hover highlight */
body.editor-active [data-block-id]:not(.editor-selected) {
  transition: outline 0.1s;
}
body.editor-active [data-block-id].editor-hover {
  outline: 2px dashed rgba(34, 211, 238, 0.3);
  outline-offset: 2px;
  cursor: pointer;
}

/* Selected */
body.editor-active .editor-selected {
  outline: 2px solid #22d3ee;
  outline-offset: 2px;
}

/* Inline editing */
.editor-inline-editing {
  outline: 2px solid #22d3ee !important;
  outline-offset: 0 !important;
  background: rgba(34, 211, 238, 0.05);
  min-height: 1.5em;
  cursor: text;
}

/* ---- FLOATING TOOLBAR ---- */
.floating-toolbar {
  display: none;
  position: absolute;
  z-index: 8500;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  padding: 3px;
  gap: 2px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.ft-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.15s;
}
.ft-btn:hover {
  color: #e2e8f0;
  background: rgba(255,255,255,0.1);
}
.ft-btn--danger:hover {
  color: #f87171;
  background: rgba(248,113,113,0.1);
}

/* ---- INSPECTOR PANEL ---- */
.inspector {
  position: fixed;
  top: 0;
  right: -320px;
  width: 320px;
  height: 100vh;
  z-index: 8900;
  background: rgba(15, 23, 42, 0.97);
  backdrop-filter: blur(16px);
  border-left: 1px solid rgba(255,255,255,0.08);
  color: #e2e8f0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 13px;
  transition: right 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.inspector.open {
  right: 0;
}

.inspector__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  position: sticky;
  top: 0;
  background: rgba(15, 23, 42, 0.97);
  z-index: 1;
}

.inspector__title {
  font-weight: 600;
  font-size: 13px;
  color: #e2e8f0;
}

.inspector__close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  color: #94a3b8;
  cursor: pointer;
  font-size: 18px;
  transition: all 0.15s;
}
.inspector__close:hover {
  color: #e2e8f0;
  background: rgba(255,255,255,0.08);
}

.inspector__body {
  padding: 12px 16px 60px;
}

.inspector__section {
  margin-bottom: 8px;
}

.inspector__section-title {
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  margin-bottom: 8px;
  margin-top: 4px;
}

.inspector__divider {
  height: 1px;
  background: rgba(255,255,255,0.06);
  margin: 12px 0;
}

.inspector__field {
  margin-bottom: 8px;
}

.inspector__field--toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.inspector__label {
  display: block;
  font-size: 11px;
  color: #94a3b8;
  margin-bottom: 3px;
  font-weight: 500;
}

.inspector__value {
  font-size: 12px;
  color: #64748b;
  font-family: 'JetBrains Mono', monospace;
}

.inspector__input {
  width: 100%;
  padding: 5px 8px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 4px;
  color: #e2e8f0;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  transition: border-color 0.15s;
}
.inspector__input:focus {
  outline: none;
  border-color: #22d3ee;
}

.inspector__textarea {
  min-height: 80px;
  resize: vertical;
  line-height: 1.5;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.inspector__checkbox {
  width: 16px;
  height: 16px;
  accent-color: #22d3ee;
  cursor: pointer;
}

.inspector__empty {
  color: #64748b;
  text-align: center;
  padding: 40px 0;
}

/* ---- BLOG STYLE PANEL ---- */
.blog-style-panel {
  position: fixed;
  top: 0;
  right: -360px;
  width: 360px;
  height: 100vh;
  z-index: 8900;
  background: rgba(15, 23, 42, 0.97);
  backdrop-filter: blur(16px);
  border-left: 1px solid rgba(255,255,255,0.08);
  color: #e2e8f0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 13px;
  transition: right 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.blog-style-panel.open {
  right: 0;
}

/* ---- BLOCK PICKER ---- */
.block-picker {
  position: fixed;
  inset: 0;
  z-index: 9500;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.block-picker.open {
  opacity: 1;
  pointer-events: auto;
}

.block-picker__inner {
  background: #1e293b;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 24px;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.block-picker__title {
  font-size: 16px;
  font-weight: 600;
  color: #e2e8f0;
  margin-bottom: 16px;
}

.block-picker__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.block-picker__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 8px;
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  color: #94a3b8;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.block-picker__item:hover {
  background: rgba(34,211,238,0.08);
  border-color: rgba(34,211,238,0.2);
  color: #22d3ee;
}

.block-picker__close {
  width: 100%;
  padding: 8px;
  border-radius: 6px;
  background: rgba(255,255,255,0.05);
  color: #94a3b8;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.block-picker__close:hover {
  color: #e2e8f0;
  background: rgba(255,255,255,0.1);
}

/* ---- MOBILE PREVIEW ---- */
body.editor-mobile-preview .page {
  max-width: 375px;
  margin-inline: auto;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  overflow: hidden;
  margin-top: 20px;
  margin-bottom: 70px;
  box-shadow: 0 0 40px rgba(0,0,0,0.2);
}

body.editor-mobile-preview .footer {
  max-width: 375px;
  margin-inline: auto;
}

body.editor-mobile-preview .nav {
  max-width: 375px;
  margin-inline: auto;
}

/* ---- VISIBILITY HELPERS ---- */
.hide-desktop { display: none !important; }
@media (max-width: 767px) {
  .hide-mobile { display: none !important; }
  .hide-desktop { display: block !important; }
}

/* ---- TOAST ---- */
.editor-toast {
  position: fixed;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(15, 23, 42, 0.95);
  color: #22d3ee;
  padding: 8px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  border: 1px solid rgba(34,211,238,0.2);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 9999;
}
.editor-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---- Scrollbar for inspector ---- */
.inspector::-webkit-scrollbar,
.blog-style-panel::-webkit-scrollbar {
  width: 4px;
}
.inspector::-webkit-scrollbar-thumb,
.blog-style-panel::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
}

/* ---- RESPONSIVE: hide editor on small screens ---- */
@media (max-width: 640px) {
  .editor-bar__center {
    display: none !important;
  }
  .inspector, .blog-style-panel {
    width: 100%;
    right: -100%;
  }
}
