/* ============================================================
   Nixus — Professional Invoicing Platform
   File: static/css/print.css
   Purpose: Print-optimized styles (invoices, reports, exports)
   Author: Nixus Team
   License: MIT
   ============================================================ */

/* ============================================================
   1. PAGE SETUP
   ============================================================ */
@page {
  size: A4;
  margin: 18mm 16mm 22mm 16mm;

  @bottom-center {
    content: "Nixus — " counter(page) " / " counter(pages);
    font-family: 'Inter', 'Helvetica', Arial, sans-serif;
    font-size: 9pt;
    color: #888;
  }
}

@page :first {
  margin-top: 14mm;
}

@page landscape {
  size: A4 landscape;
}


/* ============================================================
   2. GLOBAL PRINT RESET
   ============================================================ */
@media print {
  *,
  *::before,
  *::after {
    background: transparent !important;
    color: #000 !important;
    box-shadow: none !important;
    text-shadow: none !important;
    filter: none !important;
  }

  html,
  body {
    width: 100%;
    height: auto;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    color: #000 !important;
    font-size: 11pt;
    line-height: 1.5;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  body {
    font-family: 'Inter', 'Helvetica', Arial, sans-serif;
  }

  /* Remove decorative elements */
  .glow-orb,
  .grid-bg,
  .noise {
    display: none !important;
  }
}


/* ============================================================
   3. HIDE NON-PRINTABLE ELEMENTS
   ============================================================ */
@media print {
  .no-print,
  .navbar,
  .sidebar,
  .app-topbar,
  .footer,
  .public-header,
  .public-cta,
  .invoice-toolbar,
  .invoice-actions-bar,
  .bulk-bar,
  .pagination,
  .table-header-actions,
  .search-bar,
  .quick-actions,
  .modal-backdrop,
  .dropdown-menu,
  .toast,
  .alerts,
  .flash-messages,
  .announcement,
  .cookie-banner,
  button:not(.print-visible),
  .btn:not(.print-visible),
  .row-action,
  input[type="checkbox"],
  input[type="radio"],
  .switch,
  .check {
    display: none !important;
  }
}


/* ============================================================
   4. PAGE BREAK CONTROL
   ============================================================ */
@media print {
  h1, h2, h3, h4, h5, h6 {
    page-break-after: avoid;
    break-after: avoid;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  p, blockquote, ul, ol, dl {
    orphans: 3;
    widows: 3;
  }

  tr, td, th {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  thead {
    display: table-header-group;
  }

  tfoot {
    display: table-footer-group;
  }

  img, svg, table, figure {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .page-break {
    page-break-before: always;
    break-before: page;
  }

  .page-break-after {
    page-break-after: always;
    break-after: page;
  }

  .no-break {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .keep-together {
    page-break-inside: avoid;
    break-inside: avoid;
  }
}


/* ============================================================
   5. LAYOUT RESET FOR PRINT
   ============================================================ */
@media print {
  .app-layout {
    display: block !important;
  }

  .app-main {
    width: 100% !important;
    margin: 0 !important;
  }

  .app-content {
    padding: 0 !important;
    max-width: 100% !important;
  }

  .container,
  .container-narrow {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .card,
  .widget,
  .chart-card,
  .feature-card,
  .form-card,
  .kpi-card {
    border: 1px solid #ccc !important;
    background: #fff !important;
    box-shadow: none !important;
    border-radius: 6pt !important;
    padding: 12pt !important;
    page-break-inside: avoid;
  }

  .divider {
    background: #ccc !important;
  }
}


/* ============================================================
   6. INVOICE PRINT
   ============================================================ */
@media print {
  .invoice-shell {
    max-width: 100% !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: #fff !important;
  }

  .invoice-paper {
    padding: 0 !important;
    background: #fff !important;
    color: #000 !important;
    font-size: 10.5pt;
  }

  .invoice-header {
    border-bottom: 2px solid #000 !important;
    padding-bottom: 12pt !important;
    margin-bottom: 18pt !important;
  }

  .invoice-title {
    font-size: 26pt !important;
    color: #000 !important;
  }

  .invoice-number {
    color: #555 !important;
    font-family: 'Courier New', monospace;
  }

  .invoice-status-badge {
    border: 1px solid #333 !important;
    color: #333 !important;
    background: #f4f4f4 !important;
  }

  .invoice-status-badge.paid {
    border-color: #0a7a3d !important;
    color: #0a7a3d !important;
    background: #eafaf0 !important;
  }

  .invoice-status-badge.overdue {
    border-color: #a01a1a !important;
    color: #a01a1a !important;
    background: #fdeaea !important;
  }

  .invoice-meta-label,
  .invoice-note-title {
    color: #666 !important;
  }

  .invoice-meta-name,
  .invoice-date-value {
    color: #000 !important;
  }

  .invoice-dates {
    background: #f8f8f8 !important;
    border: 1px solid #ddd !important;
  }

  .invoice-table {
    width: 100% !important;
    border-collapse: collapse !important;
  }

  .invoice-table thead th {
    background: #eee !important;
    color: #000 !important;
    border-bottom: 1px solid #999 !important;
    font-size: 9pt !important;
  }

  .invoice-table tbody td {
    border-bottom: 1px solid #ddd !important;
    color: #000 !important;
    padding: 8pt 6pt !important;
  }

  .invoice-table .num {
    font-family: 'Courier New', monospace;
    color: #000 !important;
  }

  .invoice-summary {
    max-width: 320pt !important;
    margin-left: auto !important;
  }

  .invoice-summary-row {
    padding: 4pt 0 !important;
    font-size: 10pt !important;
  }

  .invoice-summary-row.grand {
    border-top: 2px solid #000 !important;
    padding-top: 8pt !important;
    font-size: 12pt !important;
  }

  .invoice-summary-row.grand .value {
    font-size: 14pt !important;
    color: #000 !important;
    font-weight: 800;
  }

  .invoice-paid-stamp {
    border: 2px solid #0a7a3d !important;
    color: #0a7a3d !important;
    transform: rotate(-6deg);
  }

  .invoice-notes {
    border-top: 1px solid #ccc !important;
  }

  .invoice-note-text {
    color: #333 !important;
  }

  .invoice-footer {
    border-top: 1px solid #ccc !important;
    color: #666 !important;
    font-size: 8pt !important;
  }

  .invoice-footer-highlight {
    color: #000 !important;
  }

  .invoice-qr-code {
    background: #fff !important;
  }
}


/* ============================================================
   7. TABLE PRINT
   ============================================================ */
@media print {
  .table-wrap,
  .table-container {
    overflow: visible !important;
    border: 1px solid #ccc !important;
    border-radius: 0 !important;
    background: #fff !important;
  }

  .table {
    width: 100% !important;
    border-collapse: collapse !important;
    font-size: 9.5pt !important;
  }

  .table thead {
    background: #eee !important;
  }

  .table thead th {
    position: static !important;
    background: #eee !important;
    color: #000 !important;
    border-bottom: 1px solid #999 !important;
    padding: 6pt 8pt !important;
    font-size: 8pt !important;
  }

  .table tbody td {
    border-bottom: 1px solid #ddd !important;
    padding: 6pt 8pt !important;
    color: #000 !important;
  }

  .table tbody tr:nth-child(even) {
    background: #fafafa !important;
  }

  .cell-status,
  .status-pill {
    border: 1px solid #666 !important;
    background: #f4f4f4 !important;
    color: #000 !important;
  }

  .cell-avatar {
    background: #ddd !important;
    color: #000 !important;
  }

  .cell-amount {
    color: #000 !important;
    font-family: 'Courier New', monospace;
  }
}


/* ============================================================
   8. TYPOGRAPHY FOR PRINT
   ============================================================ */
@media print {
  h1 { font-size: 20pt !important; margin: 0 0 10pt !important; }
  h2 { font-size: 16pt !important; margin: 0 0 8pt !important; }
  h3 { font-size: 13pt !important; margin: 0 0 6pt !important; }
  h4 { font-size: 11pt !important; margin: 0 0 5pt !important; }
  h5 { font-size: 10pt !important; margin: 0 0 4pt !important; }
  h6 { font-size: 9.5pt !important; margin: 0 0 4pt !important; }

  p { margin: 0 0 6pt !important; }

  a {
    color: #000 !important;
    text-decoration: none !important;
  }

  /* Show URL after link (optional) */
  a[href^="http"]:not(.no-url)::after {
    content: "";
  }

  .text-accent,
  .text-electric,
  .text-success,
  .text-warning,
  .text-danger,
  .text-info {
    color: #000 !important;
  }

  .gradient-text,
  .gradient-text-accent {
    background: none !important;
    -webkit-text-fill-color: #000 !important;
    color: #000 !important;
  }
}


/* ============================================================
   9. KPI / STATS FOR PRINT
   ============================================================ */
@media print {
  .kpi-row,
  .kpi-grid,
  .stats-mini {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 8pt !important;
  }

  .kpi-card,
  .kpi {
    border: 1px solid #ccc !important;
    padding: 8pt !important;
    background: #fff !important;
  }

  .kpi-card-value,
  .kpi-value {
    font-size: 14pt !important;
    color: #000 !important;
  }

  .kpi-card-label,
  .kpi-label {
    font-size: 8pt !important;
    color: #666 !important;
  }
}


/* ============================================================
   10. CHART PRINT
   ============================================================ */
@media print {
  .chart-card {
    border: 1px solid #ccc !important;
    background: #fff !important;
    page-break-inside: avoid;
  }

  .chart-canvas-wrap {
    height: 200pt !important;
  }

  .chart-canvas-wrap canvas {
    filter: grayscale(100%) contrast(1.2) !important;
  }

  .chart-tabs,
  .chart-card-actions {
    display: none !important;
  }
}


/* ============================================================
   11. HEADER / FOOTER FOR PRINT
   ============================================================ */
@media print {
  .print-header {
    display: block !important;
    text-align: center;
    border-bottom: 1px solid #ccc;
    padding-bottom: 8pt;
    margin-bottom: 16pt;
    font-size: 9pt;
    color: #666;
  }

  .print-footer {
    display: block !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    border-top: 1px solid #ccc;
    padding-top: 6pt;
    font-size: 8pt;
    color: #888;
  }

  .print-title {
    font-size: 14pt;
    font-weight: 700;
    color: #000;
    margin-bottom: 4pt;
  }

  .print-subtitle {
    font-size: 10pt;
    color: #666;
  }

  .print-meta {
    display: flex;
    justify-content: space-between;
    font-size: 9pt;
    color: #666;
    margin-bottom: 12pt;
  }
}

.print-header,
.print-footer {
  display: none;
}


/* ============================================================
   12. COLOR PRESERVATION
   ============================================================ */
@media print {
  .print-color-accent { color: #0a7a3d !important; }
  .print-color-danger { color: #a01a1a !important; }
  .print-color-warning { color: #a06a00 !important; }

  .print-bg-accent { background: #eafaf0 !important; }
  .print-bg-danger { background: #fdeaea !important; }
  .print-bg-warning { background: #fdf5e6 !important; }

  .print-border-accent { border-color: #0a7a3d !important; }
  .print-border-danger { border-color: #a01a1a !important; }
}


/* ============================================================
   13. HIDE SCROLLBARS & OVERFLOWS
   ============================================================ */
@media print {
  ::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
  }

  * {
    scrollbar-width: none !important;
    overflow: visible !important;
  }

  .modal,
  .dropdown,
  .autocomplete-menu {
    display: none !important;
  }
}


/* ============================================================
   14. REPORTS PRINT
   ============================================================ */
@media print {
  .report-header {
    display: flex !important;
    justify-content: space-between;
    align-items: flex-end;
    border-bottom: 2px solid #000;
    padding-bottom: 8pt;
    margin-bottom: 12pt;
  }

  .report-title {
    font-size: 16pt !important;
    color: #000 !important;
    margin: 0;
  }

  .report-meta {
    font-size: 9pt !important;
    color: #666 !important;
    text-align: right;
  }

  .report-section {
    margin-bottom: 16pt;
    page-break-inside: avoid;
  }

  .report-section-title {
    font-size: 12pt !important;
    color: #000 !important;
    border-bottom: 1px solid #ccc;
    padding-bottom: 4pt;
    margin-bottom: 8pt;
  }
}


/* ============================================================
   15. LANDSCAPE HELPER
   ============================================================ */
@media print {
  .print-landscape {
    page: landscape;
  }
}


/* ============================================================
   16. UTILITIES
   ============================================================ */
@media print {
  .print-show { display: block !important; }
  .print-hide { display: none !important; }
  .print-inline { display: inline !important; }
  .print-flex { display: flex !important; }

  .print-m-0 { margin: 0 !important; }
  .print-mt-0 { margin-top: 0 !important; }
  .print-mb-0 { margin-bottom: 0 !important; }
  .print-p-0 { padding: 0 !important; }

  .print-text-left { text-align: left !important; }
  .print-text-center { text-align: center !important; }
  .print-text-right { text-align: right !important; }

  .print-w-full { width: 100% !important; }

  .print-border { border: 1px solid #ccc !important; }
  .print-border-0 { border: 0 !important; }

  .print-rounded { border-radius: 4pt !important; }
  .print-rounded-0 { border-radius: 0 !important; }
}


/* ============================================================
   17. SCREEN — PRINT BUTTON
   ============================================================ */
@media screen {
  .print-only {
    display: none !important;
  }
}


/* ============================================================
   18. REDUCED INK / MONOCHROME FALLBACK
   ============================================================ */
@media print and (monochrome) {
  .invoice-status-badge,
  .cell-status,
  .status-pill,
  .badge {
    border: 1px solid #000 !important;
    background: #fff !important;
    color: #000 !important;
  }

  .invoice-summary-row.grand .value {
    color: #000 !important;
  }
}