/* ============================================================
   Centro de Cultura de Arabutã
   Layout adaptado do template AdminHub (sidebar + navbar),
   com a paleta do brasão/bandeira do município.
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Lato:wght@400;700&family=Poppins:wght@400;500;600;700&display=swap');

* { margin: 0; padding: 0; box-sizing: border-box; }
a { text-decoration: none; }
li { list-style: none; }

:root {
    --poppins: 'Poppins', sans-serif;
    --lato: 'Lato', sans-serif;

    /* Tokens estruturais (equivalentes do template original) */
    --light: #FFFFFF;
    --grey: #F7F5F0;
    --dark: #292926;
    --dark-grey: #6B6B66;
    --cinza-claro: #E4E1D8;

    /* Paleta de marca */
    --verde-mata: #1F4D2C;
    --verde-escuro: #12301A;
    --light-verde: #E8F0E9;
    --dourado: #D9A441;
    --light-dourado: #FBF0DC;
    --terracota: #C1440E;
    --light-terracota: #FBE7DD;
    --marrom: #8A5A2B;
    --light-marrom: #F3E6D8;
    --azul-ferro: #4A6670;
    --light-azul-ferro: #E1EAEC;

    /* Aliases usados pelos componentes internos (cards, tabelas, formulários) */
    --branco: var(--light);
    --creme: var(--grey);
    --grafite: var(--dark);
    --cinza: var(--dark-grey);
    --verde-claro: var(--light-verde);

    --raio: 10px;
    --raio-pequeno: 6px;
    --sombra: 0 1px 2px rgba(41,41,38,.06), 0 4px 14px rgba(41,41,38,.06);
    --sombra-hover: 0 2px 4px rgba(41,41,38,.08), 0 8px 24px rgba(41,41,38,.10);

    --fonte-titulo: var(--poppins);
    --fonte-corpo: var(--poppins);
}

html { overflow-x: hidden; }

body.dark {
    --light: #1B2A20;
    --grey: #101911;
    --dark: #F2F1EC;
    --dark-grey: #9DAE9F;
    --cinza-claro: #2E3D31;
    --light-verde: #23392B;
    --light-dourado: #3A2F16;
    --light-terracota: #3A2119;
    --light-marrom: #332821;
    --light-azul-ferro: #1E2C30;
}

body {
    background: var(--grey);
    color: var(--dark);
    overflow-x: hidden;
    font-family: var(--fonte-corpo);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--fonte-titulo); font-weight: 600; margin: 0 0 4px; }
h1 { font-size: 1.75rem; color: var(--dark); margin-bottom: 20px; }
h2 { font-size: 1.1rem; color: var(--verde-mata); margin-bottom: 14px; }
a { color: var(--verde-mata); }

/* ================= SIDEBAR ================= */
#sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 230px;
    height: 100%;
    background: var(--light);
    z-index: 2000;
    font-family: var(--lato);
    transition: .3s ease;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: none;
    border-right: 1px solid var(--cinza-claro);
}
#sidebar.hide { width: 64px; }
#sidebar .brand {
    font-size: 1.15rem;
    font-weight: 700;
    height: 60px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--verde-mata);
    position: sticky;
    top: 0; left: 0;
    background: var(--light);
    z-index: 500;
    padding: 0 18px;
    border-bottom: 1px solid var(--cinza-claro);
}
#sidebar .brand .bx { min-width: 26px; display: flex; justify-content: center; font-size: 1.5rem; }
#sidebar .brand .text { line-height: 1.15; white-space: nowrap; overflow: hidden; }
#sidebar .side-menu { width: 100%; margin-top: 16px; }
#sidebar .side-menu li { height: 46px; margin: 2px 8px; border-radius: 8px; }
#sidebar .side-menu li.active { background: var(--light-verde); }
#sidebar .side-menu li a {
    width: 100%; height: 100%;
    display: flex; align-items: center;
    padding: 0 14px;
    border-radius: 8px;
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--dark-grey);
    white-space: nowrap;
    overflow-x: hidden;
    gap: 12px;
}
#sidebar.hide .side-menu li a { width: calc(64px - 16px); padding: 0; justify-content: center; }
#sidebar.hide .side-menu li a .text { display: none; }
#sidebar .side-menu li a .bx { min-width: 22px; font-size: 1.2rem; display: flex; justify-content: center; }
#sidebar .side-menu.top li.active a { color: var(--verde-mata); font-weight: 600; }
#sidebar .side-menu.top li a:hover { color: var(--verde-mata); background: var(--grey); }
#sidebar .side-menu li a.logout { color: var(--terracota); }
#sidebar .side-menu.bottom { position: absolute; bottom: 12px; width: 100%; }

