/* ===== Estilos do checklist A4 fixo (compartilhado: caneta e híbrido) ===== */

/* Barra de ferramentas (não imprime) */
.ckc-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    max-width: 760px;
    margin: 0 auto;
    padding: 10px 0 4px;
}
.ckc-spacer { flex: 1; }
.ckc-btn {
    border: 1px solid var(--hk-vermelho);
    background: #fff;
    color: var(--hk-vermelho);
    border-radius: 6px;
    padding: 0.4rem 0.7rem;
    font-size: 0.85rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.ckc-btn.ativo { background: var(--hk-vermelho); color: #fff; }
.ckc-btn:disabled { opacity: 0.5; cursor: default; }
.ckc-cores { display: flex; align-items: center; gap: 0.4rem; }
.ckc-cores.desabilitado { opacity: 0.4; pointer-events: none; }
.ckc-cor { width: 24px; height: 24px; border-radius: 50%; border: 2px solid #ccc; cursor: pointer; padding: 0; }
.ckc-cor.sel { border-color: #111; box-shadow: 0 0 0 2px #fff, 0 0 0 4px #111; }
.ckc-dica { max-width: 760px; margin: 0 auto 10px; font-size: 0.8rem; color: #666; }

/* Viewport que reduz a folha A4 para caber na tela */
.ckc-viewport {
    position: relative;
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    overflow: hidden;
}

/* Folha A4 (748px ≈ 198mm, cabe no A4 com margem) */
.ck-folha-a4 {
    position: relative;
    width: 748px;
    background: #fff;
    color: #1a1a1a;
    border: 1px solid #999;
    font-size: 9px;
    line-height: 1.22;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
}
.ck-folha-a4 input,
.ck-folha-a4 textarea {
    border: none; outline: none; background: transparent;
    font-size: 9px; color: #000; font-family: inherit;
}

/* Camada de desenho */
.ck-folha-a4 .ck-canvas { position: absolute; top: 0; left: 0; z-index: 5; pointer-events: none; }

/* Cabeçalho */
.ck-folha-a4 .ck-topo { display: flex; align-items: stretch; border-bottom: 1px solid #999; }
.ck-folha-a4 .ck-topo-logo {
    flex: 0 0 185px; display: flex; flex-direction: column; align-items: center;
    justify-content: center; padding: 5px; border-right: 1px solid #999;
}
.ck-folha-a4 .ck-topo-logo img { max-width: 165px; max-height: 50px; object-fit: contain; }
.ck-folha-a4 .ck-end { font-size: 9px; font-weight: 600; margin-top: 4px; }
.ck-folha-a4 .ck-topo-tab { flex: 1; border-collapse: collapse; width: 100%; }
.ck-folha-a4 .ck-topo-tab td { border-bottom: 1px solid #ccc; padding: 3px 6px; white-space: nowrap; }
.ck-folha-a4 .ck-topo-tab tr:last-child td { border-bottom: none; }
.ck-folha-a4 .ck-topo-tab .lbl { font-weight: 600; width: 130px; }
.ck-folha-a4 .ck-topo-tab .lbl-c { font-weight: 600; text-align: center; width: 36px; }
.ck-folha-a4 .ck-topo-tab .i { border-bottom: 1px solid #aaa; min-width: 28px; width: 40px; text-align: center; }

/* Barras de seção */
.ck-folha-a4 .ck-bar {
    background: linear-gradient(180deg, #cdc1c1 0%, #bdaeae 100%);
    text-align: center; font-weight: 700; font-size: 10.5px; padding: 2px; border-bottom: 1px solid #999;
}

/* Tabelas de campos */
.ck-folha-a4 .ck-tab { width: 100%; border-collapse: collapse; }
.ck-folha-a4 .ck-tab td.f { border: 1px solid #ccc; padding: 2px 4px 4px; vertical-align: top; }
.ck-folha-a4 .ck-tab td.f > span { display: block; font-size: 8px; color: #333; }
.ck-folha-a4 .ck-tab td.f input:not([type="checkbox"]) { width: 100%; }
.ck-folha-a4 .ck-aguardando { white-space: nowrap; }
.ck-folha-a4 .ck-aguardando input[type="checkbox"] { vertical-align: middle; margin-left: 4px; }

/* Acessórios */
.ck-folha-a4 .ck-acessorios { display: flex; border-bottom: 1px solid #999; }
.ck-folha-a4 .ck-veiculo-img {
    flex: 0 0 49%; padding: 4px; border-right: 1px solid #999;
    display: flex; align-items: center; justify-content: center;
}
.ck-folha-a4 .ck-veiculo-img img { max-width: 100%; height: auto; }
.ck-folha-a4 .ck-itens { flex: 1; display: flex; padding: 5px 2px; gap: 2px; }
.ck-folha-a4 .ck-grupo { flex: 1; }
.ck-folha-a4 .ck-itens-head { display: flex; gap: 8px; font-weight: 700; margin-bottom: 2px; }
.ck-folha-a4 .ck-itens-head span:first-child { width: 22px; }
.ck-folha-a4 .ck-item { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.ck-folha-a4 .ck-item input[type="checkbox"] { width: 11px; height: 11px; margin: 0; }
.ck-folha-a4 .ck-item label { margin: 0; font-size: 9px; }
.ck-folha-a4 .ck-item label .av { border: 1px solid #999; padding: 0 14px 0 2px; margin: 0 2px; font-size: 8px; }
.ck-folha-a4 .ck-combustivel { margin-top: 5px; }
.ck-folha-a4 .ck-combustivel-title { font-size: 9px; font-weight: 700; margin-bottom: 3px; }
.ck-folha-a4 .ck-combustivel-opcoes { display: flex; flex-wrap: nowrap; gap: 6px; align-items: center; }
.ck-folha-a4 .ck-combustivel-opcoes label { display: flex; align-items: center; gap: 3px; margin: 0; font-size: 9px; white-space: nowrap; }
.ck-folha-a4 .ck-combustivel-opcoes input[type="checkbox"] { width: 11px; height: 11px; margin: 0; }

/* Defeitos */
.ck-folha-a4 .ck-defeitos { width: 100%; border-collapse: collapse; border-bottom: 1px solid #999; }
.ck-folha-a4 .ck-defeitos td { border-bottom: 1px solid #ccc; padding: 1px 4px; height: 15px; }
.ck-folha-a4 .ck-defeitos td.num { width: 28px; font-weight: 600; border-right: 1px solid #ccc; }
.ck-folha-a4 .ck-defeitos td input { width: 100%; }

/* Condições */
.ck-folha-a4 .ck-cond { margin: 0; padding: 3px 4px 3px 22px; border-bottom: 1px solid #999; font-size: 7px; line-height: 1.25; }
.ck-folha-a4 .ck-cond li { margin-bottom: 1px; text-align: justify; }
.ck-folha-a4 .ck-aviso { text-align: center; font-weight: 800; font-size: 10.5px; padding: 3px; border-bottom: 1px solid #999; }

/* Rodapé / assinaturas */
.ck-folha-a4 .ck-obs-cell span { font-size: 9px; font-weight: 600; }
.ck-folha-a4 .ck-obs-cell textarea { width: 100%; resize: none; min-height: 34px; }
.ck-folha-a4 .ck-descarta { white-space: nowrap; vertical-align: bottom; }
.ck-folha-a4 .ck-descarta span { display: inline; font-weight: 600; margin-right: 8px; }
.ck-folha-a4 .ck-descarta label { margin: 0 6px; font-size: 9px; }
.ck-folha-a4 .ck-descarta input[type="checkbox"] { vertical-align: middle; }
.ck-folha-a4 .ck-confirmo { text-align: center; font-size: 9px; padding: 3px; border-bottom: 1px solid #999; }
.ck-folha-a4 .ck-assina { display: flex; }
.ck-folha-a4 .ck-assina-esq { flex: 0 0 42%; border-right: 1px solid #999; padding: 6px; }
.ck-folha-a4 .ck-portadores { display: flex; gap: 16px; justify-content: center; margin-bottom: 11px; }
.ck-folha-a4 .ck-portadores label { font-size: 9px; }
.ck-folha-a4 .ck-portadores input { vertical-align: middle; margin-right: 3px; }
.ck-folha-a4 .ck-x { border-top: 1px solid #000; padding-top: 1px; margin-top: 13px; }
.ck-folha-a4 .ck-valor { margin-top: 7px; font-size: 9px; }
.ck-folha-a4 .ck-assina-dir { flex: 1; padding: 6px; }
.ck-folha-a4 .ck-atencao { margin: 0 0 7px; font-size: 8.5px; }
.ck-folha-a4 .ck-assina-linha { margin-bottom: 11px; }
.ck-folha-a4 .ck-assina-linha span { font-size: 9px; }

/* ===== Reimpressão: somente leitura (não editável) ===== */
.ck-folha-a4.somente-leitura input,
.ck-folha-a4.somente-leitura textarea {
    pointer-events: none;
}

/* ===== Overlay de carregamento (reimpressão) ===== */
.ckc-carregando {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.85);
    font-weight: 600;
    color: var(--hk-vermelho);
    font-size: 1rem;
}

/* ===== Modal de assinatura ===== */
.sig-overlay {
    position: fixed; inset: 0; z-index: 10001;
    background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center;
}
.sig-modal { background: #fff; border-radius: 14px; padding: 1.2rem; width: min(92vw, 640px); box-shadow: 0 20px 60px rgba(0,0,0,0.4); }
.sig-modal h3 { margin: 0 0 0.4rem; font-size: 1.1rem; color: #1a1a1a; }
.sig-modal p { margin: 0 0 0.8rem; font-size: 0.85rem; color: #666; }
.sig-pad-wrap { border: 2px dashed var(--hk-vermelho); border-radius: 10px; background: #fafafa; }
.sig-pad { width: 100%; height: 240px; display: block; touch-action: none; }
.sig-actions { display: flex; gap: 0.6rem; justify-content: flex-end; margin-top: 0.9rem; }

/* ===== Impressão A4 ===== */
@media print {
    .ckc-toolbar, .ckc-dica, .sig-overlay { display: none !important; }
    /* position:static tira o viewport do contexto de posicionamento, para a folha
       ancorar no TOPO DA PÁGINA (e não no fluxo do viewport) — evita margem superior. */
    .ckc-viewport {
        position: static !important;
        height: auto !important;
        overflow: visible !important;
        max-width: none !important;
    }
    .ck-folha-a4 {
        transform: none !important;
        position: absolute !important;
        top: 0 !important; left: 10px !important; /* leve deslocamento p/ equilibrar L/R */
        width: 748px !important;
        box-shadow: none !important;
    }
}
