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

body {
    font-family: "Segoe UI", Arial, sans-serif;
    background: #f7f7f7;
    color: #333;
    line-height: 1.6;
    display: flex;
    overflow-x: auto;
}

/* ============================================================
   MENU LATERALE (UNIFICATO)
   ============================================================ */
.sidebar {
    width: 248px;
    height: 100vh;
    background: #ffffff;
    color: #12344d;
    position: fixed;
    left: 0;
    top: 0;
    padding: 16px 14px;
    box-sizing: border-box;
    border-right: 1px solid #dbe7ea;
    box-shadow: 4px 0 18px rgba(16, 24, 40, 0.05);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.sidebar-logo {
    text-align: center;
    margin-bottom: 14px;
}

.sidebar-logo img {
    max-width: 118px;
    height: auto;
    display: block;
    margin: 0 auto;
    border-radius: 8px;
    background: #fff;
    padding: 5px;
    box-shadow: 0 6px 16px rgba(16, 24, 40, 0.06);
}

.sidebar .menu {
    list-style: none;
    padding: 0;
    margin: 0;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
    scrollbar-gutter: stable;
}

.sidebar .menu::-webkit-scrollbar {
    width: 8px;
}

.sidebar .menu::-webkit-scrollbar-track {
    background: #f1f6f8;
    border-radius: 999px;
}

.sidebar .menu::-webkit-scrollbar-thumb {
    background: #b9d0d6;
    border-radius: 999px;
}

.sidebar .menu::-webkit-scrollbar-thumb:hover {
    background: #8faeb7;
}

.sidebar .menu li {
    margin-bottom: 4px;
}

.sidebar .menu a,
.sidebar > a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: #385568;
    padding: 9px 10px;
    margin-bottom: 0;
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.sidebar .menu-label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.sidebar .menu-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar .menu-icon {
    width: 27px;
    min-width: 27px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: #f1f6f8;
    color: #567080;
    font-size: 10px;
    font-weight: 800;
    text-align: center;
    line-height: 1;
}

.sidebar .menu a:hover,
.sidebar > a:hover {
    background: #eef7f6;
    color: #1f6d6a;
    text-decoration: none;
}

.sidebar .menu a.active,
.sidebar > a.active {
    background: #e8f6f5;
    color: #1f6d6a;
    font-weight: 700;
    box-shadow: inset 3px 0 0 #258782;
}

.sidebar .menu a.active .menu-icon,
.sidebar .submenu.open > .submenu-toggle .menu-icon {
    background: #258782;
    color: #fff;
}

.sidebar .menu a.active:hover,
.sidebar > a.active:hover {
    background: #dff1ef;
    color: #1f6d6a;
}

.sidebar .submenu-toggle {
    cursor: pointer;
    font-weight: 600;
}

.sidebar .submenu.open > .submenu-toggle {
    background: #f2faf9;
    color: #1f6d6a;
}

.sidebar .submenu-arrow {
    font-size: 12px;
    transition: transform 0.2s ease;
}

.sidebar .submenu.open .submenu-arrow {
    transform: rotate(180deg);
}

.sidebar .submenu-items {
    list-style: none;
    padding: 4px 0 2px 16px;
    margin: 0;
    display: none;
}

.sidebar .submenu.open .submenu-items {
    display: block;
}

.sidebar .submenu-items li {
    margin-bottom: 4px;
}

.sidebar .submenu-items a {
    font-size: 13px;
    padding: 8px 9px;
    color: #526b7c;
}

.sidebar .submenu-items a.active {
    background: #e8f6f5;
    color: #1f6d6a;
    font-weight: 700;
    border-left: 3px solid #258782;
    padding-left: 12px;
}

.sidebar .submenu-items a.active:hover {
    background: #dff1ef;
    color: #1f6d6a;
}

.sidebar .logout,
.sidebar > a.logout {
    margin-top: 8px;
    color: #a33a3a !important;
}

.sidebar .logout:hover,
.sidebar > a.logout:hover {
    background: #fff0f0 !important;
    color: #8f2626 !important;
}

.sidebar-footer {
    margin-top: 12px;
    padding: 10px 8px 2px;
    border-top: 1px solid #e4edf5;
    color: #7a8c9a;
    font-size: 12px;
    text-align: center;
}

.sidebar-footer p {
    margin: 0 0 2px;
}

.sidebar-toggle {
    position: fixed;
    left: 256px;
    top: 14px;
    z-index: 1000;
    width: auto;
    min-width: 42px;
    height: 34px;
    margin: 0;
    padding: 0 10px;
    border: 1px solid #dbe7ea;
    border-radius: 8px;
    background: #fff;
    color: #385568;
    box-shadow: 0 6px 18px rgba(16, 24, 40, 0.12);
    font-size: 13px;
    font-weight: 800;
    line-height: 1;
}

.sidebar-toggle:hover {
    background: #eef7f6;
    color: #1f6d6a;
}

body.sidebar-collapsed .sidebar {
    display: none;
}

body.sidebar-collapsed .content {
    margin-left: 0;
    width: 100%;
}

body.sidebar-collapsed .sidebar-toggle {
    left: 14px;
    min-width: 58px;
}

/* ============================================================
   CONTENUTO
   ============================================================ */
.content {
    margin-left: 280px;
    padding: 25px;
    width: calc(100% - 280px);
    min-width: 0;
    overflow-x: auto;
    scrollbar-gutter: stable;
}

/* TITOLI */
h1,
h2 {
    color: #258782;
    margin-bottom: 20px;
}

/* BOX */
.box {
    background: #fff;
    border-left: 5px solid #258782;
    padding: 20px;
    margin-bottom: 25px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

/* CARD */
.card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    border: 1px solid #e4edf5;
}

.page-header {
    margin-bottom: 22px;
}

.page-header h1 {
    margin-bottom: 6px;
}

.page-header p {
    color: #66788a;
}

.calendar-toolbar-card {
    padding: 18px 20px;
    margin-bottom: 20px;
}

.calendar-toolbar {
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: end;
    gap: 14px;
    background: transparent;
    border: 0;
    box-shadow: none;
}

.calendar-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 160px;
}

