/* Ensure filtered-out tool cards are strictly hidden across all screen sizes */
.tool-card.is-hidden,
.tool-card[hidden],
.tool-card[style*="display: none"] {
  display: none !important;
}

/* Native scroll-behavior kept auto so Lenis inertia scrolling never conflicts */
html {
  scroll-behavior: auto !important;
  -webkit-overflow-scrolling: touch;
  font-size: calc(16px + 1pt) !important; /* Scaled base font size up by exactly +1pt (~17.333px) */
}

/* Prevent Any Horizontal Viewport Drift / Overflow Bug without breaking smooth scroll */
html, body {
  overflow-x: hidden !important;
  overflow-x: clip !important;
  max-width: 100vw !important;
  width: 100% !important;
  overscroll-behavior-x: none;
}

body {
  position: relative !important;
  isolation: isolate;
}

main {
  overflow-x: clip !important;
  width: 100% !important;
}

/* Typography Scale: Scale explicit arbitrary font sizes by exactly +1pt (~1.333px) */
.text-\[10px\] { font-size: calc(10px + 1pt) !important; }
.text-\[11px\] { font-size: calc(11px + 1pt) !important; }
.text-\[12px\] { font-size: calc(12px + 1pt) !important; }
.text-\[14px\] { font-size: calc(14px + 1pt) !important; }
.text-\[15px\] { font-size: calc(15px + 1pt) !important; }

/* Desktop Tool Cards Typography (scaled +1pt) */
.tool-card h3 {
  font-size: calc(15px + 1pt) !important; /* ~16.33px */
  line-height: 1.35 !important;
}
.tool-card p {
  font-size: calc(12px + 1pt) !important; /* ~13.33px */
  line-height: 1.4 !important;
}

#categoryPillsContainer {
  display: flex !important;
  flex-wrap: wrap !important;
  justify-content: center !important;
  align-items: center !important;
  gap: 12px 10px !important;
  row-gap: 12px !important;
  column-gap: 10px !important;
  width: 100% !important;
  max-width: 100% !important;
  overflow: visible !important;
  margin-top: 14px !important;
  margin-bottom: 34px !important;
}

@media (min-width: 640px) {
  #categoryPillsContainer {
    gap: 14px 12px !important;
    row-gap: 14px !important;
    column-gap: 12px !important;
    margin-top: 18px !important;
    margin-bottom: 42px !important;
  }
}

#toolsGrid {
  margin-top: 10px !important;
}

/* Custom styling for SerbaPDF Web Studio */
:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: #e8edf5 !important;
  color: #1e293b;
}

/* Fast yet Butter-Smooth Theme Fade Transition */
html.theme-transition,
html.theme-transition *,
html.theme-transition *::before,
html.theme-transition *::after {
  transition: background-color 220ms cubic-bezier(0.4, 0, 0.2, 1),
              border-color 220ms cubic-bezier(0.4, 0, 0.2, 1),
              color 220ms cubic-bezier(0.4, 0, 0.2, 1),
              fill 220ms cubic-bezier(0.4, 0, 0.2, 1),
              stroke 220ms cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 220ms cubic-bezier(0.4, 0, 0.2, 1) !important;
  transition-delay: 0s !important;
}

/* Dark Mode Base Overrides & Ambient Studio Glow (GPU-composited for silky scrolling) */
html.dark body {
  background-color: #0b0f19 !important;
  color: #f1f5f9 !important;
}

html.dark body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background-image:
    radial-gradient(ellipse 90% 60% at 50% -20%, rgba(37, 99, 235, 0.16), transparent 75%),
    radial-gradient(ellipse 60% 40% at 100% 40%, rgba(99, 102, 241, 0.08), transparent 60%);
  transform: translateZ(0);
}