/* ================= CONTEÚDO ================= */
#content { position: relative; width: calc(100% - 230px); left: 230px; transition: .3s ease; min-height: 100vh; }
#sidebar.hide ~ #content { width: calc(100% - 64px); left: 64px; }

/* ---- Navbar ---- */
#content nav {
    height: 60px;
    background: var(--light);
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    font-family: var(--lato);
    position: sticky;
    top: 0; left: 0;
    z-index: 1000;
    border-bottom: 1px solid var(--cinza-claro);
}
#content nav .bx.bx-menu { cursor: pointer; color: var(--dark); font-size: 1.4rem; }
#content nav .nav-link { font-size: 0.95rem; font-weight: 600; color: var(--dark); }
#content nav form { max-width: 340px; width: 100%; margin-right: auto; }
#content nav form .form-input { display: flex; align-items: center; height: 38px; }
#content nav form .form-input input {
    flex-grow: 1; padding: 0 16px; height: 100%; border: 1px solid var(--cinza-claro);
    background: var(--grey); border-radius: 38px 0 0 38px; outline: none; width: 100%;
    color: var(--dark); font-family: var(--fonte-corpo); font-size: 0.88rem;
    border-right: none;
}
#content nav form .form-input button {
    width: 38px; height: 100%; display: flex; justify-content: center; align-items: center;
    background: var(--verde-mata); color: #fff; font-size: 1.05rem; border: none; outline: none;
    border-radius: 0 38px 38px 0; cursor: pointer;
}
#content nav .swith-lm {
    background-color: var(--grey); border: 1px solid var(--cinza-claro);
    border-radius: 50px; cursor: pointer; display: flex; align-items: center;
    padding: 3px; position: relative; height: 24px; width: 46px; flex-shrink: 0;
}
#content nav .swith-lm .ball {
    background-color: var(--verde-mata); border-radius: 50%; position: absolute;
    top: 2px; left: 2px; height: 18px; width: 18px; transition: transform .2s linear;
}
#content nav .checkbox:checked + .swith-lm .ball { transform: translateX(20px); }
#content nav .swith-lm .bxs-moon { color: var(--dourado); font-size: 12px; margin-left: 2px; }
#content nav .swith-lm .bx-sun { color: var(--terracota); font-size: 12px; margin-right: 2px; }

#content nav .profile { flex-shrink: 0; position: relative; }
#content nav .profile .avatar-inicial {
    width: 38px; height: 38px; border-radius: 50%; background: var(--verde-mata); color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.95rem;
}
#content nav .profile-menu {
    display: none; position: absolute; top: 50px; right: 0; background: var(--light);
    box-shadow: var(--sombra-hover); border-radius: var(--raio); width: 210px; z-index: 9999;
    font-family: var(--fonte-corpo); border: 1px solid var(--cinza-claro); overflow: hidden;
}
#content nav .profile-menu.show { display: block; }
#content nav .profile-menu .cabecalho { padding: 12px 16px; border-bottom: 1px solid var(--cinza-claro); }
#content nav .profile-menu .cabecalho strong { display: block; font-size: 0.9rem; color: var(--dark); }
#content nav .profile-menu .cabecalho span { font-size: 0.78rem; color: var(--dark-grey); text-transform: capitalize; }
#content nav .profile-menu a {
    display: block; padding: 12px 16px; font-size: 0.88rem; color: var(--dark);
}
#content nav .profile-menu a:hover { background: var(--grey); }
#content nav .profile-menu a.logout { color: var(--terracota); }

