/* =========================================================
   स्वप्रमाणित घोषणा-पत्र - Core Stylesheet
   ========================================================= */

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #16a34a;
  --success-hover: #15803d;
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;
  --ink-blue: #000080;
  --shadow-sheet: 0 10px 30px rgba(0, 0, 0, 0.25), 0 1px 4px rgba(0, 0, 0, 0.15);
}

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

body {
  font-family: 'Poppins', 'Hind', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: #0f172a;
  color: var(--slate-800);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* App Header */
.app-header {
  background: #ffffff;
  border-bottom: 1px solid var(--slate-200);
  padding: 10px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 50;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  font-size: 26px;
  background: var(--primary-light);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid #bfdbfe;
}

.brand-text h1 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--slate-900);
  line-height: 1.2;
}

.brand-text p {
  font-size: 0.775rem;
  color: var(--slate-600);
}

.header-actions {
  display: flex;
  gap: 10px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}
.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-success {
  background: var(--success);
  color: #ffffff;
}
.btn-success:hover {
  background: var(--success-hover);
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.3);
}

.btn-secondary {
  background: var(--slate-100);
  color: var(--slate-800);
  border: 1px solid var(--slate-300);
}
.btn-secondary:hover {
  background: var(--slate-200);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--primary);
  color: var(--primary);
}
.btn-outline:hover {
  background: var(--primary-light);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.8rem;
}

/* Layout Workspace */
.workspace-container {
  display: flex;
  flex: 1;
  height: calc(100vh - 65px);
  overflow: hidden;
}

/* Left Sidebar Controls */
.control-panel {
  width: 460px;
  min-width: 420px;
  background: #ffffff;
  border-right: 1px solid var(--slate-200);
  overflow-y: auto;
  padding: 18px;
}

.panel-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Transliteration Feature Bar */
.translit-bar {
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
  border: 1.5px solid #86efac;
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  transition: all 0.2s ease;
}

.translit-bar.disabled {
  background: #f8fafc;
  border-color: var(--slate-300);
  opacity: 0.85;
}

.translit-toggle-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.translit-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.translit-title {
  font-size: 0.84rem;
  color: #15803d;
}

.translit-bar.disabled .translit-title {
  color: var(--slate-700);
}

.translit-desc {
  font-size: 0.72rem;
  color: #166534;
}

.translit-bar.disabled .translit-desc {
  color: var(--slate-600);
}

.translit-desc code {
  background: rgba(0, 0, 0, 0.06);
  padding: 1px 4px;
  border-radius: 4px;
  font-family: monospace;
}

.kbd-hint {
  font-size: 0.7rem;
  font-weight: 600;
  background: #ffffff;
  border: 1px solid #bbf7d0;
  color: #15803d;
  padding: 3px 6px;
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  white-space: nowrap;
}

.translit-bar.disabled .kbd-hint {
  border-color: var(--slate-300);
  color: var(--slate-600);
}

/* Switch styling */
.switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider.round {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  transition: .25s;
  border-radius: 24px;
}

.slider.round:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .25s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

input:checked + .slider.round {
  background-color: #16a34a;
}

input:checked + .slider.round:before {
  transform: translateX(16px);
}

/* Floating Transliteration Suggestion Popup */
.translit-popup {
  position: absolute;
  background: #ffffff;
  border: 1.5px solid var(--primary);
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: row;
  gap: 4px;
  padding: 6px;
  z-index: 99999;
  font-family: 'Hind', sans-serif;
  animation: fadeInPop 0.12s ease-out;
}

@keyframes fadeInPop {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.translit-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 9px;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  background: #f8fafc;
  color: var(--slate-900);
  transition: all 0.1s;
  white-space: nowrap;
}

.translit-item:hover, .translit-item.selected {
  background: var(--primary);
  color: #ffffff;
}

.translit-item .item-num {
  font-size: 0.7rem;
  opacity: 0.7;
}


.card-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #1e3a8a;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary-light);
}

/* Form Groups & Inputs */
.form-group {
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-row {
  display: flex;
  gap: 10px;
}

.flex-1 {
  flex: 1;
}

label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--slate-700);
}

.required {
  color: #dc2626;
}

input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 8px 12px;
  font-size: 0.88rem;
  font-family: 'Hind', 'Poppins', sans-serif;
  border: 1px solid var(--slate-300);
  border-radius: 6px;
  background: var(--slate-50);
  color: var(--slate-900);
  transition: all 0.15s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

