* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    height: 100%;
    font-family: "Roboto", sans-serif;
    font-optical-sizing: auto;
    font-weight: <weight>;
    font-style: normal;
    font-variation-settings: "wdth" 100;
    font-size: .9rem;

    background: #eef1f2; /* fundo neutro */
}

/* HEADER */
.topbar {
    height: 60px;
    background: linear-gradient(90deg, #2f6f3e, #3fa15c);
    color: white;
    display: flex;
    align-items: center;
    padding: 0 20px;
    font-weight: bold;
}

/* FOOTER */
.stats {
    height: 50px;
    background: #fff;
    border-top: 1px solid #ddd;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
}

/* LAYOUT CENTRAL */
.layout {
    height: calc(100vh - 200px);
    display: grid;
    grid-template-columns: 300px 1fr 340px;

    /* ✨ ESPAÇAMENTO BONITO */
    gap: 12px;

    padding: 12px;
    background: #eef1f2; /* fundo neutro */
    overflow: hidden;
}



/* SIDEBAR ESQUERDO */
.sidebar {
    background: #f4f4f4;
    border-right: 1px solid #ccc;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 12px;
    background: #e0e0e0;
    font-weight: bold;
    flex-shrink: 0;
}

.sidebar-tools {
    padding: 10px;
    flex-shrink: 0;
}

.sidebar-tools input {
    width: 100%;
    padding: 6px;
    margin-bottom: 6px;
}

/* ⚠️ AQUI ESTÁ O SEGREDO */
.sidebar-content {
    flex: 1;
    min-height: 0;          /* 🔥 OBRIGATÓRIO */
    overflow-y: auto;       /* 🔥 SCROLL REAL */
}

/* LISTA */
.tree-item {
    padding: 8px 10px;
    border-bottom: 1px solid #ddd;
    cursor: pointer;
}
.tree-item:hover {
    background: #e6f2ea;
}

/* MAPA */
#map {
    width: 100%;
    height: 100%;
    position: relative;
}

/* SIDEBAR DIREITO */
.details {
    background: #fff;
    border-left: 1px solid #ccc;
    display: flex;
    flex-direction: column;
}

.details-header {
    background: #2f6f3e;
    color: white;
    padding: 12px;
    font-weight: bold;
    flex-shrink: 0;
}

.details-content {
    flex: 1;
    min-height: 0;          /* 🔥 IGUALMENTE OBRIGATÓRIO */
    overflow-y: auto;
    padding: 10px;
}

.details-content img {
    border-radius: 10px;
    /*width: 100%;
    height: 180px;
    object-fit: cover;
    margin-bottom: 10px;*/
}

.details-content p {
    margin-bottom: 0;
}

.sidebar,
.details,
#map {
    background: white;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    overflow: hidden;
}
.sidebar {
    display: flex;
    flex-direction: column;
}

.sidebar-content {
    flex: 1;
    min-height: 0;     /* 🔥 DUPLA SEGURANÇA */
    overflow-y: auto;
}

.details {
    display: flex;
    flex-direction: column;
}

.details-content {
    flex: 1;
    min-height: 0;     /* 🔥 DUPLA SEGURANÇA */
    overflow-y: auto;
}


/* HEADER*/
.topbar {
    height: 60px;
    background: linear-gradient(90deg, #2f6f3e, #3fa15c);
    color: white;
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    padding: 0 20px;
}

.brand span {
    font-size: 12px;
    opacity: 0.9;
    display: block;
}

.tabs a {
    margin: 0 12px;
    cursor: pointer;
    opacity: 0.85;
    font-weight: 500;
    text-decoration: none;
}

.tabs a.active {
    opacity: 1;
    border-bottom: 2px solid white;
    padding-bottom: 4px;
}

/* VIEWS (TABS) */
.view {
    position: absolute;
    top: 125px;           /* header-top + header-tabs */
    left: 0;
    right: 0;
    bottom: 50px;         /* footer */
    background: #fff;
    padding: 20px;
    overflow: auto;
    z-index: 10000;
    bottom: 10px;
}

.view.hidden {
    display: none;
}


/* TABELA */
#tabela-arvores {
    width: 100%;
    border-collapse: collapse;
}

#tabela-arvores th,
#tabela-arvores td {
    border: 1px solid #ddd;
    padding: 8px;
    font-size: 14px;
}

#tabela-arvores th {
    background: #f0f0f0;
}

/* GRÁFICOS */
.charts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
}

@media (max-width: 900px) {
    .charts {
        grid-template-columns: 1fr;
    }
}


.sidebar-tools select,
.sidebar-tools button {
    width: 100%;
    padding: 6px;
    margin-bottom: 6px;
}

/* ===========================
   MODO IMPRESSÃO OFICIAL
=========================== */

@media print {

    body {
        background: white;
    }

    /* esconder UI */
    header,
    .sidebar,
    .tabs,
    .stats,
    button {
        display: none !important;
    }

    /* mostrar apenas mapa + detalhes */
    .layout {
        display: block;
        height: auto;
    }

    #map {
        height: 120mm !important;
        width: 100% !important;
        page-break-after: always;
    }

    .details {
        display: block !important;
        position: static;
        box-shadow: none;
        border: none;
    }

    .details-content {
        overflow: visible;
        padding: 0;
    }

    /* tipografia impressão */
    .details-content p {
        font-size: 11pt;
        line-height: 1.4;
    }
}


