/* ============================================================
   sign-pdf.css
   Tool-specific styles for the Sign PDF page.
   Site-level styles come from assets/css/styles.css
   ============================================================ */

:root {
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-light: #eff6ff;
  --green: #10b981;
  --green-dark: #059669;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-2: #64748b;
  --text-3: #94a3b8;
  --radius: 12px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow: 0 4px 16px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.05);
  --shadow-lg: 0 20px 60px rgba(0,0,0,.12), 0 8px 24px rgba(0,0,0,.08);
}

/* ============================================================
   SEO CONTENT SECTIONS
   ============================================================ */
.content-section {
  margin: 3rem auto;
  padding: 2.5rem;
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.07);
  border: 1px solid #e2e8f0;
  max-width: 1100px;
  width: 100%;
  box-sizing: border-box;
}

.content-section h2 {
  color: #2d3748;
  border-bottom: 2px solid #4a7bff;
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
  font-size: 1.75rem;
  font-family: 'Syne', sans-serif;
  font-weight: 800;
}

.content-section h3 {
  color: #2d3748;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  margin: 1.5rem 0 0.75rem;
}

.content-section p {
  color: #4a5568;
  line-height: 1.75;
  margin-bottom: 1rem;
  font-size: 0.97rem;
}

.content-section ul {
  color: #4a5568;
  line-height: 1.75;
  margin-bottom: 1rem;
  padding-left: 1.5rem;
  font-size: 0.97rem;
}

.content-section ul li { margin-bottom: 4px; }

/* ---- Feature Grid ---- */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.feature-card {
  background: #f8f9fa;
  padding: 20px;
  border-radius: 10px;
  border-left: 4px solid #4a7bff;
}

.feature-card strong {
  display: block;
  margin-bottom: 8px;
  color: #2d3748;
}

.feature-card p {
  color: #4a5568;
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.5;
}

/* ---- FAQ ---- */
.faq-item {
  margin-bottom: 20px;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 20px;
}

.faq-item:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.faq-question {
  font-weight: 600;
  color: #2d3748;
  margin-bottom: 8px;
  font-size: 1.05rem;
}

.faq-answer {
  color: #4a5568;
  line-height: 1.7;
  font-size: 0.97rem;
}

/* ============================================================
   RELATED TOOLS SECTION
   ============================================================ */
.related-tools-section {
  margin: 3rem auto;
  padding: 2rem;
  background: #f7fafc;
  border-radius: 12px;
  border: 2px solid #e2e8f0;
  max-width: 1100px;
  width: 100%;
  box-sizing: border-box;
}

.related-tools-section h3 {
  text-align: center;
  color: #2d3748;
  margin-bottom: 1.5rem;
  font-size: 1.5rem;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
}

.related-tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  justify-items: center;
}

.related-tool-btn {
  padding: 1rem 2rem;
  font-size: 1rem;
  font-weight: 600;
  background: linear-gradient(135deg, #4299e1, #2b6cb0);
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 6px 16px rgba(66, 153, 225, 0.4);
  text-decoration: none;
  width: 100%;
  max-width: 250px;
  text-align: center;
}

.related-tool-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(66, 153, 225, 0.5);
}

/* ============================================================
   TOOL WORKING AREA
   ============================================================ */
.app-container { margin: 0 0 2rem 0; }

/* ---- Upload Zone ---- */
#upload-zone {
  background: white;
  border: 2px dashed #c7d2fe;
  border-radius: var(--radius-lg);
  padding: 64px 40px;
  text-align: center;
  cursor: pointer;
  transition: all .25s ease;
  position: relative;
  overflow: hidden;
}

#upload-zone::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(37,99,235,.03), rgba(124,58,237,.03));
  opacity: 0;
  transition: opacity .25s;
}

#upload-zone:hover,
#upload-zone.drag-over { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(37,99,235,.08); }

#upload-zone:hover::before,
#upload-zone.drag-over::before { opacity: 1; }

#upload-zone.drag-over { background: #eff6ff; }

.upload-icon {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  transition: transform .25s;
}