textarea {
  resize: vertical;
}

/* Signature System Container */
.signature-box {
  background: #f8fafc;
  border: 1px solid var(--slate-300);
  border-radius: 10px;
  padding: 12px;
  margin-top: 6px;
}

.sig-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.sig-header h4 {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--slate-900);
  display: flex;
  align-items: center;
  gap: 6px;
}

.badge-tag {
  font-size: 0.68rem;
  background: #e0e7ff;
  color: #3730a3;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.sig-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--slate-200);
  margin-bottom: 10px;
}

.tab-btn {
  background: none;
  border: none;
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--slate-600);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  border-radius: 4px 4px 0 0;
  transition: all 0.15s;
  font-family: inherit;
}

.tab-btn:hover {
  color: var(--primary);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom: 2px solid var(--primary);
  background: #eff6ff;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.label-with-hint {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hint-text {
  font-size: 0.72rem;
  color: var(--slate-600);
  font-weight: 400;
}

/* Signature Tuning Bar (Thickness & Size) */
.sig-tune-bar {
  display: flex;
  gap: 10px;
  background: #ffffff;
  border: 1px solid var(--slate-200);
  border-radius: 6px;
  padding: 6px 10px;
  margin-bottom: 8px;
}

.tune-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.tune-item label {
  font-size: 0.72rem;
  color: var(--slate-600);
  display: flex;
  justify-content: space-between;
}

.compact-select {
  padding: 4px 6px !important;
  font-size: 0.78rem !important;
  height: 28px;
  background: var(--slate-50);
}

.compact-range {
  height: 18px;
}

.pen-tips {
  display: flex;
  gap: 4px;
}

.tip-pill {
  font-size: 0.72rem;
  padding: 2px 6px;
  border: 1px solid var(--slate-300);
  border-radius: 4px;
  cursor: pointer;
  background: #ffffff;
  color: var(--slate-700);
  transition: all 0.15s;
  user-select: none;
}

.tip-pill.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

/* Auto Signature Grid */
.auto-sig-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  max-height: 190px;
  overflow-y: auto;
  padding: 2px;
}

.sig-choice-card {
  background: #ffffff;
  border: 1.5px solid var(--slate-200);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60px;
  text-align: center;
}

.sig-choice-card:hover {
  border-color: #93c5fd;
  transform: translateY(-1px);
}

.sig-choice-card.selected {
  border-color: var(--primary);
  background: #f0f7ff;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.sig-choice-card .sig-sample {
  font-size: 1.35rem;
  color: var(--ink-blue);
  line-height: 1.1;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sig-choice-card .sig-label {
  font-size: 0.65rem;
  color: var(--slate-600);
  margin-top: 4px;
}

/* Upload Signature Area */
.upload-zone {
  border: 2px dashed var(--slate-300);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  background: #ffffff;
  cursor: pointer;
  transition: all 0.15s;
}

.upload-zone:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.upload-icon {
  font-size: 26px;
  margin-bottom: 4px;
}

.upload-zone p {
  font-size: 0.85rem;
  color: var(--slate-800);
}

.upload-zone span {
  font-size: 0.72rem;
  color: var(--slate-600);
}

.upload-controls {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.slider-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.8rem;
}

.slider-row input[type="range"] {
  flex: 1;
}

/* Draw Signature Area */
.draw-zone {
  background: #ffffff;
  border: 1px solid var(--slate-300);
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.canvas-box {
  width: 100%;
  height: 120px;
  background: #fbfbfb;
  border: 1px dashed var(--slate-200);
  border-radius: 4px;
  overflow: hidden;
}

#sigCanvas {
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

.canvas-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ink-colors {
  display: flex;
  gap: 6px;
  align-items: center;
}

.color-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1px var(--slate-300);
  transition: transform 0.15s;
}

.color-dot.active {
  box-shadow: 0 0 0 2px var(--primary);
  transform: scale(1.15);
}

.canvas-btn-group {
  display: flex;
  gap: 6px;
}

/* Current Signature Status */
.current-sig-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--slate-300);
  font-size: 0.8rem;
}

.sig-status-preview {
  max-width: 140px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sig-status-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.empty-hint {
  font-size: 0.72rem;
  color: var(--slate-600);
}

.btn-clear-sig {
  background: none;
  border: none;
  color: #dc2626;
  font-size: 0.78rem;
  cursor: pointer;
  font-weight: 600;
}

.btn-clear-sig:hover {
  text-decoration: underline;
}

/* Appearance Options */
.appearance-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: 8px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  cursor: pointer;
  user-select: none;
}

