* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Variabili dei colori */
:root {
    --bg: #ffffff;
    --text: #111111;
    --card: #f4f4f4;
    --nav: #111111;
    --icon: #333333;
}

body {
    font-family: sans-serif;
    background-color: var(--bg);
    color: var(--text);
}

body.dark {
    --bg: #121212;
    --text: #ffffff;
    --card: #1e1e1e;
    --nav: #000000;
    --icon: #2c2c2c;
}

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    width: 64px;
    height: 100vh;
    background: var(--nav);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 1rem;
    gap: 1rem;
    display: none;
    transition: width 0.3s ease;
    z-index: 1;
    /* ensures correct layering with cards on hover and sidebar*/
}

.sidebar:hover {
    width: 180px;
}

.sidebar:hover .sidebar-logo {
    transform: scale(1.05);
}

.sidebar:hover .label {
    display: inline;
    margin-left: 0.5rem;
}

.sidebar:hover .nav-link {
    justify-content: flex-start;
    padding-left: 1rem;
}

.nav-link {
    color: white;
    text-decoration: none;
    padding: 0.6rem;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-link.active {
    color: #a5b4fc;
    border-left: 3px solid #6366f1;
}

.icon {
    font-size: 1.4rem;
}

.sidebar-logo {
    width: 40px;
    /* dimensione adatta alla sidebar */
    margin-bottom: 1rem;
    /* spazio tra logo e primo link */
    display: block;
    margin-left: auto;
    margin-right: auto;
    /* centra orizzontalmente */
}

/* Distanza tra logo e primo link */
.nav-link:first-of-type {
    margin-top: 1.5rem;
    /* aumenta se vuoi più spazio */
}

/* ===== NAVBAR MOBILE ===== */
.navbar {
    background-color: var(--nav);
    padding: 1rem;
}

#menu-toggle {
    display: none;
}

.hamburger {
    width: 30px;
    height: 22px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
}

.hamburger span {
    height: 4px;
    background: white;
    border-radius: 2px;
}

.menu {
    list-style: none;
    display: none;
    margin-top: 1rem;
    padding: 0;
}

.menu li {
    margin: 0.5rem 0;
}

.menu a {
    color: white;
    text-decoration: none;
    font-size: 1.8rem;
    /* più grande = più leggibile su mobile */
    padding: 0.5rem;
    /* più facile da cliccare */
}

#menu-toggle:checked~.menu {
    display: flex;
    /* diventa flex quando aperto */
    flex-direction: row;
    /* icone in orizzontale */
    justify-content: center;
    /* centra nel menu */
    gap: 1rem;
    /* distanza tra le icone */
}

/* ===== MAIN CONTENT ===== */
.main-content {
    padding: 2rem;
}

.dashboard {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.card {
    background-color: var(--card);
    padding: 1.5rem;
    border-radius: 10px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

#theme-toggle {
    margin-bottom: 1.5rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    background-color: var(--card);
    color: var(--text);
}

/* ===== DESKTOP ===== */
@media (min-width: 768px) {

    .navbar {
        display: none;
    }

    .sidebar {
        display: flex;
    }

    .main-content {
        margin-left: 64px;
    }

    .dashboard {
        grid-template-columns: repeat(3, 1fr);

    }

    .label {
        display: none;
        opacity: 0;
        transition: opacity 0.2s ease;
    }

    .sidebar:hover .label {
        display: inline;
        opacity: 1;
    }

}

/* ===== FOOTER ===== */
.footer {
    margin-top: 2rem;
    padding: 1rem 0 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.8rem;
    opacity: 0.6;
    text-align: center;
}

html,
body {
    height: 100%;
}

body {
    display: flex;
    flex-direction: column;
}

.main-content {
    flex: 1;
}

/* Mobile menu */
.menu {
    animation: fadeIn 0.3s ease forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}