/* ═══════════════════════════════════════════════════════
   PDFEdit — Online PDF Editor Styles
   ═══════════════════════════════════════════════════════ */

:root {
  --bg-primary: #1a1b2e;
  --bg-secondary: #242640;
  --bg-tertiary: #2e3050;
  --bg-hover: #353760;
  --text-primary: #e8e6f0;
  --text-secondary: #9896a8;
  --accent: #a78bfa;
  --accent-hover: #c4b5fd;
  --accent-dim: #a78bfa30;
  --danger: #ef4444;
  --success: #22c55e;
  --border: #3a3d5c;
  --shadow: 0 4px 24px rgba(0,0,0,.35);
  --radius: 10px;
  --radius-sm: 6px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
}

.screen { width: 100%; height: 100vh; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px; border: none; border-radius: var(--radius-sm);
  font: 600 14px/1 'Inter', sans-serif; cursor: pointer; transition: .2s;
}
.btn-primary { background: var(--accent); color: #1a1b2e; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; }
.btn-secondary { background: var(--bg-tertiary); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-hover); }
.btn-save {
  background: var(--accent); color: #1a1b2e; padding: 8px 16px;
  border: none; border-radius: var(--radius-sm); font: 600 13px 'Inter', sans-serif;
  cursor: pointer; display: flex; align-items: center; gap: 6px; transition: .2s;
}
.btn-save:hover { background: var(--accent-hover); }
.btn-save .material-icons { font-size: 18px; }

/* Tool buttons */
.tool-btn {
  width: 36px; height: 36px; border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-secondary); cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: .15s;
  position: relative;
}
.tool-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.tool-btn.active { background: var(--accent-dim); color: var(--accent); }
.tool-btn:disabled { opacity: .3; cursor: not-allowed; }
.tool-btn .material-icons { font-size: 20px; }
.tool-btn.small { width: 30px; height: 30px; }
.tool-btn.small .material-icons { font-size: 18px; }

/* ═══════════════ UPLOAD SCREEN ═══════════════ */
.upload-screen {
  display: flex; flex-direction: column;
  background: linear-gradient(135deg, #1a1b2e 0%, #242640 50%, #1e1f38 100%);
}

.upload-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 24px; border-bottom: 1px solid var(--border);
}
.logo {
  display: flex; align-items: center; gap: 10px;
  font-size: 22px; font-weight: 700; color: var(--accent);
}
.logo .material-icons { font-size: 28px; }

.author-link {
  display: flex; align-items: center; gap: 6px;
  color: var(--text-secondary); text-decoration: none; font-size: 14px; transition: .2s;
}
.author-link:hover { color: var(--accent); }
.author-link .material-icons { font-size: 18px; }

.upload-main {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 48px; padding: 32px;
  overflow-y: auto;
}

.drop-zone {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  padding: 60px 80px; border: 2px dashed var(--border); border-radius: 16px;
  text-align: center; cursor: pointer; transition: .3s;
  max-width: 560px; width: 100%;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent); background: var(--accent-dim);
}
.drop-icon { font-size: 64px; color: var(--accent); }
.drop-zone h2 { font-size: 22px; font-weight: 600; }
.drop-zone p { color: var(--text-secondary); font-size: 14px; }

