/* =============================================
   QForm Designer — Main Stylesheet
   ============================================= */

/* --- Design Tokens --- */
:root {
  --primary-color: #6366f1;
  --primary-hover: #4f46e5;
  --bg-color: #0f172a;
  --sidebar-bg: #1e293b;
  --sidebar-header-bg: #1e293b;
  --sidebar-text: #f8fafc;
  --sidebar-text-muted: #94a3b8;
  --accent-color: #38bdf8;
  --border-color: #334155;
  --input-bg: #0f172a;
  --card-bg: #0f172a;
  --danger-color: #f43f5e;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --paper-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --bubble-size: 18px;
  --question-gap: 5px;
  --sidebar-width: 340px;
}

/* --- Reset --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Inter", "Cairo", sans-serif;
  background-color: var(--bg-color);
  height: 100vh;
  overflow: hidden;
  display: flex;
}

body.rtl {
  direction: rtl;
  font-family: "Cairo", "Inter", sans-serif;
}

/* --- App Layout --- */
.app-container {
  display: flex;
  width: 100%;
  height: 100%;
  flex-direction: row;
}

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-color);
  flex-shrink: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
}

body.rtl .sidebar {
  border-right: none;
  border-left: 1px solid #334155;
}

.sidebar-header {
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--sidebar-header-bg);
  backdrop-filter: blur(8px);
}

/* --- Control Groups --- */
.control-group {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.control-group h2 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--sidebar-text-muted);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.control-group h2 svg {
  width: 18px;
  height: 18px;
  color: var(--primary-color);
}

.control-group label {
  display: block;
  margin-bottom: 1.25rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--sidebar-text-muted);
}

.control-group label:last-child {
  margin-bottom: 0;
}

/* --- Toggle Switch --- */
.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #334155;
  transition: .3s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--primary-color);
}

input:focus + .slider {
  box-shadow: 0 0 1px var(--primary-color);
}

input:checked + .slider:before {
  transform: translateX(18px);
}

/* --- Disabled/Dimmed State --- */
.disabled-dimmed {
  opacity: 0.45;
  pointer-events: none;
  filter: grayscale(0.8);
  transition: opacity 0.3s ease, filter 0.3s ease;
}

/* --- Group Header (toggle row layout) --- */
.group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  gap: 12px;
}

/* --- Form Inputs --- */
.control-group input[type="text"],
.control-group input[type="number"],
.control-group input[type="file"],
.control-group select,
.control-group textarea {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.625rem 0.875rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background-color: var(--input-bg);
  color: white;
  font-family: inherit;
  font-size: 0.875rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
}

.control-group input:focus,
.control-group select:focus,
.control-group textarea:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

/* --- Range Slider --- */
.control-group input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--border-color);
  border-radius: 5px;
  margin-top: 1rem;
  outline: none;
}

.control-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: var(--primary-color);
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.2s;
}

.control-group input[type="range"]::-webkit-slider-thumb:hover {
  background: var(--primary-hover);
}

/* --- Excel Import Tip Box --- */
.excel-tip {
  margin-top: 1rem;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.7);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  backdrop-filter: blur(4px);
}

.control-group textarea {
  resize: vertical;
  min-height: 80px;
}

/* --- Sidebar Footer --- */
.sidebar-footer {
  padding: 1.5rem;
  margin-top: auto;
  border-top: 1px solid #334155;
}

/* --- Buttons — Tier 1: Primary CTA --- */
.primary-btn {
  width: 100%;
  padding: 0.8rem 1rem;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: white;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.875rem;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}

.primary-btn:hover {
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
  transform: translateY(-1px);
}

.primary-btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(99, 102, 241, 0.2);
}

.primary-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* --- Buttons — Tier 2: Secondary / Utility --- */
.secondary-btn {
  padding: 0.6rem 0.875rem;
  background: rgba(255, 255, 255, 0.03);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 9px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.secondary-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.5;
  color: inherit;
  transition: all 0.25s ease;
}