/* Card hover animation */
.tool-card {
  background-color: #ffffff !important;
  border: 1.5px solid #cbd5e1 !important;
  box-shadow: 0 4px 12px -2px rgba(15, 23, 42, 0.09), 0 2px 4px -2px rgba(15, 23, 42, 0.05) !important;
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.22s cubic-bezier(0.4, 0, 0.2, 1),
              border-color 0.22s cubic-bezier(0.4, 0, 0.2, 1),
              background-color 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

.tool-card:hover {
  transform: translateY(-4px) !important;
  border-color: #3b82f6 !important;
  box-shadow: 0 14px 28px -4px rgba(15, 23, 42, 0.14), 0 8px 12px -4px rgba(59, 130, 246, 0.12) !important;
}

/* Dark Mode Tool Cards: Sleek Slate Surface (Zero backdrop-filter repaint jank on 60/120fps scroll) */
html.dark .tool-card {
  background-color: rgba(24, 34, 52, 0.92) !important;
  box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.38) !important;
  border: 1px solid rgba(51, 65, 85, 0.8) !important;
}

html.dark .tool-card:hover {
  background-color: rgba(30, 41, 59, 0.98) !important;
  border-color: rgba(59, 130, 246, 0.7) !important;
  box-shadow: 0 16px 36px -8px rgba(0, 0, 0, 0.5), 0 0 25px -4px rgba(59, 130, 246, 0.2) !important;
}

html.dark .tool-card h3 {
  color: #f8fafc !important;
}

html.dark .tool-card p {
  color: #94a3b8 !important;
}

/* Mobile Compact Grid & Card Styling (<640px) - Modern SaaS Standard */
@media (max-width: 639px) {
  .tool-card {
    padding: 0.875rem !important; /* 14px generous padding */
    border-radius: 1rem !important; /* 16px smooth corners */
    min-height: 120px !important;
    display: flex;
    flex-direction: column !important;
    justify-content: flex-start !important;
    border-width: 1px !important;
  }

  .tool-card .tool-icon-box {
    width: 2.35rem !important; /* 38px */
    height: 2.35rem !important;
    border-radius: 0.625rem !important; /* 10px */
    margin-bottom: 0.5rem !important;
  }

  .tool-card .tool-icon-box svg {
    width: 1.25rem !important; /* 20px */
    height: 1.25rem !important;
  }

  /* Clean, prominent card title (+1pt) */
  .tool-card h3 {
    font-size: calc(14px + 1pt) !important; /* ~15.33px */
    line-height: 1.3 !important;
    font-weight: 700 !important;
    margin-bottom: 0.25rem !important;
    display: block !important;
    overflow: visible !important;
  }

  /* Readable description without awkward mid-word clamp (+1pt) */
  .tool-card p {
    font-size: calc(11px + 1pt) !important; /* ~12.33px */
    line-height: 1.35 !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 3 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    color: #64748b !important;
  }

  html.dark .tool-card p {
    color: #94a3b8 !important;
  }
}

/* Signature Pad Canvas */
.signature-canvas {
  touch-action: none;
  cursor: crosshair;
  background-color: #ffffff;
}

/* Interactive Signature Placement Stage */
.pdf-viewport {
  position: relative;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  background: white;
  margin: 0 auto;
  user-select: none;
}

/* Draggable & Resizable Signature Overlay Box */
.placed-signature {
  position: absolute;
  cursor: move;
  border: 2px dashed #2563eb;
  background: rgba(37, 99, 235, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.placed-signature img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.resize-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: #2563eb;
  border: 2px solid #ffffff;
  border-radius: 50%;
  right: -6px;
  bottom: -6px;
  cursor: nwse-resize;
}

.delete-sig-btn {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 22px;
  height: 22px;
  background: #ef4444;
  color: white;
  border-radius: 50%;
  font-size: calc(11px + 1pt);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  border: 1px solid white;
}

/* Modal animation */
.modal-overlay {
  transition: opacity 0.2s ease-in-out;
}

.modal-content {
  transition: transform 0.2s ease-in-out;
}

/* Drag drop area */
.dropzone {
  border: 2px dashed #cbd5e1;
  transition: all 0.2s ease;
}

.dropzone.dragover {
  border-color: #2563eb;
  background-color: #eff6ff;
}

html.dark .dropzone {
  border-color: #334155;
  background-color: rgba(30, 41, 59, 0.4);
}

html.dark .dropzone:hover {
  background-color: rgba(30, 41, 59, 0.7);
  border-color: #3b82f6;
}

html.dark .dropzone.dragover {
  border-color: #60a5fa;
  background-color: rgba(30, 58, 138, 0.3);
}

/* Dark Mode Inputs, Selects, and Textareas */
html.dark input[type="text"],
html.dark input[type="password"],
html.dark input[type="number"],
html.dark select,
html.dark textarea {
  background-color: #1e293b !important;
  border-color: #334155 !important;
  color: #f8fafc !important;
}

html.dark input::placeholder,
html.dark textarea::placeholder {
  color: #64748b !important;
}

html.dark option {
  background-color: #1e293b;
  color: #f8fafc;
}

/* Dark Mode Modals & Panels */
html.dark #genericToolModal > div,
html.dark #signModal > div {
  background-color: #0f172a;
  border: 1px solid #1e293b;
  color: #f1f5f9;
}

