/* PDF Viewer — Custom styles on top of pdf_viewer.css */

:root {
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --bg-toolbar: #ffffff;
  --bg-body: #f1f5f9;
  --bg-sidebar: #f8fafc;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* === TOOLBAR === */
#toolbarContainer {
  background: var(--bg-toolbar);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 100;
  flex-shrink: 0;
}

#mainToolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  gap: 8px;
}

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

.toolbar-separator {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 6px;
}

.toolbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-primary);
  transition: background 0.15s;
}
.toolbar-btn:hover { background: #f1f5f9; }
.toolbar-btn:active { background: #e2e8f0; }
.toolbar-btn.active { background: #dbeafe; color: var(--accent); }

/* Page input */
.page-input-group {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
}
.page-input-group input {
  width: 48px;
  height: 28px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.page-input-group input:focus { border-color: var(--accent); }
#numPages { color: var(--text-secondary); font-size: 13px; }

/* Scale select */
#scaleSelect {
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  padding: 0 8px;
  background: white;
  outline: none;
  cursor: pointer;
}
#scaleSelect:focus { border-color: var(--accent); }

/* === ANNOTATION TOOLBAR === */
#annotationToolbar {
  display: flex;
  align-items: center;
  padding: 4px 12px;
  gap: 4px;
  border-top: 1px solid var(--border);
  background: #fafbfc;
}

.anno-btn {
  width: auto !important;
  padding: 4px 10px !important;
  gap: 5px;
  font-size: 12px;
  font-family: inherit;
}
.anno-btn span { font-weight: 500; }
.anno-btn svg { flex-shrink: 0; }

/* === SEARCH BAR === */
#searchBar {
  display: flex;
  align-items: center;
  padding: 6px 12px;
  gap: 6px;
  border-top: 1px solid var(--border);
  background: #fffbeb;
}
#searchBar.hidden { display: none; }
#searchInput {
  flex: 1;
  max-width: 300px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 8px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
#searchInput:focus { border-color: var(--accent); }
#searchResultCount { font-size: 12px; color: var(--text-secondary); }

/* === MAIN CONTAINER === */

/* === SIDEBAR === */
#sidebarContainer {
  width: 200px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
}
#sidebarContainer.hidden { display: none; }

#thumbnailView {
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.thumbnail-item {
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 4px;
  overflow: hidden;
  transition: border-color 0.15s;
}
.thumbnail-item:hover { border-color: var(--accent); }
.thumbnail-item.active { border-color: var(--accent); }
.thumbnail-item canvas { display: block; width: 100%; }
.thumbnail-label {
  text-align: center;
  font-size: 11px;
  color: var(--text-secondary);
  padding: 2px 0;
}

/* === VIEWER === */
#viewerContainer {
  overflow: auto;
  background: var(--bg-body);
}

#viewer {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
}

.page-wrapper {
  background: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  position: relative;
}

.pdf-canvas {
  display: block;
}

.anno-overlay {
  pointer-events: none;
}

/* === WELCOME SCREEN === */
#welcomeScreen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: var(--bg-body);
  z-index: 10;
}
#welcomeScreen.hidden { display: none; }

.welcome-content {
  text-align: center;
  max-width: 400px;
}
.welcome-content h2 {
  font-size: 22px;
  font-weight: 600;
  margin: 20px 0 8px;
  color: var(--text-primary);
}
.welcome-content p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

/* === BUTTONS === */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 24px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  background: white;
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-secondary:hover { background: #f8fafc; }

.btn-sm { padding: 5px 12px; font-size: 12px; }

/* === DROP ZONE === */
#dropZone {
  position: absolute;
  inset: 0;
  background: rgba(37, 99, 235, 0.08);
  border: 3px dashed var(--accent);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  margin: 12px;
}
#dropZone.hidden { display: none; }
.drop-zone-content { text-align: center; }
.drop-zone-content p {
  margin-top: 12px;
  font-size: 16px;
  color: var(--accent);
  font-weight: 500;
}

/* === MODALS === */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.4); }
.modal-content {
  position: relative;
  background: white;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 20px; }

/* Properties table */
#propertiesTable { width: 100%; border-collapse: collapse; }
#propertiesTable td {
  padding: 8px 0;
  font-size: 13px;
  border-bottom: 1px solid #f1f5f9;
}
#propertiesTable td:first-child {
  font-weight: 500;
  width: 140px;
  color: var(--text-secondary);
}

/* Sign canvas */
#signCanvas {
  width: 100%;
  height: 150px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: crosshair;
}
.sign-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  justify-content: flex-end;
}

/* === OCR PROGRESS === */
#ocrProgress {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 150;
}
#ocrProgress.hidden { display: none; }
.ocr-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  font-size: 13px;
}
.progress-track {
  width: 160px;
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s;
}

/* === NOTIFICATION BAR === */
#notificationBar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: #fef3c7;
  border-bottom: 1px solid #fde68a;
  font-size: 13px;
  color: #92400e;
}
#notificationBar.hidden { display: none; }
#notificationText { flex: 1; }

/* === RESPONSIVE === */
@media (max-width: 768px) {
  #mainToolbar { padding: 4px 8px; }
  .anno-btn span { display: none; }
  .anno-btn { padding: 6px 8px !important; }
  #sidebarContainer { width: 140px; }
  .toolbar-separator { margin: 0 3px; }
}