.features {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
  max-width: 800px; width: 100%;
}
.feature-card {
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; text-align: center; transition: .2s;
}
.feature-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.feature-card .material-icons { font-size: 32px; color: var(--accent); margin-bottom: 8px; }
.feature-card h3 { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.feature-card p { font-size: 12px; color: var(--text-secondary); line-height: 1.4; }

/* ═══════════════ EDITOR SCREEN ═══════════════ */
.editor-screen {
  display: flex; flex-direction: column; height: 100vh;
}

/* Toolbar */
.toolbar {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 12px; background: var(--bg-secondary);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
  overflow-x: auto;
}
.toolbar-group { display: flex; align-items: center; gap: 2px; }
.toolbar-right { margin-left: auto; }
.toolbar-divider { width: 1px; height: 24px; background: var(--border); margin: 0 6px; }

/* Properties Bar */
.properties-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 16px; background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border); min-height: 38px; flex-shrink: 0;
}
.prop-group {
  display: flex; align-items: center; gap: 8px; font-size: 13px;
  flex-wrap: wrap;
}
.prop-group label { color: var(--text-secondary); white-space: nowrap; }
.prop-group input[type="number"] {
  width: 56px; padding: 4px 6px; background: var(--bg-primary);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-primary); font-size: 13px;
}
.prop-group input[type="color"] {
  width: 28px; height: 28px; padding: 0; border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer; background: none;
}
.prop-group select {
  padding: 4px 8px; background: var(--bg-primary); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary); font-size: 13px;
}
.prop-group input[type="range"] { width: 80px; accent-color: var(--accent); }
.prop-group input[type="checkbox"] { accent-color: var(--accent); }
.prop-group span { color: var(--text-secondary); font-size: 12px; min-width: 18px; }

/* Font Select */
.font-select {
  min-width: 140px; max-width: 180px;
}

/* Text format buttons (Bold, Italic, Underline) */
.text-format-btns {
  display: flex; gap: 2px;
}
.fmt-btn {
  width: 30px; height: 28px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--bg-primary);
  color: var(--text-secondary); cursor: pointer; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  transition: .15s; font-family: inherit;
}
.fmt-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.fmt-btn.active { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }

/* OCR hint */
.ocr-hint {
  color: var(--text-secondary); font-size: 12px; font-style: italic;
}

/* Editor Body */
.editor-body {
  display: flex; flex: 1; overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 160px; background: var(--bg-secondary); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0; transition: width .2s;
}
.sidebar.collapsed { width: 0; overflow: hidden; border-right: none; }
.sidebar-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; font-size: 13px; font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.thumbnails {
  flex: 1; overflow-y: auto; padding: 8px;
  display: flex; flex-direction: column; gap: 8px;
}
.thumb-item {
  border: 2px solid transparent; border-radius: var(--radius-sm);
  cursor: pointer; transition: .2s; padding: 4px; text-align: center;
}
.thumb-item:hover { border-color: var(--bg-hover); }
.thumb-item.active { border-color: var(--accent); }
.thumb-item canvas {
  width: 100%; display: block; border-radius: 3px;
  box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
.thumb-label {
  font-size: 11px; color: var(--text-secondary); margin-top: 4px;
}

/* Canvas Area */
.canvas-area {
  flex: 1; overflow: auto; display: flex;
  align-items: flex-start; justify-content: center;
  padding: 20px; background: #16172a;
}
.canvas-wrapper {
  position: relative; box-shadow: var(--shadow);
  line-height: 0;
}
#pdfCanvas { display: block; }
#editCanvas {
  position: absolute; top: 0; left: 0;
  cursor: crosshair;
}

/* Text input overlay */
.text-input-container {
  position: absolute; z-index: 10;
}
.text-input {
  background: rgba(167, 139, 250, .08); border: 1px dashed var(--accent);
  color: #000; font-family: 'Inter', sans-serif;
  padding: 2px 4px; min-width: 60px; resize: none; outline: none;
  overflow: hidden;
}

/* OCR Selection Overlay */
.ocr-selection {
  position: absolute; border: 2px dashed #22c55e; background: rgba(34, 197, 94, .12);
  z-index: 9; pointer-events: none;
}

