/* ━━━ FlipForge Editor Styles ━━━ */

/* ── Editor Layout ── */
.editor { display: flex; flex-direction: column; height: 100vh; overflow: hidden; background: var(--bg-surface); }

/* App Header */
.editor-header {
  height: 52px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; background: var(--bg); border-bottom: 1px solid var(--border);
  flex-shrink: 0; z-index: 20;
}
.editor-header__left { display: flex; align-items: center; gap: 12px; }
.editor-header__logo { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 0.95rem; color: var(--fg); }
.editor-header__logo svg { width: 22px; height: 22px; }
.editor-header__sep { width: 1px; height: 24px; background: var(--border); }
.editor-header__center { display: flex; align-items: center; gap: 8px; }
.editor-header__doc-title {
  font-size: 0.9rem; font-weight: 500; padding: 4px 8px; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: text; min-width: 120px; transition: all 0.2s;
}
.editor-header__doc-title:hover { border-color: var(--border); background: var(--bg-surface); }
.editor-header__doc-title:focus { border-color: var(--brand); background: var(--bg); box-shadow: 0 0 0 3px var(--brand-glow); }
.editor-header__right { display: flex; align-items: center; gap: 8px; }
.editor-header__divider { width: 1px; height: 24px; background: var(--border); margin: 0 4px; }

/* ── Main Body ── */
.editor-body { display: flex; flex: 1; min-height: 0; }

/* ── Left Panel (Pages Sidebar) ── */
.editor-pages {
  width: var(--sidebar-w); min-width: var(--sidebar-w); background: var(--bg);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  flex-shrink: 0; overflow: hidden; height: 100%;
}
.editor-pages__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  font-size: 0.85rem; font-weight: 600; flex-shrink: 0;
}
.editor-pages__count { font-size: 0.75rem; color: var(--fg-muted); font-weight: 400; }
.editor-pages__list {
  flex: 1; min-height: 0; overflow-y: auto; padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.editor-pages__thumb {
  position: relative; border-radius: var(--radius-md); overflow: hidden;
  border: 2px solid var(--border); cursor: pointer; transition: all 0.2s;
  width: 100%; aspect-ratio: 3/4; background: var(--bg-surface); flex-shrink: 0;
}
.editor-pages__thumb:hover { border-color: var(--brand); }
.editor-pages__thumb.is-active { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-glow); }
.editor-pages__thumb canvas, .editor-pages__thumb img { width: 100%; height: 100%; object-fit: cover; }
.editor-pages__thumb-num {
  position: absolute; bottom: 4px; right: 6px; font-size: 0.65rem; font-weight: 600;
  background: rgba(0,0,0,0.6); color: #fff; padding: 1px 6px; border-radius: 4px;
}
.editor-pages__thumb-del {
  position: absolute; top: 4px; right: 4px; width: 20px; height: 20px;
  display: none; align-items: center; justify-content: center;
  background: rgba(239,68,68,0.9); color: #fff; border-radius: 4px; font-size: 0.65rem;
}
.editor-pages__thumb:hover .editor-pages__thumb-del { display: flex; }
.editor-pages__thumb.is-dragging { opacity: 0.5; transform: scale(0.95); }
.editor-pages__thumb.is-drag-over { border-color: var(--brand); border-style: dashed; }
.editor-pages__actions {
  padding: 12px; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 6px; flex-shrink: 0;
  background: var(--bg); z-index: 5;
}

