/**
 * Modern document detail views (purchase, PO, stock transfer, etc.)
 * Applies to AJAX modals (.view_modal) and full-page document shells.
 */

.modern-document-show {
    --modern-doc-thead-bg: #eff6ff;
    --modern-doc-thead-text: #1e40af;
    --modern-doc-thead-border: #2563eb;
    --modern-doc-thead-border-soft: #bfdbfe;
    --modern-doc-total-bg: #eff6ff;
    --modern-doc-total-text: #1e40af;
}

.modern-doc-page-header-wrap {
    padding-bottom: 0;
}

.modern-doc-page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.modern-doc-page-title {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
    color: #0f172a;
}

.modern-doc-page-header__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.modern-doc-page-shell {
    padding-top: 0;
}

.modern-doc-page-shell .modal-dialog {
    width: 100%;
    max-width: min(96vw, 1600px);
    margin: 0 auto;
}

.modern-doc-page-shell .modal-dialog.modal-xl {
    width: 100%;
    max-width: min(96vw, 1600px);
}

.modern-document-show,
.view_modal .modal-content.modern-document-show {
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    overflow: hidden;
    background: #ffffff;
}

.modern-doc-page-shell .modern-document-show .modal-header .close,
.modern-doc-page-shell .modern-document-show .modal-footer [data-dismiss="modal"] {
    display: none;
}

.modern-document-show .modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border-bottom: 1px solid #e2e8f0;
}

.modern-document-show .modal-title {
    flex: 1;
    margin: 0;
    font-size: 1.125rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.4;
}

.modern-document-show .modal-body {
    padding: 20px;
    background: #f8fafc;
    color: #334155;
    font-size: 14px;
    line-height: 1.5;
}

.modern-document-show .modal-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 20px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
}

.modern-document-show .invoice-info {
    margin-bottom: 8px;
}

.modern-document-show .invoice-col {
    margin-bottom: 16px;
}

.modern-document-show .invoice-col > address,
.modern-document-show .invoice-col address {
    margin-top: 8px;
    padding: 14px 16px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    font-style: normal;
    color: #475569;
    line-height: 1.55;
}

.modern-document-show .invoice-col > address strong,
.modern-document-show .invoice-col address strong {
    color: #0f172a;
    font-size: 15px;
}

.modern-document-show .invoice-col > b,
.modern-document-show .invoice-col b {
    color: #0f172a;
}

.modern-document-show .table-responsive {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: auto;
    background: #ffffff;
    -webkit-overflow-scrolling: touch;
}

.modern-document-show .modern-doc-lines-scroll {
    width: 100%;
    max-width: 100%;
    margin-bottom: 16px;
    overflow-x: auto !important;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
}

.modern-document-show table.modern-doc-lines-table.table {
    width: max-content !important;
    min-width: 100% !important;
    max-width: none !important;
    table-layout: fixed !important;
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: 0;
}

.modern-document-show table.modern-doc-lines-table col.modern-doc-col-num { width: 52px; }
.modern-document-show table.modern-doc-lines-table col.modern-doc-col-product { width: 240px; }
.modern-document-show table.modern-doc-lines-table col.modern-doc-col-sku { width: 130px; }
.modern-document-show table.modern-doc-lines-table col.modern-doc-col-qty { width: 150px; }
.modern-document-show table.modern-doc-lines-table col.modern-doc-col-money { width: 140px; }
.modern-document-show table.modern-doc-lines-table col.modern-doc-col-pct { width: 100px; }
.modern-document-show table.modern-doc-lines-table col.modern-doc-col-tax { width: 120px; }
.modern-document-show table.modern-doc-lines-table col.modern-doc-col-meta { width: 110px; }

.modern-document-show table.modern-doc-lines-table > thead > tr > th,
.modern-document-show table.modern-doc-lines-table > thead > tr.bg-green > th {
    background: var(--modern-doc-thead-bg) !important;
    color: var(--modern-doc-thead-text) !important;
    border-color: var(--modern-doc-thead-border-soft) !important;
    border-bottom: 2px solid var(--modern-doc-thead-border) !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: normal !important;
    word-break: normal;
    overflow-wrap: normal;
    hyphens: manual;
    line-height: 1.35 !important;
    vertical-align: bottom;
    padding: 12px 14px !important;
}