html.dark #genericToolModal .bg-slate-50,
html.dark #signModal .bg-slate-50 {
  background-color: #1e293b;
  border-color: #334155;
}

html.dark #genericModalTitle {
  color: #f8fafc;
}

html.dark #genericModalDesc {
  color: #94a3b8;
}

html.dark #toolFileList > div {
  background-color: #1e293b !important;
  border-color: #334155 !important;
  color: #f8fafc !important;
}

html.dark #toolFileList span.text-slate-700 {
  color: #e2e8f0 !important;
}

html.dark #signStepEditor .bg-slate-50 {
  background-color: #1e293b;
  border-color: #334155;
}

html.dark #signStepEditor .bg-slate-100 {
  background-color: #1e293b;
  color: #f8fafc;
}

html.dark #signStepEditor button.bg-white {
  background-color: #0f172a;
  border-color: #334155;
  color: #f8fafc;
}

/* Modal Typography & Elements in Dark Mode */
html.dark #genericToolModal label,
html.dark #signModal label {
  color: #e2e8f0;
}

html.dark #genericToolModal .text-slate-700,
html.dark #signModal .text-slate-700 {
  color: #e2e8f0 !important;
}

html.dark #genericToolModal .text-slate-600,
html.dark #signModal .text-slate-600 {
  color: #cbd5e1 !important;
}

html.dark #genericToolModal .text-slate-500,
html.dark #signModal .text-slate-500 {
  color: #94a3b8 !important;
}

html.dark #genericToolModal .bg-amber-50,
html.dark #signModal .bg-amber-50 {
  background-color: rgba(120, 53, 15, 0.25) !important;
  border-color: rgba(180, 83, 9, 0.45) !important;
  color: #fde68a !important;
}

html.dark #genericToolModal button.bg-blue-50,
html.dark #signModal button.bg-blue-50 {
  background-color: rgba(30, 58, 138, 0.35) !important;
  border-color: rgba(37, 99, 235, 0.5) !important;
  color: #93c5fd !important;
}

html.dark #genericToolModal button.bg-blue-50:hover,
html.dark #signModal button.bg-blue-50:hover {
  background-color: rgba(30, 58, 138, 0.55) !important;
}

html.dark #genericCloseBtn,
html.dark #signCloseBtn {
  color: #94a3b8;
}

html.dark #genericCloseBtn:hover,
html.dark #signCloseBtn:hover {
  color: #f8fafc;
  background-color: #1e293b;
}

html.dark #signViewport {
  box-shadow: 0 4px 25px rgba(0, 0, 0, 0.6);
  border: 1px solid #334155;
}

html.dark #signLoadingOverlay {
  background-color: rgba(15, 23, 42, 0.85) !important;
}

html.dark #signLoadingText {
  color: #f8fafc !important;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

html.dark ::-webkit-scrollbar-track {
  background: #0f172a;
}
html.dark ::-webkit-scrollbar-thumb {
  background: #334155;
}
html.dark ::-webkit-scrollbar-thumb:hover {
  background: #475569;
}

/* Category Filter Pills (Modern SaaS Pill Design) */
.cat-pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  background-color: #ffffff;
  color: #334155;
  border: 1.5px solid #cbd5e1;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}
.cat-pill-btn:hover {
  background-color: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}
.cat-pill-btn.active {
  background-color: #0f172a !important;
  color: #ffffff !important;
  border-color: #0f172a !important;
  box-shadow: 0 4px 12px -2px rgba(15, 23, 42, 0.3) !important;
}

