@charset "UTF-8";

:root {
    --req-primary: #1f6feb;
    --req-text: #111827;
    --req-muted: #6b7280;
    --req-line: #cfcfcf;
    --req-bg: #f3f3f3;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: Arial, sans-serif;
    background: var(--req-bg);
    padding: 10px;
    font-size: 12px;
    color: var(--req-text);
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

/* Permite apenas a edição normal dos campos do formulário. */
input,
textarea,
select {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

.wrap {
    width: min(210mm, 100%);
    max-width: 850px;
    margin: auto;
    background: #fff;
    border: 1px solid #ccc;
    padding: 15px;
}

header {
    text-align: center;
}

header img {
    display: block;
    max-width: 260px;
    max-height: 70px;
    width: auto;
    height: auto;
    object-fit: contain;
    margin: 0 auto 5px;
}

header h1 {
    font-size: 13px;
    line-height: 1.3;
    margin: 4px 0;
}

header p {
    font-size: 11px;
    margin: 0;
}

.controls {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
    margin: 10px 0;
}

button {
    background: var(--req-primary);
    color: #fff;
    border: 0;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    min-height: 34px;
}

button.secondary {
    background: #f2f2f2;
    color: #333;
    border: 1px solid #999;
}

button.remove {
    background: #dc2626;
    font-size: 10px;
    position: absolute;
    right: 8px;
    top: 8px;
}

.section {
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px dashed #ccc;
}

.section h2 {
    font-size: 12px;
    margin: 0 0 6px;
}

.requerente {
    border: 1px solid #ccc;
    padding: 8px;
    margin-bottom: 15px;
    position: relative;
}

.requerente-title {
    display: block;
    padding-right: 70px;
}

.field-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 8px;
}

.field-line label {
    font-weight: bold;
    margin-right: 4px;
    white-space: nowrap;
}

.field-line input,
.field-line select {
    border: none;
    border-bottom: 1px solid #000;
    background: transparent;
    padding: 2px 3px;
    margin-right: 8px;
    font-size: 11px;
    flex-grow: 1;
    min-width: 60px;
    outline: none;
}

textarea {
    border: none;
    border-bottom: 1px solid #000;
    width: 100%;
    min-height: 60px;
    font-size: 11px;
    outline: none;
}

.conjuge {
    display: none;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dotted #aaa;
}

.assinatura {
    text-align: center;
    margin-top: 35px;
    line-height: 1.45;
}

.database-content,
.database-notes {
    margin-top: 14px;
    line-height: 1.45;
}

.database-content *,
.database-notes * {
    max-width: 100%;
}

.database-content img,
.database-notes img {
    max-width: 100%;
    height: auto;
}

.database-content table,
.database-notes table {
    width: 100%;
    border-collapse: collapse;
}

.database-content td,
.database-content th,
.database-notes td,
.database-notes th {
    padding: 4px;
}

#printDateTime,
.print-watermark,
.print-select-value {
    display: none;
}

@media (max-width: 760px) {
    body {
        padding: 6px;
        font-size: 13px;
    }

    .wrap {
        width: 100%;
        padding: 12px;
    }

    header img {
        max-width: 220px;
        max-height: 60px;
    }

    .controls {
        justify-content: stretch;
    }

    .controls button {
        flex: 1 1 140px;
        min-height: 42px;
    }

    .field-line {
        align-items: stretch;
        flex-direction: column;
    }

    .field-line label {
        margin: 5px 0 0;
        white-space: normal;
    }

    .field-line input,
    .field-line select,
    textarea {
        width: 100%;
        min-height: 34px;
        margin-right: 0;
        font-size: 16px;
    }
}

/* =========================================================
   IMPRESSÃO - replica o modelo enviado pelo usuário
   A4 = 210mm. Com margens de 5mm sobram exatamente 200mm.
   ========================================================= */
@page {
    size: A4 portrait;
    margin: 5mm;
}

@media print {
    html,
    body {
        width: 200mm !important;
        min-width: 200mm !important;
        max-width: 200mm !important;
        min-height: 0 !important;
        background: #fff !important;
        padding: 0 !important;
        margin: 0 !important;
        color: #000 !important;
        font-size: 11px !important;
        overflow: visible !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .controls,
    .no-print,
    button.remove {
        display: none !important;
    }

    /*
       O modelo original usa uma tarja lateral de 5mm. Ela agora faz parte dos
       200mm úteis e não é somada à largura da folha.
    */
    .wrap {
        width: 200mm !important;
        min-width: 200mm !important;
        max-width: 200mm !important;
        margin: 0 !important;
        padding: 0 0 0 5mm !important;
        border: none !important;
        box-shadow: none !important;
        background: #fff !important;
        box-sizing: border-box !important;
        overflow: visible !important;
    }

    header {
        text-align: center !important;
        page-break-inside: avoid;
        break-inside: avoid;
    }

    header img {
        max-height: 18mm !important;
        max-width: 65mm !important;
        width: auto !important;
        height: auto !important;
        margin: 0 auto 1mm !important;
    }

    header h1 {
        font-size: 13px !important;
        line-height: 1.25 !important;
        margin: 1mm 0 !important;
    }

    header p {
        font-size: 11px !important;
        margin: 0 !important;
    }

    .section {
        margin-top: 4mm !important;
        padding-top: 2.5mm !important;
    }

    .requerente {
        width: 100% !important;
        padding: 2mm !important;
        margin: 0 0 4mm !important;
        border: 1px solid #ccc !important;
        page-break-inside: avoid;
        break-inside: avoid;
    }

    .requerente-title {
        padding-right: 0 !important;
    }

    /* Mantém as linhas na mesma organização do modelo, sem o layout mobile. */
    .field-line {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        width: 100% !important;
        margin-bottom: 2mm !important;
        page-break-inside: avoid;
        break-inside: avoid;
    }

    .field-line label {
        flex: 0 0 auto !important;
        white-space: nowrap !important;
        margin: 0 1mm 0 0 !important;
        font-size: 11px !important;
    }

    .field-line input,
    .field-line select {
        flex: 1 1 0 !important;
        min-width: 0 !important;
        max-width: 100% !important;
        height: 5.5mm !important;
        padding: 0 1mm !important;
        margin: 0 2mm 0 0 !important;
        border: none !important;
        border-bottom: 1px solid #000 !important;
        background: transparent !important;
        color: #000 !important;
        box-shadow: none !important;
        font-size: 11px !important;
        line-height: 5.5mm !important;
        box-sizing: border-box !important;
        -webkit-appearance: none;
        appearance: none;
    }

    .field-line select {
        display: none !important;
    }

    .field-line .print-select-value {
        display: block !important;
        flex: 1 1 0 !important;
        min-width: 0 !important;
        height: 5.5mm !important;
        line-height: 5.5mm !important;
        padding: 0 1mm !important;
        margin: 0 2mm 0 0 !important;
        border-bottom: 1px solid #000 !important;
        color: #000 !important;
        font-size: 11px !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    textarea,
    .database-content input,
    .database-content select,
    .database-content textarea,
    .database-notes input,
    .database-notes select,
    .database-notes textarea {
        max-width: 100% !important;
        border: none !important;
        border-bottom: 1px solid #000 !important;
        background: transparent !important;
        color: #000 !important;
        box-shadow: none !important;
        font-size: 11px !important;
        box-sizing: border-box !important;
    }

    .conjuge {
        margin-top: 2mm !important;
        padding-top: 2mm !important;
    }

    .database-content,
    .database-notes {
        width: 100% !important;
        max-width: 100% !important;
        margin-top: 3mm !important;
        overflow: visible !important;
        overflow-wrap: break-word;
        word-break: normal;
    }

    .database-content > *,
    .database-notes > * {
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    .database-content img,
    .database-notes img,
    .database-content svg,
    .database-notes svg {
        max-width: 100% !important;
        height: auto !important;
    }

    .database-content table,
    .database-notes table {
        width: 100% !important;
        max-width: 100% !important;
        border-collapse: collapse !important;
        table-layout: auto !important;
    }

    .database-content td,
    .database-content th,
    .database-notes td,
    .database-notes th {
        overflow-wrap: break-word;
        word-break: normal;
    }

    .deferimento {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    .assinatura {
        margin-top: 10mm !important;
        page-break-inside: avoid;
        break-inside: avoid;
    }

    #printDateTime {
        display: block !important;
        position: fixed;
        right: 2mm;
        bottom: 1mm;
        font-size: 9px;
        color: #555;
        z-index: 9999;
    }

    .print-watermark {
        display: flex !important;
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        width: 5mm;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
        background: #a8a8a8;
        color: #555;
        z-index: 9999;
        overflow: hidden;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .print-watermark span {
        position: absolute;
        top: 50%;
        left: 50%;
        width: 250mm;
        text-align: center;
        transform: translate(-50%, -50%) rotate(-90deg);
        transform-origin: center;
        white-space: nowrap;
        font-size: 8px;
        line-height: 1;
        font-weight: 700;
        letter-spacing: .3px;
    }
}
