/**
 * Print Stylesheet for OpenACS Themes
 * Shared across bootstrap3, classic, and fresh themes
 * Optimizes page output for printing following modern best practices
 *
 * PRINT BEHAVIOR
 * ===============
 *
 * PAGE MARGINS: 20px left/right padding on body to prevent content from going to page edges
 *
 * FORMS: Forms are kept visible by default (they may be the page content to fill out).
 *        Only submit/reset buttons are hidden. Form inputs are styled for print-and-fill
 *        with underlines for text boxes and visible checkboxes/radios.
 *        To hide an entire form, add class="no-print" to the <form> element.
 *
 * UTILITY CLASSES FOR PRINT CONTROL
 * ==================================
 *
 * This stylesheet provides several utility classes you can use in your ADP templates
 * to control how elements appear when printed:
 *
 * HIDING ELEMENTS FROM PRINT:
 * ---------------------------
 * .print-hide         - Hide element in print view only (synonymous with .no-print)
 * .no-print           - Hide element in print view only
 * .hidden-print       - Bootstrap's standard class for hiding in print (also supported)
 *
 * Example usage in ADP templates:
 *   <div class="no-print">
 *     <a href="/edit" class="btn btn-primary">Edit Page</a>
 *   </div>
 *
 * SHOWING ELEMENTS ONLY IN PRINT:
 * --------------------------------
 * .print-show                 - Show element only in print (display: block)
 * .visible-print              - Bootstrap's standard class (display: block)
 * .visible-print-inline       - Show as inline element in print only
 * .visible-print-inline-block - Show as inline-block element in print only
 *
 * Example usage:
 *   <div class="print-show" style="display: none;">
 *     <p>This content only appears when printing the page.</p>
 *     <p>Document generated on @current_date@</p>
 *   </div>
 *
 * PAGE BREAK CONTROL:
 * -------------------
 * .print-page-break-before - Force a page break before this element
 * .print-page-break-after  - Force a page break after this element
 * .print-no-break          - Prevent page breaks inside this element
 *
 * Example usage:
 *   <section class="print-page-break-before">
 *     <h2>New Section Starting on Fresh Page</h2>
 *     ...
 *   </section>
 *
 *   <table class="print-no-break">
 *     <!-- This table will not be split across pages -->
 *   </table>
 *
 * SHOWING LINK URLS IN PRINT:
 * ----------------------------
 * By default, link URLs are NOT shown after links (overriding Bootstrap's default).
 * To show the URL after a specific link, use:
 *
 * .print-url - Show the URL in parentheses after the link text
 *
 * Example usage:
 *   <a href="https://example.com" class="print-url">Visit our website</a>
 *   Prints as: Visit our website (https://example.com)
 *
 * COMMON PATTERNS:
 * ----------------
 * Hide all buttons from print:
 *   <div class="no-print">
 *     <button class="btn btn-primary">Save</button>
 *     <button class="btn btn-default">Cancel</button>
 *   </div>
 *
 * Hide an entire form (e.g., search or login forms):
 *   <form class="no-print" method="post" action="/search">
 *     <!-- This entire form will be hidden in print -->
 *   </form>
 *
 * Keep a form visible for print-and-fill (default behavior):
 *   <form method="post" action="/submit">
 *     <label>Name: <input type="text" name="name"></label>
 *     <!-- Form will be visible with underlined input boxes -->
 *   </form>
 *
 * Add a print-only footer:
 *   <footer class="print-show" style="display: none;">
 *     <p>Printed from @system_name@ on @current_date@</p>
 *   </footer>
 *
 * Keep content blocks together:
 *   <div class="print-no-break">
 *     <h3>Important Section</h3>
 *     <p>This heading and paragraph will stay together on the same page.</p>
 *   </div>
 */

