/* ==========================================================================
   SISTEMA LMS INSTITUCIONAL - SECRETARIA MUNICIPAL DE SAÚDE
   CSS Puro / Sem Classes no HTML / Estilização Direta de Tags Nativas
   ========================================================================== */

/* --- Reset Universal & Box Sizing --- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Regra Geral de Segurança para Imagens (Nunca estourar containers) */
img {
    max-width: 100%;
    height: auto;
    display: inline-block;
    vertical-align: middle;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
    background-color: #f0f4f8;
    color: #1e293b;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Cabeçalho Superior Institucional --- */
header {
    background-color: #ffffff;
    padding: 0.75rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 3px solid #0d6e87;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    flex-wrap: nowrap;
    gap: 1.5rem;
    min-height: 75px;
}

header div {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

header img {
    height: 48px;
    max-height: 48px;
    width: auto;
    max-width: 160px;
    object-fit: contain;
    display: block;
    transition: transform 0.2s ease;
}

header img:hover {
    transform: scale(1.04);
}

header h1 {
    font-size: 1.2rem;
    color: #082e5c;
    font-weight: 700;
    text-align: center;
    line-height: 1.3;
    flex: 1;
    margin: 0;
    padding: 0 1rem;
}

/* --- Estrutura Geral (Sidebar + Conteúdo Principal) --- */
#layout {
    display: flex;
    flex-direction: row;
    flex: 1;
    min-height: calc(100vh - 140px);
}

/* --- Menu Lateral (Compatível com <aside> e <nav>) --- */
aside,
nav {
    width: 270px;
    min-width: 270px;
    max-width: 270px;
    background-color: #082e5c !important;
    color: #ffffff !important;
    padding: 1.75rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    box-shadow: 3px 0 10px rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
}

/* Imagem da logo dentro do menu lateral */
aside img,
nav img {
    max-height: 44px;
    max-width: 180px;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    margin: 0 auto 0.75rem auto;
    filter: brightness(0) invert(1);
    /* Deixa a logo toda branca para contraste perfeito */
}

aside h3,
nav h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #93c5fd;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    padding-bottom: 0.4rem;
    margin-top: 0.5rem;
}

aside ul,
nav ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0;
    margin: 0;
}

aside a,
nav a {
    display: block;
    padding: 0.65rem 0.85rem;
    color: #e2e8f0 !important;
    text-decoration: none !important;
    font-size: 0.9rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    background-color: transparent;
}

/* Reset de links de logomarcas (navegação invisível sem fundo ativo, borda ou transform) */
header div a,
header div a:hover,
header div a:focus,
header div a:active,
nav>a,
nav>a:hover,
nav>a:focus,
nav>a:active,
aside>a,
aside>a:hover,
aside>a:focus,
aside>a:active {
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    border-left: none !important;
    padding: 0 !important;
    box-shadow: none !important;
    transform: none !important;
    outline: none !important;
    border-radius: 0 !important;
}

aside a:hover,
nav a:hover {
    background-color: rgba(255, 255, 255, 0.18) !important;
    color: #ffffff !important;
    transform: translateX(4px);
}

/* Item Ativo no Menu Lateral (Padronizado com a Caixa de Perfil - Peso Normal) */
aside ul li a[style*="background-color"],
nav ul li a[style*="background-color"],
aside a:active,
nav a:active {
    background-color: rgba(255, 255, 255, 0.18) !important;
    color: #ffffff !important;
    font-weight: normal !important;
    border-left: 4px solid #93c5fd;
}

/* Link de perfil dentro do cartão do usuário no menu lateral */
nav>div a,
aside>div a {
    display: inline-block !important;
    padding: 0.3rem 0.65rem !important;
    margin-top: 0.35rem;
    color: #93c5fd !important;
    text-decoration: none !important;
    font-size: 0.78rem !important;
    font-weight: 600;
    border-radius: 4px;
    background-color: rgba(255, 255, 255, 0.08);
    transition: background-color 0.2s, color 0.2s;
    transform: none !important;
}

nav>div a:hover,
aside>div a:hover {
    background-color: rgba(255, 255, 255, 0.22) !important;
    color: #ffffff !important;
    transform: none !important;
}


/* --- Menu Sanfona: details / summary (sem JavaScript) --- */
nav details,
aside details {
    margin: 0;
}

nav details summary,
aside details summary {
    /* Remove TODOS os marcadores nativos do browser */
    display: block;
    list-style: none;
    padding: 0.55rem 0.85rem;
    font-size: 0.88rem;
    font-weight: 700;
    color: #93c5fd;
    cursor: pointer;
    border-radius: 6px;
    letter-spacing: 0.03em;
    user-select: none;
    transition: background-color 0.2s, color 0.2s;
    position: relative;
}

/* Remove marcador WebKit (Chrome, Safari, Edge) */
nav details summary::-webkit-details-marker,
aside details summary::-webkit-details-marker {
    display: none;
}

/* Remove marcador Firefox */
nav details summary::marker,
aside details summary::marker {
    content: none;
}

