/* iLovePDF-style Edit PDF workspace */

body.pm-fullbleed {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

body.pm-fullbleed .pm-header {
  flex: 0 0 auto;
}

.pm-main-fullbleed {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

body.pm-editing .pm-footer {
  display: none;
}

body.pm-editing .pm-main-fullbleed,
body.pm-editing main {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

body.pm-editing .pm-edit-workspace {
  flex: 1 1 auto;
}

.pm-edit-workspace {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 64px);
  min-height: 560px;
  background: #cfe2f3;
  margin: 0;
}

.pm-edit-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  background: transparent;
  flex: 0 0 auto;
  z-index: 5;
  position: relative;
}

.pm-edit-toolbar-inner {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.35rem 0.75rem 0.35rem 0.45rem;
  background: #e9ecef;
  border: 1px solid #ced4da;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.pm-edit-toolbar .btn-outline-pm {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
}

.pm-edit-mode {
  display: inline-flex;
  background: #f1f3f5;
  border-radius: 999px;
  padding: 0.2rem;
  gap: 0.15rem;
}

.pm-edit-mode-btn {
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--pm-muted);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.pm-edit-mode-btn.is-active {
  background: #2b2f36;
  color: #fff;
}

.pm-crown {
  color: #f0b429;
  font-size: 0.75rem;
}

.pm-edit-tools {
  display: inline-flex;
  gap: 0.25rem;
}

.pm-edit-tool {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #343a40;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.pm-edit-tool:hover {
  background: #f1f3f5;
}

.pm-edit-tool.is-active {
  background: var(--pm-red-soft);
  color: var(--pm-red);
}

.pm-tool-ai {
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: -0.04em;
}

.pm-edit-toolbar-spacer {
  flex: 1;
}

.pm-edit-body {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 120px 1fr 300px;
  min-height: 0;
}

.pm-edit-thumbs {
  background: #f8f9fa;
  border-right: 1px solid var(--pm-line);
  overflow-y: auto;
  padding: 0.75rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.pm-edit-thumb {
  border: 2px solid transparent;
  border-radius: 6px;
  background: #fff;
  padding: 0.25rem;
  cursor: pointer;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.pm-edit-thumb.is-active {
  border-color: #4dabf7;
}

.pm-edit-thumb canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 3px;
}

.pm-edit-thumb span {
  display: block;
  font-size: 0.75rem;
  color: var(--pm-muted);
  margin-top: 0.25rem;
}

.pm-edit-canvas-wrap {
  position: relative;
  min-width: 0;
  background: #cfe2f3;
  display: flex;
  flex-direction: column;
}

.pm-edit-canvas-scroll {
  flex: 1;
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 1.5rem;
}

.pm-edit-page-stage {
  position: relative;
  background: #fff;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
  line-height: 0;
}

.pm-edit-page-stage canvas {
  display: block;
  max-width: none;
}

.pm-edit-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.pm-edit-overlay.is-interactive {
  pointer-events: auto;
  cursor: crosshair;
}

.pm-edit-ann {
  position: absolute;
  border: 1px dashed rgba(227, 28, 37, 0.55);
  background: rgba(255, 255, 255, 0.15);
  color: inherit;
  font-family: var(--pm-font);
  padding: 2px 4px;
  white-space: nowrap;
  pointer-events: none;
  transform: translateY(-100%);
}

.pm-edit-ann-box {
  pointer-events: auto;
  cursor: move;
  user-select: none;
  z-index: 3;
  box-sizing: border-box;
}

.pm-edit-ann-text,
.pm-edit-ann-shape {
  pointer-events: auto;
  cursor: move;
  user-select: none;
  z-index: 3;
}

.pm-edit-ann-box.is-dragging,
.pm-edit-ann-box.is-resizing,
.pm-edit-ann-text.is-dragging,
.pm-edit-ann-shape.is-dragging,
.pm-edit-ann-img.is-dragging {
  border-color: var(--pm-red, #e31c25);
  box-shadow: 0 6px 18px rgba(227, 28, 37, 0.35);
  opacity: 0.92;
  z-index: 5;
}

.pm-edit-ann-img {
  border: 1px dashed rgba(33, 37, 41, 0.35);
  background: transparent;
  padding: 0;
  white-space: normal;
  transform: none;
  overflow: visible;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
  pointer-events: auto;
  cursor: move;
  user-select: none;
  -webkit-user-drag: none;
}

.pm-edit-ann-img-inner {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
  -webkit-user-drag: none;
}

.pm-edit-resize {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #fff;
  border: 2px solid var(--pm-red, #e31c25);
  border-radius: 2px;
  z-index: 6;
  pointer-events: auto;
  box-sizing: border-box;
}

.pm-edit-resize-nw { left: -5px; top: -5px; cursor: nwse-resize; }
.pm-edit-resize-ne { right: -5px; top: -5px; cursor: nesw-resize; }
.pm-edit-resize-sw { left: -5px; bottom: -5px; cursor: nesw-resize; }
.pm-edit-resize-se { right: -5px; bottom: -5px; cursor: nwse-resize; }

.pm-edit-ann-text .pm-edit-resize {
  /* text uses translateY(-100%); keep handles on the visible box */
}

.pm-edit-canvas-wrap.is-drop-target,
.pm-edit-page-stage.is-drop-target {
  outline: 2px dashed var(--pm-red, #e31c25);
  outline-offset: -4px;
  background: #b6d4f0 !important;
}

.pm-edit-page-stage.is-drop-target::after {
  content: "Drop image to place";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: rgba(33, 37, 41, 0.85);
  color: #fff;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 6;
  pointer-events: none;
  line-height: 1.2;
}

.pm-edit-stroke {
  pointer-events: none;
}

.pm-edit-floatbar {
  position: absolute;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: rgba(33, 37, 41, 0.92);
  color: #fff;
  border-radius: 12px;
  padding: 0.4rem 0.65rem;
  z-index: 4;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.pm-edit-floatbar button {
  border: 0;
  background: transparent;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pm-edit-floatbar button:hover {
  background: rgba(255, 255, 255, 0.12);
}

.pm-edit-page-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.85rem;
  margin: 0 0.35rem;
}

.pm-edit-page-indicator input {
  width: 2.5rem;
  border: 0;
  border-radius: 6px;
  text-align: center;
  padding: 0.15rem;
  font-size: 0.85rem;
}

#editZoomLabel {
  min-width: 3rem;
  text-align: center;
  font-size: 0.85rem;
}

.pm-edit-side {
  background: #fff;
  border-left: 1px solid var(--pm-line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.pm-edit-side-top {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1.5rem 1.25rem 1rem;
}

.pm-edit-side-top h2 {
  font-family: var(--pm-display);
  font-weight: 700;
  font-size: 1.5rem;
  text-align: center;
  margin-bottom: 1rem;
}

.pm-edit-info {
  display: flex;
  gap: 0.65rem;
  background: #e7f5ff;
  color: #1864ab;
  border-radius: 12px;
  padding: 0.85rem 0.9rem;
  margin-bottom: 1.25rem;
}

.pm-edit-info i {
  font-size: 1.15rem;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.pm-edit-info p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.45;
}

.pm-edit-text-opts .form-label {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.pm-edit-ann-list {
  margin-top: 1rem;
}

.pm-edit-ann-list .item {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.8rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--pm-line);
  border-radius: 8px;
  margin-bottom: 0.4rem;
}

.pm-edit-side-bottom {
  flex: 0 0 auto;
  padding: 1rem 1.25rem 1.25rem;
  border-top: 1px solid var(--pm-line);
  background: #fff;
}

.pm-edit-save {
  width: 100%;
  border: 0;
  border-radius: 999px;
  background: #e85d6a;
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 0.85rem 1.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  box-shadow: 0 8px 20px rgba(232, 93, 106, 0.35);
}

.pm-edit-save:hover:not(:disabled) {
  background: var(--pm-red);
  color: #fff;
}

.pm-edit-save:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.pm-edit-save-arrow {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 991.98px) {
  .pm-edit-body {
    grid-template-columns: 88px 1fr;
  }

  .pm-edit-side {
    display: none;
  }

  .pm-edit-workspace {
    height: auto;
    min-height: calc(100vh - 64px);
  }
}