.modern-document-show table.modern-doc-lines-table > tbody > tr > td {
    padding: 12px 14px !important;
    vertical-align: middle !important;
    border-top: 1px solid #e2e8f0;
    overflow-wrap: anywhere;
}

.modern-document-show table.modern-doc-lines-table > tbody > tr > td.modern-doc-col-product,
.modern-document-show table.modern-doc-lines-table > tbody > tr > td.modern-doc-col-sku,
.modern-document-show table.modern-doc-lines-table > tbody > tr > td.modern-doc-col-qty {
    white-space: normal !important;
    word-break: break-word;
    line-height: 1.45;
}

.modern-document-show table.modern-doc-lines-table > tbody > tr > td.modern-doc-col-money,
.modern-document-show table.modern-doc-lines-table > tbody > tr > td.modern-doc-col-pct,
.modern-document-show table.modern-doc-lines-table > tbody > tr > td.modern-doc-col-tax,
.modern-document-show table.modern-doc-lines-table > thead > tr > th.modern-doc-col-money,
.modern-document-show table.modern-doc-lines-table > thead > tr > th.modern-doc-col-pct,
.modern-document-show table.modern-doc-lines-table > thead > tr > th.modern-doc-col-tax {
    white-space: nowrap !important;
    font-variant-numeric: tabular-nums;
}

.modern-document-show table.modern-doc-lines-table > thead > tr > th.modern-doc-col-num,
.modern-document-show table.modern-doc-lines-table > tbody > tr > td.modern-doc-col-num {
    text-align: center !important;
}

.modern-document-show .table {
    margin-bottom: 0;
    background: #ffffff;
}

.modern-document-show .table:not(.modern-doc-lines-table) > thead > tr > th,
.modern-document-show .table:not(.modern-doc-lines-table) > thead > tr.bg-green > th,
.modern-document-show .table:not(.modern-doc-lines-table) > tbody > tr.bg-green > th {
    background: var(--modern-doc-thead-bg) !important;
    color: var(--modern-doc-thead-text) !important;
    border-color: var(--modern-doc-thead-border-soft) !important;
    border-bottom: 2px solid var(--modern-doc-thead-border) !important;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
    vertical-align: middle;
    padding: 10px 12px;
}

.modern-document-show .table:not(.modern-doc-lines-table) > tbody > tr > td,
.modern-document-show .table:not(.modern-doc-lines-table) > tbody > tr > th {
    border-top: 1px solid #e2e8f0;
    padding: 12px 14px;
    vertical-align: middle;
}

.modern-document-show .modern-doc-totals-row {
    margin-top: 8px;
}

.modern-document-show .modern-doc-totals-panel {
    margin-left: auto;
}

.modern-document-show .modern-doc-totals-table {
    width: 100%;
    min-width: 320px;
    table-layout: fixed;
}

.modern-document-show .modern-doc-totals-table th {
    width: 52%;
    color: #64748b;
    font-weight: 600;
    border: none;
    padding: 10px 14px;
    vertical-align: middle;
    white-space: normal;
}

.modern-document-show .modern-doc-totals-table td:nth-child(2) {
    width: 8%;
    text-align: center;
    color: #94a3b8;
    border: none;
    padding: 10px 8px;
}

.modern-document-show .modern-doc-totals-table td:last-child {
    width: 40%;
    text-align: right;
    font-variant-numeric: tabular-nums;
    border: none;
    padding: 10px 14px;
}

.modern-document-show .modern-doc-totals-table tr:last-child th,
.modern-document-show .modern-doc-totals-table tr:last-child td {
    background: var(--modern-doc-total-bg);
    color: var(--modern-doc-total-text);
    font-weight: 700;
    font-size: 15px;
}

.modern-document-show .modern-doc-payment-table > thead > tr > th {
    white-space: nowrap;
}

