/* Print-Optimized Styles for Session Scripts, Worksheets, and Manual Pages */

@media print {
  /* ===== GLOBAL HIDE: Navigation, UI chrome, interactive elements ===== */
  header,
  footer,
  nav,
  .no-print,
  [role="search"],
  [aria-label*="search"],
  [aria-label*="Search"],
  [data-radix-popper-content-wrapper],
  /* Hide all buttons except those explicitly marked for print */
  button:not(.print-keep),
  /* Hide tab triggers — we show the active tab content directly */
  [role="tablist"],
  /* Hide text-to-speech player */
  [class*="TextToSpeech"],
  /* Hide theme toggle, search command, mobile menu */
  [class*="ThemeToggle"],
  [class*="SearchCommand"],
  /* Hide badges that are interactive (completion status) */
  .print\\:hidden {
    display: none !important;
  }

  /* ===== PAGE SETUP ===== */
  @page {
    margin: 0.75in;
    size: letter portrait;
  }

  @page :first {
    margin-top: 0.5in;
  }

  /* ===== BODY & TYPOGRAPHY ===== */
  body {
    background: white !important;
    color: black !important;
    font-size: 11pt;
    line-height: 1.5;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* ===== LAYOUT RESET ===== */
  .container {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  /* Force single-column layout for grid content */
  .grid {
    display: block !important;
  }

  /* ===== HEADINGS ===== */
  h1 {
    font-size: 20pt;
    margin-top: 0;
    page-break-after: avoid;
  }

  h2 {
    font-size: 16pt;
    page-break-after: avoid;
    margin-top: 12pt;
  }

  h3 {
    font-size: 14pt;
    page-break-after: avoid;
  }

  h1, h2, h3, h4, h5, h6 {
    page-break-inside: avoid;
    page-break-after: avoid;
  }

  /* ===== PARAGRAPH & LIST FLOW ===== */
  p, li {
    page-break-inside: avoid;
    orphans: 3;
    widows: 3;
  }

  ul, ol {
    page-break-inside: avoid;
  }

  li {
    margin-bottom: 0.5em;
  }

  section {
    margin-bottom: 2em;
  }

  /* ===== SESSION SCRIPT SPECIFIC ===== */

  /* Module header area — keep compact, no background */
  .bg-muted\/30 {
    background: transparent !important;
    border: none !important;
    padding-top: 0 !important;
    padding-bottom: 8pt !important;
  }

  /* Week badge — keep visible but simple */
  [class*="Badge"] {
    border: 1px solid #666 !important;
    background: transparent !important;
    color: black !important;
    padding: 2pt 6pt !important;
    font-size: 9pt !important;
  }

  /* Session script card — remove card chrome, let content flow */
  [class*="Card"] {
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    padding: 0 !important;
    page-break-inside: auto;
    margin-bottom: 1em;
  }

  [class*="CardHeader"] {
    padding: 0 0 6pt 0 !important;
    border-bottom: 1pt solid #ccc !important;
    margin-bottom: 8pt !important;
  }

  [class*="CardContent"] {
    padding: 0 !important;
  }

  [class*="CardTitle"] {
    font-size: 14pt !important;
    color: black !important;
  }

  /* Tab content — show the active tab, hide inactive */
  [role="tabpanel"][data-state="active"] {
    display: block !important;
  }

  [role="tabpanel"][data-state="inactive"] {
    display: none !important;
  }

  /* ===== PROSE / MARKDOWN CONTENT (Streamdown) ===== */
  .prose {
    max-width: 100% !important;
    font-size: 11pt !important;
    color: black !important;
  }

  .prose h2 {
    font-size: 14pt !important;
    margin-top: 16pt !important;
    margin-bottom: 6pt !important;
    border-bottom: 0.5pt solid #ccc;
    padding-bottom: 4pt;
  }

  .prose h3 {
    font-size: 12pt !important;
    margin-top: 12pt !important;
    margin-bottom: 4pt !important;
  }

  .prose p {
    font-size: 11pt !important;
    margin-bottom: 6pt !important;
    line-height: 1.5 !important;
  }

  .prose strong {
    font-weight: 700 !important;
  }

  .prose em {
    font-style: italic !important;
  }

  /* Script dialogue formatting — "You:" and "Them:" lines */
  .prose p strong:first-child {
    display: inline;
  }

  /* Blockquotes in scripts (used for exercise instructions, breathing cues) */
  .prose blockquote {
    border-left: 2pt solid #999 !important;
    padding-left: 8pt !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    font-style: italic;
    color: #333 !important;
    page-break-inside: avoid;
  }

  /* Horizontal rules between script sections */
  .prose hr {
    border: none !important;
    border-top: 0.5pt solid #ccc !important;
    margin: 12pt 0 !important;
  }

  /* Lists within scripts */
  .prose ul, .prose ol {
    padding-left: 16pt !important;
    margin-bottom: 8pt !important;
  }

  .prose li {
    font-size: 11pt !important;
    margin-bottom: 3pt !important;
  }

  /* ===== KEY OBJECTIVES SIDEBAR (prints inline after script) ===== */
  .md\:col-span-4 {
    margin-top: 16pt !important;
    padding-top: 12pt !important;
    border-top: 1pt solid #ccc !important;
  }

  .md\:col-span-4 [class*="Card"] {
    border: 1px solid #ccc !important;
    padding: 8pt !important;
    page-break-inside: avoid;
  }

  .md\:col-span-8 {
    width: 100% !important;
    max-width: 100% !important;
  }

  /* ===== CHECKLIST TAB ===== */
  .rounded-lg.border {
    border: 1px solid #ccc !important;
    padding: 6pt 8pt !important;
    margin-bottom: 4pt !important;
    page-break-inside: avoid;
  }

  /* Checklist number circles */
  .rounded-full.border-primary {
    border: 1px solid black !important;
    color: black !important;
  }

  /* ===== WORKSHEET OPTIMIZATIONS ===== */
  .worksheet-question {
    page-break-inside: avoid;
    margin-bottom: 1em;
  }

  textarea,
  input[type="text"],
  input[type="textarea"] {
    border: 1px solid #000 !important;
    background: white !important;
    min-height: 2em;
    page-break-inside: avoid;
  }

  /* ===== TABLE OPTIMIZATIONS ===== */
  table {
    page-break-inside: avoid;
    border-collapse: collapse;
    width: 100%;
  }

  th, td {
    border: 1px solid #000 !important;
    padding: 6pt !important;
    text-align: left;
    font-size: 10pt;
  }

  /* ===== CLEANUP ===== */
  * {
    box-shadow: none !important;
    text-shadow: none !important;
  }

  a {
    color: #000 !important;
    text-decoration: underline;
  }

  /* Show URL for external links only */
  a[href^="http"]:after {
    content: " (" attr(href) ")";
    font-size: 8pt;
    color: #666;
  }

  /* Don't show URL for internal navigation links */
  a[href^="/"]:after,
  a[href^="#"]:after {
    content: none !important;
  }

  /* Hide example toggles */
  [class*="toggle"],
  [class*="Toggle"] {
    display: none !important;
  }

  /* Show all content (no hidden sections) */
  [hidden] {
    display: block !important;
  }

  /* Crisis Plan specific */
  .crisis-plan-section {
    page-break-inside: avoid;
    margin-bottom: 1.5em;
  }

  /* Remove interactive elements styling */
  button,
  input[type="button"],
  input[type="submit"] {
    border: 1px solid #000 !important;
    background: white !important;
    color: black !important;
  }

  /* ===== ATTRIBUTION FOOTER (visible only in print) ===== */
  body::after {
    content: "Curran's Coaching Manuals — curranscoachingmanuals.manus.space — For personal use only.";
    display: block;
    text-align: center;
    font-size: 8pt;
    color: #999;
    margin-top: 24pt;
    padding-top: 8pt;
    border-top: 0.5pt solid #ddd;
  }
}