/* ── Center Panel ── */
.editor-canvas { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.editor-canvas__toolbar {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 8px 16px; background: var(--bg); border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.editor-canvas__responsive { display: flex; gap: 2px; background: var(--bg-surface); border-radius: var(--radius-sm); padding: 2px; }
.editor-canvas__responsive-btn {
  padding: 5px 10px; font-size: 0.75rem; font-weight: 500; border-radius: 4px;
  color: var(--fg-muted); transition: all 0.2s; display: flex; align-items: center; gap: 4px;
}
.editor-canvas__responsive-btn.is-active { background: var(--bg); color: var(--fg); box-shadow: var(--shadow-sm); }
.editor-canvas__preview {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: var(--bg-elevated); overflow: auto; position: relative;
}
.editor-canvas__preview-frame {
  background: var(--bg); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  overflow: hidden; transition: width 0.4s var(--ease-out), height 0.4s var(--ease-out);
  width: 100%; max-width: 900px;
}
.editor-canvas__preview-frame.is-tablet { max-width: 768px; }
.editor-canvas__preview-frame.is-mobile { max-width: 375px; }
.editor-canvas__controls {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  padding: 12px 16px; background: var(--bg); border-top: 1px solid var(--border); flex-shrink: 0;
}
.editor-canvas__page-nav { display: flex; align-items: center; gap: 8px; }
.editor-canvas__page-info { font-size: 0.85rem; font-weight: 500; color: var(--fg-muted); min-width: 60px; text-align: center; }
.editor-canvas__zoom { display: flex; align-items: center; gap: 8px; }
.editor-canvas__zoom-label { font-size: 0.8rem; color: var(--fg-muted); }

/* Empty state */
.editor-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 40px; gap: 16px; color: var(--fg-muted);
}
.editor-empty__icon { width: 80px; height: 80px; color: var(--fg-subtle); opacity: 0.5; }
.editor-empty h3 { color: var(--fg); }
.editor-empty p { font-size: 0.9rem; max-width: 360px; }

/* ── Right Panel (Settings) ── */
.editor-settings {
  width: var(--panel-w); min-width: var(--panel-w); background: var(--bg);
  border-left: 1px solid var(--border); display: flex; flex-direction: column;
  flex-shrink: 0;
}
.editor-settings__close { display: none; }
.editor-settings__tabs { flex-shrink: 0; }
.editor-settings__body { flex: 1; overflow-y: auto; padding: 16px; }
.editor-settings__group { margin-bottom: 24px; }
.editor-settings__group-title {
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--fg-subtle); margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.editor-settings__row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.editor-settings__row-label { font-size: 0.85rem; color: var(--fg-muted); }

/* Toolbar buttons group */
.settings-toolbar-toggles { display: flex; flex-direction: column; gap: 8px; }
.settings-toolbar-toggle {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; background: var(--bg-surface); border-radius: var(--radius-sm);
  font-size: 0.8rem;
}

/* Custom CSS area */
.editor-settings__css-area {
  font-family: 'Fira Code', 'SF Mono', monospace; font-size: 0.8rem;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 12px; min-height: 100px;
  resize: vertical; tab-size: 2; line-height: 1.5;
}

/* ── Drag & Drop Upload Zone ── */
.upload-zone {
  border: 2px dashed var(--border-strong); border-radius: var(--radius-lg);
  padding: 40px; text-align: center; transition: all 0.3s;
  cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.upload-zone:hover, .upload-zone.is-dragover {
  border-color: var(--brand); background: var(--brand-light);
}
.upload-zone__icon { width: 48px; height: 48px; color: var(--fg-subtle); }
.upload-zone__text { font-size: 0.9rem; color: var(--fg-muted); }
.upload-zone__text strong { color: var(--brand); }
.upload-zone__hint { font-size: 0.75rem; color: var(--fg-subtle); }

/* ── Embed Modal ── */
.embed-preview { display: flex; flex-direction: column; gap: 16px; }
.embed-preview__code {
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 14px; font-family: 'SF Mono', monospace; font-size: 0.8rem;
  word-break: break-all; max-height: 120px; overflow-y: auto;
}
.embed-preview__options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── QR Code ── */
.qr-code { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 16px; }
.qr-code canvas { border-radius: var(--radius-md); }

/* ── Share Section ── */
.share-link-row { display: flex; gap: 6px; }
.share-link-row .fb-input { flex: 1; font-family: monospace; font-size: 0.8rem; }

/* ── Mobile Responsive ── */
@media (max-width: 1024px) {
  .editor-pages { width: 180px; min-width: 180px; }
  .editor-settings { width: 250px; min-width: 250px; }
}
@media (max-width: 768px) {
  .editor-body { flex-direction: column; }
  
  /* Positions the pages strip at the bottom */
  .editor-canvas {
    order: 1;
    flex: 1;
  }
  .editor-pages {
    order: 2;
    width: 100%; min-width: auto; height: auto; max-height: none;
    flex-direction: column; border-right: none; border-top: 1px solid var(--border);
    background: var(--bg);
  }
  .editor-pages__header { display: none; }
  .editor-pages__list {
    flex-direction: row; overflow-x: auto; overflow-y: hidden;
    padding: 8px; gap: 8px; height: 96px; flex: none;
  }
  .editor-pages__thumb { width: 60px; min-width: 60px; aspect-ratio: 3/4; }
  .editor-pages__actions {
    flex-direction: row; gap: 8px; padding: 8px;
    border-top: 1px solid var(--border); border-left: none;
    justify-content: center; background: var(--bg-surface);
    overflow-x: auto; white-space: nowrap; flex-shrink: 0;
  }
  .editor-pages__actions .fb-btn {
    width: auto !important; margin-top: 0 !important;
    flex: 1; justify-content: center; min-width: max-content;
  }

  /* Header adjustments for clean viewport space */
  .editor-header__logo { font-size: 0; }
  .editor-header__sep, .save-indicator { display: none; }
  .editor-header__doc-title {
    max-width: 150px; white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; display: inline-block;
  }
  .editor-header__right > :not(#btn-settings-toggle) { display: none !important; }

  /* Settings drawer with close button */
  .editor-settings {
    position: fixed; right: -100%; top: 0; bottom: 0;
    width: 85vw; max-width: 320px; z-index: 100;
    transition: right 0.3s var(--ease-out); box-shadow: var(--shadow-lg);
    border-left: 1px solid var(--border);
  }
  .editor-settings.is-open { right: 0; }
  .editor-settings__tabs { padding-right: 48px; }
  .editor-settings__close {
    display: flex; align-items: center; justify-content: center;
    position: absolute; top: 8px; right: 8px; width: 32px; height: 32px;
    border-radius: 50%; background: var(--bg-surface); border: 1px solid var(--border);
    color: var(--fg); cursor: pointer; font-size: 1.1rem; z-index: 110;
    transition: all 0.2s;
  }
  .editor-settings__close:hover { background: var(--border); color: var(--fg-strong); }
}

/* ── Keyboard shortcut modal ── */
.shortcuts-table { width: 100%; }
.shortcuts-table tr { border-bottom: 1px solid var(--border); }
.shortcuts-table td { padding: 8px 0; font-size: 0.85rem; }
.shortcuts-table td:first-child { color: var(--fg-muted); }
.shortcuts-table kbd {
  display: inline-block; padding: 2px 8px; background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: 4px; font-size: 0.75rem;
  font-family: monospace; font-weight: 600;
}

/* ── Save indicator ── */
.save-indicator { display: flex; align-items: center; gap: 6px; font-size: 0.75rem; color: var(--fg-subtle); }
.save-indicator__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); }
.save-indicator__dot.is-saving { background: var(--warning); animation: fb-pulse 1s infinite; }
.save-indicator__dot.is-unsaved { background: var(--fg-subtle); }

/* Desktop collapse state for Settings Sidebar */
.editor-settings.is-closed {
  display: none !important;
}

#btn-settings-toggle.is-active {
  color: var(--brand);
  background: var(--brand-light);
  border-color: var(--brand);
}
