/* ========================
   MODERN VARIABLES & RESET
   ======================== */
:root {
    --primary: #1a365d;
    --primary-light: #2c5282;
    --primary-glow: rgba(26, 54, 93, 0.25);
    --accent: #c53030;
    --accent-light: #e53e3e;
    --surface: rgba(255, 255, 255, 0.95);
    --surface-hover: rgba(255, 255, 255, 1);
    --text-main: #1a202c;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --input-bg: #f7fafc;
    --input-border: #e2e8f0;
    --input-focus: #3182ce;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-attachment: fixed;
    min-height: 100vh;
    color: var(--text-main);
    line-height: 1.6;
}

/* ========================
   GLASS CONTAINER
   ======================== */
.container {
    max-width: 900px;
    width: 100%;
    margin: 40px auto;
    background: var(--surface);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.5s ease-out;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

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

/* ========================
   HEADER MODERNO
   ======================== */
.header-inline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 28px 40px;
    background: #800000;
    color: white;
    position: relative;
    overflow: hidden;
}

.header-inline::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    border-radius: 50%;
}

.header-inline h2 {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    position: relative;
    z-index: 1;
    color: white;
}

.header-inline h2::after {
    content: '';
    display: block;
    width: 60px;
    height: 4px;
    border-radius: 2px;
    margin-top: 8px;
}

/* Botões de ação no header */
.action-buttons {
    display: flex;
    gap: 12px;
    position: relative;
    z-index: 1;
}

.btn-luxury {
    background: rgb(255, 255, 255);
    border: 4px solid rgb(255, 255, 255);
    color: white;
    padding: 10px 24px;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: var(--transition);
    backdrop-filter: blur(4px);
}

.btn-luxury:hover {
    background: rgb(255, 255, 255);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgb(255, 255, 255);
}

.btn-luxury:active {
    transform: translateY(0);
}

/* ========================
   FORMULÁRIO MODERNO
   ======================== */
form {
    padding: 40px;
}

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

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

form input[type="text"] {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid var(--input-border);
    border-radius: var(--border-radius);
    background: var(--input-bg);
    font-size: 15px;
    font-family: inherit;
    color: var(--text-main);
    transition: var(--transition);
}

form input[type="text"]:hover {
    border-color: #cbd5e0;
    background: white;
}

form input[type="text"]:focus {
    outline: none;
    border-color: var(--input-focus);
    background: white;
    box-shadow: 0 0 0 4px rgba(49, 130, 206, 0.15);
}

form input[type="text"]::placeholder {
    color: var(--text-muted);
    font-size: 14px;
}

/* ========================
   EDITOR DE TEXTO COMPLETO (Estilo Gmail/Word)
   ======================== */
.editor-container {
    background: white;
    border: 2px solid var(--input-border);
    border-radius: var(--border-radius);
    overflow: hidden;
    transition: var(--transition);
}

.editor-container:focus-within {
    border-color: var(--input-focus);
    box-shadow: 0 0 0 4px rgba(49, 130, 206, 0.15);
}

/* Toolbar Principal */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 1px solid var(--input-border);
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0 8px;
    border-right: 1px solid #e2e8f0;
}

.toolbar-group:last-child {
    border-right: none;
}

.toolbar button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 14px;
    transition: var(--transition);
}

.toolbar button:hover {
    background: white;
    border-color: #cbd5e0;
    color: var(--text-main);
    box-shadow: var(--shadow-sm);
}

.toolbar button.active {
    background: #dbeafe;
    border-color: #3b82f6;
    color: #1d4ed8;
}

.toolbar button svg {
    width: 18px;
    height: 18px;
}

/* Selects na toolbar */
.toolbar select {
    padding: 6px 10px;
    border: 1px solid #e2e8f0;
    border-radius: var(--border-radius-sm);
    background: white;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.toolbar select:hover {
    border-color: #cbd5e0;
}

.toolbar select:focus {
    outline: none;
    border-color: var(--input-focus);
}

/* Color picker */
.toolbar input[type="color"] {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    padding: 0;
    overflow: hidden;
}

.toolbar input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.toolbar input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: var(--border-radius-sm);
}

/* Área de edição */
#body {
    min-height: 400px;
    padding: 24px;
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-main);
    outline: none;
}

#body:empty::before {
    content: 'Digite o conteúdo do documento aqui...';
    color: var(--text-muted);
    font-style: italic;
}

#body ul, #body ol {
    margin: 12px 0;
    padding-left: 28px;
}

#body li {
    margin: 6px 0;
}

#body blockquote {
    margin: 16px 0;
    padding: 12px 20px;
    border-left: 4px solid var(--primary);
    background: #f8fafc;
    color: var(--text-secondary);
    font-style: italic;
}

#body a {
    color: var(--input-focus);
    text-decoration: underline;
}

/* ========================
   BOTÃO GERAR PDF
   ======================== */
.button-container {
    margin-top: 32px;
}

form button#generatePdf {
    width: 100%;
    padding: 18px 32px;
    background: linear-gradient(135deg, var(--accent) 0%, #9b2c2c 100%);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 14px rgba(197, 48, 48, 0.35);
    position: relative;
    overflow: hidden;
}

form button#generatePdf::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: 0.5s;
}

form button#generatePdf:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(197, 48, 48, 0.45);
}

form button#generatePdf:hover::before {
    left: 100%;
}

form button#generatePdf:active {
    transform: translateY(0);
}

/* Ícone no botão */
form button#generatePdf::after {
    content: '📄';
    margin-left: 12px;
    font-size: 18px;
}

/* ========================
   SEPARADOR VISUAL
   ======================== */