/* =========================================================
   Right Panel: Document Live Preview & A4 Sheet
   ========================================================= */

.preview-area {
  flex: 1;
  background: #334155;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 20px 40px;
}

.preview-toolbar {
  width: 100%;
  max-width: 210mm;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  color: #ffffff;
}

.preview-title {
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.preview-instructions {
  font-size: 0.78rem;
  color: #cbd5e1;
}

.page-viewport {
  display: flex;
  justify-content: center;
  width: 100%;
}

/* The Authentic Official A4 Sheet Replica */
.a4-sheet {
  width: 210mm;
  min-height: 297mm;
  background: #ffffff;
  padding: 24mm 22mm 24mm 22mm;
  box-shadow: var(--shadow-sheet);
  font-family: 'Noto Serif Devanagari', 'Hind', serif;
  color: #000000;
  position: relative;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

/* Header Section */
.doc-header {
  text-align: center;
  margin-bottom: 34px;
}

.doc-subhead {
  font-size: 15.5px;
  font-weight: 600;
  margin-bottom: 34px;
  letter-spacing: 0.2px;
}

.doc-subhead u {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.doc-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* Document Content Body */
.doc-content {
  font-size: 16.5px;
  line-height: 2.35;
  color: #000000;
  margin-bottom: 20px;
}

.doc-line {
  text-align: justify;
  letter-spacing: 0.2px;
}

.line-1 {
  margin-bottom: 0px;
}

.line-2 {
  margin-bottom: 0px;
}

.spacer-gap {
  display: inline-block;
  width: 24px;
}

/* Dynamic Field Spans */
.fill-field {
  display: inline;
  color: #000000;
  letter-spacing: 0.3px;
  transition: all 0.15s ease;
}

.fill-field.has-val {
  color: #0f172a;
}

body.bold-filled .fill-field.has-val {
  font-weight: 700;
}

body.underline-filled .fill-field.has-val {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Footer Section */
.doc-footer {
  margin-top: 100px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  font-size: 16.5px;
  line-height: 2.3;
}

.footer-col-left {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 40%;
}

.footer-col-right {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 58%;
  text-align: right;
}

.footer-item {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.footer-col-right .footer-item {
  justify-content: flex-end;
}

.sig-row {
  align-items: center;
  min-height: 60px;
}

.sig-target-container {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 140px;
  position: relative;
  vertical-align: middle;
}

.sig-img-element {
  max-height: 56px;
  max-width: 180px;
  object-fit: contain;
  display: inline-block;
  vertical-align: middle;
}

.sig-text-element {
  font-size: 21px;
  color: var(--ink-blue);
  display: inline-block;
  white-space: nowrap;
  vertical-align: middle;
  line-height: 1;
  font-weight: 300;
  letter-spacing: 0.5px;
}

/* =========================================================
   PRINT STYLING (Perfect A4 Output)
   ========================================================= */

@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  .no-print {
    display: none !important;
  }

  .workspace-container {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
  }

  .preview-area {
    background: transparent !important;
    padding: 0 !important;
    overflow: visible !important;
    display: block !important;
  }

  .page-viewport {
    display: block !important;
    width: 100% !important;
  }

  .a4-sheet {
    width: 100% !important;
    min-height: 100% !important;
    box-shadow: none !important;
    padding: 12mm 15mm !important;
    margin: 0 !important;
    page-break-after: avoid;
    page-break-inside: avoid;
  }

  @page {
    size: A4 portrait;
    margin: 10mm 15mm;
  }
}

/* Responsive adjustments */
@media (max-width: 1024px) {
  body {
    overflow-y: auto;
  }

  .workspace-container {
    flex-direction: column;
    height: auto;
    overflow: visible;
  }

  .control-panel {
    width: 100%;
    min-width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--slate-200);
  }

  .preview-area {
    padding: 16px 8px;
  }

  .a4-sheet {
    transform: scale(0.92);
    transform-origin: top center;
    margin-bottom: -30px;
  }
}

@media (max-width: 768px) {
  .app-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .header-actions {
    flex-wrap: wrap;
  }

  .header-actions .btn {
    flex: 1;
    justify-content: center;
  }

  .a4-sheet {
    transform: scale(0.68);
    transform-origin: top center;
    margin-bottom: -160px;
  }
}
