:root {
  --brand-red: #e5322d;
  --brand-red-hover: #c9221d;
  --canvas-bg: #eef0f4;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100vh;
  background: #f5f6f8;
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
}

/* Upload Dropzone */
.dropzone-box {
  max-width: 680px;
  margin: 2.5rem auto;
  background: #ffffff;
  border: 2px dashed #cbd5e1;
  border-radius: 24px;
  padding: 3.5rem 2rem;
  text-align: center;
  transition: all 0.18s ease;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
}

.dropzone-box.is-hover {
  border-color: var(--brand-red);
  background: #fef2f2;
  transform: scale(1.01);
}

.btn-primary-red {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  background: var(--brand-red);
  color: #ffffff;
  border: none;
  border-radius: 14px;
  padding: 1rem 2.25rem;
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(229, 50, 45, 0.25);
  transition: all 0.15s ease;
}

.btn-primary-red:hover:not(:disabled) {
  background: var(--brand-red-hover);
  transform: translateY(-1px);
}

.btn-primary-red:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Split Workspace Layout (Visual Doc Viewer Left + Controls Right) */
.studio-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  min-height: calc(100vh - 64px);
}

.studio-canvas {
  background: var(--canvas-bg);
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.studio-sidebar {
  background: #ffffff;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
}

/* Sejda-Style Top Editor Toolbar */
.editor-toolbar {
  position: sticky;
  top: 64px;
  z-index: 40;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 0.55rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.8rem;
  border-radius: 9px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #334155;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s ease;
}

.tool-btn:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.tool-btn.active {
  background: #fef2f2;
  border-color: var(--brand-red);
  color: var(--brand-red);
}

/* Interactive PDF Page Wrapper */
.pdf-page-stage {
  position: relative;
  background: #ffffff;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
  border-radius: 4px;
  margin-bottom: 1.5rem;
  user-select: none;
  overflow: hidden;
}

.pdf-page-stage canvas {
  display: block;
}

.overlay-layer {
  position: absolute;
  inset: 0;
  cursor: crosshair;
}

/* Editable Overlay Items (Text, Whiteout, Signature, Image, Rect) */
.doc-item {
  position: absolute;
  cursor: move;
  border: 1.5px dashed transparent;
  padding: 2px 4px;
  transition: border-color 0.1s ease;
}

.doc-item:hover,
.doc-item.selected {
  border-color: #2563eb;
  background: rgba(37, 99, 235, 0.04);
}

.doc-item-text {
  min-width: 60px;
  min-height: 22px;
  outline: none;
  white-space: pre-wrap;
  line-height: 1.25;
  cursor: text;
}

.doc-item-delete {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: none;
  background: #e5322d;
  color: #ffffff;
  font-size: 11px;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.doc-item:hover .doc-item-delete,
.doc-item.selected .doc-item-delete {
  display: flex;
}

/* Signature Modal */
.modal-backdrop-custom {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-card-custom {
  background: #ffffff;
  border-radius: 18px;
  max-width: 480px;
  width: 100%;
  padding: 1.5rem;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.25);
}

@media (max-width: 900px) {
  .studio-layout {
    grid-template-columns: 1fr;
  }
  .studio-sidebar {
    border-left: none;
    border-top: 1px solid var(--border);
  }
}
