/* ==========================================================================
   DETRAN — Sistema de Controle de Viaturas
   Identidade: documento oficial eletrônico. Serifada para títulos (força de
   um cabeçalho de ofício), monoespaçada para dados numéricos/placas (como
   um carimbo de máquina de escrever preenchendo um formulário), selo de
   autenticação como elemento de assinatura do termo emitido.
   ========================================================================== */

.detran-plugin-wrapper {
    --primary-color: #0d3b66;
    --primary-color-dark: #082744;
    --secondary-color: #eef1f5;
    --accent-color: #b8912c;
    --text-color: #1c2b3a;
    --header-text-color: #ffffff;
    --bg-container: #ffffff;
    --success-color: #2f7d4f;
    --border-radius: 6px;
    --border-color: #d7dee6;
    --card-bg: #ffffff;
    --alert-bg: #f5f7fa;
    --text-muted: #5b6b7a;
    --footer-bg: #0d1b2a;
    --footer-text: #a9b8c4;

    --font-display: Georgia, 'Iowan Old Style', 'Times New Roman', serif;
    --font-body: 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'Courier New', ui-monospace, SFMono-Regular, Consolas, monospace;

    font-family: var(--font-body);
    color: var(--text-color);
    background-color: var(--secondary-color);
    padding: 20px;
    border-radius: var(--border-radius);
    position: relative;
}

body.theme-dark .detran-plugin-wrapper {
    --primary-color: #5b9bd5;
    --primary-color-dark: #3c7bb8;
    --secondary-color: #0f1720;
    --accent-color: #d9b64c;
    --text-color: #e4ebf1;
    --header-text-color: #ffffff;
    --bg-container: #182430;
    --border-color: #2a3949;
    --card-bg: #1e2b3a;
    --alert-bg: #17222d;
    --text-muted: #93a3b1;
    --footer-bg: #0a1119;
    --footer-text: #8ea0af;
}

body.theme-colorblind .detran-plugin-wrapper {
    --primary-color: #005ab5;
    --primary-color-dark: #003d7a;
    --secondary-color: #f0f4f8;
    --accent-color: #b5860a;
    --text-color: #111111;
    --header-text-color: #ffffff;
    --bg-container: #ffffff;
    --border-color: #000000;
    --card-bg: #ffffff;
    --alert-bg: #e6f0fa;
    --text-muted: #333333;
    --footer-bg: #002b5c;
    --footer-text: #ffffff;
}

/* Tema daltonismo: distinções não podem depender só de cor.
   Itens obrigatórios ganham borda tracejada + rótulo de texto, em vez de
   contarem apenas com o tom de dourado para se destacar. */
body.theme-colorblind .checklist-item.text-highlight {
    border-left-style: dashed;
    border-left-width: 5px;
}
body.theme-colorblind .checklist-item.text-highlight::after {
    content: "OBRIGATÓRIO";
    position: static;
    margin-left: auto;
    padding-left: 8px;
    font-size: 0.62rem;
    white-space: nowrap;
    font-weight: 700;
}
body.theme-colorblind .km-destaque {
    text-decoration: underline;
    text-underline-offset: 3px;
}

* { box-sizing: border-box; }

.eyebrow {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0 0 6px 0;
}
.eyebrow-header { color: rgba(255,255,255,0.75); }

.detran-app-header {
    background: linear-gradient(160deg, var(--primary-color) 0%, var(--primary-color-dark) 100%);
    color: var(--header-text-color);
    padding: 26px 20px 22px;
    text-align: center;
    position: relative;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}
.detran-app-header::after {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 6px;
    background: var(--accent-color);
    border-bottom: 1px solid rgba(0,0,0,0.15);
}

.detran-app-header h1 {
    font-family: var(--font-display);
    font-size: 1.7rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    margin-bottom: 6px;
    color: #fff;
}
.detran-app-header p { color: rgba(255,255,255,0.9); }

.detran-container-app {
    background: var(--bg-container);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 16px rgba(13, 59, 102, 0.12);
}

.detran-plugin-wrapper h2 {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 10px;
    margin-bottom: 20px;
    margin-top: 30px;
    border-bottom: 2px solid var(--border-color);
}
.detran-plugin-wrapper h2::before {
    content: "";
    width: 8px;
    height: 8px;
    background: var(--accent-color);
    flex-shrink: 0;
}
.detran-plugin-wrapper h2:first-of-type { margin-top: 0; }

.form-group { margin-bottom: 15px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.form-row-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 15px; }

.detran-plugin-wrapper label {
    display: block;
    margin-bottom: 5px;
    font-weight: 700;
    font-size: 0.82rem;
    letter-spacing: 0.02em;
    color: var(--text-muted);
    text-transform: uppercase;
}

.detran-plugin-wrapper input[type="text"],
.detran-plugin-wrapper input[type="number"],
.detran-plugin-wrapper select,
.detran-plugin-wrapper textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    font-family: var(--font-body);
    background-color: var(--bg-container);
    color: var(--text-color);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

/* Campos numéricos e de identificação usam a fonte mono: reforça a
   sensação de preenchimento de um formulário oficial (placa, matrícula, km). */
#motorista, #matricula, #viatura, #placa, #km_retirada, #km_devolucao {
    font-family: var(--font-mono);
    letter-spacing: 0.03em;
}