@media print {

    body::before {
        content: "Município de Ourém – Cadastro do Arvoredo";
        display: block;
        font-size: 14pt;
        font-weight: bold;
        margin-bottom: 10mm;
        border-bottom: 2px solid #000;
        padding-bottom: 5mm;
    }

    body::after {
        content: "Documento gerado automaticamente – uso informativo";
        display: block;
        position: fixed;
        bottom: 10mm;
        left: 10mm;
        font-size: 8pt;
        color: #555;
    }
}


/* ================= HEADER ================= */

.header {
    display: flex;
    flex-direction: column;
}

/* Linha verde principal */
.header-top {
    /*background: linear-gradient(90deg, #2f6f3e, #3fa15c);*/
    color: white;
    padding: 14px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.tree-icon {
    font-size: 42px; /* árvore grande */
    line-height: 1;
}

.header-title .title-main {
    font-size: 22px;
    font-weight: 600;
}

.header-title .title-sub {
    font-size: 14px;
    opacity: 0.9;
}

.header-right img {
    height: 42px;
}

/* Linha branca das tabs */
.header-tabs {
    background: #ffffff;
    border-bottom: 1px solid #ddd;
    padding: 0 24px;
}

.tabs {
    display: flex;
    gap: 24px;
}

.tabs a {
    padding: 12px 0;
    cursor: pointer;
    font-weight: 500;
    color: #444;
    border-bottom: 3px solid transparent;
}

.tabs a.active {
    color: #2f6f3e;
    border-bottom-color: #2f6f3e;
}


/* Botão hamburger */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 26px;
    cursor: pointer;
    margin-left: 12px;
}

/* MOBILE */
@media (max-width: 768px) {

    .menu-toggle {
        display: block;
    }

    .header-tabs {
        display: none;
    }

    .header-tabs.open {
        display: block;
        position: absolute;
        top: 70px; /* altura da linha verde */
        left: 0;
        right: 0;
        background: white;
        border-bottom: 1px solid #ddd;
        z-index: 3000;
    }

    .tabs {
        flex-direction: column;
        gap: 0;
    }

    .tabs a {
        padding: 14px 20px;
        border-bottom: 1px solid #eee;
    }

    /* Ajuste layout central em mobile */
    .layout {
        height: calc(100vh - 70px);
        grid-template-columns: 1fr;
    }

    .sidebar,
    .details {
        display: none;
    }
}

/* ================= ESTATÍSTICAS ================= */

.stats {
    height: 70px;
    background: white;
    display: flex;

    /* 🔑 CENTRAR TUDO */
    justify-content: center;
    align-items: center;

    /* espaço entre os blocos */
    gap: 60px;

    padding: 0 24px;
    border-top: 1px solid #ddd;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 180px;
    justify-content: center;
}
.stat-item > div {
    text-align: left;
}



.stat-icon {
    font-size: 40px;
}

.stat-value {
    font-size: 18px;
    font-weight: 600;
    color: #2f6f3e;
}

.stat-label {
    font-size: 12px;
    color: #666;
}


.leaflet-popup-content button.popup-btn {
    width: 100%;
    padding: 6px;
    margin-bottom: 4px;
    background: #2f6f3e;
    color: white;
    border: none;
    cursor: pointer;
    font-size: 12px;
}

.leaflet-popup-content button.popup-btn.secondary {
    background: #4e8f64;
}

.tree-item.active {
    background: #e6f2ea;
    border-left: 4px solid #2f6f3e;
}



/* =====================================================
   RESPONSIVO SEM QUEBRAR DESKTOP
===================================================== */

/* TABLET */
@media (max-width: 1024px) {

    .layout {
        grid-template-columns: 300px 1fr;
    }

    .details {
        position: fixed;
        right: -360px;
        top: 140px;
        width: 340px;
        height: calc(100vh - 210px);
        transition: right 0.3s;
        z-index: 3000;
        background: white;
    }

    .details.open {
        right: 12px;
    }
}

@media (max-width: 768px) {

    /* header ocupa menos espaço */
    .header-top {
        height: 56px;
        padding: 0 14px;
    }

    .tree-icon {
        font-size: 28px;
    }

    .header-title .title-main {
        font-size: 16px;
        line-height: 1.1;
    }

    .header-title .title-sub {
        display: none; /* 🔥 fora em mobile */
    }

    /* tabs NÃO fazem parte do layout */
    .header-tabs {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        z-index: 5000;
        border-top: 1px solid #ddd;
        border-bottom: none;
    }
}

@media (max-width: 768px) {

    html, body {
        height: 100%;
        overflow: hidden;
    }

    .layout {
        height: calc(100vh - 56px); /* só header */
        padding: 0;
        gap: 0;
        grid-template-columns: 1fr;
    }

    #map {
        height: 100%;
        width: 100%;
        border-radius: 0;
    }
}
@media (max-width: 768px) {

    .sidebar,
    .details {
        position: fixed;
        top: 56px;
        bottom: 0;
        width: 90%;
        max-width: 340px;
        background: white;
        z-index: 6000;
        transition: transform 0.3s ease;
    }

    .sidebar {
        left: 0;
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .details {
        right: 0;
        transform: translateX(100%);
    }

    .details.open {
        transform: translateX(0);
    }
}
