/* ==========================================================================
   Finance Web Planet - Print Stylesheet
   Version: 1.0.0
   Last Updated: November 4, 2025
   Purpose: Optimized print styles for reports and documents
   ========================================================================== */

@media print {
  /* ==========================================================================
     1. Page Setup
     ========================================================================== */
  @page {
    size: A4;
    margin: 1.5cm 1cm;
  }

  /* ==========================================================================
     2. Global Print Styles
     ========================================================================== */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  body {
    font-size: 10pt;
    line-height: 1.4;
    color: #000;
    background: white;
    padding: 0;
    margin: 0;
  }

  /* ==========================================================================
     3. Hide Non-Essential Elements
     ========================================================================== */
  .navbar,
  .sidebar,
  nav,
  .breadcrumb,
  .btn,
  button,
  .pagination,
  .modal,
  .dropdown-menu,
  .offcanvas,
  .toast,
  .alert,
  footer,
  .no-print,
  [class*="bi-"]:not(.print-icon) {
    display: none !important;
  }

  /* Hide export buttons */
  a[href*="pdf"],
  a[href*="excel"],
  a[href*="export"] {
    display: none !important;
  }

  /* ==========================================================================
     4. Container & Layout
     ========================================================================== */
  .container,
  .container-fluid {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .row {
    width: 100% !important;
    margin: 0 !important;
  }

  .col,
  [class*="col-"] {
    width: 100% !important;
    float: none !important;
    padding: 0 0.5cm !important;
  }

  /* ==========================================================================
     5. Typography
     ========================================================================== */
  h1 {
    font-size: 18pt;
    font-weight: bold;
    margin-bottom: 0.5cm;
    page-break-after: avoid;
  }

  h2 {
    font-size: 14pt;
    font-weight: bold;
    margin-top: 0.5cm;
    margin-bottom: 0.3cm;
    page-break-after: avoid;
  }

  h3 {
    font-size: 12pt;
    font-weight: bold;
    margin-top: 0.4cm;
    margin-bottom: 0.2cm;
    page-break-after: avoid;
  }

  h4, h5, h6 {
    font-size: 11pt;
    font-weight: bold;
    margin-top: 0.3cm;
    margin-bottom: 0.2cm;
    page-break-after: avoid;
  }

  p {
    margin-bottom: 0.3cm;
    orphans: 3;
    widows: 3;
  }

  /* ==========================================================================
     6. Cards & Panels
     ========================================================================== */
  .card {
    border: 1pt solid #ddd !important;
    margin-bottom: 0.5cm;
    page-break-inside: avoid;
    box-shadow: none !important;
  }

  .card-header {
    background-color: #f8f9fa !important;
    border-bottom: 1pt solid #ddd !important;
    padding: 0.3cm !important;
    font-weight: bold;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .card-header.bg-dark {
    background-color: #343a40 !important;
    color: white !important;
  }

  .card-header.bg-primary {
    background-color: #0d6efd !important;
    color: white !important;
  }

  .card-body {
    padding: 0.4cm !important;
  }

  /* ==========================================================================
     7. Tables
     ========================================================================== */
  table {
    width: 100% !important;
    border-collapse: collapse;
    margin-bottom: 0.5cm;
    page-break-inside: avoid;
  }

  thead {
    display: table-header-group;
    background-color: #f8f9fa !important;
  }

  tfoot {
    display: table-footer-group;
  }

  tr {
    page-break-inside: avoid;
    page-break-after: auto;
  }

  th {
    background-color: #e9ecef !important;
    font-weight: bold;
    padding: 0.2cm !important;
    border: 1pt solid #dee2e6 !important;
    text-align: left;
  }

  td {
    padding: 0.15cm !important;
    border: 1pt solid #dee2e6 !important;
  }

  .table-hover tbody tr:hover {
    background-color: transparent !important;
  }

  /* ==========================================================================
     8. Charts & Visualizations
     ========================================================================== */
  canvas {
    max-width: 100% !important;
    height: auto !important;
    page-break-inside: avoid;
  }

  /* Hide charts if preferred, uncomment to enable */
  /* canvas {
    display: none !important;
  } */

  /* ==========================================================================
     9. Badges & Status Indicators
     ========================================================================== */
  .badge {
    border: 1pt solid currentColor !important;
    padding: 0.1cm 0.2cm !important;
    background-color: white !important;
    color: #000 !important;
  }

  .badge.bg-success {
    color: #198754 !important;
  }

  .badge.bg-warning {
    color: #ffc107 !important;
  }

  .badge.bg-danger {
    color: #dc3545 !important;
  }

  .badge.bg-primary {
    color: #0d6efd !important;
  }

  .badge.bg-info {
    color: #0dcaf0 !important;
  }

  /* ==========================================================================
     10. Links
     ========================================================================== */
  a {
    color: #000 !important;
    text-decoration: none !important;
  }

  a[href]:after {
    content: "" !important;
  }

  /* ==========================================================================
     11. Page Breaks
     ========================================================================== */
  .page-break-before {
    page-break-before: always;
  }

  .page-break-after {
    page-break-after: always;
  }

  .avoid-break {
    page-break-inside: avoid;
  }

  /* ==========================================================================
     12. Headers & Footers
     ========================================================================== */
  .print-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 1cm;
    text-align: center;
    font-size: 9pt;
    color: #666;
  }

  .print-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1cm;
    text-align: center;
    font-size: 9pt;
    color: #666;
    border-top: 1pt solid #ddd;
  }

  /* ==========================================================================
     13. Summary Cards (KPIs)
     ========================================================================== */
  .card.border-0,
  .card.shadow-sm {
    border: 1pt solid #ddd !important;
    box-shadow: none !important;
  }

  /* Make KPI cards display inline */
  @media print {
    .row .col-md-3 {
      width: 25% !important;
      float: left !important;
      padding: 0.2cm !important;
    }
  }

  /* ==========================================================================
     14. Text Colors
     ========================================================================== */
  .text-success {
    color: #198754 !important;
  }

  .text-danger {
    color: #dc3545 !important;
  }

  .text-warning {
    color: #ffc107 !important;
  }

  .text-primary {
    color: #0d6efd !important;
  }

  .text-info {
    color: #0dcaf0 !important;
  }

  .text-muted {
    color: #6c757d !important;
  }

  /* ==========================================================================
     15. Utilities
     ========================================================================== */
  .d-print-none {
    display: none !important;
  }

  .d-print-block {
    display: block !important;
  }

  .d-print-inline {
    display: inline !important;
  }

  .d-print-inline-block {
    display: inline-block !important;
  }

  /* ==========================================================================
     16. Report Specific Styles
     ========================================================================== */
  .report-title {
    font-size: 20pt;
    font-weight: bold;
    margin-bottom: 0.5cm;
    text-align: center;
  }

  .report-date {
    text-align: right;
    font-size: 9pt;
    color: #666;
    margin-bottom: 0.3cm;
  }

  .report-summary {
    border: 1pt solid #ddd;
    padding: 0.4cm;
    margin-bottom: 0.5cm;
    background-color: #f8f9fa !important;
  }

  /* Numeric alignment */
  .text-end,
  .text-right {
    text-align: right !important;
  }

  .text-center {
    text-align: center !important;
  }

  /* Currency values */
  .currency {
    font-weight: bold;
  }

  /* ==========================================================================
     17. Signature Lines
     ========================================================================== */
  .signature-block {
    margin-top: 1cm;
    page-break-inside: avoid;
  }

  .signature-line {
    border-top: 1pt solid #000;
    margin-top: 1.5cm;
    padding-top: 0.2cm;
    width: 6cm;
  }

  /* ==========================================================================
     18. Watermark (Optional)
     ========================================================================== */
  .watermark {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    font-size: 72pt;
    color: rgba(0, 0, 0, 0.05);
    z-index: -1;
    pointer-events: none;
  }
}
