/* RuRu Lab — PDF Editor (PDFAid-style unified workspace) */

.pdf-editor-body {
  margin: 0;
  overflow: hidden;
  height: 100dvh;
  background: #eef1f6;
}

.pdf-editor-app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

/* ---------- Top bar ---------- */
.pe-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 52px;
  padding: 0 12px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  z-index: 20;
}
.pe-top-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 200px;
  flex-shrink: 0;
}
.pe-brand { font-size: 15px; }
.pe-doc-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pe-top-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}
.pe-btn-sm { padding: 7px 14px; font-size: 13px; }

.pe-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  justify-content: center;
  overflow-x: auto;
  padding: 4px 0;
  scrollbar-width: none;
}
.pe-toolbar::-webkit-scrollbar { display: none; }
.pe-tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 52px;
  padding: 4px 8px;
  border: none;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  transition: background .12s, color .12s;
}
.pe-tool svg { width: 20px; height: 20px; }
.pe-tool:hover { background: var(--surface-2); color: var(--text); }
.pe-tool.active {
  background: #fff0ef;
  color: var(--brand);
  box-shadow: inset 0 0 0 1px rgba(229, 50, 45, .25);
}
.pe-tool-sep {
  width: 1px;
  height: 28px;
  background: var(--line);
  margin: 0 4px;
  flex-shrink: 0;
}

/* ---------- Workspace ---------- */
.pe-workspace {
  display: grid;
  grid-template-columns: 168px 1fr 260px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.pe-sidebar {
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.pe-props { border-right: none; border-left: 1px solid var(--line); }

.pe-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.pe-thumb-actions { display: flex; gap: 4px; }

.pe-thumb-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.pe-thumb {
  position: relative;
  border: 2px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  background: var(--surface-2);
  padding: 4px;
  transition: border-color .12s;
}
.pe-thumb:hover { border-color: var(--line-strong); }
.pe-thumb.active { border-color: var(--brand); }
.pe-thumb.selected { border-color: #7b3ff2; background: #f5f0ff; }
.pe-thumb canvas, .pe-thumb img {
  width: 100%;
  height: auto;
  border-radius: 4px;
  display: block;
}
.pe-thumb-label {
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  margin-top: 4px;
}
.pe-thumb-drag { cursor: grab; }

.pe-page-select {
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}
.pe-page-select label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 4px;
}
.pe-page-select input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
}

/* ---------- Canvas area ---------- */
.pe-canvas-area {
  position: relative;
  background: #c8cdd6;
  min-height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pe-welcome {
  text-align: center;
  max-width: 520px;
  padding: 24px;
}
.pe-welcome-img {
  width: 100%;
  max-width: 400px;
  margin: 0 auto 16px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.pe-welcome h2 { margin: 0 0 8px; font-size: 22px; }
.pe-welcome p { color: var(--muted); font-size: 14px; margin: 0 0 16px; }
.pe-hint { font-size: 12px !important; margin-top: 12px !important; }

.pe-viewer {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.pe-canvas-wrap {
  position: relative;
  box-shadow: 0 8px 32px rgba(0,0,0,.22);
  background: #fff;
  max-width: calc(100% - 40px);
  max-height: calc(100% - 80px);
}
.pe-canvas-wrap canvas { display: block; max-width: 100%; height: auto; }
.pe-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.pe-overlay.interactive { pointer-events: auto; cursor: crosshair; }
.pe-anno {
  position: absolute;
  border: 1px dashed rgba(229, 50, 45, .6);
  pointer-events: auto;
  cursor: move;
}
.pe-anno.redact { background: rgba(0,0,0,.75); border: none; }
.pe-anno.watermark-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  border: none;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
}

.pe-float-bar {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(20, 26, 36, .88);
  color: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}
.pe-sep { width: 1px; height: 18px; background: rgba(255,255,255,.25); }
.pe-icon-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 16px;
  display: grid;
  place-items: center;
}
.pe-icon-btn:hover { background: rgba(255,255,255,.12); }

/* ---------- Properties panel ---------- */
.pe-props-head {
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 800;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.pe-props-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}
.pe-props-empty {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
}
.pe-prop-fld { margin-bottom: 14px; }
.pe-prop-fld label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
}
.pe-prop-fld input[type="text"],
.pe-prop-fld input[type="number"],
.pe-prop-fld select,
.pe-prop-fld textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
}
.pe-prop-fld input[type="range"] { width: 100%; }
.pe-prop-fld input[type="color"] {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2px;
  cursor: pointer;
}
.pe-prop-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}
.pe-prop-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.pe-prop-actions .btn { width: 100%; font-size: 13px; }

/* AI panel inside props */
.pe-ai-chat {
  max-height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 13px;
}
.pe-ai-msg { padding: 8px 10px; border-radius: 8px; line-height: 1.45; }
.pe-ai-msg.user { background: var(--brand); color: #fff; align-self: flex-end; }
.pe-ai-msg.assistant { background: var(--surface-2); border: 1px solid var(--line); }

.pe-status {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 26, 36, .9);
  color: #fff;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s;
}
.pe-status.show { opacity: 1; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .pe-workspace { grid-template-columns: 120px 1fr 220px; }
  .pe-tool span { display: none; }
  .pe-tool { min-width: 40px; }
}
@media (max-width: 640px) {
  .pe-workspace { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
  .pe-thumbs { max-height: 120px; border-right: none; border-bottom: 1px solid var(--line); }
  .pe-thumb-list { flex-direction: row; overflow-x: auto; overflow-y: hidden; }
  .pe-thumb { min-width: 72px; }
  .pe-props { max-height: 200px; border-left: none; border-top: 1px solid var(--line); }
  .pe-doc-name { display: none; }
}