#upload-zone:hover .upload-icon { transform: scale(1.05) translateY(-2px); }

.upload-icon svg { width: 38px; height: 38px; color: var(--blue); }

.upload-title {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 20px;
  color: var(--text);
  margin-bottom: 8px;
}

.upload-sub { color: var(--text-2); font-size: 14px; margin-bottom: 24px; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .2s ease;
  text-decoration: none;
  font-family: 'DM Sans', sans-serif;
}

.btn-primary {
  background: linear-gradient(135deg, var(--blue), #7c3aed);
  color: white;
  box-shadow: 0 4px 14px rgba(37,99,235,.35);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(37,99,235,.45); }
.btn-primary:active { transform: translateY(0); }

.btn-success {
  background: linear-gradient(135deg, var(--green), #059669);
  color: white;
  box-shadow: 0 4px 14px rgba(16,185,129,.3);
}
.btn-success:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(16,185,129,.4); }

.btn-outline {
  background: white;
  color: var(--text);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.btn-outline:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-light); }

.btn-sm { padding: 8px 16px; font-size: 13px; }

.btn-danger { background: #fef2f2; color: #dc2626; border: 1.5px solid #fecaca; }
.btn-danger:hover { background: #fee2e2; }

#file-input { display: none; }

/* ---- Workspace ---- */
#workspace { display: none; }

.workspace-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 24px;
  align-items: start;
}

/* ---- Sidebar ---- */
.sidebar {
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  position: sticky;
  top: 88px;
}

.sidebar-header { padding: 20px 24px 0; }

.sidebar-title {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  margin-bottom: 16px;
}

/* ---- Tabs ---- */
.tabs {
  display: flex;
  background: var(--bg);
  border-radius: 10px;
  padding: 4px;
  gap: 2px;
}

.tab-btn {
  flex: 1;
  padding: 9px 10px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-2);
  transition: all .2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  white-space: nowrap;
}

.tab-btn.active { background: white; color: var(--blue); box-shadow: var(--shadow-sm); }
.tab-btn svg { width: 14px; height: 14px; }

.tab-content { display: none; padding: 20px 24px 24px; }
.tab-content.active { display: block; }

/* ---- Form Elements ---- */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  font-family: 'DM Sans', sans-serif;
  color: var(--text);
  transition: border-color .2s;
  outline: none;
  background: white;
}
.form-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }

.font-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.font-option {
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
  font-size: 20px;
  transition: all .2s;
  background: white;
  color: var(--text);
  line-height: 1.3;
}
.font-option:hover { border-color: var(--blue); background: var(--blue-light); }
.font-option.selected { border-color: var(--blue); background: var(--blue-light); }

.color-row { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }

.color-swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: all .2s;
  outline: none;
}
.color-swatch.selected,
.color-swatch:hover { border-color: var(--text); transform: scale(1.15); }

.sig-preview {
  background: linear-gradient(135deg, #f8fafc, #f1f5f9);
  border: 1px solid var(--border);
  border-radius: 10px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  color: #1e293b;
  overflow: hidden;
  margin-bottom: 16px;
  padding: 8px;
}

/* ---- Draw Canvas ---- */
#draw-canvas-wrap {
  position: relative;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: white;
  cursor: crosshair;
  margin-bottom: 12px;
}

#draw-canvas { display: block; touch-action: none; }

.draw-actions { display: flex; gap: 8px; margin-bottom: 16px; }

/* ---- Upload Sig Zone ---- */
.upload-sig-zone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  margin-bottom: 16px;
}
.upload-sig-zone:hover { border-color: var(--blue); background: var(--blue-light); }
.upload-sig-zone p { font-size: 13px; color: var(--text-2); margin-top: 8px; }

#sig-img-preview {
  max-width: 100%;
  max-height: 100px;
  display: none;
  border-radius: 8px;
  margin: 0 auto 12px;
}

/* ---- Sidebar footer ---- */
.sig-sep { border: none; border-top: 1px solid var(--border); margin: 0; }
.apply-btn-wrap { padding: 0 24px 20px; }