/* Dark Mode Category Pills */
html.dark .cat-pill-btn {
  background-color: rgba(30, 41, 59, 0.7);
  color: #cbd5e1;
  border: 1px solid rgba(51, 65, 85, 0.8);
  box-shadow: none;
}
html.dark .cat-pill-btn:hover {
  background-color: rgba(51, 65, 85, 0.85);
  color: #ffffff;
  border-color: #64748b;
}
html.dark .cat-pill-btn.active {
  background-color: #2563eb !important;
  color: #ffffff !important;
  border-color: #3b82f6 !important;
  box-shadow: 0 4px 14px -2px rgba(37, 99, 235, 0.5) !important;
}

/* Hide horizontal scrollbar for pills while preserving smooth touch scrolling */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Responsive Grid Columns: 6 Columns on Desktop/Laptop (>=960px) */
@media (min-width: 960px) {
  #toolsGrid {
    display: grid !important;
    grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
    gap: 0.75rem !important;
  }
}
@media (min-width: 680px) and (max-width: 959px) {
  #toolsGrid {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 0.625rem !important;
  }
}
@media (min-width: 480px) and (max-width: 679px) {
  #toolsGrid {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 0.5rem !important;
  }
}
@media (max-width: 479px) {
  #toolsGrid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.5rem !important;
  }
}
/* Color-coded Icon Badges matching SaaS standard */
.tool-icon-box {
  width: 2.75rem !important;
  height: 2.75rem !important;
  border-radius: 0.75rem !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05) !important;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
  flex-shrink: 0 !important;
}
.group:hover .tool-icon-box {
  transform: scale(1.1) !important;
}