.calendar-field label {
    margin: 0;
    color: #12344d;
}

.calendar-card {
    background: #fff;
    border: 1px solid #e4edf5;
    border-radius: 12px;
    padding: 18px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.calendar-warning {
    margin-bottom: 20px;
    padding: 14px 16px;
    background: #fff7ed;
    border-color: #fed7aa;
    color: #9a3412;
    font-weight: 600;
}

.calendar {
    display: grid;
    grid-template-columns: repeat(7, minmax(90px, 1fr));
    gap: 10px;
}

.day-header {
    padding: 10px;
    border-radius: 8px;
    background: #f2f7f8;
    color: #526b7c;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
}

.day {
    min-height: 96px;
    border: 1px solid #e4edf5;
    border-radius: 10px;
    background: #fbfdfe;
}

.day.empty {
    background: transparent;
    border: 0;
}

.day a {
    display: flex;
    min-height: 96px;
    padding: 12px;
    flex-direction: column;
    justify-content: space-between;
    color: #12344d;
    text-decoration: none;
}

.day:not(.empty):hover {
    border-color: #b9d9d6;
    background: #f4fbfa;
}

.day-number {
    font-size: 18px;
    font-weight: 700;
}

.badge {
    align-self: flex-start;
    min-width: 34px;
    padding: 5px 9px;
    border-radius: 999px;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
}

.badge.green {
    background: #258782;
}

.badge.orange {
    background: #d97706;
}

.badge.red {
    background: #b91c1c;
}

@media (max-width: 900px) {
    .calendar {
        grid-template-columns: repeat(7, minmax(42px, 1fr));
        gap: 6px;
    }

    .day,
    .day a {
        min-height: 72px;
    }

    .day a {
        padding: 8px;
    }

    .day-number {
        font-size: 15px;
    }

    .badge {
        min-width: 28px;
        padding: 3px 7px;
        font-size: 12px;
    }

    .calendar-toolbar {
        align-items: stretch;
        flex-direction: column;
    }
}

/* FORM */
form {
    background: #fff;
    padding: 20px;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    max-width: 600px;
    margin-bottom: 25px;
}

input[type="text"],
input[type="month"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font: inherit;
}

input[type="submit"],
button,
.btn-primary {
    margin-top: 15px;
    padding: 12px 20px;
    background: #258782;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: 0.2s;
}

input[type="submit"]:hover,
button:hover,
.btn-primary:hover {
    background: #1f6d6a;
}

/* ============================================================
   TABELLE
   ============================================================ */
table {
    width: 100%;
    min-width: max-content;
    border-collapse: collapse;
    margin-top: 15px;
}

th,
td {
    padding: 10px;
    border-bottom: 1px solid #ddd;
}

th {
    background: #258782;
    color: #fff;
    text-align: left;
}

tr:hover {
    background: #e8f7f6;
}

a {
    color: #258782;
    font-weight: bold;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
    body {
        display: block;
        overflow-x: auto;
    }

    .sidebar {
        position: relative;
        width: 100%;
        height: auto;
        min-height: auto;
        border-radius: 0 0 16px 16px;
        overflow: visible;
    }

    .sidebar .menu {
        max-height: none;
        overflow: visible;
        padding-right: 0;
    }

    .sidebar-toggle {
        left: auto;
        right: 14px;
        top: 14px;
    }

    body.sidebar-collapsed .sidebar-toggle {
        left: auto;
        right: 14px;
    }

    .content {
        margin-left: 0;
        width: 100%;
        padding: 18px;
    }

    table {
        min-width: 760px;
    }

}