@media print {

  /* ===========================
     DISABLE BOOTSTRAP DEFAULTS
     =========================== */

  /* Override Bootstrap's default behavior of showing URLs after links */
  a[href]:after {
    content: "" !important;
  }

  abbr[title]:after {
    content: "" !important;
  }


  /* ===========================
     HIDE NAVIGATION & UI ELEMENTS
     =========================== */

  /* Navigation elements - both HTML tags and Bootstrap 3 classes */
  .navbar,
  .navbar-header,
  .navbar-brand,
  .navbar-toggle,
  .navbar-collapse,
  .navbar-nav,
  .nav,
  nav,
  [role="navigation"],
  .breadcrumb,
  .pagination,
  .pager,
  .navbarbuttons,
  .memberbuttons {
    display: none !important;
  }

  /* Buttons and actions */
  .btn,
  .btn-group,
  .btn-toolbar,
  button,
  .button,
  input[type="submit"],
  input[type="button"],
  input[type="reset"] {
    display: none !important;
  }

  /* UI components */
  .dropdown,
  .dropdown-menu,
  .dropdown-toggle,
  .modal,
  .modal-dialog,
  .modal-backdrop,
  .tooltip,
  .popover,
  .alert-dismissible .close,
  .close,
  .carousel-control,
  .carousel-indicators,
  .tab-pane:not(.active) {
    display: none !important;
  }

  /* Sidebars and auxiliary content */
  [class*="sidebar"],
  [class*="aside"],
  aside,
  .js-offcanvas,
  .panel > .panel-heading .btn,
  .panel > .panel-heading .btn-group {
    display: none !important;
  }

  /* Footer (you may want to customize this per site) */
  footer,
  .footer {
    display: none !important;
  }

  /* Search boxes and interactive-only forms */
  [class*="search"],
  .search-form {
    display: none !important;
  }


  /* ===========================
     OPTIMIZE COLORS & BACKGROUNDS
     =========================== */

  /* Force white background and black text for readability and ink savings */
  * {
    background: white !important;
    color: black !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }

  /* Remove background images */
  body {
    background-image: none !important;
  }


  /* ===========================
     FORM STYLING FOR PRINT
     =========================== */

  /*
   * Forms are kept visible by default since they may be the page content
   * (e.g., forms to print and fill out by hand). Only interactive elements
   * like submit buttons are hidden.
   */

  /* Style text inputs and textareas for print-and-fill */
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="url"],
  input[type="number"],
  input[type="date"],
  input[type="password"],
  textarea {
    border: none !important;
    border-bottom: 1px solid #333 !important;
    border-radius: 0 !important;
    background: transparent !important;
    color: black !important;
    padding: 2px 4px !important;
    font-family: "Times New Roman", Times, serif !important;
    font-size: 11pt !important;
  }

  /* Textareas need a bit more structure */
  textarea {
    border: 1px solid #333 !important;
    border-radius: 0 !important;
    min-height: 3em;
  }

  /* Select dropdowns - show current value with indicator */
  select {
    border: none !important;
    border-bottom: 1px solid #333 !important;
    border-radius: 0 !important;
    background: transparent !important;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    padding-right: 1em;
  }

  /* Keep checkboxes and radio buttons visible */
  input[type="checkbox"],
  input[type="radio"] {
    border: 1px solid #333 !important;
    background: white !important;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 12pt;
    height: 12pt;
    display: inline-block;
    vertical-align: middle;
    margin-right: 0.25em;
  }

  input[type="radio"] {
    border-radius: 50%;
  }

  /* Show checked state for checkboxes */
  input[type="checkbox"]:checked::before {
    content: "✓";
    display: block;
    text-align: center;
    font-size: 10pt;
    line-height: 12pt;
  }

  /* Show checked state for radio buttons */
  input[type="radio"]:checked::before {
    content: "●";
    display: block;
    text-align: center;
    font-size: 8pt;
    line-height: 12pt;
  }

  /* Labels should be visible and properly styled */
  label {
    display: inline-block !important;
    font-weight: normal !important;
    color: black !important;
    margin-bottom: 0.25em;
  }

  /* Form groups should remain visible */
  .form-group {
    margin-bottom: 1em;
  }

  /* Fix form-horizontal layout for print */
  .form-horizontal .form-group {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  .form-horizontal .control-label {
    text-align: left !important;
    float: none !important;
    width: auto !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    margin-bottom: 0.25em;
  }

  .form-horizontal .form-group > div[class*="col-"] {
    float: none !important;
    width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  /* Hide form validation messages and help text */
  .help-block,
  .form-error,
  .error-message,
  [class*="invalid-feedback"],
  [class*="valid-feedback"] {
    display: none !important;
  }

  /* Utility class: use this to hide entire forms that shouldn't be printed */
  form.no-print,
  form.print-hide {
    display: none !important;
  }


  /* ===========================
     TYPOGRAPHY OPTIMIZATION
     =========================== */

  body {
    font-family: "Times New Roman", Times, serif !important;
    font-size: 12pt;
    line-height: 1.5;
    padding: 0;
    margin: 0 20px !important; /* Add left/right margins for print */
  }

  h1 {
    font-size: 24pt;
    margin-top: 0;
  }

  h2 {
    font-size: 18pt;
  }

  h3 {
    font-size: 14pt;
  }

  h4, h5, h6 {
    font-size: 12pt;
  }

  p {
    margin: 0 0 1em 0;
  }


  /* ===========================
     LINK STYLING
     =========================== */

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

  /* For important links, you can show the URL in parentheses */
  a.print-url:after {
    content: " (" attr(href) ")";
    font-size: 0.9em;
    font-style: italic;
  }


  /* ===========================
     PAGE BREAK CONTROL
     =========================== */

  /* Avoid breaks after headings */
  h1, h2, h3, h4, h5, h6 {
    page-break-after: avoid;
    page-break-inside: avoid;
  }

  /* Avoid breaks inside these elements */
  table,
  figure,
  img,
  pre,
  blockquote,
  ul,
  ol {
    page-break-inside: avoid;
  }

  /* Orphan/widow control */
  p {
    orphans: 3;
    widows: 3;
  }


  /* ===========================
     TABLE STYLING
     =========================== */

  table {
    width: 100%;
    border-collapse: collapse;
  }

  thead {
    display: table-header-group; /* Repeat header on each page */
  }

  tfoot {
    display: table-footer-group;
  }

  /* th, td {
    border: 1px solid #ddd !important;
    padding: 8px;
    text-align: left;
  }

  th {
    background-color: #f5f5f5 !important;
    font-weight: bold;
  } */


  /* ===========================
     IMAGE HANDLING
     =========================== */

  img {
    max-width: 100% !important;
    height: auto !important;
  }


  /* ===========================
     UTILITY CLASSES
     =========================== */

  /* Hide elements from print */
  .print-hide,
  .no-print,
  .hidden-print {
    display: none !important;
  }

  /* Show elements only in print */
  .print-show,
  .visible-print {
    display: block !important;
  }

  .visible-print-inline {
    display: inline !important;
  }

  .visible-print-inline-block {
    display: inline-block !important;
  }

  /* Page break utilities */
  .print-page-break-before {
    page-break-before: always;
  }

  .print-page-break-after {
    page-break-after: always;
  }

  .print-no-break {
    page-break-inside: avoid;
  }


  /* ===========================
     CONTAINER & LAYOUT
     =========================== */

  .container,
  .container-fluid {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .row {
    margin: 0 !important;
  }

  /* Make columns stack in print */
  [class*="col-"] {
    width: 100% !important;
    float: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }


  /* ===========================
     CONTENT OPTIMIZATION
     =========================== */

  /* Ensure main content is visible */
  .content,
  main,
  article,
  [role="main"] {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* Code blocks */
  code,
  pre {
    border: 1px solid #ddd !important;
    background: #f9f9f9 !important;
    color: black !important;
    padding: 2px 4px;
    font-family: "Courier New", monospace;
    font-size: 10pt;
    white-space: pre-wrap;
    word-wrap: break-word;
  }

  /* Blockquotes */
  blockquote {
    border-left: 3px solid #ddd !important;
    padding-left: 1em;
    margin: 1em 0;
    font-style: italic;
  }

  /* Lists */
  ul, ol {
    margin: 0 0 1em 2em;
  }

  li {
    margin: 0.25em 0;
  }

}
