:root {
    --primary: #005A9C;
    --primary-hover: #00467A;
    --secondary: #0B7CC1;

    --background: #005A9C;
    --surface: #FFFFFF;

    --text: #243447;
    --text-light: #364f6d;
    --text-lightR: #cfddee;
    --e-global-color-primary: #2F8789;

    --border: #DCE3EA;

    --success: #16A34A;
    --warning: #F59E0B;
    --danger: #DC2626;

    --shadow: 0 4px 20px rgba(0,0,0,.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--background);
    min-height: 100vh;
}

/* Login Screen */
.login-container {
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background:
        radial-gradient(circle at 12% 18%, rgba(255,255,255,0.14) 0%, transparent 42%),
        radial-gradient(circle at 88% 82%, rgba(0,0,0,0.18) 0%, transparent 48%),
        linear-gradient(135deg, var(--primary) 0%, var(--secondary) 55%, var(--primary-hover) 100%);
}

/* Manchas de luz desfocadas (efeito "aurora"), puramente decorativas */
.login-container::before,
.login-container::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(70px);
    pointer-events: none;
    z-index: 0;
}

.login-container::before {
    width: 460px;
    height: 460px;
    top: -140px;
    left: -120px;
    background: var(--secondary);
    opacity: 0.35;
}

.login-container::after {
    width: 520px;
    height: 520px;
    bottom: -180px;
    right: -140px;
    background: var(--primary-hover);
    opacity: 0.35;
}

.login-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow);
}

.login-icon {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.login-card h2 {
    font-size: 28px;
    text-align: center;
    margin-bottom: 8px;
    color: var(--text);
}

.subtitle {
    text-align: center;
    color: var(--text-light);
    margin-bottom: 30px;
}

/* Navbar */
.navbar {
    background: var(--surface);
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 64px;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary);
}

.nav-links {
    display: flex;
    gap: 20px;
}

.nav-link {
    background: none;
    border: none;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-light);
    border-radius: 6px;
    transition: all 0.3s;
}

.nav-link:hover {
    background: var(--background);
    color: var(--text);
}

.nav-link.active {
    background: var(--primary);
    color: white;
}

.nav-link.admin-only {
    display: none;
}

/* User Menu */
.user-menu {
    position: relative;
}

.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    border-radius: 6px;
    transition: background 0.3s;
}

.user-menu-btn:hover {
    background: var(--background);
}

.user-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow);
    min-width: 220px;
    padding: 12px 0;
    margin-top: 8px;
}

.user-dropdown.show {
    display: block;
}

.user-dropdown .user-info {
    padding: 8px 16px;
}

.user-dropdown .user-info strong {
    display: block;
    font-size: 14px;
    color: var(--text);
}

.user-dropdown .user-info span {
    display: block;
    font-size: 12px;
    color: var(--text-light);
}

.user-dropdown hr {
    margin: 8px 0;
    border: none;
    border-top: 1px solid var(--border);
}

.user-dropdown button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 16px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    color: var(--text);
    transition: background 0.2s;
}

.user-dropdown button:hover {
    background: var(--background);
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

.page {
    display: none;
}

.page.active {
    display: block;
    animation: fadeIn 0.5s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Cards */
.import-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 30px;
    box-shadow: var(--shadow);
}

.import-card h3 {
    margin-bottom: 20px;
    color: var(--text);
}

/* Form */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    font-size: 14px;
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,90,156,.15);
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group {
    flex: 1;
    margin-bottom: 0;
}

/* Buttons */
.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    width: 100%;
    transition: all 0.3s;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,90,156,0.3);
}

.btn-secondary {
    background: var(--background);
    color: var(--text-light);
    border: 1px solid var(--border);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.3s;
}

.btn-secondary:hover {
    background: #E8ECF0;
    color: var(--text);
}