/* Seta fechada: ▼ à direita via float — funciona em TODOS os browsers */
nav details summary::after,
aside details summary::after {
    content: ' ▼';
    float: right;
    font-size: 0.7rem;
    color: #64748b;
    margin-top: 0.1rem;
    transition: transform 0.2s ease;
}

/* Seta aberta: troca para ▲ */
nav details[open] summary::after,
aside details[open] summary::after {
    content: ' ▲';
}

nav details summary:hover,
aside details summary:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

/* Links dentro do painel expansível: recuo visual de subnível */
nav details ul,
aside details ul {
    padding-left: 0;
    margin: 0.25rem 0 0.5rem 0;
    border-left: 2px solid rgba(255, 255, 255, 0.15);
    margin-left: 0.85rem;
}

nav details ul a,
aside details ul a {
    font-size: 0.83rem;
    padding: 0.4rem 0.65rem;
    color: #cbd5e1 !important;
}

nav details ul a:hover,
aside details ul a:hover {
    color: #ffffff !important;
    transform: translateX(3px);
}

/* --- Cards de Categoria (dashboard index.php) --- */
#layout main article:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

/* --- Conformidade: badges de status de validade --- */
nav+main section p[style*="color:#15803d"],
nav+main section p[style*="color:#b91c1c"],
nav+main section p[style*="color:#92400e"] {
    font-weight: 600;
}

/* --- Imagem de boas-vindas no dashboard (index.php) --- */
main>img:first-of-type {
    width: 100%;
    max-width: 800px;
    height: auto;
    display: block;
    margin: 0 auto 2rem auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    object-fit: cover;
}

/* --- Formulário de Avaliação (avaliacao.php): radios e checkbox --- */
main form input[type="radio"],
main form input[type="checkbox"] {
    width: 1.1rem;
    height: 1.1rem;
    accent-color: #0d6e87;
    cursor: pointer;
    flex-shrink: 0;
}

main form input[type="radio"]:focus,
main form input[type="checkbox"]:focus {
    outline: 2px solid #0d6e87;
    outline-offset: 2px;
}

main form label:has(input[type="radio"]),
main form label:has(input[type="checkbox"]) {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.35rem 0.65rem;
    border-radius: 5px;
    transition: background-color 0.15s;
    font-size: 0.95rem;
}

main form label:has(input[type="radio"]):hover,
main form label:has(input[type="checkbox"]):hover {
    background-color: #f0f4f8;
}

main form label:has(input[type="radio"]:checked) {
    background-color: #e0f2fe;
    color: #0c4a6e;
    font-weight: 700;
}

main form label:has(input[type="checkbox"]:checked) {
    background-color: #f0fdf4;
    color: #15803d;
    font-weight: 700;
}