.modern-document-show table.modern-doc-lines-table > tbody > tr:nth-child(even) > td {
    background: #f8fafc;
}

.modern-document-show table.modern-doc-lines-table > tbody > tr:hover > td {
    background: #f1f5f9;
}

.modern-document-show .table:not(.modern-doc-lines-table) > tbody > tr:nth-child(even) > td {
    background: #f8fafc;
}

.modern-document-show .table:not(.modern-doc-lines-table) > tbody > tr:hover > td {
    background: #f1f5f9;
}

.modern-document-show .well,
.modern-document-show .well-sm {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #ffffff !important;
    box-shadow: none;
    padding: 12px 14px;
    color: #475569;
}

.modern-document-show .procurement-workflow-panel .box {
    border: 1px solid #dbeafe;
    border-radius: 12px;
    box-shadow: none;
    overflow: hidden;
}

.modern-document-show .procurement-workflow-panel .box-header {
    background: #eff6ff;
    border-bottom: 1px solid #dbeafe;
    padding: 12px 16px;
}

.modern-document-show .procurement-workflow-panel .box-title {
    font-size: 14px;
    font-weight: 700;
    color: #1e3a8a;
}

.modern-document-show .procurement-workflow-panel .box-body {
    background: #ffffff;
    padding: 16px;
}

.modern-document-show .procurement-workflow-badges .status-badge,
.modern-document-show .label {
    border-radius: 999px;
    font-weight: 600;
}

.modern-document-show .col-md-6.col-sm-12.col-xs-12.col-md-offset-6 .table,
.modern-document-show .col-xs-12.col-md-6.col-md-offset-6 .table,
.modern-document-show .modern-doc-totals-panel .table-responsive {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    background: #ffffff;
}

.modern-document-show .col-md-6.col-sm-12.col-xs-12.col-md-offset-6 .table th,
.modern-document-show .col-xs-12.col-md-6.col-md-offset-6 .table th,
.modern-document-show .modern-doc-totals-table th {
    color: #64748b;
    font-weight: 600;
    border: none;
    padding: 8px 12px;
}

.modern-document-show .col-md-6.col-sm-12.col-xs-12.col-md-offset-6 .table td,
.modern-document-show .col-xs-12.col-md-6.col-md-offset-6 .table td,
.modern-document-show .modern-doc-totals-table td {
    border-top: 1px solid #e2e8f0;
    padding: 8px 12px;
}

.modern-document-show .col-md-6.col-sm-12.col-xs-12.col-md-offset-6 .table tr:last-child th,
.modern-document-show .col-md-6.col-sm-12.col-xs-12.col-md-offset-6 .table tr:last-child td,
.modern-document-show .col-xs-12.col-md-6.col-md-offset-6 .table tr:last-child th,
.modern-document-show .col-xs-12.col-md-6.col-md-offset-6 .table tr:last-child td,
.modern-document-show .modern-doc-totals-table tr:last-child th,
.modern-document-show .modern-doc-totals-table tr:last-child td {
    background: var(--modern-doc-total-bg);
    color: var(--modern-doc-total-text);
    font-weight: 700;
}

.modern-document-show .pull-right {
    float: none !important;
    text-align: right;
    display: block;
}

.modern-document-show strong {
    color: #0f172a;
}

.view_modal .modal-dialog .modern-document-show {
    border: none;
    border-radius: 0 0 14px 14px;
    box-shadow: none;
}

.view_modal .modal-dialog.modal-xl {
    width: calc(100% - 24px);
    max-width: min(96vw, 1600px);
}

#scrollable-container .modern-document-show table.modern-doc-lines-table > thead > tr > th,
#scrollable-container .modern-document-show table.modern-doc-lines-table > thead > tr.bg-green > th,
[data-theme="dark"] #scrollable-container .modern-document-show table.modern-doc-lines-table > thead > tr > th,
[data-theme="dark"] #scrollable-container .modern-document-show table.modern-doc-lines-table > thead > tr.bg-green > th {
    background: #1e3a8a !important;
    color: #eff6ff !important;
    border-color: #3b82f6 !important;
    border-bottom-color: #60a5fa !important;
    white-space: normal !important;
}