.btn-danger {
    background: var(--danger);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.3s;
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-download {
    background: var(--success);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.3s;
}

.btn-download:hover {
    background: #15803d;
}

/* Certificates Table */
.certificates-table {
    background: var(--surface);
    border-radius: 12px;
    padding: 20px;
    overflow-x: auto;
    box-shadow: var(--shadow);
}

.certificates-table h3 {
    margin-bottom: 15px;
    color: var(--text);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 12px 15px;
    background: var(--background);
    font-weight: 600;
    color: var(--text-lightR);
    font-size: 13px;
    border-bottom: 2px solid var(--border);
}

td {
    padding: 12px 15px;
    border-top: 1px solid var(--border);
    font-size: 14px;
    color: var(--text);
}

.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.status-valid { background: #d1fae5; color: #065f46; }
.status-warning { background: #fed7aa; color: #92400e; }
.status-critical { background: #fecaca; color: #991b1b; }
.status-expired { background: #fee2e2; color: #991b1b; }

/* Messages */
.error-message {
    background: #fee2e2;
    color: #991b1b;
    padding: 10px 15px;
    border-radius: 6px;
    margin-top: 15px;
    font-size: 14px;
    display: none;
}

.success-message {
    background: #d1fae5;
    color: #065f46;
    padding: 10px 15px;
    border-radius: 6px;
    margin-top: 15px;
    font-size: 14px;
    display: none;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: var(--surface);
    border-radius: 12px;
    padding: 0;
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow);
    animation: modalFadeIn 0.3s;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    margin: 0;
    color: var(--text);
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-light);
    transition: color 0.2s;
}

.close-btn:hover {
    color: var(--danger);
}

#editProfileForm,
#changePasswordForm {
    padding: 24px;
}

#editProfileForm .btn-primary,
#changePasswordForm .btn-primary {
    width: 100%;
}

/* Portal Filters */
.portal-filters {
    background: var(--surface);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

/* Links */
a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
    .nav-container {
        flex-wrap: wrap;
        height: auto;
        padding: 10px 20px;
        gap: 10px;
    }
    
    .nav-links {
        order: 3;
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .user-menu {
        order: 2;
    }
    
    .form-row {
        flex-direction: column;
    }
    
    .form-row .form-group {
        margin-bottom: 20px;
    }
    
    .container {
        padding: 20px 15px;
    }
    
    th, td {
        padding: 8px 10px;
        font-size: 12px;
    }
    
    .user-dropdown {
        right: -10px;
    }
}

/* Additional styles */
.success-message {
    background: #d1fae5;
    color: #065f46;
    padding: 15px;
    border-radius: 6px;
    border-left: 4px solid var(--success);
    margin-top: 10px;
}

.error-message {
    background: #fee2e2;
    color: #991b1b;
    padding: 15px;
    border-radius: 6px;
    border-left: 4px solid var(--danger);
    margin-top: 10px;
}

.error-message strong,
.success-message strong {
    display: block;
    margin-bottom: 5px;
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: var(--text-light);
    font-size: 12px;
}

.import-card .btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Badge de required */
.required-field::after {
    content: ' *';
    color: var(--danger);
    font-weight: bold;
}

/* Login form specific */
#loginForm .btn-primary {
    margin-top: 10px;
}

#loginFormContainer .form-group input {
    background: var(--surface);
}

/* Register form specific */
#registerFormContainer .btn-primary {
    margin-top: 10px;
}

/* Forgot password link */
#forgotPasswordLink {
    color: var(--primary);
    font-size: 13px;
    text-decoration: none;
    transition: color 0.2s;
}

#forgotPasswordLink:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Show register link */
#showRegisterLink,
#showLoginLink {
    color: var(--primary);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: color 0.2s;
}

#showRegisterLink:hover,
#showLoginLink:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Verification form */
#verifyFormContainer h3 {
    color: var(--text);
    margin-bottom: 10px;
}

/* Reset password forms */
#resetFormContainer h3,
#resetNewPasswordContainer h3 {
    color: var(--text);
    margin-bottom: 10px;
}

#resetFormContainer p,
#resetNewPasswordContainer p {
    color: var(--text-light);
    font-size: 14px;
    margin-bottom: 20px;
}

