/* ========================================
   PRINT STYLES - ORDINI
   Stili ottimizzati per la stampa degli ordini
   ======================================== */

@media print {
    /* ============ RESET E CONFIGURAZIONE GENERALE ============ */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    body {
        margin: 0;
        padding: 0;
        background: white !important;
        color: black !important;
        font-size: 10pt;
        line-height: 1.3;
        font-family: Arial, Helvetica, sans-serif;
    }

    /* ============ NASCONDI ELEMENTI UI NON NECESSARI ============ */
    .navbar,
    .fab-wrapper,
    .no-print,
    .breadcrumb,
    .modal,
    .modal-backdrop,
    .alert,
    button:not(.print-visible),
    .btn-group,
    .dropdown,
    footer,
    .col-lg-4,
    #confirmCancelModal,
    form[action*="cancel"] {
        display: none !important;
    }

    /* ============ LAYOUT PAGINA ============ */
    .container,
    .container-fluid {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 10mm !important;
    }

    .row {
        display: block !important;
        margin: 0 !important;
    }

    .col-12,
    .col-lg-8,
    [class*="col-"] {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* ============ HEADER STAMPA ============ */
    .print-header {
        display: block !important;
        margin-bottom: 12pt;
        page-break-after: avoid;
    }

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

    .print-header h1 {
        font-size: 18pt;
        font-weight: bold;
        margin: 0 0 12pt 0;
        padding-bottom: 8pt;
        border-bottom: 2pt solid #000;
        color: #000 !important;
        text-align: center;
        letter-spacing: 2pt;
    }

    .print-header h1 i {
        display: none;
    }

    /* Box informazioni stile documento ufficiale */
    .print-info-box {
        display: table !important;
        width: 100%;
        border: 1.5pt solid #000;
        margin-bottom: 12pt;
        page-break-inside: avoid;
    }

    .print-info-box .print-section {
        display: table-cell;
        width: 33.33%;
        padding: 8pt;
        vertical-align: top;
        border-right: 1pt solid #000;
    }

    .print-info-box .print-section:last-child {
        border-right: none;
    }

    .print-info-box .print-section h6 {
        font-weight: bold;
        font-size: 10pt;
        margin: 0 0 6pt 0;
        padding-bottom: 4pt;
        border-bottom: 1pt solid #999;
        color: #000 !important;
        text-transform: uppercase;
    }

    .print-info-box .print-section p {
        margin: 3pt 0;
        font-size: 9pt;
        color: #000 !important;
        line-height: 1.4;
    }

    .print-info-box .print-section strong {
        font-weight: bold;
        font-size: 10pt;
    }

    /* ============ CARDS - GESTIONE STAMPA ============ */
    .card {
        border: 1pt solid #000 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        margin-bottom: 10pt !important;
        page-break-inside: avoid;
        background: white !important;
    }

    /* Nascondi la prima card "Informazioni Ordine" perché abbiamo il print-header */
    .col-lg-8 > .card:first-of-type {
        display: none !important;
    }

    .card-header {
        background: #e8e8e8 !important;
        border-bottom: 1pt solid #000 !important;
        padding: 6pt 8pt !important;
        font-weight: bold;
        font-size: 11pt;
        color: #000 !important;
    }

    .card-header h5 {
        font-size: 11pt;
        margin: 0;
        color: #000 !important;
        font-weight: bold;
    }

    .card-header .icon-accent,
    .card-header i {
        display: none;
    }

    .card-body {
        padding: 8pt !important;
        background: white !important;
    }

    /* ============ BADGE E LABEL ============ */
    .badge {
        border: 1pt solid #000 !important;
        background: white !important;
        color: #000 !important;
        padding: 2pt 5pt;
        font-weight: bold;
        font-size: 9pt;
    }

    /* ============ TABELLA ARTICOLI - VISTA DESKTOP ============ */
    /* Forza visualizzazione della tabella desktop */
    .d-none.d-lg-block {
        display: block !important;
        visibility: visible !important;
    }

    /* Nascondi completamente la vista mobile */
    .d-lg-none,
    .mobile-card-view {
        display: none !important;
        visibility: hidden !important;
    }

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

    .table {
        width: 100% !important;
        border-collapse: collapse !important;
        margin: 0 !important;
        page-break-inside: auto;
        background: white !important;
        display: table !important;
        font-size: 9pt;
    }

    .table thead {
        display: table-header-group !important;
    }

    .table tbody {
        display: table-row-group !important;
    }

    .table tfoot {
        display: table-footer-group !important;
        font-weight: bold;
    }

    .table tr {
        display: table-row !important;
        page-break-inside: avoid;
    }

    .table th,
    .table td {
        display: table-cell !important;
        border: 1pt solid #000 !important;
        padding: 4pt 6pt !important;
        color: #000 !important;
        background: white !important;
        page-break-inside: avoid;
        vertical-align: middle;
    }

    .table thead th {
        background: #e8e8e8 !important;
        font-weight: bold;
        text-align: left;
        font-size: 9pt;
    }

    .table tfoot th,
    .table tfoot td {
        background: #f0f0f0 !important;
        font-weight: bold;
        border-top: 2pt solid #000 !important;
        font-size: 10pt;
    }

    /* Allineamenti */
    .table .text-end {
        text-align: right !important;
    }

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

    /* Nascondi immagini per risparmiare inchiostro */
    .article-thumbnail-stack,
    .article-thumb-lg,
    .article-thumb-md,
    .article-inline img,
    img {
        display: none !important;
    }

    .article-inline {
        display: inline !important;
    }

    /* ============ TESTO GENERATO / NOTE ============ */
    pre {
        white-space: pre-wrap !important;
        word-wrap: break-word !important;
        font-family: 'Courier New', monospace;
        font-size: 8pt;
        border: 1pt solid #000 !important;
        padding: 6pt !important;
        background: #f9f9f9 !important;
        page-break-inside: avoid;
        line-height: 1.3;
    }

    /* ============ COLORI E STILI - B/N ============ */
    .text-primary,
    .text-success,
    .text-danger,
    .text-warning,
    .text-info,
    .text-muted,
    strong {
        color: #000 !important;
    }

    .bg-success,
    .bg-danger,
    .bg-warning,
    .bg-info,
    .bg-light,
    .bg-primary {
        background: white !important;
    }

    .border-success,
    .border-danger,
    .border-warning,
    .border-primary {
        border-color: #000 !important;
    }

    /* ============ INTERRUZIONI DI PAGINA ============ */
    h1, h2, h3, h4, h5, h6 {
        page-break-after: avoid;
        color: #000 !important;
    }

    .card,
    .print-info-box,
    .table tr {
        page-break-inside: avoid;
    }

    /* ============ FOOTER STAMPA ============ */
    .print-footer {
        display: block !important;
        margin-top: 15pt;
        padding-top: 10pt;
        border-top: 1pt solid #000;
        font-size: 8pt;
        page-break-inside: avoid;
    }

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

    .print-footer #print-date {
        text-align: center;
        margin: 0;
        color: #666 !important;
    }

    /* RIMUOVI FIRMA E TIMBRO */
    .print-footer > div {
        display: none !important;
    }

    /* ============ SPECIFICO PER TIMELINE ============ */
    .order-timeline,
    .order-timeline-compact,
    .order-timeline-vertical {
        display: none !important;
    }

    /* ============ OTTIMIZZAZIONI GENERALI ============ */
    dl {
        margin: 0;
    }

    dt {
        font-weight: bold;
        color: #000 !important;
        margin-bottom: 2pt;
        font-size: 9pt;
    }

    dd {
        margin-bottom: 6pt;
        color: #000 !important;
        font-size: 9pt;
    }

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

    /* Rimuovi colori di sfondo dalle righe alternate */
    .table-striped tbody tr:nth-of-type(odd) {
        background: white !important;
    }

    /* Nascondi bordi decorativi */
    .border-start,
    .border-end {
        border-left: none !important;
        border-right: none !important;
    }

    /* Bordi interni tabella per confronto ordinato/ricevuto */
    .table th.border-end,
    .table td.border-end {
        border-right: 2pt solid #000 !important;
    }

    /* ============ MARGINI E PADDING RIDOTTI ============ */
    .mb-3,
    .my-3,
    .mt-3 {
        margin-bottom: 8pt !important;
        margin-top: 0 !important;
    }

    hr {
        border: none;
        border-top: 1pt solid #ccc;
        margin: 6pt 0;
    }

    /* ============ LAYOUT COMPATTO ============ */
    @page {
        margin: 15mm;
        size: A4;
    }
}
