﻿/* ============================================================
   Job Card — CSS  (vinci-inspired HTML print layout)
   ============================================================ */

/* ── Page wrapper (inside Dolibarr layout) ────────────────── */
.jc-page {
    background: #fff;
    box-shadow: 0 3px 12px rgba(0,0,0,0.25);
    margin: 16px auto;
    padding: 0;
    box-sizing: border-box;
    overflow: hidden;
}
.jc-a4 { width: 210mm; min-height: 294mm; }
.jc-a5 { width: 148mm; min-height: 208mm; }

/* ── Top banner ───────────────────────────────────────────── */
.jc-banner {
    background: #00003c;
    color: #fff;
    display: flex;
    align-items: center;
    padding: 8px 12px;
    gap: 12px;
}
.jc-banner-logo {
    flex: 0 0 auto;
    min-width: 80px;
    border-right: 1px solid rgba(255,255,255,0.25);
    padding-right: 12px;
    display: flex;
    align-items: center;
}
.jc-logo { max-height: 36px; max-width: 100px; display: block; }
.jc-company-name {
    font-size: 15pt;
    font-weight: bold;
    letter-spacing: 1px;
    color: #fff;
}
.jc-banner-title { flex: 1 1 auto; text-align: right; }
.jc-doc-type {
    font-size: 9pt;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: rgba(255,255,255,0.7);
}
.jc-doc-ref {
    font-size: 16pt;
    font-weight: bold;
    color: #fff;
    margin-top: 2px;
}

/* ── Info grid ────────────────────────────────────────────── */
.jc-info-grid {
    display: flex;
    border-bottom: 2px solid #00003c;
    padding: 8px 12px;
    gap: 12px;
    align-items: flex-start;
}
.jc-info-left  { flex: 1 1 auto; }
.jc-info-right { flex: 0 0 auto; text-align: center; }
.jc-info-table { border-collapse: collapse; font-size: 10pt; }
.jc-info-table tr { line-height: 1.5; }
.jc-lbl {
    color: #555;
    font-size: 8.5pt;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    padding-right: 8px;
    width: 64px;
    vertical-align: top;
}
.jc-val { font-size: 10pt; vertical-align: top; }
#jc-qrcode canvas,
#jc-qrcode img { width: 76px !important; height: 76px !important; display: block; }
.jc-qr-caption { font-size: 7.5pt; color: #666; margin-top: 2px; }

/* ── Section titles ───────────────────────────────────────── */
.jc-section-title {
    background: #eef2f7;
    border-top: 1px solid #00003c;
    border-bottom: 1px solid #00003c;
    font-size: 8.5pt;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #00003c;
    padding: 3px 12px;
}

/* ── Operations table ─────────────────────────────────────── */
.jc-ops-table { width: 100%; border-collapse: collapse; font-size: 9.5pt; }
.jc-ops-table th,
.jc-ops-table td { border: 1px solid #b0b8c8; padding: 5px 7px; vertical-align: middle; }
.jc-ops-table thead tr { background: #00003c; }
.jc-ops-table th {
    font-weight: bold;
    text-align: center;
    font-size: 8.5pt;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.jc-ops-table tbody tr:nth-child(even) { background: #f6f8fb; }
.jc-ops-table tbody td { height: 26px; }
.jc-empty-row { text-align: center; padding: 10px; color: #888; font-style: italic; }
.col-op   { width: 4%;  text-align: center; }
.col-name { width: 28%; }
.col-ws   { width: 18%; }
.col-sign { width: 24%; }
.col-date { width: 12%; }
.col-note { width: 14%; }
.jc-label-note { font-size: 8pt; color: #c0392b; font-style: italic; font-weight: bold; }

/* ── Notes box ────────────────────────────────────────────── */
.jc-notes-box { padding: 6px 12px 8px; min-height: 36px; }
.jc-notes-lines .jc-line { border-bottom: 1px solid #c8cdd5; height: 20px; margin-bottom: 2px; }
.jc-bom-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.jc-bom-table tr { border-bottom: 1px solid #e0e4ec; }
.jc-bom-table td { padding: 3px 6px; }
.jc-bom-ref  { color: #00003c; font-weight: 600; width: 120px; }
.jc-bom-qty  { color: #333; width: 50px; }
.jc-bom-batch { color: #555; }

/* ── Footer ───────────────────────────────────────────────── */
.jc-footer {
    border-top: 2px solid #00003c;
    padding: 4px 12px;
    font-size: 8pt;
    color: #444;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    background: #f5f7fa;
}

/* ── Queue preview dialog ─────────────────────────────────── */
/* Make the iframe fill the entire dialogforpopup content area */
#dialogforpopup:has(#jc-preview-iframe) {
    padding: 0 !important;
    overflow: hidden !important;
}
#jc-preview-iframe {
    border: none;
    display: block;
}
/* Fallback for browsers without :has() — class added via JS on dialog open */
.jc-dlg-noPad > .ui-dialog-content {
    padding: 0 !important;
    overflow: hidden !important;
}

/* ── @media print
   ============================================================ */
@media print {
    .noprint { display: none !important; }

    /* Hide all Dolibarr chrome, show only the job card */
    body * { visibility: hidden; }
    .jc-page, .jc-page * { visibility: visible; }
    .jc-page {
        position: fixed !important;
        top: 0 !important; left: 0 !important;
        width: 100% !important;
        box-shadow: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    .jc-a4 { page: A4; }
    .jc-a5 { page: A5; }
    @page A4 { size: A4 portrait; margin: 0; }
    @page A5 { size: A5 portrait; margin: 0; }
    .jc-banner,
    .jc-section-title,
    .jc-ops-table thead tr,
    .jc-ops-table tbody tr:nth-child(even),
    .jc-footer { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .jc-ops-table th,
    .jc-ops-table td { border: 1px solid #000 !important; }
}

/* ── Preview dialog spinner ───────────────────────────────── */
#dialogforpopup {
    position: relative;
    overflow: hidden;
}
.jc-spinner {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #fff;
    gap: 14px;
    z-index: 10;
}
.jc-spinner-ring {
    width: 48px;
    height: 48px;
    border: 5px solid #e0e4ec;
    border-top-color: #00003c;
    border-radius: 50%;
    animation: jc-spin 0.8s linear infinite;
}
@keyframes jc-spin {
    to { transform: rotate(360deg); }
}
.jc-spinner-label {
    font-size: 13px;
    color: #555;
    letter-spacing: 0.3px;
}