/* ---- Main ---- */
#content main { width: 100%; padding: 28px 24px 0; font-family: var(--fonte-corpo); }

/* Cards de indicador do painel (estilo box-info do template) */
.box-info { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 24px; }
.box-info li {
    padding: 20px; background: var(--light); border-radius: var(--raio);
    display: flex; align-items: center; gap: 18px; box-shadow: var(--sombra); border: 1px solid var(--cinza-claro);
}
.box-info li .bx { width: 60px; height: 60px; border-radius: var(--raio); font-size: 1.6rem; display: flex; justify-content: center; align-items: center; flex-shrink: 0; }
.box-info li:nth-child(1) .bx { background: var(--light-verde); color: var(--verde-mata); }
.box-info li:nth-child(2) .bx { background: var(--light-dourado); color: var(--dourado); }
.box-info li:nth-child(3) .bx { background: var(--light-terracota); color: var(--terracota); }
.box-info li:nth-child(4) .bx { background: var(--light-marrom); color: var(--marrom); }
.box-info li:nth-child(5) .bx { background: var(--light-azul-ferro); color: var(--azul-ferro); }
.box-info li .texto h3 { font-size: 1.5rem; font-weight: 700; color: var(--dark); line-height: 1; margin-bottom: 4px; }
.box-info li .texto p { color: var(--dark-grey); font-size: 0.85rem; }

/* ---------------- Cards ---------------- */
.card { background: var(--branco); border-radius: var(--raio); padding: 22px 24px; box-shadow: var(--sombra); margin-bottom: 20px; border: 1px solid var(--cinza-claro); }

.indicadores { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; margin-bottom: 24px; }
.indicador { background: var(--branco); border-radius: var(--raio); padding: 20px; box-shadow: var(--sombra); border-top: 6px double var(--dourado); text-align: left; }
.indicador .numero { font-size: 2.1rem; font-weight: 700; color: var(--verde-mata); line-height: 1; display: block; margin-bottom: 6px; }
.indicador .rotulo { font-size: 0.85rem; color: var(--cinza); }