/* --- Painel Expansível de Alteração de Senha (perfil.php) --- */
main details {
    background-color: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    margin-top: 1.5rem;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

main details summary {
    display: block;
    list-style: none;
    padding: 1rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: #082e5c;
    background-color: #f8fafc;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s;
    border-bottom: 1px solid transparent;
}

main details summary::-webkit-details-marker {
    display: none;
}

main details summary::marker {
    content: none;
}

main details summary::after {
    content: ' ▼';
    float: right;
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 0.2rem;
}

main details[open] summary {
    background-color: #f1f5f9;
    border-bottom: 1px solid #cbd5e1;
}

main details[open] summary::after {
    content: ' ▲';
}

main details summary:hover {
    background-color: #e2e8f0;
}

main details form {
    padding: 1.5rem;
    background-color: #ffffff;
    box-shadow: none;
    border-radius: 0;
}


/* --- Área de Conteúdo Principal --- */
main {
    flex: 1;
    min-width: 0;
    padding: 2.5rem;
    background-color: #f0f4f8;
}

h2 {
    font-size: 1.75rem;
    color: #082e5c;
    margin-bottom: 0.75rem;
    font-weight: 700;
}

h3 {
    font-size: 1.25rem;
    color: #0d6e87;
    margin-bottom: 0.75rem;
    font-weight: 600;
}

/* --- Tabelas HTML Limpas e Formatadas --- */
table {
    width: 100%;
    border-collapse: collapse;
    background-color: #ffffff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07);
    margin: 1.25rem 0 2.5rem 0;
}

thead {
    background-color: #082e5c;
    color: #ffffff;
}

thead th {
    background-color: #082e5c;
    color: #ffffff;
    padding: 1rem 1.25rem;
    text-align: left;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: none;
}

tbody td {
    padding: 1rem 1.25rem;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.95rem;
    color: #1e293b;
    vertical-align: middle;
}

tbody tr:nth-child(even) {
    background-color: #f8fafc;
}

tbody tr:hover {
    background-color: #f1f5f9;
}

/* --- Formulários & Controles Nativos --- */
form {
    background-color: #ffffff;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

label {
    font-weight: 600;
    font-size: 0.9rem;
    color: #1e293b;
    display: block;
    margin-bottom: 0.25rem;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="number"],
input[type="url"],
input[type="file"],
textarea,
select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
    background-color: #ffffff;
    color: #1e293b;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="file"] {
    padding: 0.5rem;
    background-color: #f8fafc;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #0d6e87;
    box-shadow: 0 0 0 3px rgba(13, 110, 135, 0.15);
}

textarea {
    resize: vertical;
    min-height: 90px;
}

/* Fieldsets (Módulos e Questões) */
fieldset {
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 1.5rem;
    background-color: #f8fafc;
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

legend {
    font-weight: 700;
    color: #0d6e87;
    padding: 0 0.5rem;
    font-size: 1rem;
}

/* --- Botões e Ações --- */
button,
a[role="button"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background-color: #0d6e87;
    color: #ffffff !important;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none !important;
    transition: background-color 0.2s, transform 0.1s;
}

button:hover,
a[role="button"]:hover {
    background-color: #082e5c;
}

button[type="button"] {
    background-color: #18a38c;
}

button[type="button"]:hover {
    background-color: #12826f;
}

/* --- Artigos (Módulos e Cards) --- */
article {
    background-color: #ffffff;
    border-radius: 8px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07);
    border-left: 6px solid #18a38c;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}


/* --- Vídeo Players / Iframes Responsivos (Proporção 16:9 sem cortes) --- */
.video-container {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 Aspect Ratio universal fallback (9/16 = 0.5625) */
    background-color: #000000;
    border-radius: 8px;
    overflow: hidden;
    margin: 1.25rem 0;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

@supports (aspect-ratio: 16 / 9) {
    .video-container {
        padding-top: 0;
        aspect-ratio: 16 / 9;
    }
}

.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    border: none !important;
    margin: 0 !important;
    border-radius: 8px;
    display: block;
}

iframe:not(.video-container iframe) {
    width: 100%;
    aspect-ratio: 16 / 9;
    min-height: 380px;
    border: none;
    border-radius: 6px;
    margin: 1rem 0;
    background-color: #000000;
}

/* --- Seções de Materiais Complementares (PDFs) --- */
section {
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 1.25rem;
    margin-top: 1rem;
}

section ul {
    list-style: none;
    padding-left: 0;
    margin-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

section a {
    color: #0d6e87;
    text-decoration: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

section a:hover {
    text-decoration: underline;
    color: #082e5c;
}

/* --- Rodapé Institucional --- */
footer {
    background-color: #0f172a;
    color: #94a3b8;
    text-align: center;
    padding: 1.25rem;
    font-size: 0.85rem;
    margin-top: auto;
}

footer img {
    max-height: 38px;
    width: auto;
    object-fit: contain;
}

/* --- Páginas de Autenticação (Login / Cadastro) ---
   Quando a main aparece SEM o #layout (sem sidebar), fica centralizada */
body:not(:has(#layout))>main {
    max-width: 560px;
    margin: 3rem auto;
    padding: 0 1.5rem;
    background-color: transparent;
    box-shadow: none;
}

body:not(:has(#layout))>main>form {
    max-width: 100%;
}

/* --- Painel Admin: badge de papel na tabela --- */
tbody td:has(> span[style*="color:#64748b"]) {
    font-style: italic;
}

/* --- Link de ação dentro de tabela (Promover / trocar) --- */
tbody td>a[role="button"] {
    display: inline-flex;
    padding: 0.4rem 0.9rem;
    font-size: 0.82rem;
    margin: 0.15rem 0;
    border-radius: 5px;
}

/* --- Responsividade Mobile --- */
@media (max-width: 900px) {
    header {
        flex-direction: column;
        text-align: center;
    }

    #layout {
        flex-direction: column;
    }

    aside,
    nav {
        width: 100%;
        min-width: 100%;
        max-width: 100%;
        padding: 1.25rem;
    }

    main {
        padding: 1.5rem 1rem;
    }

    iframe:not(.video-container iframe) {
        height: 240px;
        min-height: auto;
    }

    table {
        display: block;
        overflow-x: auto;
    }

    body:not(:has(#layout))>main {
        margin: 1.5rem auto;
        padding: 0 1rem;
    }
}

/* --- Campo de Senha com Alternador de Visibilidade (Olhinho) --- */
.campo-senha-wrapper {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
}

.campo-senha-wrapper input {
    padding-right: 2.75rem !important;
    width: 100%;
}

button.btn-toggle-senha,
.btn-toggle-senha {
    position: absolute;
    right: 0.6rem;
    top: 50%;
    transform: translateY(-50%);
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0.35rem !important;
    color: #64748b !important;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: color 0.2s ease, background-color 0.2s ease;
    z-index: 2;
}

button.btn-toggle-senha:hover,
.btn-toggle-senha:hover {
    color: #0d6e87 !important;
    background-color: rgba(13, 110, 135, 0.08) !important;
}

button.btn-toggle-senha:focus,
.btn-toggle-senha:focus {
    outline: none;
    color: #0d6e87 !important;
}