.icon-box-rose    { background-color: #fff1f2 !important; border: 1px solid #fecdd3 !important; color: #e11d48 !important; }
.icon-box-orange  { background-color: #fff7ed !important; border: 1px solid #fed7aa !important; color: #ea580c !important; }
.icon-box-emerald { background-color: #f0fdf4 !important; border: 1px solid #bbf7d0 !important; color: #16a34a !important; }
.icon-box-blue    { background-color: #eff6ff !important; border: 1px solid #bfdbfe !important; color: #2563eb !important; }
.icon-box-indigo  { background-color: #eef2ff !important; border: 1px solid #c7d2fe !important; color: #4f46e5 !important; }
.icon-box-purple  { background-color: #faf5ff !important; border: 1px solid #e9d5ff !important; color: #9333ea !important; }
.icon-box-amber   { background-color: #fffbeb !important; border: 1px solid #fde68a !important; color: #d97706 !important; }
.icon-box-cyan    { background-color: #ecfeff !important; border: 1px solid #a5f3fc !important; color: #0891b2 !important; }
.icon-box-teal    { background-color: #f0fdfa !important; border: 1px solid #99f6e4 !important; color: #0d9488 !important; }
.icon-box-slate   { background-color: #f8fafc !important; border: 1px solid #cbd5e1 !important; color: #475569 !important; }

/* Dark mode icon badges */
html.dark .icon-box-rose    { background-color: rgba(136, 19, 55, 0.35) !important; border-color: rgba(244, 63, 94, 0.4) !important; color: #fb7185 !important; }
html.dark .icon-box-orange  { background-color: rgba(124, 45, 18, 0.35) !important; border-color: rgba(251, 146, 60, 0.4) !important; color: #fb923c !important; }
html.dark .icon-box-emerald { background-color: rgba(6, 78, 59, 0.35) !important; border-color: rgba(52, 211, 153, 0.4) !important; color: #34d399 !important; }
html.dark .icon-box-blue    { background-color: rgba(30, 58, 138, 0.35) !important; border-color: rgba(96, 165, 250, 0.4) !important; color: #60a5fa !important; }
html.dark .icon-box-indigo  { background-color: rgba(49, 46, 129, 0.35) !important; border-color: rgba(129, 140, 248, 0.4) !important; color: #818cf8 !important; }
html.dark .icon-box-purple  { background-color: rgba(88, 28, 135, 0.35) !important; border-color: rgba(192, 132, 252, 0.4) !important; color: #c084fc !important; }
html.dark .icon-box-amber   { background-color: rgba(120, 53, 15, 0.35) !important; border-color: rgba(251, 191, 36, 0.4) !important; color: #fbbf24 !important; }
html.dark .icon-box-cyan    { background-color: rgba(22, 78, 99, 0.35) !important; border-color: rgba(34, 211, 238, 0.4) !important; color: #22d3ee !important; }
html.dark .icon-box-teal    { background-color: rgba(19, 78, 74, 0.35) !important; border-color: rgba(45, 212, 191, 0.4) !important; color: #2dd4bf !important; }
html.dark .icon-box-slate   { background-color: rgba(30, 41, 59, 0.6) !important; border-color: rgba(100, 116, 139, 0.4) !important; color: #94a3b8 !important; }

/* Batch Processing & Live Progress Engine */
.bg-batch-pill {
  background: linear-gradient(135deg, #2563eb, #4f46e5) !important;
  color: #ffffff !important;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.25) !important;
}

.bg-batch-btn {
  background: linear-gradient(135deg, #2563eb, #4f46e5) !important;
  color: #ffffff !important;
  padding: 0.75rem 1.5rem !important;
  border: 1px solid rgba(147, 197, 253, 0.25) !important;
  border-radius: 0.875rem !important;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.35) !important;
  outline: none !important;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease !important;
}
.bg-batch-btn:hover {
  background: linear-gradient(135deg, #1d4ed8, #4338ca) !important;
  box-shadow: 0 8px 22px rgba(37, 99, 235, 0.48) !important;
  transform: translateY(-1px) !important;
}
.bg-batch-btn:focus-visible {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.45), 0 6px 18px rgba(37, 99, 235, 0.35) !important;
}

.bg-batch-bar {
  background: linear-gradient(90deg, #2563eb, #6366f1, #10b981) !important;
}

.custom-scrollbar::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
.custom-scrollbar::-webkit-scrollbar-track {
  background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 9999px;
}
html.dark .custom-scrollbar::-webkit-scrollbar-thumb {
  background: #475569;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}
html.dark .custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

@keyframes pulse-subtle {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.85; transform: scale(1.02); }
}
.batch-active-pulse {
  animation: pulse-subtle 2s infinite ease-in-out;
}

/* Camera & Smart Crop Studio */
#genericToolModal > div {
  max-height: 92vh !important;
  max-height: 92dvh !important;
}
#genericModalBody {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
}
#cameraBox {
  background-color: #0f172a !important;
}
#scanVideo {
  width: 100% !important;
  max-height: 38vh !important;
  max-height: 38dvh !important;
  object-fit: contain !important;
  background-color: #000000 !important;
}
#switchCamBtn {
  background-color: #334155 !important;
  color: #ffffff !important;
}
#switchCamBtn:hover {
  background-color: #475569 !important;
}
#stopCameraBtn {
  background-color: #475569 !important;
  color: #ffffff !important;
  border: 1px solid rgba(148, 163, 184, 0.35) !important;
}
#stopCameraBtn:hover {
  background-color: #64748b !important;
}
#scanCamButtons,
#scActionButtons {
  grid-template-columns: minmax(0, 1fr);
}
#scQuickTools {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
@media (min-width: 640px) {
  #scanCamButtons,
  #scActionButtons {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
html.dark #nativeCamBtn {
  background-color: rgba(6, 78, 59, 0.35) !important;
  border-color: rgba(16, 185, 129, 0.45) !important;
  color: #34d399 !important;
}
html.dark #nativeCamBtn:hover {
  background-color: rgba(6, 78, 59, 0.55) !important;
}
html.dark #scAutoBtn {
  border-color: rgba(37, 99, 235, 0.5) !important;
}
#scAddPageBtn {
  background-color: #eff6ff !important;
  color: #1d4ed8 !important;
  border-color: #93c5fd !important;
}
#scAddPageBtn:hover {
  background-color: #dbeafe !important;
}
html.dark #scAddPageBtn {
  background-color: #1e293b !important;
  color: #60a5fa !important;
  border-color: rgba(59, 130, 246, 0.5) !important;
}
html.dark #scAddPageBtn:hover {
  background-color: rgba(30, 58, 138, 0.55) !important;
}