/* ---------------- Tabelas ---------------- */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--cinza-claro); text-align: left; font-size: 0.9rem; }
th { background: var(--light-verde); color: var(--verde-escuro); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
tbody tr:hover { background: var(--grey); }
td a { text-decoration: none; font-weight: 500; }
td a:hover { text-decoration: underline; }

/* ---------------- Formulários ---------------- */
form label { display: block; margin-top: 14px; font-size: 0.85rem; font-weight: 600; color: var(--dark); }
form input, form select, form textarea {
    width: 100%; padding: 10px 12px; margin-top: 5px; border: 1px solid var(--cinza-claro);
    border-radius: var(--raio-pequeno); font-size: 0.95rem; font-family: var(--fonte-corpo);
    background: var(--branco); color: var(--grafite); transition: border-color .15s ease, box-shadow .15s ease;
}
form input:focus, form select:focus, form textarea:focus { outline: none; border-color: var(--verde-mata); box-shadow: 0 0 0 3px var(--verde-claro); }
form input[readonly] { background: var(--creme); color: var(--cinza); }
fieldset { border: 1px solid var(--cinza-claro); border-radius: var(--raio); }
legend { font-weight: 600; color: var(--verde-mata); padding: 0 6px; }

/* ---------------- Botões ---------------- */
.btn {
    display: inline-block; margin-top: 18px; padding: 11px 20px; background: var(--verde-mata); color: #fff;
    border: none; border-radius: var(--raio-pequeno); cursor: pointer; text-decoration: none; font-size: 0.9rem;
    font-weight: 600; font-family: var(--fonte-corpo); box-shadow: var(--sombra);
    transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.btn:hover { background: var(--verde-escuro); box-shadow: var(--sombra-hover); transform: translateY(-1px); }
.btn-secundario { background: var(--branco); color: var(--grafite); border: 1px solid var(--cinza-claro); box-shadow: none; }
.btn-secundario:hover { background: var(--creme); transform: none; }
.btn-perigo { background: var(--terracota); }
.btn-perigo:hover { background: #9B370B; }

/* ---------------- Alertas ---------------- */
.alerta { padding: 12px 16px; border-radius: var(--raio-pequeno); margin-bottom: 16px; font-size: 0.88rem; border-left: 4px solid; }
.alerta-erro { background: var(--light-terracota); color: var(--terracota); border-color: var(--terracota); }
.alerta-sucesso { background: var(--light-verde); color: var(--verde-mata); border-color: var(--verde-mata); }

/* ---------------- Badges ---------------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 100px; font-size: 0.74rem; font-weight: 600; }
.badge-verde { background: var(--light-verde); color: var(--verde-escuro); }
.badge-dourado { background: var(--light-dourado); color: #8A6118; }
.badge-terracota { background: var(--light-terracota); color: var(--terracota); }
.badge-cinza { background: var(--cinza-claro); color: var(--cinza); }

/* ---------------- Login ---------------- */
.login-box {
    max-width: 380px; margin: 8vh auto; background: var(--branco); padding: 36px 34px; border-radius: var(--raio);
    box-shadow: var(--sombra-hover); border-top: 6px double var(--dourado); text-align: center; overflow: hidden;
}
.login-box h2, .login-box p, .login-box form { text-align: left; }
.login-box h2 { font-size: 1.4rem; }
.login-box > p { color: var(--cinza); margin-top: 0; margin-bottom: 20px; font-size: 0.92rem; }
.login-logo { display: block; margin: 0 auto 18px auto; max-width: 190px; width: 100%; height: auto; object-fit: contain; }

/* ---------------- Rodapé ---------------- */
.rodape { background: transparent; padding: 24px 0 28px; margin-top: 20px; text-align: center; font-size: 0.85rem; color: var(--cinza); border-top: 1px solid var(--cinza-claro); }
.rodape-logos { display: flex; align-items: center; justify-content: center; gap: 28px; flex-wrap: wrap; margin-bottom: 10px; }
.rodape-logo-municipio { height: 34px; width: auto; }
.rodape-dev { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--cinza); }
.rodape-logo-grafato { height: 26px; width: auto; }

/* ---------------- Relatórios ---------------- */
.topo-relatorio { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.topo-relatorio h1 { margin-bottom: 0; }
.grade-graficos { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.grafico-wrap { position: relative; height: 220px; width: 100%; }
.grafico-wrap-largo { height: 280px; }
.barra-progresso { background: var(--cinza-claro); border-radius: 100px; height: 8px; overflow: hidden; margin-bottom: 4px; }
.barra-progresso-preenchida { height: 100%; border-radius: 100px; }

.termo-autorizacao { max-width: 720px; margin-left: auto; margin-right: auto; }

@media print {
    .termo-autorizacao { break-after: page; border: 1px solid #ccc; }
    .termo-autorizacao:last-child { break-after: auto; }
}

@media print {
    #sidebar, #content nav, .ocultar-impressao, .rodape { display: none !important; }
    #content { width: 100% !important; left: 0 !important; }
    body { background: #fff; }
    .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
    canvas { max-height: 220px !important; }
}

/* ---------------- Responsivo ---------------- */
@media screen and (max-width: 768px) {
    #sidebar { width: 220px; }
    #content { width: calc(100% - 64px); left: 220px; }
    #content nav .nav-link { display: none; }
}
@media screen and (max-width: 576px) {
    #content nav .nav-link { display: none; }
    #content nav form { max-width: 160px; }
    #content nav form .form-input input { font-size: 0.8rem; padding: 0 10px; }
    #content main { padding: 20px 16px 0; }
    h1 { font-size: 1.4rem; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