.secondary-btn:hover {
  background: rgba(99, 102, 241, 0.05);
  border-color: rgba(99, 102, 241, 0.3);
  color: #fff;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.12);
}

.secondary-btn:hover svg {
  opacity: 0.9;
  color: var(--primary-color);
  transform: translateY(-0.5px);
}

.secondary-btn:active {
  background: rgba(99, 102, 241, 0.08);
  transform: scale(0.97);
  box-shadow: 0 0 4px rgba(99, 102, 241, 0.08);
}

/* --- Buttons — Tier 3: Section Add Buttons --- */
.buttons-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.section-add-btn {
  --btn-accent: #94a3b8;
  position: relative;
  padding: 0.55rem 0.5rem;
  background: rgba(255, 255, 255, 0.03);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 500;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

/* Accent bar on the start side */
.section-add-btn::before {
  content: '';
  position: absolute;
  top: 20%;
  bottom: 20%;
  width: 2.5px;
  border-radius: 2px;
  background: var(--btn-accent);
  opacity: 0.7;
  transition: opacity 0.2s ease, top 0.2s ease, bottom 0.2s ease;
}

/* LTR: accent on left */
body.ltr .section-add-btn::before,
.section-add-btn::before {
  left: 0;
  right: auto;
}

/* RTL: accent on right */
body.rtl .section-add-btn::before {
  right: 0;
  left: auto;
}

.section-add-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--btn-accent);
  opacity: 0.8;
  transition: opacity 0.2s ease;
}

.section-add-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: color-mix(in srgb, var(--btn-accent) 40%, transparent);
  color: #f1f5f9;
}

.section-add-btn:hover::before {
  opacity: 1;
  top: 10%;
  bottom: 10%;
}

.section-add-btn:hover svg {
  opacity: 1;
}

.section-add-btn:active {
  transform: scale(0.97);
}