/* Back to login links */
#backToLoginFromReset,
#resendCodeLink {
    color: var(--primary);
    font-size: 13px;
    text-decoration: none;
    transition: color 0.2s;
}

#backToLoginFromReset:hover,
#resendCodeLink:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}




/* Footer Fixo */
.main-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    padding: 12px 0;
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    z-index: 99;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-info {
    display: flex;
    align-items: center;
    gap: 20px;
}

.footer-copyright {
    color: var(--text-light);
    font-size: 13px;
    margin: 0;
}

.footer-copyright strong {
    color: var(--primary);
}

.footer-version {
    color: var(--text-light);
    font-size: 12px;
    margin: 0;
    opacity: 0.9;
}

/* Ajuste para não sobrepor o conteúdo */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px 80px 20px; /* Adiciona padding inferior para o rodapé */
}

/* Logos dinâmicas de município */
.login-corner-logo {
    position: fixed;
    top: 24px;
    
    width: auto;
    max-width: 320px;
    max-height: 150px;
    object-fit: contain;
    z-index: 5;
    background: rgba(255,255,255,0.9);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.login-corner-left { left: 24px; }
.login-corner-right { right: 24px; }

.footer-logo {
    height: 32px;
    padding: 2px;
    width: auto;
    object-fit: contain;
    background: var(--e-global-color-primary);
    border-radius: 10px;
}

/* Texto exibido no lugar da logo quando a pasta do município ainda não existe */
.municipio-logo-fallback {
    display: none;
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    background: rgba(255,255,255,0.9);
    padding: 6px 12px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    white-space: nowrap;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.login-corner-left + .municipio-logo-fallback {
    position: fixed;
    top: 24px;
    left: 24px;
}

.login-corner-right + .municipio-logo-fallback {
    position: fixed;
    top: 24px;
    right: 24px;
}

#logoMunicipioNavbar + .municipio-logo-fallback {
    box-shadow: none;
    background: transparent;
    padding: 0;
}

@media (max-width: 768px) {
    .login-corner-left + .municipio-logo-fallback,
    .login-corner-right + .municipio-logo-fallback {
        position: static;
        display: inline-block;
        margin: 0 8px 12px;
    }
}

@media (max-width: 768px) {
    .login-corner-logo {
        position: static;
        height: 36px;
        margin: 0 8px 12px;
        display: inline-block;
    }
}

/* Responsivo */
@media (max-width: 768px) {
    .footer-content {
        flex-direction: column;
        text-align: center;
        gap: 5px;
    }
    
    .footer-info {
        flex-direction: column;
        gap: 3px;
    }
    
    .footer-copyright {
        font-size: 12px;
    }
    
    .footer-version {
        font-size: 11px;
    }

    .footer-logo {
        margin-top: 6px;
    }
}



.footer {
    background: white;
    border-top: 1px solid #e5e7eb;
    padding: 20px 0;
    margin-top: 40px;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 15px;
}

.footer-logo {
    height: 40px;
    width: auto;
    transition: transform 0.3s ease;
    cursor: pointer;
}

.footer-logo:hover {
    transform: scale(1.05);
}

.footer-content p {
    color: #6b7280;
    font-size: 14px;
    margin: 0;
}

@media (max-width: 768px) {
    .footer-content {
        flex-direction: column;
        text-align: center;
    }
}




/* Modal de Termos */
#termsModal {
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    cursor: default; /* Remove o cursor pointer que indica que pode clicar */
}

#termsModal .modal-content {
    cursor: default;
    pointer-events: auto; /* Garante que o conteúdo do modal seja clicável */
}

/* Remove o efeito de clique no overlay do modal de termos */
#termsModal[data-closable="false"] {
    pointer-events: none; /* Bloqueia cliques no overlay */
}

#termsModal[data-closable="false"] .modal-content {
    pointer-events: auto; /* Permite cliques no conteúdo do modal */
}

/* Estilo para o modal de termos - sem botão de fechar */
#termsModal .modal-header {
    border-bottom: 2px solid var(--primary);
    padding: 20px 24px;
}

