:root {
    --bg-color: #f0f4f8;
    --sidebar-bg: rgba(255, 255, 255, 0.92);
    --text-main: #333;
    --gold: #c5a059;
    --dark-blue: #1a2a3a;
    --dark-red: #4a1515;
    --green-emerald: #10b981;
    
    --font-ui: 'Inter', sans-serif;
    --font-title: 'Cinzel', serif;
    --font-cursive: 'Great Vibes', cursive;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-ui);
    background: linear-gradient(135deg, #e0eaf5 0%, #cfd9df 100%);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
}

/* Modal Glassmorphism Login */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-card {
    width: 100%;
    max-width: 440px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.8);
}

.modal-header h2 {
    color: var(--dark-blue);
    font-size: 1.4rem;
    margin-bottom: 0.3rem;
}

.modal-header p {
    color: #64748b;
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
}

.error-message {
    background: #fee2e2;
    color: #b91c1c;
    padding: 0.6rem;
    border-radius: 6px;
    font-size: 0.85rem;
    margin-bottom: 1rem;
    text-align: center;
}

.btn-primary {
    width: 100%;
    padding: 0.85rem;
    background: var(--dark-blue);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: #0f172a;
}

.modal-quick-login {
    margin-top: 1.5rem;
    padding-top: 1.2rem;
    border-top: 1px dashed #cbd5e1;
}

.modal-quick-login p {
    font-size: 0.8rem;
    color: #475569;
    margin-bottom: 0.6rem;
    font-weight: 600;
}

.quick-btns {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.btn-demo {
    padding: 0.6rem 0.8rem;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.8rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
    color: #1e293b;
    font-weight: 500;
}

.btn-demo:hover {
    background: #e2e8f0;
    border-color: var(--gold);
}

.modal-footer {
    margin-top: 1.2rem;
    text-align: center;
}

.btn-link {
    background: none;
    border: none;
    color: #64748b;
    font-size: 0.85rem;
    cursor: pointer;
    text-decoration: underline;
}

/* Status Bar de Login */
.status-bar {
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(0,0,0,0.08);
    padding: 0.6rem 0.8rem;
    border-radius: 8px;
    margin-top: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.badge-online {
    display: inline-block;
    background: #d1fae5;
    color: #047857;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    text-transform: uppercase;
}

.badge-offline {
    display: inline-block;
    background: #e2e8f0;
    color: #64748b;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    text-transform: uppercase;
}

.btn-login-trigger {
    background: var(--dark-blue);
    color: white;
    border: none;
    padding: 0.35rem 0.65rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
}

/* Sidebar Tabs */
.sidebar-tabs {
    display: flex;
    gap: 0.4rem;
    background: rgba(0, 0, 0, 0.05);
    padding: 0.3rem;
    border-radius: 8px;
    margin-bottom: 1.2rem;
}

.tab-btn {
    flex: 1;
    padding: 0.55rem;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn.active {
    background: white;
    color: var(--dark-blue);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.tab-content {
    display: none;
}
.tab-content.active {
    display: block;
}

.section-help {
    font-size: 0.8rem;
    color: #64748b;
    margin-bottom: 1rem;
    line-height: 1.4;
}

/* Navegação em Lote */
.lote-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.8rem;
    background: rgba(255, 255, 255, 0.8);
    padding: 0.5rem;
    border-radius: 6px;
}

.btn-mini {
    padding: 0.35rem 0.65rem;
    background: var(--dark-blue);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
}

#lote-nav-indicator {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--dark-blue);
}

.batch-wrapper {
    display: none;
    width: 100%;
}

/* App Layout */
.app-container {
    display: flex;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 380px;
    background: var(--sidebar-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-right: 1px solid rgba(255,255,255,0.6);
    padding: 1.5rem;
    box-shadow: 5px 0 15px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 10;
}

.sidebar-header {
    margin-bottom: 1.2rem;
}

.sidebar h1 {
    font-size: 1.4rem;
    color: var(--dark-blue);
    margin-bottom: 0.1rem;
}

.sidebar-header > p {
    font-size: 0.85rem;
    color: #666;
}

.form-section {
    background: rgba(255, 255, 255, 0.5);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.2rem;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.form-section h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--gold);
    margin-bottom: 0.8rem;
    font-weight: 700;
}

.input-group {
    margin-bottom: 1rem;
}
.input-group:last-child {
    margin-bottom: 0;
}

.input-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.input-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.5rem;
}

.input-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
    color: #444;
}

.input-group input, .input-group select {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-family: var(--font-ui);
    font-size: 0.9rem;
    background: rgba(255,255,255,0.95);
    transition: all 0.2s ease;
}

.input-group input:focus, .input-group select:focus {
    border-color: var(--gold);
    outline: none;
    box-shadow: 0 0 0 3px rgba(197, 160, 89, 0.2);
}

.form-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
}

.btn-print {
    width: 100%;
    padding: 0.85rem;
    background-color: var(--dark-blue);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: background-color 0.3s, transform 0.1s;
}

.btn-print:disabled {
    background-color: #94a3b8;
    cursor: not-allowed;
}