/* --- Accent colors per type --- */
.section-add-btn.btn-mcq    { --btn-accent: #60a5fa; }
.section-add-btn.btn-tf     { --btn-accent: #34d399; }
.section-add-btn.btn-essay  { --btn-accent: #fbbf24; }
.section-add-btn.btn-testlet  { --btn-accent: #a78bfa; }
.section-add-btn.btn-matching { --btn-accent: #2dd4bf; }

/* --- Page button — full-width, dashed style --- */
.section-add-btn.btn-page {
  --btn-accent: #818cf8;
  grid-column: 1 / -1;
  margin-top: 2px;
  border-style: dashed;
  border-color: rgba(129, 140, 248, 0.3);
  background: transparent;
}

.section-add-btn.btn-page:hover {
  border-color: rgba(129, 140, 248, 0.55);
  background: rgba(99, 102, 241, 0.06);
}

/* --- Clear button — full-width, danger outline --- */
.section-add-btn.btn-clear {
  --btn-accent: #f87171;
  grid-column: 1 / -1;
  margin-top: 2px;
  border-color: rgba(248, 113, 113, 0.2);
  color: #fca5a5;
}

.section-add-btn.btn-clear:hover {
  border-color: rgba(248, 113, 113, 0.45);
  background: rgba(239, 68, 68, 0.08);
  color: #fca5a5;
}

/* Legacy compat — keep .danger-btn minimal */
.danger-btn {
  padding: 0.5rem;
  background-color: transparent;
  color: #fca5a5;
  border: 1px solid rgba(248, 113, 113, 0.25);
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s ease;
}

.danger-btn:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(248, 113, 113, 0.45);
}

/* --- Section Cards --- */
.section-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.25rem;
  position: relative;
  margin-bottom: 1rem;
  transition: all 0.2s ease;
}

.section-card:hover {
  border-color: var(--primary-color);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.sidebar-page-header {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--sidebar-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 1.5rem 0 0.75rem 0;
  margin-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.section-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
}

.section-card-header svg {
  width: 16px;
  height: 16px;
  color: var(--primary-color);
}

.remove-section-btn {
  background: none;
  border: none;
  color: #ef4444;
  font-size: 1.2rem;
  cursor: pointer;
  line-height: 1;
}

/* =============================================
   Preview Area — A4 Paper Rendering
   ============================================= */

.preview-area {
  flex-grow: 1;
  overflow: auto;
  padding: 2rem;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.paper-wrapper {
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* A4 sheet dimensions (210mm × 297mm) */
.a4-sheet {
  background: white;
  width: 210mm;
  min-height: 297mm;
  max-height: 297mm;
  padding: 10mm;
  box-shadow: var(--paper-shadow);
  position: relative;
  color: black;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* --- OMR Header --- */
.omr-header {
  display: flex;
  justify-content: space-between;
  border-bottom: 2px solid black;
  padding-bottom: 10px;
  margin-bottom: 10px;
  padding-left: 0;
}

.a4-sheet.rtl .omr-header {
  padding-left: 0;
  padding-right: 0;
}

/* --- Top Header Row --- */
.new-header-wrapper {
  display: flex;
  flex-direction: column;
  margin-bottom: 5px;
}

.top-header-row {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 5px;
  margin-bottom: 5px;
}

/* Institution and exam detail columns */
.header-inst-lines,
.header-exam-lines {
  display: flex;
  flex-direction: column;
  font-size: 13pt;
  font-weight: bold;
  line-height: 1.4;
  min-width: 170px;
}

.header-inst-lines {
  text-align: start;
}

.header-exam-lines {
  text-align: end;
}

/* Center barcode area */
.header-center-barcode {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

/* Attendance bubbles (absent / cheating) */
.attendance-bubbles {
  display: flex;
  justify-content: center;
  gap: 20px;
}

.attendance-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10pt;
  font-weight: bold;
}

.student-barcode {
  max-width: 250px;
  max-height: 60px;
}

/* Institution logo */
.header-logo {
  width: 120px;
  height: 120px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.header-logo img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* --- Student Info Table --- */
.student-info-table-container {
  width: 100%;
  margin-bottom: 5px;
}

.student-info-table {
  width: 100%;
  border-collapse: collapse;
  border: 2px solid black;
  font-size: 12pt;
  text-align: center;
  font-weight: bold;
}

.student-info-table td,
.student-info-table th {
  border: 2px solid black;
  padding: 8px;
}

.student-info-table .label-cell {
  background-color: #f3f4f6;
  width: 12%;
}

/* --- Signature Row --- */
.signature-row {
  display: flex;
  justify-content: space-between;
  width: 100%;
  margin-top: 15px;
  margin-bottom: 10px;
  font-size: 11pt;
  font-weight: bold;
}

.sig-box {
  display: flex;
  align-items: flex-end;
}

.omr-content {
  flex-grow: 1;
}

.sheet-body {
  display: block;
  width: 100%;
}

/* --- ID Grid Section --- */
.id-section {
  border: 2px solid black;
  padding: 10px;
  background: white;
  display: inline-block;
  width: auto;
  z-index: 10;
  position: relative;
}

/* ID grid position is controlled via JS float direction */

.student-name-container {
  width: 100%;
  margin-bottom: 20px;
  display: block;
}

#questionsContainerWrapper {
  display: block;
}

/* --- Questions Grid (flow layout for float-wrapping around ID section) --- */
.questions-grid {
  display: flow-root;
  font-size: 10pt;
  clear: none;
}

.question-column {
  float: right;
  vertical-align: top;
  box-sizing: border-box;
  margin-bottom: 5px;
}

body.ltr .question-column {
  float: left;
}

/* Section block container */
.section-block {
  display: block;
  margin-bottom: 15px;
  clear: none;
  position: relative;
  transition: outline 0.15s ease;
}

.section-block.interactive:hover {
  outline: 2px dashed #6366f1;
  outline-offset: 3px;
  border-radius: 4px;
}

/* Section overlay toolbar (screen only) */
.section-overlay-toolbar {
  position: absolute;
  top: -14px;
  right: 4px;
  display: flex;
  gap: 2px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 20;
}

body.rtl .section-overlay-toolbar {
  right: auto;
  left: 4px;
}

.section-block.interactive:hover .section-overlay-toolbar,
.section-block.active-toolbar .section-overlay-toolbar {
  opacity: 1;
  pointer-events: auto;
}

.section-block.active-toolbar {
  outline: 2px dashed #6366f1;
  outline-offset: 3px;
  border-radius: 4px;
}

.section-overlay-toolbar button {
  width: 26px;
  height: 26px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: white;
  color: #475569;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
  transition: all 0.15s ease;
  padding: 0;
}

.section-overlay-toolbar button:hover {
  background: #6366f1;
  color: white;
  border-color: #6366f1;
}

.section-overlay-toolbar button.danger-overlay:hover {
  background: #ef4444;
  border-color: #ef4444;
}

/* Inline counter controls */
.overlay-counter-group {
  display: flex;
  align-items: center;
  gap: 1px;
  background: white;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
  height: 26px;
}

.overlay-counter-label {
  font-size: 9px;
  font-weight: 600;
  padding: 0 5px;
  color: #64748b;
  white-space: nowrap;
  user-select: none;
  background: #f8fafc;
  height: 100%;
  display: flex;
  align-items: center;
  border-right: 1px solid #e2e8f0;
}

body.rtl .overlay-counter-label {
  border-right: none;
  border-left: 1px solid #e2e8f0;
}

.overlay-counter-btn {
  width: 22px;
  height: 100%;
  border: none;
  background: white;
  color: #475569;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  transition: background 0.15s;
  padding: 0;
}

.overlay-counter-btn:hover {
  background: #6366f1;
  color: white;
}

.overlay-counter-value {
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  text-align: center;
  color: #1e293b;
  user-select: none;
  padding: 0 2px;
}

.overlay-separator {
  width: 1px;
  height: 18px;
  background: #e2e8f0;
  margin: 0 2px;
}

.section-header {
  border-bottom: 1px solid #000;
  margin-top: 15px;
  margin-bottom: 8px;
  padding-bottom: 2px;
  font-size: 11pt;
  font-weight: bold;
  color: #000;
  width: auto;
  display: block;
  clear: none;
}

/* Editable section header (screen only) */
.section-header.editable-header {
  cursor: text;
  transition: outline 0.15s ease, background 0.15s ease;
  outline: 2px solid transparent;
  outline-offset: 2px;
  border-radius: 2px;
  padding: 2px 4px;
}

.section-header.editable-header:hover {
  outline: 1px dashed #94a3b8;
}

.section-header.editable-header:focus {
  outline: 2px solid #6366f1;
  background: #f0f0ff;
}

body.ltr .section-header {
  clear: none;
}

/* Essay question rows */
.question-row.essay {
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  margin-bottom: 10px;
}

.essay-lines {
  width: 100%;
  margin-top: 5px;
}

.essay-line {
  border-bottom: 1px solid black;
  height: 8mm;
  width: 100%;
}

/* --- Matching Question Table --- */
.matching-section {
  width: 100%;
  margin-bottom: 5px;
}

.matching-table {
  width: auto;
  border-collapse: collapse;
  font-size: 10pt;
  margin: 0 auto;
  border: 1px solid #000;
}

.matching-table th {
  font-weight: bold;
  font-size: 10pt;
  background: #f3f4f6;
  border: 1px solid #000;
  padding: 3px 8px;
  text-align: center;
}

.matching-table td {
  padding: 3px 8px;
  text-align: center;
  vertical-align: middle;
  border: none;
}

.matching-table td.matching-num {
  font-weight: bold;
  min-width: 30px;
  background: #f9fafb;
  border: 1px solid #000;
}

/* Standard question row */
.question-row {
  display: flex;
  align-items: center;
  margin-bottom: var(--question-gap);
  gap: 10px;
  box-sizing: border-box;
  padding-right: 5px;
  break-inside: avoid;
  width: 100%;
}

/* --- Bubble Styles --- */
.bubble {
  width: var(--bubble-size) !important;
  height: var(--bubble-size) !important;
}

.bubble-sm {
  width: var(--bubble-size) !important;
  height: var(--bubble-size) !important;
  margin-bottom: var(--question-gap) !important;
  border-radius: 50%;
  border: 1px solid black;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 0.5em;
}

/* --- Text Wrapping --- */
#displayInstructions {
  white-space: pre-wrap;
  font-size: 0.9rem;
}

/* Override: center-align header text columns */
.header-inst-lines,
.header-exam-lines {
  text-align: center;
}

/* Timing marks (currently disabled) */
.timing-marks-left {
  display: none;
}

/* =============================================
   Mobile Responsive
   ============================================= */

.mobile-header {
  display: none;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background-color: var(--sidebar-bg);
  border-bottom: 1px solid #334155;
  color: white;
  z-index: 900;
}

.mobile-logo {
  height: 32px;
  filter: brightness(0) invert(1);
}

.hamburger-btn {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
}

.sidebar-overlay.active {
  display: block;
}

@media screen and (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }

  .mobile-header {
    display: flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    width: 320px;
    max-width: 85%;
    z-index: 1000;
    transition: transform 0.3s ease;
  }

  /* LTR slide-in from left */
  body:not(.rtl) .sidebar {
    left: 0;
    transform: translateX(-100%);
  }

  body:not(.rtl) .sidebar.open {
    transform: translateX(0);
  }

  /* RTL slide-in from right */
  body.rtl .sidebar {
    right: 0;
    transform: translateX(100%);
  }

  body.rtl .sidebar.open {
    transform: translateX(0);
  }

  .preview-area {
    padding: 0;
    overflow-x: hidden;
    display: flex;
    justify-content: center;
  }

  .paper-wrapper {
    transform-origin: top center;
  }
}

/* =============================================
   Print Styles
   ============================================= */

@media print {
  body {
    background: none;
  }

  .sidebar {
    display: none;
  }

  #overflowWarning {
    display: none !important;
  }

  .section-overlay-toolbar {
    display: none !important;
  }

  .section-block {
    outline: none !important;
  }

  .section-header.editable-header {
    outline: none !important;
    background: none !important;
    padding: 0;
    cursor: default;
  }

  .preview-area {
    padding: 0;
    overflow: visible;
    display: block;
  }

  .paper-wrapper {
    box-shadow: none;
    gap: 0;
  }

  .a4-sheet {
    margin: 0;
    box-shadow: none;
    width: 210mm;
    height: 297mm;
    position: relative;
    border: none;
    page-break-after: always;
  }

  .a4-sheet:last-child {
    page-break-after: auto;
  }

  /* Print footer */
  .sheet-footer {
    position: absolute;
    bottom: 10mm;
    left: 0;
    right: 0;
    text-align: center;
    font-family: "Courier New", Courier, monospace;
    font-size: 14pt;
    font-weight: bold;
    color: black;
    z-index: 10;
  }

  .page-number {
    display: inline-block;
    padding: 2mm 5mm;
    border: 1px solid #ccc;
    background: #fdfdfd;
  }

  @page {
    size: A4;
    margin: 0;
  }
}

/* --- Screen Footer (preview mode) --- */
.a4-sheet {
  position: relative;
}

.sheet-footer {
  position: absolute;
  bottom: 10mm;
  left: 0;
  right: 0;
  text-align: center;
  font-family: "Courier New", Courier, monospace;
  font-size: 14pt;
  font-weight: bold;
  color: black;
}

.page-number {
  display: inline-block;
  padding: 1mm 4mm;
  border: 1px dashed #94a3b8;
  border-radius: 4px;
}
