/* ── Adobe‑like PDF Editor ────────────────────────────── */

#pdf-annotator {
  --ann-toolbar-h: 48px;
  --ann-sidebar-w: 180px;
  --ann-status-h: 32px;
  --ann-accent: #4f46e5;
  display: flex; flex-direction: column;
  height: calc(100vh - 60px); /* below header */
  background: #1e1e2f;
  color: #e0e0e0;
  font-family: system-ui, -apple-system, sans-serif;
  position: relative;
  overflow: hidden;
  border-radius: 12px 12px 0 0;
  margin: 0;
}

/* ── Top toolbar ───────────────────────────────── */
.ann-toolbar {
  display: flex; align-items: center; gap: 4px;
  height: var(--ann-toolbar-h); min-height: var(--ann-toolbar-h);
  padding: 0 12px;
  background: #2a2a3e;
  border-bottom: 1px solid #3a3a50;
  flex-shrink: 0;
  overflow-x: auto;
}
.ann-toolbar .tool-group {
  display: flex; gap: 2px; align-items: center;
}
.ann-toolbar .tool-btn {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border: none; border-radius: 6px;
  background: transparent; color: #b0b0c8; cursor: pointer;
  font-size: 16px; transition: all 0.12s;
}
.ann-toolbar .tool-btn:hover { background: #3a3a50; color: #fff; }
.ann-toolbar .tool-btn.active { background: var(--ann-accent); color: #fff; }
.ann-toolbar .tool-btn .tool-icon { font-size: 18px; line-height: 1; }
.ann-toolbar .sep { width: 1px; height: 24px; background: #3a3a50; margin: 0 6px; flex-shrink: 0; }
.ann-toolbar .color-wrap { display: flex; align-items: center; gap: 4px; }
.ann-toolbar .color-wrap label { font-size: 11px; color: #8888a0; }
.ann-toolbar input[type="color"] {
  width: 28px; height: 28px; padding: 0; border: 1px solid #3a3a50;
  border-radius: 4px; cursor: pointer; background: none;
}
.ann-toolbar input[type="range"] { width: 56px; height: 3px; accent-color: var(--ann-accent); }
.ann-toolbar .stroke-val { font-size: 11px; color: #8888a0; min-width: 16px; text-align: center; }
.ann-toolbar-right {
  margin-left: auto; display: flex; align-items: center; gap: 6px;
}
.ann-toolbar-right button {
  padding: 6px 14px; border: none; border-radius: 6px; cursor: pointer;
  font-size: 12px; font-weight: 600; transition: all 0.12s;
}
#ann-undo-btn { background: #3a3a50; color: #b0b0c8; }
#ann-undo-btn:hover { background: #4a4a60; color: #fff; }
#ann-save-btn { background: var(--ann-accent); color: #fff; }
#ann-save-btn:hover { opacity: 0.9; }
#ann-save-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Body: sidebar + canvas ─────────────────────── */
.ann-body {
  display: flex; flex: 1; min-height: 0; overflow: hidden;
}

/* ── Left sidebar (thumbnails) ──────────────────── */
.ann-sidebar {
  width: var(--ann-sidebar-w); min-width: var(--ann-sidebar-w);
  background: #232336; border-right: 1px solid #3a3a50;
  display: flex; flex-direction: column; overflow: hidden;
}
.ann-sidebar-header {
  padding: 10px 12px; font-size: 11px; font-weight: 600;
  color: #8888a0; text-transform: uppercase; letter-spacing: 0.5px;
  border-bottom: 1px solid #3a3a50; flex-shrink: 0;
}
.ann-thumb-list {
  flex: 1; overflow-y: auto; padding: 8px; display: flex;
  flex-direction: column; gap: 6px;
}
.ann-thumb-item {
  border: 2px solid transparent; border-radius: 6px; cursor: pointer;
  overflow: hidden; transition: all 0.12s; position: relative;
}
.ann-thumb-item:hover { border-color: #4a4a60; }
.ann-thumb-item.active { border-color: var(--ann-accent); }
.ann-thumb-item img { display: block; width: 100%; height: auto; }
.ann-thumb-label {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,0.6); color: #fff; font-size: 10px;
  text-align: center; padding: 2px 0;
}

/* ── Main canvas area ───────────────────────────── */
.ann-canvas-area {
  flex: 1; overflow: auto; display: flex; justify-content: center;
  align-items: flex-start; padding: 24px; background: #1a1a2e;
  position: relative;
}
.ann-page-wrap {
  background: #fff; border-radius: 4px; box-shadow: 0 4px 24px rgba(0,0,0,0.3);
  overflow: hidden; position: relative; margin-bottom: 24px;
  flex-shrink: 0;
}
.ann-canvas-wrap {
  position: relative; cursor: crosshair;
}
.ann-canvas-wrap img { display: block; max-width: 100%; height: auto; }
.ann-canvas-wrap canvas {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
}
.ann-page-label {
  text-align: center; font-size: 12px; color: #8888a0;
  padding: 6px 0 0; margin-bottom: 20px;
}

/* ── Status bar ─────────────────────────────────── */
.ann-status {
  height: var(--ann-status-h); min-height: var(--ann-status-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px; background: #2a2a3e; border-top: 1px solid #3a3a50;
  font-size: 11px; color: #8888a0; flex-shrink: 0;
}
.ann-status span { display: flex; align-items: center; gap: 6px; }
.ann-zoom-btn {
  background: none; border: none; color: #8888a0; cursor: pointer;
  font-size: 14px; padding: 2px 4px; border-radius: 4px;
}
.ann-zoom-btn:hover { background: #3a3a50; color: #fff; }

/* ── Upload section ─────────────────────────────── */
.ann-upload-section {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  flex: 1; padding: 40px;
}
.ann-upload-zone {
  border: 2px dashed #3a3a50; border-radius: 12px;
  padding: 60px 40px; text-align: center; cursor: pointer;
  transition: all 0.2s; background: #2a2a3e; max-width: 480px; width: 100%;
}
.ann-upload-zone:hover, .ann-upload-zone.dragover { border-color: var(--ann-accent); background: #2a2a40; }
.ann-upload-zone .icon { font-size: 56px; margin-bottom: 12px; display: block; }
.ann-upload-zone .hint { font-size: 12px; color: #8888a0; margin-top: 8px; }
#ann-file-input { display: none; }
.ann-upload-section h2 { font-size: 22px; font-weight: 700; color: #e0e0e0; margin-bottom: 4px; }
.ann-upload-section .subtitle { color: #8888a0; font-size: 13px; margin-bottom: 24px; }

/* ── Uploading spinner ──────────────────────────── */
.ann-uploading {
  display: none; flex-direction: column; align-items: center; justify-content: center;
  flex: 1; padding: 40px;
}
.ann-uploading .spinner { width: 40px; height: 40px; border: 3px solid #3a3a50; border-top-color: var(--ann-accent); border-radius: 50%; animation: ann-spin 0.8s linear infinite; margin-bottom: 16px; }
@keyframes ann-spin { to { transform: rotate(360deg); } }
.ann-uploading p { color: #8888a0; font-size: 14px; }

/* ── Editor ─────────────────────────────────────── */
.ann-editor { display: none; flex-direction: column; flex: 1; min-height: 0; }

/* ── Result ─────────────────────────────────────── */
.ann-result {
  display: none; flex-direction: column; align-items: center; justify-content: center;
  flex: 1; padding: 60px 24px;
}
.ann-result .success-icon { font-size: 48px; color: #10b981; margin-bottom: 12px; }
.ann-result h3 { font-size: 20px; font-weight: 700; color: #e0e0e0; margin-bottom: 6px; }
.ann-result p { color: #8888a0; margin-bottom: 20px; }
.ann-result .dl-btn {
  display: inline-block; padding: 10px 28px; background: var(--ann-accent); color: #fff;
  border-radius: 8px; text-decoration: none; font-weight: 600;
}

/* ── Text input overlay ─────────────────────────── */
.ann-text-input {
  position: absolute; z-index: 50; min-width: 80px; min-height: 28px;
  padding: 6px 10px; font-size: 16px; border: 2px solid var(--ann-accent);
  background: #fff; outline: none; border-radius: 4px;
  color: #000; font-family: sans-serif;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

/* ── Upload section (inside editor view) ────────── */
.ann-new-upload {
  display: none; flex-direction: column; align-items: center; justify-content: center;
  flex: 1; padding: 40px;
}
.ann-new-upload .ann-upload-zone { max-width: 400px; }
