/**
 * AccountingLT - Print Stylesheet
 *
 * Optimized for printing reports and documents.
 * Include via: <link rel="stylesheet" href="{% static 'css/print.css' %}" media="print">
 */

@media print {
    /* ==========================================================================
       Hide UI Elements
       ========================================================================== */

    .navbar,
    .footer,
    .btn,
    .btn-group,
    .no-print,
    .date-presets,
    .saved-filters,
    .loading-overlay,
    .breadcrumb,
    .alert-dismissible .btn-close,
    form[method="get"],
    .dropdown-menu,
    .form-check input,
    input[type="checkbox"],
    input[type="radio"],
    select,
    .pagination,
    .card-header .btn-group {
        display: none !important;
    }

    /* ==========================================================================
       Page Layout
       ========================================================================== */

    @page {
        margin: 1.5cm;
        size: A4;
    }

    @page :first {
        margin-top: 2cm;
    }

    body {
        font-family: "Times New Roman", Times, serif;
        font-size: 10pt;
        line-height: 1.3;
        color: #000;
        background: #fff;
    }

    html, body {
        width: 100%;
        height: auto;
        margin: 0;
        padding: 0;
    }

    main {
        padding: 0 !important;
        margin: 0 !important;
    }

    .container-fluid {
        padding: 0 !important;
        max-width: none !important;
    }

    /* ==========================================================================
       Page Breaks
       ========================================================================== */

    .page-break {
        page-break-before: always;
    }

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

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

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

    table, figure {
        page-break-inside: avoid;
    }

    tr {
        page-break-inside: avoid;
    }

    /* ==========================================================================
       Cards
       ========================================================================== */

    .card {
        border: 1px solid #000 !important;
        box-shadow: none !important;
        margin-bottom: 0.5cm !important;
    }

    .card-header {
        background-color: #f0f0f0 !important;
        border-bottom: 1px solid #000 !important;
        padding: 0.25cm 0.5cm !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .card-header h5,
    .card-header h6 {
        margin: 0;
        font-size: 12pt;
    }

    .card-body {
        padding: 0.5cm !important;
    }

    /* ==========================================================================
       Tables
       ========================================================================== */

    .table-responsive {
        overflow: visible !important;
    }

    table {
        border-collapse: collapse !important;
        width: 100% !important;
        font-size: 9pt;
    }

    table th,
    table td {
        border: 1px solid #000 !important;
        padding: 2px 4px !important;
    }

    table th {
        background-color: #e0e0e0 !important;
        font-weight: bold !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .table-dark th {
        background-color: #333 !important;
        color: #fff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .table-light td,
    .table-light th {
        background-color: #f5f5f5 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .table-striped tbody tr:nth-of-type(odd) {
        background-color: #f9f9f9 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    tfoot tr {
        font-weight: bold !important;
        border-top: 2px solid #000 !important;
    }

    .text-end {
        text-align: right !important;
    }

    .text-center {
        text-align: center !important;
    }

    /* ==========================================================================
       Collapsible Sections
       ========================================================================== */

    .collapsible-section .collapse,
    .collapsible-section .collapsing {
        display: block !important;
        height: auto !important;
        visibility: visible !important;
    }

    .collapsible-header {
        background-color: #f0f0f0 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .collapsible-icon {
        display: none !important;
    }

    /* ==========================================================================
       Links
       ========================================================================== */

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

    /* Don't show URL after links in print */
    a[href]:after {
        content: none !important;
    }

    /* ==========================================================================
       Headers & Titles
       ========================================================================== */

    h1 {
        font-size: 16pt;
        margin-bottom: 0.5cm;
    }

    h2 {
        font-size: 14pt;
    }

    h3, h4 {
        font-size: 12pt;
    }

    h5, h6 {
        font-size: 11pt;
    }

    /* ==========================================================================
       Alerts and Badges
       ========================================================================== */

    .alert {
        border: 1px solid #000 !important;
        padding: 0.25cm !important;
        margin-bottom: 0.25cm !important;
    }

    .badge {
        border: 1px solid #000 !important;
        padding: 1px 4px !important;
    }

    /* ==========================================================================
       Report-Specific Styles
       ========================================================================== */

    /* Company header for reports */
    .report-header {
        text-align: center;
        margin-bottom: 0.5cm;
        border-bottom: 1px solid #000;
        padding-bottom: 0.25cm;
    }

    .report-header .company-name {
        font-size: 14pt;
        font-weight: bold;
    }

    .report-header .company-code {
        font-size: 10pt;
    }

    .report-header .report-title {
        font-size: 12pt;
        font-weight: bold;
        margin-top: 0.25cm;
    }

    .report-header .report-period {
        font-size: 10pt;
    }

    /* Report footer */
    .report-footer {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        text-align: center;
        font-size: 8pt;
        border-top: 1px solid #ccc;
        padding-top: 0.1cm;
    }

    /* ==========================================================================
       Balance Sheet Specific
       ========================================================================== */

    .balance-sheet-section {
        margin-bottom: 0.5cm;
    }

    .balance-sheet-section h4 {
        font-size: 11pt;
        font-weight: bold;
        margin: 0.25cm 0;
        border-bottom: 1px solid #ccc;
    }

    .balance-sheet-row {
        display: flex;
        justify-content: space-between;
        padding: 1px 0;
    }

    .balance-sheet-row.indent-1 {
        padding-left: 0.5cm;
    }

    .balance-sheet-row.indent-2 {
        padding-left: 1cm;
    }

    .balance-sheet-row.total {
        font-weight: bold;
        border-top: 1px solid #000;
        margin-top: 0.1cm;
        padding-top: 0.1cm;
    }

    /* ==========================================================================
       Invoice Specific
       ========================================================================== */

    .invoice-header {
        display: flex;
        justify-content: space-between;
        margin-bottom: 0.5cm;
    }

    .invoice-logo {
        max-width: 3cm;
        max-height: 2cm;
    }

    .invoice-details {
        text-align: right;
    }

    .invoice-parties {
        display: flex;
        justify-content: space-between;
        margin-bottom: 0.5cm;
    }

    .invoice-seller,
    .invoice-buyer {
        width: 48%;
    }

    .invoice-totals {
        margin-top: 0.5cm;
        text-align: right;
    }

    .invoice-totals .total-row {
        display: flex;
        justify-content: flex-end;
        gap: 1cm;
    }

    .invoice-totals .grand-total {
        font-size: 12pt;
        font-weight: bold;
        border-top: 2px solid #000;
        margin-top: 0.25cm;
        padding-top: 0.25cm;
    }

    /* ==========================================================================
       Utilities
       ========================================================================== */

    .fw-bold {
        font-weight: bold !important;
    }

    .text-muted {
        color: #666 !important;
    }

    .text-danger {
        color: #c00 !important;
    }

    .text-success {
        color: #060 !important;
    }

    .small {
        font-size: 8pt !important;
    }

    .border-top {
        border-top: 1px solid #000 !important;
    }

    .border-bottom {
        border-bottom: 1px solid #000 !important;
    }

    /* Hide screen-only elements */
    .d-print-none {
        display: none !important;
    }

    /* Show print-only elements */
    .d-none.d-print-block {
        display: block !important;
    }

    .d-none.d-print-inline {
        display: inline !important;
    }
}