/* Bottom Bar */
.bottom-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 16px; background: var(--bg-secondary);
  border-top: 1px solid var(--border); flex-shrink: 0; font-size: 13px;
}
.page-nav, .zoom-controls {
  display: flex; align-items: center; gap: 6px;
}
#pageInfo, #zoomLevel {
  min-width: 60px; text-align: center; color: var(--text-secondary);
}
.file-info {
  color: var(--text-secondary); font-size: 12px;
  max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ═══════════════ MODALS ═══════════════ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
}
.modal {
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 12px; width: 460px; max-width: 95vw;
  max-height: 85vh; display: flex; flex-direction: column;
  box-shadow: 0 8px 48px rgba(0,0,0,.5);
}
.modal-wide { width: 580px; }
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close {
  width: 32px; height: 32px; border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-secondary); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-hint { color: var(--text-secondary); font-size: 13px; margin-bottom: 12px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 12px 20px; border-top: 1px solid var(--border);
}

/* Form elements */
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }
.input {
  width: 100%; padding: 8px 12px; background: var(--bg-primary);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-primary); font-size: 14px;
}
.input:focus { outline: none; border-color: var(--accent); }

/* Merge */
.merge-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.merge-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; background: var(--bg-tertiary); border-radius: var(--radius-sm);
  font-size: 13px;
}
.merge-item .material-icons { font-size: 16px; cursor: pointer; color: var(--text-secondary); }
.merge-item .material-icons:hover { color: var(--danger); }

/* Split pages */
.split-pages {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
  gap: 8px; margin-bottom: 12px;
}
.split-page-item {
  display: flex; align-items: center; justify-content: center;
  padding: 10px 8px; background: var(--bg-tertiary); border: 2px solid transparent;
  border-radius: var(--radius-sm); cursor: pointer; font-size: 14px; font-weight: 500;
  transition: .15s;
}
.split-page-item:hover { border-color: var(--bg-hover); }
.split-page-item.selected { border-color: var(--accent); background: var(--accent-dim); color: var(--accent); }

/* Signature pad */
.sig-body { display: flex; justify-content: center; }
#signaturePad {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: #fff; cursor: crosshair;
}

/* OCR Result Modal */
.ocr-textarea {
  font-family: 'Inter', sans-serif; resize: vertical;
  min-height: 180px; line-height: 1.6;
}
.ocr-info {
  background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 14px;
  margin-bottom: 12px; font-size: 13px; color: var(--text-secondary);
  line-height: 1.5;
}
.ocr-info strong { color: var(--text-primary); }

/* OCR Progress Overlay */
.ocr-progress-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(0,0,0,.7); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
}
.ocr-progress-card {
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 16px; padding: 40px 48px; text-align: center;
  box-shadow: 0 8px 48px rgba(0,0,0,.5);
  display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.ocr-progress-icon {
  font-size: 48px; color: var(--accent);
  animation: ocrPulse 1.5s ease infinite;
}
@keyframes ocrPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}
.ocr-progress-card h3 { font-size: 16px; font-weight: 600; }
.ocr-progress-bar {
  width: 240px; height: 6px; background: var(--bg-tertiary);
  border-radius: 3px; overflow: hidden;
}
.ocr-progress-fill {
  height: 100%; width: 0%; background: var(--accent);
  border-radius: 3px; transition: width .3s;
}
.ocr-progress-pct {
  font-size: 14px; color: var(--text-secondary); font-variant-numeric: tabular-nums;
}

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  padding: 10px 24px; background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 14px; z-index: 2000;
  box-shadow: 0 4px 16px rgba(0,0,0,.4); animation: toastIn .3s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 20px); } }

/* Scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--bg-hover); }

/* Responsive */
@media (max-width: 768px) {
  .features { grid-template-columns: repeat(2, 1fr); }
  .drop-zone { padding: 40px 24px; }
  .sidebar { width: 100px; }
  .toolbar { padding: 4px 6px; }
  .btn-label { display: none; }
  .toolbar-group { gap: 1px; }
  .font-select { min-width: 100px; }
}
@media (max-width: 480px) {
  .features { grid-template-columns: 1fr 1fr; gap: 8px; }
  .feature-card { padding: 12px; }
  .sidebar { display: none; }
}