/* ---- PDF Panel ---- */
.pdf-panel {
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.pdf-toolbar {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: white;
}

.toolbar-left,
.toolbar-right { display: flex; align-items: center; gap: 8px; }

.pdf-info { font-size: 13px; color: var(--text-2); font-weight: 500; }

.page-nav { display: flex; align-items: center; gap: 8px; }

.page-btn {
  width: 32px;
  height: 32px;
  border: 1.5px solid var(--border);
  background: white;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  transition: all .2s;
  font-family: 'DM Sans', sans-serif;
}
.page-btn:hover:not(:disabled) { border-color: var(--blue); color: var(--blue); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

.page-num { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; }

.pdf-canvas-wrap {
  padding: 24px;
  min-height: 500px;
  background: #f1f5f9;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  position: relative;
  overflow: auto;
}

#pdf-render-canvas {
  box-shadow: var(--shadow-lg);
  border-radius: 4px;
  display: block;
  max-width: 100%;
}

/* ---- Signature Overlay ---- */
#sig-overlay {
  position: absolute;
  cursor: grab;
  user-select: none;
  touch-action: none;
}
#sig-overlay:active { cursor: grabbing; }
#sig-overlay img,
#sig-overlay canvas { display: block; width: 100%; height: 100%; }

.resize-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: white;
  border: 2px solid var(--blue);
  border-radius: 50%;
  z-index: 10;
}
.resize-handle.br { bottom: -6px; right: -6px;  cursor: se-resize; }
.resize-handle.bl { bottom: -6px; left: -6px;   cursor: sw-resize; }
.resize-handle.tr { top: -6px;    right: -6px;  cursor: ne-resize; }
.resize-handle.tl { top: -6px;    left: -6px;   cursor: nw-resize; }

.rotate-handle {
  position: absolute;
  top: -32px;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 24px;
  background: var(--blue);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.rotate-handle svg { width: 12px; height: 12px; fill: white; }

.overlay-border {
  position: absolute;
  inset: -2px;
  border: 2px dashed var(--blue);
  border-radius: 4px;
  pointer-events: none;
}

.instruction-bar {
  padding: 12px 20px;
  background: linear-gradient(135deg, #eff6ff, #f0fdf4);
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-2);
  text-align: center;
}

.upload-another { display: flex; align-items: center; gap: 8px; }

/* ---- Spinner ---- */
.tool-spinner {
  display: none;
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: toolSpin .8s linear infinite;
  margin: 60px auto;
}
@keyframes toolSpin { to { transform: rotate(360deg); } }

/* ---- Toast ---- */
#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text);
  color: white;
  padding: 14px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  z-index: 9999;
  transform: translateY(80px);
  opacity: 0;
  transition: all .3s cubic-bezier(.34,1.56,.64,1);
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  max-width: 320px;
}
#toast.show  { transform: translateY(0); opacity: 1; }
#toast.success { background: var(--green-dark); }
#toast.error   { background: #dc2626; }

/* ---- Fade in ---- */
.fade-in { animation: fadeIn .35s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 940px) {
  .content-section,
  .related-tools-section { margin-left: 1rem; margin-right: 1rem; width: calc(100% - 2rem); }
}

@media (max-width: 900px) {
  .workspace-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .content-section  { padding: 1.5rem; margin: 2rem 1rem; width: calc(100% - 2rem); }
  .related-tools-section { padding: 1.5rem; margin: 2rem 1rem; width: calc(100% - 2rem); }
  .related-tools-grid { grid-template-columns: 1fr; max-width: 400px; margin: 0 auto; }
  .related-tool-btn { max-width: 100%; }
  .feature-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .pdf-toolbar { flex-direction: column; align-items: flex-start; }
  .toolbar-right { width: 100%; justify-content: flex-end; }
  #upload-zone { padding: 40px 20px; }
}

@media (max-width: 480px) {
  .content-section,
  .related-tools-section { margin-left: 0.5rem; margin-right: 0.5rem; width: calc(100% - 1rem); padding: 1rem; }
}