/* Print styles for FAMAS application */
/* This stylesheet controls what is visible when printing pages */

/* ======================================
   PRINT MEDIA QUERY
   ====================================== */
@media print {
    /* Reset page margins for better printing */
    @page {
        size: A4;
        margin: 15mm 10mm;
    }

    /* ======================================
       HIDE NON-PRINTABLE ELEMENTS
       ====================================== */
    
    /* Hide sidebar, navigation, and layout chrome */
    .sidebar,
    .sidebar-header,
    .sidebar-nav,
    .navbar,
    .topbar,
    .dashboard-topbar,
    .page-footer,
    footer,
    .sidebar-toggle,
    .mobile-menu-toggle {
        display: none !important;
    }

    /* Hide action buttons and interactive elements */
    .detail-action-buttons,
    .btn-copy,
    .wizard-actions-dropdown,
    .dropdown-container,
    .btn-link-badge,
    .btn-link-text,
    .btn-add,
    .btn-close,
    .no-print,
    .d-print-none {
        display: none !important;
    }

    /* Hide update banners and notifications */
    .update-banner,
    .notification-panel,
    .toast-container,
    .toast,
    .alert-dismissible .btn-close {
        display: none !important;
    }

    /* Hide comment input sections (but show existing comments) */
    .comment-input-section,
    .comment-actions,
    .comment-reply-btn {
        display: none !important;
    }

    /* Hide attachment management sections (upload area, delete buttons) */
    .attachment-upload,
    .attachment-manager-actions,
    .attachment-delete-btn,
    .attachment-edit-btn {
        display: none !important;
    }

    /* Hide modals and overlays */
    .modal,
    .modal-backdrop,
    .offcanvas,
    .offcanvas-backdrop {
        display: none !important;
    }

    /* Hide scrollbars */
    * {
        overflow: visible !important;
    }

    /* ======================================
       LAYOUT ADJUSTMENTS FOR PRINTING
       ====================================== */
    
    /* Remove sidebar layout constraints */
    .dashboard-container,
    .dashboard-container.sidebar-collapsed {
        display: block !important;
        padding-left: 0 !important;
        margin-left: 0 !important;
    }

    /* Make content fill the page */
    .dashboard-content,
    .main-content,
    .content-area {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Reset any transforms or positions */
    body {
        padding: 0 !important;
        margin: 0 !important;
        background: white !important;
        font-size: 11pt !important;
        line-height: 1.4 !important;
    }

    html {
        background: white !important;
    }

    /* ======================================
       PAGE BREAK CONTROLS
       ====================================== */
    
    /* Prevent page breaks inside these elements */
    .detail-card,
    .card,
    .info-grid,
    .info-item,
    tr,
    .comment-item,
    .approver-step {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    /* Allow page breaks before major sections */
    .detail-card {
        break-before: auto;
        page-break-before: auto;
    }

    /* Force page breaks before attachment contents */
    .print-attachment-section {
        break-before: page;
        page-break-before: always;
    }

    /* ======================================
       TYPOGRAPHY FOR PRINT
       ====================================== */
    
    /* Ensure text is readable when printed */
    body, p, span, div, td, th {
        color: #000 !important;
    }

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

    /* Ensure headers stand out */
    h1, h2, h3, h4, h5, h6,
    .page-title,
    .card-title {
        color: #000 !important;
        font-weight: 600 !important;
    }

    .page-title {
        font-size: 16pt !important;
        margin-bottom: 8pt !important;
    }

    .page-subtitle {
        font-size: 10pt !important;
        color: #666 !important;
    }

    /* ======================================
       DETAIL PAGE HEADER
       ====================================== */
    
    .detail-page-header {
        border-bottom: 1px solid #ccc !important;
        padding-bottom: 10pt !important;
        margin-bottom: 15pt !important;
    }

    .detail-title-row {
        display: block !important;
    }

    .detail-header-info {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 10pt !important;
    }

    .detail-info-item {
        margin-right: 15pt !important;
    }

    .detail-label {
        font-weight: 600 !important;
        color: #333 !important;
    }

    .detail-value {
        color: #000 !important;
    }

    /* ======================================
       CARDS AND SECTIONS
       ====================================== */
    
    .detail-card {
        border: 1px solid #ddd !important;
        border-radius: 0 !important;
        margin-bottom: 15pt !important;
        box-shadow: none !important;
        background: white !important;
    }

    .detail-card .card-header,
    .card-header {
        background: #f5f5f5 !important;
        border-bottom: 1px solid #ddd !important;
        padding: 8pt 12pt !important;
    }

    .card-title {
        font-size: 12pt !important;
        margin: 0 !important;
    }

    .card-body {
        padding: 12pt !important;
    }

    /* ======================================
       INFO GRID AND ITEMS
       ====================================== */
    
    .info-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 8pt !important;
    }

    .info-item {
        margin-bottom: 6pt !important;
    }

    .info-label {
        font-weight: 600 !important;
        font-size: 9pt !important;
        color: #666 !important;
    }

    .info-value {
        font-size: 10pt !important;
        color: #000 !important;
    }

    .info-full-width {
        grid-column: span 2 !important;
    }

    /* ======================================
       TABLES (Line Items, Attachments)
       ====================================== */
    
    table,
    .line-items-table,
    .attachments-table {
        width: 100% !important;
        border-collapse: collapse !important;
        font-size: 9pt !important;
    }

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

    table th {
        background: #f5f5f5 !important;
        font-weight: 600 !important;
    }

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

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

    .total-row {
        font-weight: 600 !important;
        background: #f9f9f9 !important;
    }

    /* ======================================
       STATUS AND PRIORITY BADGES
       ====================================== */
    
    .status-badge,
    .priority-badge,
    .workflow-badge,
    .currency-badge,
    .file-type-badge {
        display: inline-block !important;
        padding: 2pt 6pt !important;
        border: 1px solid #999 !important;
        border-radius: 3pt !important;
        font-size: 8pt !important;
        background: #f5f5f5 !important;
        color: #000 !important;
    }

    /* ======================================
       COMMENTS SECTION
       ====================================== */
    
    .comments-list {
        border: 1px solid #ddd !important;
    }

    .comment-item {
        padding: 8pt 12pt !important;
        border-bottom: 1px solid #eee !important;
    }

    .comment-item:last-child {
        border-bottom: none !important;
    }

    .comment-item.is-action-comment {
        background: #f9f9f9 !important;
    }

    .comment-header {
        font-weight: 600 !important;
        font-size: 9pt !important;
        margin-bottom: 4pt !important;
    }

    .comment-body,
    .comment-text {
        font-size: 10pt !important;
        color: #333 !important;
    }

    .comment-meta {
        font-size: 8pt !important;
        color: #666 !important;
    }

    /* ======================================
       APPROVERS SUMMARY
       ====================================== */
    
    .approvers-summary {
        border: 1px solid #ddd !important;
        margin-bottom: 15pt !important;
    }

    .approver-step {
        padding: 8pt 12pt !important;
        border-bottom: 1px solid #eee !important;
    }

    .approver-step:last-child {
        border-bottom: none !important;
    }

    /* ======================================
       PRINT ATTACHMENT SECTION
       (For embedded attachment contents)
       ====================================== */
    
    .print-attachments-container {
        display: block !important;
    }

    .print-attachment-section {
        margin-top: 20pt !important;
        padding-top: 10pt !important;
        border-top: 2px solid #000 !important;
    }

    .print-attachment-header {
        font-size: 12pt !important;
        font-weight: 600 !important;
        margin-bottom: 10pt !important;
        padding: 8pt !important;
        background: #f5f5f5 !important;
        border: 1px solid #ddd !important;
    }

    .print-attachment-content {
        max-width: 100% !important;
    }

    .print-attachment-content img {
        max-width: 100% !important;
        height: auto !important;
        page-break-inside: avoid !important;
    }

    .print-attachment-content embed,
    .print-attachment-content iframe,
    .print-attachment-content object {
        width: 100% !important;
        min-height: 800pt !important;
        border: 1px solid #ddd !important;
    }

    /* For PDF pages rendered as images */
    .print-pdf-page {
        max-width: 100% !important;
        margin-bottom: 10pt !important;
        border: 1px solid #ddd !important;
        box-shadow: none !important;
    }

    .print-attachment-error {
        padding: 10pt !important;
        background: #fee !important;
        border: 1px solid #fcc !important;
        color: #c00 !important;
        font-size: 10pt !important;
    }

    .print-attachment-info {
        font-size: 9pt !important;
        color: #666 !important;
        margin-bottom: 8pt !important;
    }

    /* ======================================
       SCREEN-ONLY ELEMENTS
       (Hide print-specific elements on screen)
       ====================================== */
}

/* ======================================
   SCREEN-ONLY STYLES
   ====================================== */

/* Hide print-only content when viewing on screen */
@media screen {
    .print-only,
    .print-attachments-container {
        display: none !important;
    }
}

/* Print button styling (visible on screen, hidden on print) */
.btn-print {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

@media print {
    .btn-print {
        display: none !important;
    }
}