.section-divider {
    display: flex;
    align-items: center;
    margin: 32px 0;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.section-divider::before,
.section-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, #e2e8f0, transparent);
}

.section-divider::before {
    margin-right: 16px;
}

.section-divider::after {
    margin-left: 16px;
}


/* =================================================================
   PDF CONTENT - ÁREA INTOCÁVEL (Lógica do Documento)
   ================================================================= */
/* =================================================================
   PDF CONTENT - ÁREA INTOCÁVEL (Lógica do Documento)
   ================================================================= */
#pdf-content {
    display: none;
    position: absolute;
    left: -9999px;
    width: 210mm;
    height: 297mm;
    background: #fff;
    overflow: hidden;
    padding: 20mm;
    box-sizing: border-box;
    color: #000;
    font-family: Arial, sans-serif; 
}

.right-bar {
    position: absolute;
    top: 0;
    right: 0;
    width: 3mm;
    height: 100%;
    background-color: #800000;
}

.logo {
    display: block;
    margin: 0 auto;
    width: 25mm;
    height: auto;
}

.municipio {
    text-align: center;
    font-size: 14pt;
    font-weight: bold;
    margin-top: 0;
    margin-bottom: 0;
    color: black;
    text-transform: uppercase;
    font-family: Arial, sans-serif;
}

.title {
    text-align: center;
    font-size: 14pt;
    font-weight: bold;
    margin: 0;
    color: black;
    text-transform: uppercase;
}

.department {
    text-align: center;
    font-size: 14pt;
    font-weight: bold;
    margin: 0;
    margin-bottom: 4mm;
    color: black;
}

/* --- DESTINATÁRIO DINÂMICO --- */
.recipient {
    font-size: 12pt;
    font-weight: bold;
    color: #333;
    margin-bottom: 10mm;
    s
    /* Configuração para o bloco dinâmico à direita */
    display: table;       /* Faz o bloco ter apenas a largura do conteúdo (shrink-to-fit) */
    margin-left: auto;    /* Empurra o bloco todo para a direita */
    margin-right: 0;      /* Garante que encosta na margem direita */
    
    text-align: left;     /* O texto DENTRO do bloco continua alinhado à esquerda */
    white-space: pre-wrap;
    
    /* Opcional: define um max-width para não ficar largo demais se o texto for gigante */
    max-width: 60%;       
}
/* ---------------------------------- */

.header-info {
    display: flex;
    justify-content: space-between;
    background-color: #fff8f7;
    padding: 4mm 4mm;
    margin-bottom: 6mm;
    font-size: 10pt;
    font-weight: normal;
    border-radius: 2mm;
    box-sizing: border-box;
}

/* --- TIPO DE DOCUMENTO CENTRALIZADO --- */
.doc-type-container {
    text-align: center;
    margin: 4mm 0 2mm 0;
    padding: 2mm 0;
}

.doc-type {
    font-size: 14pt;
    font-weight: bold;
    color: #000;
    text-transform: uppercase;
    text-align: center;
    letter-spacing: 1px;
    margin: 0;
    padding: 0;
}
/* ----------------------------------------------------- */

.body-text {
    font-size: 12pt;
    line-height: 1.5;
    white-space: pre-wrap;
    margin-bottom: 20mm;
    margin-top: 0;
    text-align: justify;
}

.cafe {
    position: absolute;
    bottom: 40mm;
    left: -50mm;
    width: 185mm;
    height: auto;
    opacity: 0.05;
    pointer-events: none;
    user-select: none;
}

.footer {
    position: absolute;
    bottom: 10mm;
    left: 20mm;
    width: calc(100% - 40mm);
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.address {
    margin-right: 5mm; 
    font-size: 8pt;
    color: #800000;
    text-align: right;
    line-height: 1.3;
}

.qrcode {
    width: 18mm;
    height: 18mm;
}


/* ========================
   BOTÃO REMOVER FORMATAÇÃO DESTACADO
   ======================== */
.remove-format-group {
    border-right: none !important;
}

.btn-remove-format {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    width: auto !important;
    padding: 6px 14px !important;
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%) !important;
    color: white !important;
    border: none !important;
    border-radius: 6px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    text-transform: none !important;
    transition: all 0.25s ease !important;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.35) !important;
}

.btn-remove-format:hover {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.45) !important;
}

.btn-remove-format svg {
    width: 16px !important;
    height: 16px !important;
    stroke: white !important;
}

.btn-remove-format span {
    white-space: nowrap;
}

/* MEDIA PRINT */
@media print {
    body {
        background: #fff !important;
        padding: 0;
    }
    .container {
        display: none !important;
    }
    #pdf-content {
        display: block !important;
        position: relative !important;
        left: 0;
        box-shadow: none;
    }
}

.save-load-container button {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: opacity 0.2s;
}

.save-load-container button:hover {
    opacity: 0.8;
}
/* --- Ajuste de Título e Botões Laterais --- */
.header-inline {
    display: flex;
    justify-content: space-between; /* Joga o título pra um lado e botões pro outro */
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    background: #800000;
    border-bottom: none;
}

.header-inline h2 {
    margin: 0;
    font-size: 1.5rem;
    color: white;
    font-weight: 600;
}

.action-buttons {
    display: flex;
    gap: 10px;
}

/* Botão com toque de luxo (clean) */
.btn-luxury {
    background: transparent;
    border: 1px solid #d1d1d1;
    color: #666;
    padding: 6px 18px;
    border-radius: 50px; /* Estilo pílula, bem moderno */
    font-size: 13px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-luxury:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(128, 0, 0, 0.05);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}


