/* ==============================================================================
   ClassKit Global - Conditional If-Else Flowchart Adventure Map Studio Stylesheet
   Pure Vanilla CSS | A4 210mm x 297mm Vector Print Engine
   Full-Page Wide Master Layout | Crisp Vector SVG Flowchart & Variable Trace Table
   Curricular Alignment: CSTA 1B-AP-10 / 2-AP-12
   Strict Rule 4 Compliance: Under 600 lines
   ============================================================================== */

:root {
  --flowchart-border-thick: 2px solid #0F172A;
  --flowchart-border-thin: 1px solid #CBD5E1;
  --flowchart-ans-green: #16A34A;
  --flowchart-ans-bg: rgba(22, 163, 74, 0.12);
}

/* ------------------------------------------------------------------------------
   1. Left Control Panel Options & Form Elements
   ------------------------------------------------------------------------------ */
.form-group-wb { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.form-label-wb { font-size: 12px; font-weight: 800; color: var(--text-main, #0F172A); }
.form-input-wb {
  height: 38px; padding: 0 12px; border: 1.5px solid var(--border-medium, #CBD5E1);
  border-radius: var(--radius-sm, 6px); font-size: 13px; font-weight: 700;
  color: var(--text-main, #0F172A); outline: none; background: #FFFFFF;
  box-sizing: border-box; transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-input-wb:focus { border-color: var(--primary, #4F46E5); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12); }
.form-row-checkboxes { display: flex; flex-direction: column; gap: 8px; }
.checkbox-label-wb { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--text-main, #1E293B); cursor: pointer; user-select: none; }
.checkbox-label-wb input[type="checkbox"] { accent-color: var(--primary, #4F46E5); width: 16px; height: 16px; cursor: pointer; }

.option-label-sub { font-size: 11.5px; font-weight: 700; color: var(--text-muted, #64748B); margin-bottom: 6px; letter-spacing: -0.2px; }
.segmented-control { display: flex; gap: 4px; background: #EDF2F7; padding: 4px; border-radius: 8px; }
.seg-btn {
  flex: 1; padding: 8px 4px; font-size: 11.5px; font-weight: 700; color: #64748B;
  background: transparent; border: none; border-radius: 6px; cursor: pointer;
  transition: all 0.15s ease; text-align: center; user-select: none; white-space: nowrap;
}
.seg-btn:hover { color: #0F172A; }
.seg-btn.active { background: #FFFFFF; color: #0F172A; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); }
.layout-hint-text { font-size: 11.5px; color: #64748B; line-height: 1.4; margin-top: 8px; padding: 4px 6px; }

/* Initial Vars Display Box */
.initial-vars-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #F8FAFC;
  border: 1.5px solid #CBD5E1;
  border-radius: 8px;
  padding: 10px 12px;
}

.init-var-pill {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12.5px;
  font-weight: 700;
  color: #1E293B;
}

.init-var-val {
  color: #4F46E5;
  font-weight: 800;
}

.btn-secondary-action {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px;
  font-size: 13px; font-weight: 700; background: #FFFFFF; color: #334155; border: 1px solid #CBD5E1;
  cursor: pointer; transition: all 0.15s ease;
}
.btn-secondary-action:hover { background: #F8FAFC; border-color: #94A3B8; color: #0F172A; }

.btn-sidebar-generate {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 12px;
  border-radius: 10px; font-size: 13.5px; font-weight: 800; background: #F1F5F9; border: 1.5px solid #CBD5E1;
  color: #1E293B; cursor: pointer; transition: all 0.18s ease;
}
.btn-sidebar-generate:hover { background: #E2E8F0; border-color: #94A3B8; color: #0F172A; transform: translateY(-1px); }

/* ------------------------------------------------------------------------------
   2. A4 Printable Sheet Engine (Portrait 210mm x 297mm)
   ------------------------------------------------------------------------------ */
.print-pages-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
  align-items: center;
}

.flowchart-sheet {
  width: 210mm;
  height: 297mm;
  min-height: 297mm;
  max-height: 297mm;
  box-sizing: border-box;
  padding: 10mm 14mm 8mm 14mm;
  background: #FFFFFF;
  color: #0F172A;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.1);
  border-radius: 2px;
}

/* Unified Standard Header (No Badges, Top-Right Metadata, Full-Width Bold Title) */
.sheet-header-block {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 1.5mm;
  border-bottom: 2px solid #0F172A;
  padding-bottom: 1.8mm;
  margin-bottom: 2mm;
  flex-shrink: 0;
}

.sheet-meta-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6mm;
  font-size: 8.5pt;
  font-weight: 700;
  color: #334155;
}

.sheet-name-field {
  display: inline-block;
  min-width: 26mm;
  border-bottom: 1.5px solid #0F172A;
}

.sheet-answer-tag {
  font-size: 9pt;
  font-weight: 900;
  color: #166534;
  background: #DCFCE7;
  padding: 1mm 3mm;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.sheet-main-title {
  font-size: 16pt;
  font-weight: 900;
  color: #0F172A;
  margin: 0;
  line-height: 1.2;
}

/* ------------------------------------------------------------------------------
   3. Mission Briefing Banner & Initial Inventory
   ------------------------------------------------------------------------------ */
.flowchart-hero-banner {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  background: #F5F3FF;
  border: 1.5px solid #DDD6FE;
  border-radius: 7px;
  padding: 2.2mm 4mm;
  margin-bottom: 2mm;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.flowchart-hero-banner.theme-pirate {
  background: #FFFBEB;
  border-color: #FCD34D;
}

.flowchart-hero-banner.theme-dungeon {
  background: #F5F3FF;
  border-color: #DDD6FE;
}

.flowchart-hero-banner.theme-space {
  background: #F0F9FF;
  border-color: #BAE6FD;
}

.flowchart-mission-text {
  font-size: 8.2pt;
  color: #334155;
  line-height: 1.45;
  flex: 1;
  padding-right: 4mm;
}

.flowchart-mission-text strong {
  color: #0F172A;
}

.inventory-hero-card {
  display: flex;
  align-items: center;
  gap: 2mm;
  background: #FFFFFF;
  border: 2px solid #4F46E5;
  border-radius: 6px;
  padding: 1.5mm 3.5mm;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  white-space: nowrap;
}

.theme-pirate .inventory-hero-card { border-color: #D97706; }
.theme-dungeon .inventory-hero-card { border-color: #4F46E5; }
.theme-space .inventory-hero-card { border-color: #0284C7; }

.inv-card-title {
  font-size: 8pt;
  font-weight: 800;
  color: #64748B;
}

.inv-card-items {
  font-size: 10.5pt;
  font-weight: 900;
  color: #4F46E5;
  font-family: 'Outfit', sans-serif;
}

.theme-pirate .inv-card-items { color: #D97706; }
.theme-dungeon .inv-card-items { color: #4F46E5; }
.theme-space .inv-card-items { color: #0284C7; }

/* ------------------------------------------------------------------------------
   4. Flowchart SVG Diagram Canvas
   ------------------------------------------------------------------------------ */
.flowchart-sheet-body {
  flex: 1;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  gap: 2mm;
  min-height: 0;
}

.flowchart-svg-container {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #F8FAFC;
  border: 1.5px solid #0F172A;
  border-radius: 8px;
  padding: 1.5mm;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
  flex-shrink: 0;
}

.flowchart-svg {
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 76mm;
  display: block;
}

.flowchart-svg text {
  font-family: 'Inter', -apple-system, sans-serif;
  user-select: none;
}

/* ------------------------------------------------------------------------------
   5. Variable Trace Table Section
   ------------------------------------------------------------------------------ */
.trace-table-section {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  background: #F8FAFC;
  border: 1.5px solid #CBD5E1;
  border-radius: 6px;
  padding: 1mm 2mm;
  flex-shrink: 0;
  overflow: hidden;
}

.trace-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.8mm;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.trace-title {
  font-size: 7.2pt;
  font-weight: 800;
  color: #334155;
  display: flex;
  align-items: center;
  gap: 1mm;
}

.trace-sub-title {
  font-size: 6.5pt;
  color: #64748B;
  font-weight: 600;
}

.trace-table-grid {
  width: 100%;
  max-width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 7pt;
  text-align: center;
  background: #FFFFFF;
  box-sizing: border-box;
}

.trace-table-grid th {
  background: #F1F5F9;
  border: 1px solid #CBD5E1;
  padding: 0.6mm 0.5mm;
  font-weight: 800;
  color: #334155;
  word-break: break-word;
  white-space: normal;
  overflow: hidden;
  box-sizing: border-box;
}

.trace-table-grid td {
  border: 1px solid #CBD5E1;
  padding: 0.6mm 0.5mm;
  color: #0F172A;
  font-weight: 600;
  line-height: 1.15;
  word-break: break-word;
  overflow: hidden;
  box-sizing: border-box;
}

.trace-table-grid tr:hover td {
  background-color: #F8FAFC;
}

/* Answer Key Highlights */
.is-answer-key-page .trace-table-grid .trace-correct-dest {
  background: #DCFCE7 !important;
  color: #166534 !important;
  font-weight: 900;
}

.answer-summary-banner {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  background: #F0FDF4;
  border: 1.5px solid #86EFAC;
  border-radius: 8px;
  padding: 2.2mm 3.5mm;
  box-sizing: border-box;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2mm;
  flex-shrink: 0;
}

.ans-sum-text {
  font-size: 8.5pt;
  color: #166534;
  font-weight: 700;
}

.ans-sum-badge {
  font-size: 11pt;
  font-weight: 900;
  color: #15803D;
  background: #FFFFFF;
  border: 1.5px solid #16A34A;
  border-radius: 6px;
  padding: 1mm 4mm;
}

/* ------------------------------------------------------------------------------
   6. Footer Meta Information
   ------------------------------------------------------------------------------ */
.sheet-footer-block {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  border-top: 1px solid #E2E8F0;
  padding-top: 1.8mm;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 7.2pt;
  color: #94A3B8;
  margin-top: auto;
  flex-shrink: 0;
}

.footer-meta-brand {
  font-weight: 700;
  color: #64748B;
}

.footer-brand-tag {
  font-weight: 800;
  color: #4F46E5;
}

/* ------------------------------------------------------------------------------
   7. Native Print Optimization (@media print)
   ------------------------------------------------------------------------------ */
@media print {
  @page {
    size: A4 portrait;
    margin: 0;
  }

  html, body {
    margin: 0 !important;
    padding: 0 !important;
    background: #FFFFFF !important;
  }

  .top-navbar,
  .studio-header,
  .studio-sidebar,
  .pro-modal-backdrop,
  footer {
    display: none !important;
  }

  .studio-body {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
  }

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

  .a4-wrapper {
    transform: none !important;
  }

  .print-pages-container {
    gap: 0 !important;
  }

  .flowchart-sheet {
    box-shadow: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
    page-break-after: always !important;
    break-after: page !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .flowchart-sheet:last-child {
    page-break-after: avoid !important;
    break-after: avoid !important;
  }
}
