/* Modern Client-Side PDF Editor Stylesheet */
:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --border: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --accent: #ef4444;
}

body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  color: var(--text-main);
  background-color: #f1f5f9;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Glassmorphism Panels */
.glass-panel {
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(226, 232, 240, 0.95);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
}

.dark-glass-panel {
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(51, 65, 85, 0.9);
  box-shadow: 0 20px 30px -5px rgba(0, 0, 0, 0.35), 0 10px 15px -6px rgba(0, 0, 0, 0.2);
}

/* PDF Page Container & Dual-Canvas Layering */
.pdf-page-wrapper {
  position: relative !important;
  margin: 0 auto 28px auto;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.12), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
  background-color: #ffffff;
  border-radius: 4px;
  overflow: visible;
  transition: box-shadow 0.2s ease;
}

.pdf-page-wrapper:hover {
  box-shadow: 0 20px 35px -5px rgba(0, 0, 0, 0.18), 0 6px 10px -2px rgba(0, 0, 0, 0.06);
}

/* Background PDF Canvas (rendered by PDF.js) */
.pdf-canvas-bg {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  pointer-events: none !important;
  z-index: 1 !important;
  display: block !important;
}

/* Fabric.js Canvas Container & Canvases (Interactive Vector Layer) */
.canvas-container {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  z-index: 10 !important;
  display: block !important;
  touch-action: none;
}

.upper-canvas {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  z-index: 12 !important;
  cursor: default;
}

.lower-canvas {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  z-index: 10 !important;
}

/* Interactive In-Place Text Editing Layer */
.pdf-text-edit-layer {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  pointer-events: none !important;
  z-index: 15 !important;
  display: block;
}

.pdf-text-edit-layer.active {
  pointer-events: auto !important;
}

.existing-text-block {
  position: absolute;
  cursor: text;
  border-radius: 3px;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  box-sizing: border-box;
}

.pdf-text-edit-layer.active .existing-text-block {
  background-color: rgba(79, 70, 229, 0.04);
  border: 1px dashed rgba(79, 70, 229, 0.25);
}

.pdf-text-edit-layer.active .existing-text-block:hover {
  background-color: rgba(79, 70, 229, 0.2) !important;
  border: 1.5px solid #4f46e5 !important;
  box-shadow: 0 0 10px rgba(79, 70, 229, 0.35);
  z-index: 25;
}

/* Tool Cursors */
.cursor-draw .upper-canvas {
  cursor: crosshair !important;
}
.cursor-text-tool .upper-canvas {
  cursor: text !important;
}
.cursor-shape-tool .upper-canvas {
  cursor: crosshair !important;
}
.cursor-eraser .upper-canvas {
  cursor: cell !important;
}

/* Thumbnail Selection */
.thumbnail-item {
  transition: all 0.2s ease;
  border: 2px solid transparent;
}
.thumbnail-item:hover {
  transform: translateY(-2px);
}
.thumbnail-item.active {
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.25);
}

/* Toolbar Buttons */
.tool-btn {
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}
.tool-btn:hover {
  transform: translateY(-1px);
}
.tool-btn:active {
  transform: translateY(1px);
}
.tool-btn.active {
  background-color: #4f46e5 !important;
  color: #ffffff !important;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

/* Drag & Drop Overlay */
.drag-over-active {
  border-color: #4f46e5 !important;
  background-color: rgba(79, 70, 229, 0.06) !important;
}

/* Signature Fonts */
@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@600&family=Dancing+Script:wght@700&family=Great+Vibes&family=Pacifico&family=Satisfy&display=swap');

.font-signature-1 { font-family: 'Great Vibes', cursive; }
.font-signature-2 { font-family: 'Caveat', cursive; }
.font-signature-3 { font-family: 'Dancing Script', cursive; }
.font-signature-4 { font-family: 'Satisfy', cursive; }
.font-signature-5 { font-family: 'Pacifico', cursive; }

/* Active Toggle Buttons in Text Options Panel */
.active-toggle {
  background-color: #e0e7ff !important;
  color: #4338ca !important;
  font-weight: 700 !important;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

/* ===================== SMOOTHER TEXT BLOCK HOVER ===================== */
.existing-text-block {
  position: absolute;
  cursor: text;
  border-radius: 3px;
  border: 1px solid transparent;
  transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
}

/* ===================== EDIT MODE BANNER ===================== */
#editModeBanner {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 16px;
  background: linear-gradient(90deg, #eef2ff, #e0e7ff);
  border-bottom: 1px solid #c7d2fe;
  font-size: 12px;
  font-weight: 600;
  color: #4338ca;
  flex-shrink: 0;
  z-index: 28;
  animation: slideDown 0.2s ease;
}
#editModeBanner.visible { display: flex; }
@keyframes slideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ===================== TOAST NOTIFICATIONS ===================== */
#toastContainer {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  pointer-events: auto;
  animation: toastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  min-width: 240px;
  max-width: 360px;
}
.toast.toast-success { background: linear-gradient(135deg, #059669, #10b981); }
.toast.toast-error   { background: linear-gradient(135deg, #dc2626, #ef4444); }
.toast.toast-info    { background: linear-gradient(135deg, #4f46e5, #6366f1); }
.toast.toast-warning { background: linear-gradient(135deg, #d97706, #f59e0b); }
.toast.toast-exit    { animation: toastOut 0.3s ease forwards; }
@keyframes toastIn  { from { opacity:0; transform:translateX(40px) scale(0.92); } to { opacity:1; transform:translateX(0) scale(1); } }
@keyframes toastOut { from { opacity:1; transform:translateX(0); } to { opacity:0; transform:translateX(40px); } }

/* ===================== TOOLBAR ICON TOOLTIP ===================== */
.tool-btn {
  position: relative;
}
.tool-btn::after {
  content: attr(title);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.92);
  color: #f1f5f9;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  padding: 4px 8px;
  border-radius: 6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
  transform: translateX(-50%) translateY(4px);
  z-index: 50;
}
.tool-btn:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===================== DRAG AND DROP ACTIVE STATE ===================== */
.drag-over-active {
  border-color: #4f46e5 !important;
  background-color: rgba(79, 70, 229, 0.08) !important;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.15) !important;
  transform: scale(1.01);
  transition: all 0.2s ease;
}