[data-theme="dark"] #scrollable-container .modern-document-show table.modern-doc-lines-table > tbody > tr > td {
    background: #1e293b !important;
    color: #cbd5e1 !important;
    border-color: #334155 !important;
}

[data-theme="dark"] .modern-document-show table.modern-doc-lines-table > tbody > tr:nth-child(even) > td {
    background: #0f172a !important;
}

@media (max-width: 991px) {
    .modern-document-show .modern-doc-totals-panel.col-md-offset-6 {
        margin-left: 0;
    }
}

[data-theme="dark"] .modern-doc-page-title {
    color: #f8fafc;
}

[data-theme="dark"] .modern-document-show,
[data-theme="dark"] .view_modal .modal-content.modern-document-show {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .modern-document-show .modal-header {
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    border-bottom-color: #334155;
}

[data-theme="dark"] .modern-document-show .modal-title,
[data-theme="dark"] .modern-document-show strong,
[data-theme="dark"] .modern-document-show .invoice-col > b,
[data-theme="dark"] .modern-document-show .invoice-col b {
    color: #f8fafc;
}

[data-theme="dark"] .modern-document-show .invoice-col > address strong,
[data-theme="dark"] .modern-document-show .invoice-col address strong,
[data-theme="dark"] .modern-document-show .modal-title b,
[data-theme="dark"] .modern-document-show .modern-doc-date b {
    color: #f8fafc !important;
}

[data-theme="dark"] .modern-document-show .modal-body {
    background: #0f172a;
    color: #cbd5e1;
}

[data-theme="dark"] .modern-document-show .modal-footer {
    background: #1e293b;
    border-top-color: #334155;
}

[data-theme="dark"] .modern-document-show .invoice-col > address,
[data-theme="dark"] .modern-document-show .invoice-col address,
[data-theme="dark"] .modern-document-show .well,
[data-theme="dark"] .modern-document-show .table,
[data-theme="dark"] .modern-document-show .table-responsive {
    background: #1e293b;
    border-color: #334155;
    color: #cbd5e1;
}

[data-theme="dark"] .modern-document-show .table:not(.modern-doc-lines-table) > tbody > tr:nth-child(even) > td {
    background: #0f172a;
}

[data-theme="dark"] .modern-document-show .procurement-workflow-panel .box-header {
    background: #172554;
    border-bottom-color: #1d4ed8;
}

[data-theme="dark"] .modern-document-show .procurement-workflow-panel .box-body {
    background: #1e293b;
}

[data-theme="dark"] .modern-document-show {
    --modern-doc-thead-bg: #1e3a8a;
    --modern-doc-thead-text: #eff6ff;
    --modern-doc-thead-border: #60a5fa;
    --modern-doc-thead-border-soft: #3b82f6;
    --modern-doc-total-bg: #172554;
    --modern-doc-total-text: #bfdbfe;
}

[data-theme="dark"] .modern-document-show .modern-doc-totals-table th,
[data-theme="dark"] .modern-document-show .col-md-6.col-sm-12.col-xs-12.col-md-offset-6 .table th,
[data-theme="dark"] .modern-document-show .col-xs-12.col-md-6.col-md-offset-6 .table th {
    color: #94a3b8;
}

[data-theme="dark"] .modern-document-show .modern-doc-totals-table tr:last-child th,
[data-theme="dark"] .modern-document-show .modern-doc-totals-table tr:last-child td {
    background: var(--modern-doc-total-bg);
    color: var(--modern-doc-total-text);
}

@media print {
    .modern-doc-page-header-wrap,
    .modern-document-show .modal-header .close,
    .modern-document-show .modal-footer .no-print {
        display: none !important;
    }

    .modern-document-show,
    .modern-doc-page-shell .modal-dialog {
        box-shadow: none;
        border: none;
        max-width: none;
        width: 100%;
    }

    .modern-document-show .modern-doc-lines-scroll {
        overflow: visible;
    }

    .modern-document-show .modern-doc-lines-table {
        min-width: 0;
        font-size: 11px;
    }
}