.btn-print:hover:not(:disabled) {
    background-color: #111c26;
}
.btn-print:active:not(:disabled) {
    transform: scale(0.98);
}

.btn-secondary {
    width: 100%;
    padding: 0.65rem;
    background: transparent;
    color: var(--dark-blue);
    border: 1px solid var(--dark-blue);
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-secondary:hover {
    background: rgba(26, 42, 58, 0.08);
}

/* Preview Area */
.preview-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    background-color: transparent;
    overflow-y: auto;
    align-items: center;
}

.preview-header {
    text-align: center;
    margin-bottom: 1.5rem;
}
.preview-header h2 {
    color: var(--dark-blue);
    font-size: 1.3rem;
}
.preview-header p {
    color: #666;
    font-size: 0.85rem;
}

.certificate-wrapper {
    background: white;
    padding: 10px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.15);
    border-radius: 4px;
    transition: all 0.5s ease;
}

/* Certificate Styles */
.certificate {
    width: 210mm;
    height: 297mm;
    position: relative;
    background-color: #fffaf0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    overflow: hidden;
    transition: width 0.5s ease, height 0.5s ease;
}

.certificate.landscape {
    width: 297mm;
    height: 210mm;
}

/* Regras Padrão de Moldura / Fundo */
.certificate.batismo.landscape { background-image: url('bg_batismo_landscape.png'); }
.certificate.batismo.portrait { background-image: url('bg_batismo_portrait.png'); }
.certificate.eucaristia.landscape { background-image: url('bg_eucaristia_landscape.png'); }
.certificate.eucaristia.portrait { background-image: url('bg_eucaristia_portrait.png'); }
.certificate.crisma.landscape { background-image: url('bg_crisma_landscape.png'); }
.certificate.crisma.portrait { background-image: url('bg_crisma_portrait.png'); }

/* Estilos de Novos Documentos (Suavização e Alta Legibilidade do Texto) */
.certificate.declaracao,
.certificate.homenagem,
.certificate.carta {
    background-color: #faf8f5;
}

.certificate.declaracao .cert-content,
.certificate.homenagem .cert-content,
.certificate.carta .cert-content {
    background: rgba(255, 255, 255, 0.90) !important;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.07) !important;
    border: 1.5px solid rgba(197, 160, 89, 0.4);
    padding: 2.2rem 3.2rem;
    backdrop-filter: blur(6px) !important;
    margin: 1.5rem auto;
}

.certificate.declaracao .sacrament-text,
.certificate.homenagem .sacrament-text,
.certificate.carta .sacrament-text {
    font-size: 1.15rem;
    line-height: 1.8;
    color: #1e293b !important;
    text-align: justify;
    text-align-last: center;
    margin: 1.2rem 0;
    font-weight: 500;
}

/* Brasão / Logo da Paróquia */
.cert-logo-container {
    margin-bottom: 0.8rem;
    display: flex;
    justify-content: center;
}
.cert-logo {
    max-height: 85px;
    max-width: 130px;
    object-fit: contain;
}

/* Assinatura Digitalizada */
.signature-img-container {
    height: 48px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    margin-bottom: -8px;
    z-index: 5;
}
.signature-img {
    max-height: 52px;
    max-width: 170px;
    object-fit: contain;
}

.cert-border {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    bottom: 20px;
    border: 2px solid var(--gold);
    pointer-events: none;
    outline: 1px solid var(--gold);
    outline-offset: 4px;
}

.cert-content {
    position: relative;
    z-index: 2;
    text-align: center;
    background: transparent !important;
    padding: 2rem 3rem;
    box-shadow: none !important;
    max-width: 90%;
    backdrop-filter: none !important;
}

.cert-header {
    margin-bottom: 1.5rem;
}

.paroquia-display {
    font-family: var(--font-title);
    font-size: 1.5rem;
    color: #701a1e !important;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 0.2rem;
    font-weight: 700;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.6);
}

.cidade-display {
    font-family: var(--font-ui);
    font-size: 0.95rem;
    color: #334155 !important;
    margin-bottom: 1rem;
    letter-spacing: 1px;
    font-weight: 600;
}

.title-display {
    font-family: var(--font-title);
    font-size: 2.6rem;
    color: #881337 !important;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8), 0 2px 4px rgba(0,0,0,0.1);
    margin: 0;
    font-weight: 700;
    letter-spacing: 1px;
    transition: font-size 0.3s;
}
.certificate.landscape .title-display {
    font-size: 3.2rem;
}

.cert-body {
    font-family: var(--font-ui);
    font-size: 1.1rem;
    color: #0f172a !important;
    line-height: 1.7;
    font-weight: 500;
    transition: font-size 0.3s;
}
.certificate.landscape .cert-body {
    font-size: 1.15rem;
}

.name-display {
    font-family: var(--font-cursive);
    font-size: 3.5rem;
    color: #4c1d95 !important;
    margin: 0.4rem 0;
    font-weight: bold;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
    transition: font-size 0.3s;
}
.certificate.landscape .name-display {
    font-size: 3.8rem;
}

.padrinhos-container, .registro-container {
    margin-top: 0.5rem;
}

