/* ==========================================================================
   Workspace Layout (3-Column Layout: Thumbnails, Viewport, Controls)
   ========================================================================== */
.workspace-layout {
  display: flex;
  height: calc(100vh - 68px);
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   Left Sidebar: Thumbnails
   -------------------------------------------------------------------------- */
.sidebar-thumbnails {
  width: 220px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
}

.doc-meta-badge {
  display: flex;
  align-items: center;
  gap: 10px;
}

.doc-meta-badge i {
  font-size: 1.5rem;
  color: var(--accent-danger);
}

.doc-meta-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.doc-meta-info strong {
  font-size: 0.85rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doc-meta-info span {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.thumbnails-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px 8px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.thumbnails-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.thumbnail-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  background: var(--bg-base);
  transition: var(--transition-fast);
}

.thumbnail-item:hover {
  background: var(--bg-surface-elevated);
  border-color: var(--border-color);
}

.thumbnail-item.active {
  border-color: var(--accent-primary);
  background: var(--bg-surface-elevated);
  box-shadow: 0 0 12px var(--accent-primary-glow);
}

.thumbnail-canvas-wrapper {
  position: relative;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  background: #ffffff;
}

.thumbnail-canvas-wrapper canvas {
  display: block;
  width: 130px !important;
  height: auto !important;
}

.thumbnail-number {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.thumbnail-item.active .thumbnail-number {
  color: var(--accent-primary);
}

.thumb-rule-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-success);
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.8);
}

/* --------------------------------------------------------------------------
   Center: PDF Viewport
   -------------------------------------------------------------------------- */
.workspace-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-base);
  position: relative;
  overflow: hidden;
}

/* Floating Toolbar */
.viewer-toolbar {
  height: 52px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 18px;
  gap: 12px;
  z-index: 20;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  background: var(--border-color);
  margin: 0 4px;
}

.tool-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition-fast);
}

.tool-btn:hover {
  background: var(--bg-surface-elevated);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.page-counter {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.page-counter input {
  width: 38px;
  height: 28px;
  border-radius: 4px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  text-align: center;
  font-size: 0.82rem;
  font-weight: 600;
}

.zoom-level {
  font-size: 0.82rem;
  font-weight: 600;
  min-width: 48px;
  text-align: center;
  color: var(--text-primary);
}

.page-rule-indicator {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent-primary);
  background: var(--accent-primary-glow);
  padding: 4px 12px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* PDF Viewport Scroll Area */
.pdf-viewport-container {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 36px 20px;
  position: relative;
}

.pdf-page-wrapper {
  position: relative;
  background: #ffffff;
  box-shadow: var(--shadow-lg);
  border-radius: 2px;
  display: inline-block;
  user-select: none;
}

#pdf-render-canvas {
  display: block;
}

/* --------------------------------------------------------------------------
   Placement Overlay Box (Draggable & Resizable)
   -------------------------------------------------------------------------- */
.placement-overlay {
  position: absolute;
  border: 2px dashed var(--accent-primary);
  background: rgba(59, 130, 246, 0.08);
  border-radius: 4px;
  cursor: grab;
  z-index: 10;
  touch-action: none;
  box-sizing: border-box;
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.3);
  transition: border-color 0.15s ease;
}

.placement-overlay.dragging {
  cursor: grabbing;
  border-color: var(--accent-success);
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
}

.overlay-content {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  pointer-events: none;
}

.overlay-content img {
  width: 100%;
  height: 100%;
  object-fit: fill;
  display: block;
}

.overlay-badge {
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent-primary);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 8px;
  white-space: nowrap;
  pointer-events: none;
}

/* 8-Point Resize Handles */
.overlay-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #ffffff;
  border: 2px solid var(--accent-primary);
  border-radius: 50%;
  z-index: 12;
}

.handle-nw { top: -5px; left: -5px; cursor: nwse-resize; }
.handle-ne { top: -5px; right: -5px; cursor: nesw-resize; }
.handle-se { bottom: -5px; right: -5px; cursor: nwse-resize; }
.handle-sw { bottom: -5px; left: -5px; cursor: nesw-resize; }
.handle-n  { top: -5px; left: calc(50% - 5px); cursor: ns-resize; }
.handle-s  { bottom: -5px; left: calc(50% - 5px); cursor: ns-resize; }
.handle-w  { top: calc(50% - 5px); left: -5px; cursor: ew-resize; }
.handle-e  { top: calc(50% - 5px); right: -5px; cursor: ew-resize; }

.placement-overlay[data-type="signature"] {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.08);
}
.placement-overlay[data-type="signature"] .overlay-badge {
  background: #2563eb;
}
.placement-overlay[data-type="signature"] .overlay-handle {
  border-color: #3b82f6;
}

.placement-overlay[data-type="logo"] {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.08);
}
.placement-overlay[data-type="logo"] .overlay-badge {
  background: #d97706;
}
.placement-overlay[data-type="logo"] .overlay-handle {
  border-color: #f59e0b;
}

.placement-overlay[data-type="initials"] {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.08);
}
.placement-overlay[data-type="initials"] .overlay-badge {
  background: #059669;
}
.placement-overlay[data-type="initials"] .overlay-handle {
  border-color: #10b981;
}

.placement-overlay.selected {
  z-index: 20;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.4), 0 0 20px rgba(59, 130, 246, 0.5);
}

.element-chips-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.element-chip-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.element-chip-item:hover {
  border-color: var(--accent-primary);
}

.element-chip-item.active {
  border-color: var(--accent-primary);
  background: rgba(59, 130, 246, 0.12);
}

.element-chip-item[data-element="logo"].active {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.12);
}

.element-chip-item[data-element="initials"].active {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.12);
}

.element-chip-left {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  font-weight: 500;
}

.chip-status-tag {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

.element-chip-item.active .chip-status-tag {
  background: var(--accent-primary);
  color: #fff;
}

.element-chip-item[data-element="logo"].active .chip-status-tag {
  background: #d97706;
  color: #fff;
}

.element-chip-item[data-element="initials"].active .chip-status-tag {
  background: #059669;
  color: #fff;
}

.overlay-quick-actions {
  position: absolute;
  top: -28px;
  right: 0;
  display: flex;
  gap: 4px;
  z-index: 15;
}

.overlay-quick-actions button {
  box-shadow: var(--shadow-sm);
}

/* --------------------------------------------------------------------------
   Right Sidebar: Controls & Studio
   -------------------------------------------------------------------------- */
.sidebar-controls {
  width: 360px;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.controls-tabs {
  display: flex;
  background: var(--bg-base);
  border-bottom: 1px solid var(--border-color);
  padding: 4px 6px;
}

.tab-btn {
  flex: 1;
  padding: 10px 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: var(--transition-fast);
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  background: var(--bg-surface);
  color: var(--accent-primary);
  box-shadow: var(--shadow-sm);
}

.tab-content {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 18px;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
}

.sidebar-bottom-actions {
  padding: 14px 18px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 10px;
  background: var(--bg-surface-elevated);
}

.sidebar-bottom-actions button {
  flex: 1;
}

.sidebar-section-title {
  font-size: 0.88rem;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--text-primary);
  margin-bottom: 4px;
}

.sidebar-section-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
