/* ─────────────────────────────────────────────────────────────────────────────
   Digital Forms — CSS de Impressão / PDF
   ───────────────────────────────────────────────────────────────────────────── */

/* Barra de topo (só no ecrã) */
.df-print-topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    background: #1e40af;
    color: #fff;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 9999;
    box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

.df-print-topbar .df-meta-text {
    color: rgba(255,255,255,.8);
    font-size: 13px;
}

.df-print-page body,
body.df-print-page {
    background: #e5e7eb;
    padding-top: 60px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.df-form--print {
    background: #fff;
    max-width: 210mm;
    margin: 20px auto;
    padding: 15mm 15mm;
    box-shadow: 0 4px 24px rgba(0,0,0,.15);
    border-radius: 4px;
}

.df-print-meta {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    padding: 8px 0 12px;
    border-bottom: 1px solid #d1d5db;
    margin-bottom: 16px;
    font-size: 12px;
    color: #6b7280;
}

/* ── Estilos específicos da vista de impressão ─────────────────────────── */

@media print {
    .no-print,
    .df-print-topbar {
        display: none !important;
    }

    body.df-print-page {
        background: white !important;
        padding-top: 0 !important;
    }

    .df-form--print {
        box-shadow: none !important;
        margin: 0 !important;
        padding: 8mm 10mm !important;
        max-width: 100% !important;
        border-radius: 0 !important;
    }

    /* Evitar quebras de página dentro de secções */
    .df-section {
        break-inside: avoid;
        page-break-inside: avoid;
        border: 1px solid #ccc !important;
        box-shadow: none !important;
        margin-bottom: 8px !important;
    }

    /* Cabeçalho da OP nunca quebra */
    .df-op-header {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    /* Tabelas */
    .df-table th,
    .df-table td {
        border: 1px solid #999 !important;
        font-size: 11px !important;
        padding: 4px 6px !important;
    }

    .df-table th {
        background: #f3f4f6 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Inputs em readonly ficam com texto limpo */
    .df-input[readonly],
    .df-input:disabled {
        border: none !important;
        background: transparent !important;
        padding: 0 !important;
        font-size: 11px !important;
        color: #111 !important;
    }

    /* Assinaturas */
    .df-signature__signed {
        background: #d1fae5 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        font-size: 11px !important;
    }

    /* Badges */
    .df-badge {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Cabeçalho da OP */
    .df-op-table th {
        background: #dbeafe !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .df-op-produto {
        background: #1e40af !important;
        color: #fff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Títulos de secção */
    .df-section__title {
        font-size: 12px !important;
        padding-bottom: 4px !important;
        margin-bottom: 8px !important;
    }

    @page {
        size: A4 portrait;
        margin: 12mm 12mm;
    }
}

/* ── Cabeçalho OP — estilos comuns (ecrã + impressão) ──────────────────── */

.df-op-header {
    margin-bottom: 16px;
    border: 2px solid #1e40af;
    border-radius: 6px;
    overflow: hidden;
}

.df-op-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.df-op-table th {
    background: #dbeafe;
    border: 1px solid #93c5fd;
    padding: 7px 10px;
    font-weight: 700;
    font-size: 12px;
    text-align: center;
    color: #1e3a8a;
}

.df-op-produto {
    background: #1e40af !important;
    color: #fff !important;
    font-weight: 700 !important;
    text-align: center !important;
    width: 18%;
}

.df-op-produto-val {
    background: #eff6ff;
    text-align: center;
    font-weight: 700;
    width: 18%;
}

.df-op-table td {
    border: 1px solid #bfdbfe;
    padding: 7px 10px;
    text-align: center;
    vertical-align: middle;
}

.df-op-table em {
    color: #374151;
    font-style: italic;
}

.df-op-table--fields th {
    background: #f3f4f6;
    color: #374151;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.df-op-table--fields td {
    background: #fff;
}

.df-header-input {
    border: 1px solid #d1d5db !important;
    border-radius: 4px !important;
    padding: 5px 8px !important;
    font-size: 13px !important;
    width: 100% !important;
    box-sizing: border-box;
}

.df-op-input {
    font-weight: 700 !important;
    font-size: 14px !important;
}

.df-op-hint {
    display: block;
    color: #9ca3af;
    font-size: 10px;
    margin-top: 2px;
}

.df-status-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.df-btn--print {
    background: #7c3aed;
    color: #fff;
    padding: 6px 16px;
    font-size: 13px;
    border-radius: 20px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.df-btn--print:hover {
    opacity: .88;
    color: #fff;
}

/* ── Cabeçalho bloqueado após 1º guardado ──────────────────────────────── */

.df-op-val {
    font-size: 14px;
    vertical-align: middle;
    padding: 8px 12px !important;
    background: #f8fafc;
    color: #111827;
}

.df-op-val--op strong {
    font-size: 15px;
    color: #1e40af;
    letter-spacing: .5px;
}

/* ── Valores de texto puro no PDF ──────────────────────────────────────── */

.df-print-val {
    display: inline-block;
    font-size: 12px;
    color: #111827;
    min-width: 40px;
}

.df-print-check {
    font-size: 14px;
    color: #16a34a;
    font-weight: 700;
}

/* Células de tabela com texto puro — padding e alinhamento */
.df-form--print .df-table td .df-print-val,
.df-form--print .df-table td .df-print-check {
    padding: 0;
    display: block;
    line-height: 1.4;
}

/* Campos simples no modo print */
.df-form--print .df-field .df-print-val {
    font-size: 13px;
    font-weight: 500;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 2px;
    min-width: 120px;
}

@media print {
    .df-print-val,
    .df-print-check {
        font-size: 11px !important;
    }
}