#termsModal .modal-header h3 {
    color: var(--primary);
    font-size: 20px;
    margin: 0;
}

/* Garantir que o modal fique sobre todos os outros elementos */
#termsModal {
    z-index: 9999 !important;
}

/* Animação de entrada do modal */
#termsModal .modal-content {
    animation: modalFadeIn 0.2s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

#termsModal {
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    cursor: default;
    z-index: 99999 !important;
    pointer-events: auto !important; /* Permite que o overlay capture cliques */
}

/* O conteúdo do modal deve ser o único interagível */
#termsModal .modal-content {
    pointer-events: auto !important;
    cursor: default;
    position: relative;
    z-index: 100000;
}

/* Tudo que está fora do modal de termos fica bloqueado */
#termsModal ~ * {
    pointer-events: none !important;
    user-select: none !important;
}

/* Garantir que o body não role enquanto o modal está aberto */
body:has(#termsModal[style*="display: flex"]) {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
}

/* Impedir interação com o fundo */
#termsModal::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 99998;
    pointer-events: auto;
}

/* Scroll apenas dentro do modal */
#termsModal .modal-content {
    max-height: 90vh;
    overflow-y: auto;
}

#termsModal .modal-content::-webkit-scrollbar {
    width: 6px;
}

#termsModal .modal-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

#termsModal .modal-content::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}

/* Bloquear tecla ESC globalmente quando modal está aberto */
body.terms-modal-open {
    overflow: hidden;
}

/* Forçar que o modal de termos fique acima de tudo */
.terms-modal-active .modal:not(#termsModal) {
    display: none !important;
}


/* Bloqueio visual e de interação quando modal de termos está ativo */
.terms-modal-open #appScreen,
.terms-modal-open .navbar,
.terms-modal-open .container,
.terms-modal-open .main-footer,
.terms-modal-open .login-container {
    filter: blur(2px);
    pointer-events: none !important;
    user-select: none !important;
}

/* Garantir que o modal de termos fique VISÍVEL e NÍTIDO */
#termsModal .modal-content {
    filter: none !important;
    pointer-events: auto !important;
}

/* Scrollbar do modal de termos */
#termsModal .modal-content {
    scroll-behavior: smooth;
}


#termsLogoutBtn {
    background: none;
    border: none;
    font-size: 14px;
    cursor: pointer;
    color: #ef4444;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: 6px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 6px;
}

#termsLogoutBtn:hover {
    background: #fef2f2;
    color: #dc2626;
}

/* Ajuste no header do modal de termos para alinhar os elementos */
#termsModal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 2px solid var(--primary);
}

#termsModal .modal-header h3 {
    margin: 0;
    color: var(--primary);
    font-size: 20px;
}






/* ===== CORREÇÃO PARA BOTÃO DESABILITADO ===== */

/* Garantir que o botão desabilitado não tenha hover */
.btn-primary:disabled,
.btn-primary[disabled] {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: none !important;
    background: var(--primary) !important;
    pointer-events: none !important;
}

/* Remover todos os efeitos de hover quando desabilitado */
.btn-primary:disabled:hover,
.btn-primary:disabled:active,
.btn-primary:disabled:focus,
.btn-primary[disabled]:hover,
.btn-primary[disabled]:active,
.btn-primary[disabled]:focus {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: none !important;
    background: var(--primary) !important;
}

/* Estilo específico para o botão de aceitar termos desabilitado */
#acceptTermsBtn:disabled,
#acceptTermsBtn[disabled] {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: none !important;
    background: #6b7280 !important; /* Cinza quando desabilitado */
    pointer-events: none !important;
}

#acceptTermsBtn:disabled:hover,
#acceptTermsBtn[disabled]:hover {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: none !important;
    background: #6b7280 !important;
}

/* Também adicionar para o botão no modal de termos */
#termsModal .btn-primary:disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: none !important;
    background: #6b7280 !important;
    pointer-events: none !important;
}

#termsModal .btn-primary:disabled:hover {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: none !important;
    background: #6b7280 !important;
}