.detran-plugin-wrapper input:focus,
.detran-plugin-wrapper select:focus,
.detran-plugin-wrapper textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(13, 59, 102, 0.15);
}

.checklist-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    background: var(--alert-bg);
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
}

.checklist-item {
    display: flex;
    align-items: center;
    background: var(--card-bg);
    padding: 10px 12px;
    border-radius: 4px;
    border-left: 4px solid var(--primary-color);
    position: relative;
}
.checklist-item.text-highlight { border-left-color: var(--accent-color); }
.checklist-item.text-highlight::after {
    content: "★";
    position: absolute;
    top: 6px;
    right: 8px;
    font-size: 0.7rem;
    color: var(--accent-color);
}
.checklist-item input[type="checkbox"] {
    margin-right: 12px;
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
}
.checklist-item label { text-transform: none; font-size: 0.95rem; color: var(--text-color); }

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    width: 100%;
    margin-top: 25px;
    padding: 13px;
    border: none;
    border-radius: 4px;
    font-weight: 700;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: background-color 0.15s ease;
}
.btn-primary:hover:not(:disabled) { background-color: var(--primary-color-dark); }
.btn-primary:disabled { opacity: 0.7; cursor: wait; }

.btn-secondary { background-color: #6c757d; color: white; padding: 6px 12px; font-size: 0.8rem; border: none; border-radius: 4px; cursor: pointer; }

.print-btn {
    background-color: var(--success-color);
    color: white;
    margin-top: 15px;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-weight: 700;
    cursor: pointer;
}
.print-btn:hover { filter: brightness(1.08); }

#cautela-output {
    display: none;
    margin-top: 30px;
    padding: 28px;
    border: 2px solid var(--primary-color);
    background: var(--bg-container);
    border-radius: var(--border-radius);
    position: relative;
    overflow: hidden;
}

.cautela-header { text-align: center; margin-bottom: 20px; position: relative; }
.cautela-header h3 { font-family: var(--font-display); color: var(--primary-color); }
.cautela-header h4 { font-family: var(--font-display); font-weight: 700; }
.timestamp { font-size: 0.8rem; color: var(--text-muted); font-family: var(--font-mono); }

/* Selo de autenticação — o elemento de assinatura do termo emitido,
   como um carimbo oficial girado, no canto superior do documento. */
.selo-oficial {
    position: absolute;
    top: -6px;
    right: 4px;
    width: 92px;
    height: 92px;
    border: 2px dashed var(--accent-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    transform: rotate(-11deg);
    color: var(--accent-color);
    font-family: var(--font-mono);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    line-height: 1.3;
    padding: 6px;
}

.resumo-bloco {
    background: var(--alert-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 12px 14px;
    margin-top: 10px;
}
.resumo-bloco h5 {
    font-family: var(--font-mono);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.km-destaque { color: var(--primary-color); }

.observacoes-bloco {
    margin-top: 14px;
    padding: 12px 14px;
    background: var(--alert-bg);
    border-left: 3px solid var(--accent-color);
    font-size: 0.92rem;
}

.theme-switcher-container { position: absolute; top: 15px; right: 15px; z-index: 100; }
.btn-theme {
    background-color: var(--primary-color);
    color: white;
    border: 2px solid var(--accent-color);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 0.85rem;
}
.btn-theme:focus-visible,
.detran-plugin-wrapper button:focus-visible,
.detran-plugin-wrapper a:focus-visible {
    outline: 3px solid var(--accent-color);
    outline-offset: 2px;
}

.detran-footer {
    background-color: var(--footer-bg);
    color: var(--footer-text);
    text-align: center;
    padding: 20px;
    font-size: 0.85rem;
    margin-top: 20px;
    border-top: 3px solid var(--accent-color);
    border-radius: 0 0 var(--border-radius) var(--border-radius);
}

@media (max-width: 768px) { .form-row-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) {
    .form-row, .form-row-4, .checklist-grid { grid-template-columns: 1fr; }
    .selo-oficial { width: 76px; height: 76px; font-size: 0.55rem; top: -30px; right: -6px; }
}

@media (prefers-reduced-motion: reduce) {
    .btn-primary, .print-btn { transition: none; }
}

/* ==========================================================================
   CONFIGURAÇÃO DA IMPRESSÃO DO RELATÓRIO CAUTELAR (A4)
   ========================================================================== */
@media print {
    header, footer, .detran-app-header, .detran-footer, #vtrForm, .theme-switcher-container, #btnPrint {
        display: none !important;
    }

    #cautela-output {
        display: block !important;
        position: fixed !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 20px !important;
        border: 2px solid #000 !important;
        background: #fff !important;
        color: #000 !important;
        box-shadow: none !important;
        z-index: 999999 !important;
    }

    .eyebrow { color: #444 !important; }
    .cautela-header h3 { font-size: 1.4rem !important; color: #000 !important; font-weight: bold; }
    .cautela-header h4 { font-size: 1.1rem !important; color: #000 !important; }
    .selo-oficial { border-color: #000 !important; color: #000 !important; }
    .resumo-bloco { border: 1px solid #000 !important; background: #fafafa !important; padding: 10px !important; margin-top: 10px !important; color: #000 !important; }
    .km-destaque { color: #000 !important; text-decoration: underline; }
    .observacoes-bloco { border-left-color: #000 !important; }
}
