/* =========================
   Sidebar
========================= */
.sidebar {
    width: 240px;
    background-color: #34495e;
    color: #ecf0f1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    height: 100vh; /* full viewport height */
    overflow-y: auto; /* allow sidebar to scroll independently if needed */
    position: fixed; /* keep sidebar fixed */
    left: 0;
    top: 0;
}

.sidebar-logo {
    width: 150px;
    display: block;
    margin: 20px auto 20px auto; 
}

/* Primo pulsante sotto il logo: distanzia meglio */
.sidebar .menu-btn:first-of-type {
  margin-top: 30px;
}

.sidebar h2 {
    font-size: 1.6em;
    margin-bottom: 30px;
    text-align: center;
}

.menu-btn {
    background: none;
    border: none;
    color: #ecf0f1;
    font-size: 1em;
    text-align: left;
    padding: 12px 20px;
    margin-bottom: 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.3s, color 0.3s;
    display: flex;
    align-items: center;
    gap: 12px;
}

.menu-btn svg {
    flex-shrink: 0;
    opacity: 0.85;
    width: 18px;
    height: 18px;
    min-width: 18px; /* keep icon width fixed to align labels */
}

.menu-btn span {
    flex: 1;
    white-space: nowrap; /* prevent unexpected wrapping that may shift alignment */
}

/* Fix Extra tab text alignment */
#btn-altro span {
    margin-left: 6px; /* Compensate for icon visual difference */
}
.sidebar-submenu {
    margin: 6px 0 12px 0;
    padding-left: 6px;
    max-height: 240px;
    overflow: auto;
    border-left: 2px solid rgba(255,255,255,0.06);
}

.sidebar-submenu.hidden {
    display: none;
}

.submenu-item {
    display: block;
    width: 100%;
    padding: 6px 8px;
    margin: 2px 0;
    background: transparent;
    color: #dce6ff;
    border: none;
    text-align: left;
    cursor: pointer;
}

.submenu-item.active {
    background: rgba(255,255,255,0.06);
    color: #fff;
    font-weight: 600;
}

.card.selected {
    outline: 3px solid rgba(10,132,255,0.15);
    box-shadow: 0 2px 10px rgba(16,24,40,0.08);
}

.menu-btn:hover {
    background-color: #2c3a4e;
}

.menu-btn.active {
    background-color: #1abc9c;
    color: #fff;
}

/* Back button on site detail view */
.back-btn {
    background-color: #ffffff;
    color: #34495e;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid rgba(0,0,0,0.06);
    display: inline-block;
    margin-bottom: 12px;
}

/* Sections for POD and PDR in detail view */
.detail-section {
    margin-top: 18px;
    padding: 12px 0;
    border-top: 1px solid rgba(52,73,94,0.06);
}

.detail-section h5 {
    margin: 0 0 10px 0;
}

.detail-section .card {
    margin-bottom: 10px;
}

/* =========================
   Main content
========================= */
.main {
    flex: 1;
    padding: 30px;
    margin-left: 240px; /* offset for fixed sidebar */
    height: 100vh; /* full viewport height */
    overflow-y: auto; /* allow main content to scroll independently */
}

.main h3 {
    font-size: 1.5em;
    margin-bottom: 28px;
    color: #34495e;
}

/* Grid generico */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 48px; /* add space between cards grid and following sections */
}

/* Grid totali: impedisce che le card diventino troppo strette su schermi larghi */
.grid-totals {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    justify-content: left;
}

/* Ensure chart area sits lower than preceding content */
.chart-container {
    margin-top: 40px;
}

/* =========================
   Responsive
========================= */
@media (max-width: 900px) {
    .sidebar { width: 200px; padding: 15px; }
    .main { margin-left: 200px; }
    .menu-btn { font-size: 0.9em; padding: 10px 15px; }
}

@media (max-width: 600px) {
    body { flex-direction: column; overflow: auto; }
    .sidebar { 
        width: 100%; 
        flex-direction: row; 
        overflow-x: auto; 
        justify-content: space-around;
        position: relative;
        height: auto;
    }
    .main { 
        padding: 15px; 
        margin-left: 0;
        height: auto;
        overflow-y: visible;
    }
    .grid { grid-template-columns: 1fr; }
}
