@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

/* ==========================================================================
   DESIGN SYSTEM & DESIGN TOKENS (SaaS LEVEL)
   ========================================================================== */
.detran-plugin-wrapper {
    --primary-dark: #0f172a;        /* Slate 900 */
    --primary-blue: #2563eb;        /* Blue 600 */
    --primary-hover: #1d4ed8;       /* Blue 700 */
    --accent-amber: #f59e0b;        /* Amber 500 */
    --bg-main: #f8fafc;             /* Slate 50 */
    --surface-card: #ffffff;
    --surface-alt: #f1f5f9;          /* Slate 100 */
    --border-color: #e2e8f0;         /* Slate 200 */
    --text-primary: #0f172a;        /* Slate 900 */
    --text-secondary: #475569;      /* Slate 600 */
    --text-muted: #94a3b8;          /* Slate 400 */
    --success-color: #10b981;        /* Emerald 500 */
    
    --radius-lg: 16px;
    --radius-md: 10px;
    --radius-sm: 6px;
    
    --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
    --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 12px 28px -6px rgba(15, 23, 42, 0.12);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);

    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text-primary);
    background-color: var(--bg-main);
    padding: 32px 16px;
    border-radius: var(--radius-lg);
    box-sizing: border-box;
    line-height: 1.5;
}

/* Modo Escuro */
body.theme-dark .detran-plugin-wrapper {
    --primary-dark: #38bdf8;
    --primary-blue: #38bdf8;
    --primary-hover: #0ea5e9;
    --bg-main: #0b0f19;
    --surface-card: #151c2c;
    --surface-alt: #1e293b;
    --border-color: #273549;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    --shadow-lg: 0 12px 28px -6px rgba(0, 0, 0, 0.5);
}

/* Modo Daltonismo */
body.theme-colorblind .detran-plugin-wrapper {
    --primary-blue: #005ab5;
    --accent-amber: #ffdd00;
    --border-color: #000000;
    --text-primary: #000000;
    --surface-card: #ffffff;
}

/* ==========================================================================
   CONTAINER & HEADER MODERNO
   ========================================================================== */
.detran-container-app {
    max-width: 920px;
    margin: 0 auto;
    background: var(--surface-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.detran-app-header {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #ffffff;
    padding: 40px 36px;
    position: relative;
    border-bottom: 4px solid var(--primary-blue);
}

.detran-app-header h1 {
    font-size: 1.75rem;
    font-weight: 800;
    margin: 0 0 8px 0;
    color: #ffffff;
    letter-spacing: -0.025em;
}

.detran-app-header p {
    margin: 0;
    color: #94a3b8;
    font-size: 0.95rem;
    font-weight: 500;
}

/* ==========================================================================
   FORMULÁRIO & HIERARQUIA VISUAL
   ========================================================================== */
#vtrForm {
    padding: 36px;
}

.detran-plugin-wrapper h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary-blue);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 36px 0 20px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.detran-plugin-wrapper h2:first-of-type {
    margin-top: 0;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.form-row-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.form-group {
    margin-bottom: 20px;
}

.detran-plugin-wrapper label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.detran-plugin-wrapper input[type="text"], 
.detran-plugin-wrapper input[type="number"], 
.detran-plugin-wrapper select, 
.detran-plugin-wrapper textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    background-color: var(--surface-card);
    color: var(--text-primary);
    box-sizing: border-box;
    transition: var(--transition);
    outline: none;
}

.detran-plugin-wrapper input:focus,
.detran-plugin-wrapper select:focus,
.detran-plugin-wrapper textarea:focus {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

/* ==========================================================================
   CHECKLIST INTERATIVO (CARDS SELECIONÁVEIS)
   ========================================================================== */
.checklist-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    background: var(--surface-alt);
    padding: 20px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.checklist-item {
    display: flex;
    align-items: center;
    background: var(--surface-card);
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border-color);
    transition: var(--transition);
    cursor: pointer;
    user-select: none;
}

.checklist-item:hover {
    border-color: var(--primary-blue);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.checklist-item.checked-active {
    border-color: var(--primary-blue);
    background-color: rgba(37, 99, 235, 0.05);
}

.checklist-item.text-highlight {
    border-left: 4px solid var(--accent-amber);
}

.checklist-item input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 5px;
    margin-right: 12px;
    display: grid;
    place-content: center;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.checklist-item input[type="checkbox"]:checked {
    background-color: var(--primary-blue);
    border-color: var(--primary-blue);
}

.checklist-item input[type="checkbox"]:checked::before {
    content: "✓";
    color: #ffffff;
    font-size: 13px;
    font-weight: 800;
}

.checklist-item label {
    margin: 0;
    cursor: pointer;
    flex: 1;
    font-size: 0.9rem;
    font-weight: 500;
}

/* ==========================================================================
   BOTÕES E SELETORES
   ========================================================================== */
.btn-primary {
    background-color: var(--primary-blue);
    color: #ffffff;
    width: 100%;
    margin-top: 32px;
    padding: 16px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.theme-switcher-container {
    position: absolute;
    top: 28px;
    right: 28px;
    z-index: 10;
}

.btn-theme {
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(10px);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 8px 18px;
    border-radius: 30px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: var(--transition);
}

.btn-theme:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ==========================================================================
   EMISSÃO DO TERMO DE CAUTELA (OUTPUT CARD)
   ========================================================================== */
#cautela-output {
    display: none;
    margin: 36px;
    padding: 32px;
    border: 2px dashed var(--primary-blue);
    background: var(--surface-alt);
    border-radius: var(--radius-md);
    animation: slideUp 0.35s ease-out;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

.cautela-header {
    text-align: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.cautela-header h3 {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0;
}

.cautela-header h4 {
    font-size: 1rem;
    color: var(--primary-blue);
    margin: 6px 0;
}

.resumo-bloco {
    background: var(--surface-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    margin-top: 14px;
    box-shadow: var(--shadow-sm);
}

.resumo-bloco h5 {
    margin: 0 0 10px 0;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.print-btn {
    background-color: var(--success-color);
    color: #ffffff;
    margin-top: 24px;
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    width: 100%;
}

.print-btn:hover {
    filter: brightness(1.1);
}

.detran-footer {
    background-color: var(--surface-alt);
    color: var(--text-secondary);
    text-align: center;
    padding: 24px 36px;
    font-size: 0.85rem;
    border-top: 1px solid var(--border-color);
}

/* Responsividade Aprimorada */
@media (max-width: 768px) {
    .form-row, .form-row-4, .checklist-grid { grid-template-columns: 1fr; }
    .theme-switcher-container { position: relative; top: 0; right: 0; margin-bottom: 16px; }
    #vtrForm { padding: 20px; }
    #cautela-output { margin: 20px; padding: 20px; }
}

/* Impressão Limpa */
@media print {
    header, footer, .detran-app-header, .detran-footer, #vtrForm, .theme-switcher-container, #btnPrint {
        display: none !important;
    }
    #cautela-output {
        display: block !important;
        position: absolute !important;
        left: 0 !important; top: 0 !important;
        width: 100% !important; margin: 0 !important; padding: 0 !important;
        border: none !important; background: #fff !important; color: #000 !important;
    }
    .resumo-bloco { border: 1px solid #ccc !important; background: #fff !important; }
}