/* ==============================================================
   RRIT PRINT STYLESHEET - V6 (Verified)
   ============================================================== */

@media print {
  /* ==================================================
     1. GLOBAL HIDE/SHOW & LAYOUT
     ================================================== */
  
  /* Hide any element with the .print-hide class, plus all standard UI chrome */
  .print-hide,
  #wb-bnr, #wb-tphp, #wb-lng, #rrit-intro, #step0,
  footer, nav, #lang-switch,
  #btnGenerateSummary, #generateSummaryBtn, #printSummaryBtn, #editAnswersBtn, #newScenarioBtn,
  #questionsSection, #summaryActionRow, #postResultActions, #summaryControls,
  button, .btn, .no-print {
    display: none !important;
  }

  /* Show only current language content */
  html[data-print-lang="en"] [data-lang="fr"],
  html[data-print-lang="en"] [lang="fr"],
  html[data-print-lang="fr"] [data-lang="en"],
  html[data-print-lang="fr"] [lang="en"] {
    display: none !important;
  }
  
  html[data-print-lang="en"] [data-lang="en"],
  html[data-print-lang="en"] [lang="en"],
  html[data-print-lang="fr"] [data-lang="fr"],
  html[data-print-lang="fr"] [lang="fr"] {
    display: block !important;
  }

  /* Force show essential summary elements */
  #rrit-summary, #summarySection, #projectInfo,
  #projectInfo.panel, #projectInfo .panel-heading,
  #projectInfo .panel-title, #projectInfo .panel-body {
    display: block !important;
    visibility: visible !important;
    height: auto !important;
    overflow: visible !important;
  }

  /* Specifically hide the inactive language for the Project Info title */
  #projectInfo .panel-title [data-lang] { display: none !important; }
  html[data-print-lang="en"] #projectInfo .panel-title [data-lang="en"],
  html[data-print-lang="fr"] #projectInfo .panel-title [data-lang="fr"] {
    display: block !important;
  }

  /* ==================================================
     2. BASE TYPOGRAPHY & PAGE SETUP
     ================================================== */

  html, body {
    margin: 0.5in;
    font: 12pt/1.5 "Noto Sans", "Helvetica Neue", Helvetica, Arial, sans-serif !important;
    background: #fff !important;
    color: #000;
  }

  h1, h2, h3, h4, p, ul, ol, li {
    font-size: 12pt !important;
    line-height: 1.5 !important;
  }
  h1 { font-size: 16pt !important; }
  h2 { font-size: 14pt !important; }
  h3 { font-size: 13pt !important; }

  /* Page title */
  html[data-print-lang="en"]:before {
    content: "Risk Profile Summary";
    font-size: 16pt; font-weight: bold; text-align: center; display: block;
    margin-bottom: 0.5rem; border-bottom: 2px solid #000; padding-bottom: 0.5rem;
  }
  html[data-print-lang="fr"]:before {
    content: "Sommaire du profil de risque";
    font-size: 16pt; font-weight: bold; text-align: center; display: block;
    margin-bottom: 0.5rem; border-bottom: 2px solid #000; padding-bottom: 0.5rem;
  }

  /* Print date */
  html:after {
    display: block; font-size: 12pt; text-align: center;
    margin-bottom: 1rem; color: #666;
  }
  html[data-print-lang="en"]:after { content: "Generated: " attr(data-print-date); }
  html[data-print-lang="fr"]:after { content: "Généré le : " attr(data-print-date); }

  /* ==================================================
     3. PROJECT INFO & RISK ITEM STYLING (VERIFIED)
     ================================================== */

  /* Project info section */
  #projectInfo { margin-bottom: 1rem; }
  #projectInfo fieldset {
    border: none !important;
    padding: 0 !important;
    margin: 0 0 1rem 0 !important; /* Remove left margin */
  }
  
  /* --- VERIFIED INDENTATION RULE --- */
  /* Add a 1rem left padding to both the title (legend) and the content (::after) */
  #projectInfo fieldset legend {
    font-size: 12pt !important;
    font-weight: bold !important;
    margin-bottom: 0.25rem !important;
    padding-left: 1rem !important; /* The indent */
  }
  
  #projectInfo input, #projectInfo textarea { display: none !important; }
  
  #projectInfo fieldset[data-content]::after {
    content: attr(data-content);
    display: block !important;
    font-size: 12pt !important;
    font-weight: normal !important;
    white-space: pre-wrap !important;
    word-wrap: break-word !important;
    padding-left: 1rem !important; /* The indent */
  }

  /* Unified Risk Item styling */
  .risk-item {
    page-break-inside: avoid !important;
    margin-bottom: 1.5rem !important;
    border: 1px solid #ccc !important;
    padding: 1rem !important;
    background-color: #f9f9f9 !important;
  }

  /* Style the question */
  .risk-item .risk-q {
    font-size: 12pt !important;
    font-weight: bold !important;
    color: #264a88 !important;
    margin-top: 0 !important;
  }

  /* Style the risk statement */
  .risk-item .risk-statement {
    margin: 1rem 0 !important;
    padding-left: 0.75rem !important;
    border-left: 4px solid #d9534f !important;
  }

  /* Style the mitigations */
  .risk-item .risk-mitigations {
    margin-top: 0.75rem !important;
    padding: 0.75rem !important;
    border-left: 4px solid #5bc0de !important;
    background-color: #f0f8ff !important;
  }
}