.registro-display {
    color: #1e3a8a !important;
    font-weight: 700;
}

.cert-footer {
    margin-top: 3rem;
    display: flex;
    justify-content: center;
    gap: 3rem;
    width: 100%;
}

.signature {
    text-align: center;
    flex: 1;
    max-width: 250px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.signature .line {
    border-bottom: 1.5px solid #0f172a !important;
    margin-bottom: 0.4rem;
    width: 100%;
}

.padre-display, .secretario-display {
    font-weight: 700;
    font-size: 1rem;
    color: #0f172a !important;
}

.role-display, .sec-role-display {
    font-size: 0.85rem;
    color: #475569 !important;
    font-style: italic;
}

/* Responsive Scaling for Preview */
@media (max-width: 1400px) {
    .certificate-wrapper {
        transform: scale(0.75);
        transform-origin: top center;
    }
}
@media (max-width: 1100px) {
    .certificate-wrapper {
        transform: scale(0.55);
        transform-origin: top center;
    }
}
@media (max-width: 900px) {
    .app-container {
        flex-direction: column;
        overflow: auto;
    }
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid rgba(255,255,255,0.5);
    }
}

/* Print Styles */
@media print {
    body {
        margin: 0;
        padding: 0;
        background: none;
    }
    
    .no-print {
        display: none !important;
    }
    
    .app-container {
        height: auto;
        overflow: visible;
        display: block;
    }

    .preview-area {
        padding: 0;
        overflow: visible;
        display: block;
    }

    .certificate-wrapper {
        padding: 0;
        box-shadow: none;
        border-radius: 0;
        transform: none !important;
        background: transparent;
    }

    .batch-wrapper {
        display: block !important;
    }

    .batch-wrapper .certificate {
        position: relative;
        page-break-after: always;
        break-after: page;
        margin-bottom: 0;
    }

    .certificate {
        position: absolute;
        left: 0;
        top: 0;
        margin: 0;
        padding: 2rem;
        transform: none !important; 
        box-shadow: none !important;
        border: none !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        width: 210mm;
        height: 297mm;
    }
    
    .certificate.landscape {
        width: 297mm;
        height: 210mm;
    }

    .cert-content {
        background: transparent !important;
        box-shadow: none !important;
        backdrop-filter: none !important;
        border-radius: 0 !important;
    }
}

/* Botão Engrenagem Discreto ⚙️ (Canto Inferior Direito) */
.admin-gear-trigger {
    position: fixed;
    bottom: 15px;
    right: 15px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(30, 41, 59, 0.35);
    color: #94a3b8;
    border: 1px solid rgba(255, 255, 255, 0.25);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0.4;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

.admin-gear-trigger:hover {
    opacity: 1;
    background: var(--dark-blue);
    color: #ffffff;
    transform: rotate(90deg) scale(1.1);
}

/* Modal Admin Largo */
.modal-lg {
    max-width: 780px;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header-admin {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 1.2rem;
}

.modal-header-admin h2 {
    color: var(--dark-blue);
    font-size: 1.4rem;
}

.modal-header-admin p {
    color: #64748b;
    font-size: 0.85rem;
}

.btn-close-x {
    background: none;
    border: none;
    font-size: 1.4rem;
    color: #64748b;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}
.btn-close-x:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.admin-section {
    background: rgba(248, 250, 252, 0.8);
    padding: 1.2rem;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

.admin-section.margin-top {
    margin-top: 1.5rem;
}

.admin-section h3 {
    font-size: 0.95rem;
    color: var(--dark-blue);
    margin-bottom: 1rem;
}

.admin-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
    margin-bottom: 0.8rem;
}

.admin-btn-row {
    display: flex;
    gap: 0.8rem;
    margin-top: 1.2rem;
}

.form-actions-row {
    display: flex;
    gap: 0.6rem;
    margin-top: 1rem;
}

/* Tabela Administrativa */
.admin-table-container {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.admin-table th, .admin-table td {
    padding: 0.75rem 0.85rem;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

.admin-table th {
    background: #f1f5f9;
    color: #334155;
    font-weight: 700;
}

.status-badge-ativo {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    background: #d1fae5;
    color: #047857;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.75rem;
}

.status-badge-suspenso {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    background: #fee2e2;
    color: #b91c1c;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.75rem;
}

.admin-actions-cell {
    display: flex;
    gap: 0.4rem;
}

.btn-tbl {
    padding: 0.3rem 0.6rem;
    border: none;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-tbl-edit {
    background: #e2e8f0;
    color: #1e293b;
}
.btn-tbl-edit:hover { background: #cbd5e1; }

.btn-tbl-suspend {
    background: #fee2e2;
    color: #b91c1c;
}
.btn-tbl-suspend:hover { background: #fca5a5; }

.btn-tbl-activate {
    background: #d1fae5;
    color: #047857;
}
.btn-tbl-activate:hover { background: #6ee7b7; }

.info-message {
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    font-size: 0.85rem;
    margin-top: 0.8rem;
    font-weight: 600;
}

.msg-sucesso {
    background: #d1fae5;
    color: #047857;
    border: 1px solid #a7f3d0;
}

.msg-erro {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}




