/*
==================================================
GESTIONALE CUSTOM - CALENDAR CSS
==================================================
Stili per la pagina Calendario Appuntamenti.
Contiene:
- Layout container calendario (sidebar + main)
- Header e toolbar calendario
- Sidebar filtri con Select2 personalizzato
- Vista giornaliera (day-view-grid)
- Vista settimanale (week-view)
- Vista mensile (month-view-grid)
- Vista lista (list-view)
- Card pratiche e appuntamenti
- Resize handle colonne
- Scrollbar sincronizzate
- Responsive design (tablet/mobile)
- Utility classes Bootstrap-like
- Form checks (checkbox/radio)
- Btn-group e badge
==================================================
*/
/* Calendar Container */
.calendar-container {
    min-height: 100vh;
    background-color: #f8f9fa;
    display: flex;
    flex-direction: column;
}

/* Header */
.calendar-header {
    background-color: #fff;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #dee2e6;
    box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}

.header-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    margin-right: 1rem;
}

/* Calendar Body Layout */
.calendar-body {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

/* Sidebar */
.calendar-sidebar {
    width: 280px;
    background-color: #fff;
    padding: 1.5rem;
    border-right: 1px solid #dee2e6;
    overflow-y: auto;
    overflow-x: hidden;
    transition: all 0.3s ease-in-out;
    position: relative;
    flex: 0 0 auto;
    min-height: 0;
}

.calendar-sidebar::-webkit-scrollbar {
    width: 8px;
}

.calendar-sidebar::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.calendar-sidebar::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.calendar-sidebar::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Fix link menu laterale (Bootstrap 5 da CDN sottolinea i link) */
.page-sidebar a,
.page-sidebar a:hover,
.page-sidebar a:focus,
.page-sidebar a:active {
    text-decoration: none !important;
}

/* Resize handle sidebar */
.sidebar-resize-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    right: -6px;
    width: 12px;
    cursor: col-resize;
    z-index: 50;
    background: transparent;
    touch-action: none;
}

.sidebar-resize-handle:hover,
.sidebar-resize-handle.active {
    background: rgba(13, 110, 253, 0.18);
}

body.sidebar-resizing {
    cursor: col-resize !important;
    user-select: none !important;
    touch-action: none;
}

body.sidebar-resizing .calendar-sidebar {
    transition: none !important;
}

body.sidebar-resizing * {
    cursor: col-resize !important;
}

@media (max-width: 991px) {
    .sidebar-resize-handle {
        display: none;
    }
}

/* Sidebar nascosta su desktop */
.calendar-sidebar.collapsed {
    width: 0 !important;
    min-width: 0 !important;
    padding: 0 !important;
    border: none !important;
    overflow: hidden !important;
    flex: 0 0 0 !important;
}

.calendar-sidebar.collapsed .sidebar-resize-handle {
    display: none;
}

.sidebar-section {
    margin-bottom: 1.5rem;
}

.sidebar-title {
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    color: #6c757d;
    margin-bottom: 1rem;
    letter-spacing: 0.5px;
}

/* Filter Groups */
.filter-group-header {
    display: flex;
    align-items: center;
    font-weight: 500;
    color: #495057;
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
}

.filter-items {
    padding-left: 0.5rem;
}

.filter-items .form-check {
    margin-bottom: 0.5rem;
}

.filter-items .form-check-label {
    display: flex;
    align-items: center;
    font-size: 0.9rem;
    cursor: pointer;
}

/* Select2 (filtro modelli pratica) - stile coerente e arrotondato */
.calendar-sidebar .select2-container {
    width: 100% !important;
}

/*
 * Nota: nel backend reale è presente anche Select2 v3 (tema Pages) che usa classi diverse
 * (select2-container-multi / select2-search-choice) e forza colori grigi.
 * Qui sovrascriviamo SOLO il Select2 del filtro modelli pratica.
 */
.calendar-sidebar .select2-container-multi .select2-choices {
    background: #f8fbff !important;
    border: 1px solid #dee2e6 !important;
    border-radius: 10px !important;
    min-height: 42px;
    padding: 6px 8px;
}

.calendar-sidebar .select2-container-multi .select2-choices .select2-search-choice {
    background: rgba(13, 110, 253, 0.10) !important;
    border: 1px solid rgba(13, 110, 253, 0.28) !important;
    color: #0b5ed7 !important;
    border-radius: 10px !important;
    box-shadow: none !important;
    font-size: 0.78rem;
    padding: 5px 10px 5px 30px !important;
    margin-top: 6px !important;
    max-width: 100%;
    white-space: normal !important;
    line-height: 1.15;
    word-break: break-word;
    text-overflow: clip;
}

.calendar-sidebar .select2-container-multi .select2-search-choice-close {
    top: 50% !important;
    transform: translateY(-50%) !important;
    left: 8px !important;
    right: auto !important;
    width: 18px !important;
    height: 18px !important;
    border-radius: 50% !important;
    background: rgba(13, 110, 253, 0.12) !important;
    border: 1px solid rgba(13, 110, 253, 0.22) !important;
    text-decoration: none !important;
    box-shadow: none !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    text-indent: 0 !important;
}

/* Pages/Select2 v3 usa spesso :before (FontAwesome) per la X: la rimpiazziamo e la centriamo */
.calendar-sidebar .select2-container-multi .select2-search-choice-close:before {
    content: "×" !important;
    font-family: inherit !important;
    font-size: 12px !important;
    line-height: 1 !important;
    position: static !important;
    top: auto !important;
    right: auto !important;
    left: auto !important;
    bottom: auto !important;
    transform: none !important;
    color: #0b5ed7 !important;
}

.calendar-sidebar .select2-container-multi .select2-search-choice-close:hover {
    background: rgba(13, 110, 253, 0.18) !important;
    border-color: rgba(13, 110, 253, 0.30) !important;
}

.calendar-sidebar .select2-container--default .select2-selection--multiple {
    border: 1px solid #dee2e6 !important;
    border-radius: 10px;
    min-height: 42px;
    padding: 6px 8px;
    background-color: #f8fbff !important;
}

.calendar-sidebar .select2-container--default.select2-container--focus .select2-selection--multiple {
    border-color: #0d6efd !important;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15) !important;
}

.calendar-sidebar .select2-container--default .select2-selection--multiple .select2-selection__rendered {
    padding-left: 0;
}

.calendar-sidebar .select2-container--default .select2-selection--multiple .select2-selection__clear {
    margin-top: 2px;
}

.calendar-sidebar .select2-container--default .select2-selection--multiple .select2-search__field {
    margin-top: 2px;
    font-size: 0.9rem;
    line-height: 1.2;
}

.calendar-sidebar .select2-container--default .select2-selection--multiple .select2-selection__choice {
    border-radius: 10px !important;
    background-color: rgba(13, 110, 253, 0.10) !important;
    border: 1px solid rgba(13, 110, 253, 0.28) !important;
    color: #0b5ed7 !important;
    font-size: 0.78rem;
    padding: 5px 10px;
    margin-top: 6px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: clip;
    white-space: normal !important;
    line-height: 1.15;
    word-break: break-word;
    display: inline-flex;
    align-items: center;
}

.calendar-sidebar .select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    color: #0b5ed7 !important;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 8px;
    border: 1px solid rgba(13, 110, 253, 0.22);
    background: rgba(13, 110, 253, 0.12);
    text-decoration: none !important;
    box-shadow: none !important;
    line-height: 1;
    font-weight: 700;
    padding: 0 !important;
    font-size: 12px !important;
}

.calendar-sidebar .select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
    background: rgba(13, 110, 253, 0.18);
    border-color: rgba(13, 110, 253, 0.30);
}

.calendar-sidebar .select2-container--default .select2-dropdown {
    border-radius: 10px;
    border: 1px solid #dee2e6 !important;
    overflow: hidden;
}

.calendar-sidebar .select2-container--default .select2-results__option {
    font-size: 0.9rem;
    padding: 8px 10px;
    line-height: 1.2;
}

.calendar-sidebar .select2-container--default .select2-results__option--selectable {
    background-color: #fff !important;
    color: #212529 !important;
}

.calendar-sidebar .select2-container--default .select2-results__option--selected {
    background-color: #e7f3ff !important;
    color: #0b5ed7 !important;
}

.calendar-sidebar .select2-container--default .select2-results__option--highlighted.select2-results__option--selectable {
    background-color: #0d6efd !important;
    color: #fff !important;
}

.operator-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 0.1rem;
}

/* Stats Box */
.stats-box {
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid #e9ecef;
}

.stat-item:last-child {
    border-bottom: none;
}

.stat-label {
    font-size: 0.875rem;
    color: #6c757d;
}

.stat-value {
    font-weight: 600;
    font-size: 1.1rem;
}

/* Main Calendar Area */
.calendar-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* Toolbar */
.calendar-toolbar {
    background-color: #fff;
    padding: 1.25rem 2rem;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

/* Datepicker (toolbar) - compatto e con icona centrata */
#calendar_datepicker_component.gc-calendar-date {
    width: auto;
    border: 1px solid #6c757d;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

#calendar_datepicker_component.gc-calendar-date .gc-calendar-date-input {
    height: 30px;
    line-height: 30px;
    padding-top: 4px;
    padding-bottom: 4px;
    font-weight: 700;
    border: 0;
    box-shadow: none;
}

#calendar_datepicker_component.gc-calendar-date .gc-calendar-date-addon {
    height: 30px;
    line-height: 28px;
    padding: 0 10px;
    cursor: pointer;
    border: 0;
    background: #f8f9fa;
    color: #6c757d;
    min-width: 32px;
}

#calendar_datepicker_component.gc-calendar-date .gc-calendar-date-addon i {
    line-height: inherit;
    vertical-align: middle;
    height: auto;
}

/* Assicura che il dropdown non venga nascosto da overlay/toolbar */
.datepicker,
.datepicker-dropdown {
    z-index: 20000 !important;
}

.view-tabs .btn {
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
}

/* Fix border-radius per btn-group con radio buttons (soluzione robusta)
   Bootstrap azzera il radius su .btn:not(:first-child) perché i .btn-check
   sono i veri first-child: arrotondiamo il contenitore e clippiamo i bordi. */
.btn-group.view-tabs {
    border-radius: 0.375rem;
    overflow: hidden;
    border: 1px solid var(--bs-primary);
}

.btn-group.view-tabs > label.btn {
    border-radius: 0 !important;
    border: 0 !important;
}

/* Linee di separazione interne tra i bottoni (gli input stanno tra le label) */
.btn-group.view-tabs > input.btn-check:not(:first-child) + label.btn {
    border-left: 1px solid var(--bs-primary) !important;
}

/* Margin icona bottone nuovo appuntamento quando il testo è visibile */
#btn_new_appointment .fa-plus {
    margin-right: 0.5rem;
}

#btn_today{
    border-radius: 8px!important;
}

#btn_toggle_filters{
    border-radius: 8px!important;
}

#btn_new_appointment{
    border-radius: 8px!important;
}

/* Calendar Views */
.calendar-views {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.5rem 2rem;
    min-height: 0;
    min-width: 0;
}

.calendar-view {
    animation: fadeIn 0.3s ease-in;
    min-width: 0;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Pratiche Box */
.pratiche-box {
    background-color: #e7f3ff;
    border: 1px solid #b8deff;
    border-radius: 8px;
    overflow: hidden;
}

.pratiche-box-header {
    background-color: #d4ebff;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #b8deff;
    display: flex;
    align-items: center;
    font-size: 0.95rem;
    color: #0c5a9e;
}

.pratiche-box-header i {
    font-size: 1.1rem;
}

.pratiche-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
    padding: 1rem;
}

/* Empty state: centra il messaggio nel box pratiche del giorno */
.pratiche-container.is-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 190px;
    gap: 1rem;
}

.pratiche-container .pratica-card {
    background-color: #fff;
    border: 1px solid #e9ecef;
    border-left: 4px solid #dc3545;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    position: relative;
}

.pratiche-container .pratica-card.pratica-completed {
    border-left-color: #198754;
}

.pratiche-container .pratica-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    transform: translateY(-2px);
}

.pratiche-container .pratica-card-icon {
    font-size: 1.1rem;
    color: #6c757d;
    margin-top: 0.125rem;
}

.pratiche-container .pratica-card-content {
    flex: 1;
    min-width: 0;
}

.pratiche-container .pratica-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.pratiche-container .pratica-card-alert {
    position: absolute;
    top: 1rem;
    right: 1rem;
    color: #dc3545;
    font-size: 0.9rem;
}

.pratiche-container .pratica-type-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    background-color: #dc3545;
    color: white;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pratiche-container .pratica-card.pratica-completed .pratica-type-badge {
    background-color: #198754;
}

.pratiche-container .pratica-operator-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.375rem;
    margin-bottom: 0.375rem;
    font-size: 0.813rem;
    color: #495057;
}

.pratiche-container .pratica-operator-info .operator-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.pratiche-container .pratica-operator-info i {
    font-size: 0.75rem;
    color: #6c757d;
    flex-shrink: 0;
}

.pratiche-container .pratica-operator-info .operator-name {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pratiche-container .pratica-card-client {
    font-weight: 600;
    font-size: 0.95rem;
    color: #212529;
    margin-bottom: 0.25rem;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.pratiche-container .pratica-card-description {
    font-size: 0.875rem;
    color: #6c757d;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Day View - Grid unico con header integrato */
.day-view-grid {
    display: grid;
    grid-template-columns: 80px repeat(10, minmax(150px, 1fr));
    gap: 1px;
    background-color: #dee2e6;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    overflow-x: auto;
    max-width: 100%;
}

/* Top scrollbar sincronizzato */
.top-scrollbar-container {
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
    margin-bottom: 8px;
    height: 17px; /* Altezza dello scrollbar */
    background-color: #f8f9fa;
}

/* Scrollbar orizzontali: stile sottile e uniforme (Chrome/Edge/Safari + Firefox) */
.top-scrollbar-container {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.20) transparent;
}

.top-scrollbar-container::-webkit-scrollbar {
    height: 6px;
}

.top-scrollbar-container::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.20);
    border-radius: 3px;
}

.top-scrollbar-container::-webkit-scrollbar-track {
    background: transparent;
}

/* Vista settimana: la top scrollbar resta nascosta finché non serve */
#week_top_scrollbar_container {
    display: none;
}

.top-scrollbar-content {
    height: 1px;
    /* Larghezza viene settata dinamicamente via JS per matchare il contenuto del grid */
}

/* Header cells (prima riga) - sticky */
.day-view-grid .header-cell {
    position: relative;
    z-index: 12;
    background-color: #f8f9fa;
    border-bottom: 2px solid #0d6efd;
    padding: 1rem;
    font-weight: 600;
    font-size: 0.875rem;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap;
    min-width: 0;
}

/* Evita che il nome operatore sfori nell'header: ellipsis */
.day-view-grid .header-cell span:not(.operator-dot) {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Resize handle tra colonne */
.resize-handle {
    position: absolute;
    right: -6px;
    top: 0;
    bottom: 0;
    width: 12px;
    cursor: col-resize;
    z-index: 20;
    background: transparent;
    touch-action: none;
}

.resize-handle:hover,
.resize-handle.active {
    background: rgba(13, 110, 253, 0.3);
}

/* Durante il resize, blocca selezione testo */
body.col-resizing {
    cursor: col-resize !important;
    user-select: none !important;
    touch-action: none;
    overflow: hidden;
}

body.col-resizing * {
    cursor: col-resize !important;
}

/* Angolo in alto a sinistra - sticky sia verticalmente che orizzontalmente */
.day-view-grid .header-cell.corner {
    position: sticky;
    top: 0;
    left: 0;
    z-index: 13;
    background-color: #e9ecef;
    border-right: 2px solid #dee2e6;
}

.time-slot {
    position: sticky;
    left: 0;
    z-index: 11;
    background-color: #f8f9fa;
    padding: 0.75rem;
    font-size: 0.8rem;
    color: #6c757d;
    font-weight: 600;
    text-align: center;
    border-bottom: 1px solid #e9ecef;
    min-height: 60px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.operator-slot {
    background-color: #fff;
    padding: 0.5rem;
    position: relative;
    min-height: 60px;
    border-bottom: 1px solid #f8f9fa;
}

.appointment-card {
    background-color: #e7f3ff;
    border-left: 4px solid #0d6efd;
    border-radius: 6px;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
    position: relative;
}

.appointment-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transform: translateY(-1px);
}

.appointment-card.success {
    background-color: #d1f4e0;
    border-left-color: #198754;
}

.appointment-card.warning {
    background-color: #fff3cd;
    border-left-color: #ffc107;
}

.appointment-card.danger {
    background-color: #f8d7da;
    border-left-color: #dc3545;
}

.appointment-time {
    font-weight: 600;
    font-size: 0.75rem;
    color: #495057;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-bottom: 0.25rem;
}

.appointment-title {
    font-weight: 500;
    margin-bottom: 0.25rem;
    font-size: 0.85rem;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.appointment-meta {
    font-size: 0.75rem;
    color: #6c757d;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.week-item-popover {
    cursor: pointer;
}

.week-item-popover:focus {
    outline: 2px solid rgba(13, 110, 253, 0.35);
    outline-offset: 2px;
}

/* Assicura che i popover siano visibili sopra tutto */
.popover {
    z-index: 9999 !important;
    opacity: 1 !important;
}

.bs-popover-auto[data-popper-placement^=top],
.bs-popover-top {
    z-index: 9999 !important;
    opacity: 1 !important;
}

/* Fix per popover Bootstrap 5 */
.popover.show {
    opacity: 1 !important;
}

/* Pallino operatore nelle card appuntamento (vista settimana) */
.appointment-card .week-operator-dot {
    position: absolute;
    left: 8px;
    top: 8px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.08);
    margin-right: 0;
}

.appointment-card .week-operator-dot ~ .appointment-time,
.appointment-card .week-operator-dot ~ .appointment-title,
.appointment-card .week-operator-dot ~ .appointment-meta {
    padding-left: 0.9rem;
}

/* Week View */
.week-view-header {
    display: grid;
    grid-template-columns: 60px repeat(7, 1fr);
    gap: 1px;
    background-color: #dee2e6;
    border: 1px solid #dee2e6;
    border-radius: 8px 8px 0 0;
    overflow-x: scroll;
    overflow-y: hidden;
    width: 100%;
    max-width: 100%;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge legacy */
    margin-bottom: 1px;
}

.week-view-header::-webkit-scrollbar {
    display: none;
}

.week-day-header {
    background-color: #fff;
    padding: 1rem;
    text-align: center;
    font-weight: 600;
    position: relative;
}

.week-day-header.week-time-header {
    background-color: #f8f9fa;
    cursor: col-resize;
}

.week-day-header .resize-handle.week-time-resize {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 8px;
    cursor: col-resize;
    background-color: transparent;
    transition: background-color 0.2s;
    z-index: 10;
}

.week-day-header .resize-handle.week-time-resize:hover,
.week-day-header .resize-handle.week-time-resize.active {
    background-color: rgba(13, 110, 253, 0.3);
}

.week-day-header.today {
    background-color: #0d6efd;
    color: white;
}

.week-day-number {
    font-size: 1.5rem;
    display: block;
}

.week-day-name {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.week-pratiche-row {
    display: grid;
    grid-template-columns: 60px repeat(7, 1fr);
    gap: 1px;
    background-color: #dee2e6;
    border-left: 1px solid #dee2e6;
    border-right: 1px solid #dee2e6;
    border-bottom: 1px solid #dee2e6;
    overflow-x: scroll;
    overflow-y: hidden;
    width: 100%;
    max-width: 100%;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge legacy */
}

.week-pratiche-row::-webkit-scrollbar {
    display: none;
}

/* In vista settimanale "solo pratiche" mostra la scrollbar orizzontale sotto */
.week-pratiche-row.week-bottom-scrollbar {
    scrollbar-width: thin; /* Firefox - sottile come quella superiore */
    -ms-overflow-style: auto; /* IE/Edge legacy */
}

.week-pratiche-row.week-bottom-scrollbar::-webkit-scrollbar {
    display: block;
    height: 6px; /* Sottile come la scrollbar superiore */
}

.week-pratiche-row.week-bottom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.week-pratiche-row.week-bottom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

.week-pratiche-label {
    background-color: #fff4e6;
    padding: 0.75rem 0.5rem;
    font-size: 0.75rem;
    color: #6c757d;
    text-align: center;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.week-pratiche-cell {
    background-color: #fff4e6;
    padding: 0.5rem;
    min-height: 50px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 0;
    overflow: hidden;
}

.week-pratica-mini-card {
    background-color: #fff;
    border: 1px solid #e9ecef;
    border-left: 3px solid #dc3545;
    border-radius: 4px;
    padding: 0.5rem;
    font-size: 0.75rem;
    transition: all 0.2s;
    cursor: pointer;
    min-width: 0;
    max-width: 100%;
}

.week-pratica-mini-card.pratica-completed {
    border-left-color: #198754;
}

.week-pratica-mini-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transform: translateY(-1px);
}

.week-pratica-mini-header {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    margin-bottom: 0.375rem;
    min-width: 0;
    max-width: 100%;
}

.pratica-type-badge-mini {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 600;
    background-color: #dc3545;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.week-pratica-mini-card.pratica-completed .pratica-type-badge-mini {
    background-color: #198754;
}

.week-pratica-mini-client {
    font-weight: 500;
    color: #212529;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    max-width: 100%;
}

.week-pratica-mini-name {
    font-size: 0.7rem;
    color: #6c757d;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    max-width: 100%;
 }

.week-pratiche-more {
    font-size: 0.7rem;
    color: #6c757d;
    text-align: center;
    padding: 0.25rem;
    font-style: italic;
}

.week-view-grid {
    display: grid;
    grid-template-columns: 60px repeat(7, 1fr);
    gap: 1px;
    background-color: #dee2e6;
    border: 1px solid #dee2e6;
    border-top: none;
    border-radius: 0 0 8px 8px;
    overflow-x: auto;
    overflow-y: hidden;
    width: 100%;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
}

/* Vista settimana: scrollbar orizzontale inferiore (grid) sottile come la top */
.week-view-grid {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.20) transparent;
}

.week-view-grid::-webkit-scrollbar {
    height: 6px;
}

.week-view-grid::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.20);
    border-radius: 3px;
}

.week-view-grid::-webkit-scrollbar-track {
    background: transparent;
}

.week-time-column {
    background-color: #f8f9fa;
    padding: 0.5rem;
    font-size: 0.75rem;
    color: #6c757d;
    text-align: center;
    border-bottom: 1px solid #e9ecef;
    min-height: 60px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    font-weight: 500;
}

.week-day-slot {
    background-color: #fff;
    padding: 0.75rem;
}

.week-day-slot.has-pratica {
    position: relative;
}

.week-day-slot.has-pratica::before {
    content: '';
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 8px;
    height: 8px;
    background-color: #dc3545;
    border-radius: 50%;
}

.pratica-badge {
    display: inline-block;
    background-color: #ffe5e5;
    color: #000;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    border: 1px solid #dc3545;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Month View */
.month-view-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background-color: #dee2e6;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    overflow-x: hidden;
    overflow-y: hidden;
    max-width: 100%;
}

/* Vista mese: la top scrollbar resta nascosta finché non serve */
#month_top_scrollbar_container {
    display: none;
}

.month-day-header {
    background-color: #f8f9fa;
    padding: 0.75rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
}

.month-day-cell {
    background-color: #fff;
    padding: 0.75rem;
    min-height: 120px;
    position: relative;
    min-width: 0;
}

.month-day-cell.other-month {
    background-color: #f8f9fa;
    color: #adb5bd;
}

.month-day-cell.today {
    background-color: #e7f3ff;
}

.month-day-number {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.month-day-cell.today .month-day-number {
    display: inline-block;
    background-color: #0d6efd;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    line-height: 28px;
    text-align: center;
}

.month-appointment-mini {
    background-color: #0d6efd;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.month-pratica-mini {
    background-color: #fff;
    border: 1px solid #e9ecef;
    border-left: 3px solid #dc3545;
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.month-pratica-mini.pratica-completed {
    border-left-color: #198754;
}

.month-pratica-mini .pratica-type-badge-mini {
    display: inline-block;
    padding: 0.05rem 0.35rem;
    border-radius: 3px;
    font-size: 0.62rem;
    font-weight: 700;
    background-color: #dc3545;
    color: #fff;
    margin-right: 0.35rem;
    vertical-align: baseline;
    max-width: 100%;
}

.month-pratica-mini.pratica-completed .pratica-type-badge-mini {
    background-color: #198754;
}

.month-appointment-mini:hover {
    opacity: 0.8;
}

.month-more-link {
    font-size: 0.75rem;
    color: #0d6efd;
    cursor: pointer;
    margin-top: 0.25rem;
}

/* Vista mese: distanzia pratiche dalla sezione appuntamenti per leggibilità */
.month-appointment-mini + .month-pratica-mini,
.month-more-link + .month-pratica-mini {
    margin-top: 10px;
}

.month-more-link.month-more-pratiche {
    color: #dc3545;
}

/* Vista settimana: stesso stile del link pratiche mensile */
.week-more-link {
    font-size: 0.75rem;
    color: #dc3545;
    cursor: pointer;
    margin-top: 0.25rem;
    display: inline-block;
}

/* Vista settimana: pratiche oltre le prime 4 (toggle via contenitore) */
.week-pratiche-cell .week-pratica-extra {
    display: none;
}

.week-pratiche-cell.is-expanded .week-pratica-extra {
    display: block;
}

/* List View */
.list-view-content {
    max-width: 1200px;
}

.list-day-section {
    margin-bottom: 2rem;
}

.list-day-title {
    background-color: #d4ebff;
    border: 1px solid #b8deff;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-weight: 600;
    color: #0c5a9e;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.list-day-title .badge {
    font-size: 0.7rem;
    background-color: #0c5a9e;
    color: #fff;
    border-radius: 999px;
    padding: 0.2rem 0.55rem;
}

.list-section-header {
    background-color: #f8f9fa;    
    border-radius: 6px;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    font-weight: 600;
    color: #495057;
    display: flex;
    align-items: center;    
}

.list-item-card {
    background-color: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.2s;
    cursor: pointer;
}

.list-item-card.pratica-completed .list-item-indicator {
    background-color: #198754 !important;
}

.list-item-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transform: translateX(4px);
}

.list-item-indicator {
    width: 4px;
    height: 60px;
    border-radius: 4px;
    background-color: #0d6efd;
}

.list-item-content {
    flex: 1;
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 1rem;
    align-items: center;
    min-width: 0;
}

.list-item-content > div {
    min-width: 0;
}

.list-item-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.list-item-subtitle {
    font-size: 0.875rem;
    color: #6c757d;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.list-item-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: #495057;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.list-item-status {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.list-item-status.confermato {
    background-color: #d1f4e0;
    color: #0f5132;
}

.list-item-status.in-lavorazione {
    background-color: #cfe2ff;
    color: #084298;
}

.list-item-status.in-attesa {
    background-color: #fff3cd;
    color: #664d03;
}

.list-item-status.scadenza {
    background-color: #f8d7da;
    color: #842029;
}

.list-item-price {
    font-weight: 600;
    font-size: 1rem;
}

/* Bottone chiusura sidebar (nascosto su desktop) */
.btn-close-sidebar {
    display: none;
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: #6c757d;
    cursor: pointer;
    z-index: 1001;
    padding: 0.5rem;
    line-height: 1;
    margin-bottom: 10px;
}

.btn-close-sidebar.visible {
    display: block;
}

.btn-close-sidebar:hover {
    color: #000;
}

/* Overlay per mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s;
}

.sidebar-overlay.show {
    display: block;
    opacity: 1;
}

/* Responsive */
@media (max-width: 1200px) {
    .calendar-sidebar {
        width: 240px;
    }
    
    .day-view-header,
    .day-view-grid {
        grid-template-columns: 70px repeat(5, 1fr);
    }
}

/* Tablet */
@media (max-width: 992px) {
    .calendar-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 320px;
        height: 100vh;
        z-index: 1000;
        transition: transform 0.3s ease-in-out;
        transform: translateX(-110%);
        box-shadow: none;
    }
    
    .calendar-sidebar.show {
        transform: translateX(0);
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    }
    
    .calendar-sidebar.collapsed {
        width: 320px !important;
        min-width: 320px !important;
        padding: 1.5rem !important;
        border-right: 1px solid #dee2e6 !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        flex: 0 0 auto !important;
        transform: translateX(-110%);
    }
    
    .calendar-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .list-item-content {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    /* Più spazio utile: riduci padding contenuto calendario */
    .calendar-views {
        padding: 1rem;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .calendar-sidebar {
        width: 100vw;
        transform: translateX(-110%);
    }
    
    .calendar-sidebar.show {
        transform: translateX(0);
    }
    
    .calendar-toolbar {
        padding: 1rem;
    }
    
    .calendar-toolbar h5 {
        font-size: 1rem;
    }
    
    .view-tabs .btn {
        font-size: 0.75rem;
        padding: 0.375rem 0.5rem;
    }

    /* Più spazio utile su schermi piccoli */
    .calendar-views {
        padding: 0.75rem;
    }
    
    /* Nascondi testo bottone Nuovo Appuntamento, mostra solo icona */
    #btn_new_appointment .btn-text {
        display: none !important;
    }
    
    #btn_new_appointment .fa-plus {
        margin-right: 0 !important;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.d-none {
    display: none !important;
}

.d-flex {
    display: flex !important;
}

.align-items-center {
    align-items: center !important;
}

.gap-3 {
    gap: 1rem !important;
}

.mb-3 {
    margin-bottom: 1rem !important;
}

.mb-4 {
    margin-bottom: 1.5rem !important;
}

.me-1 {
    margin-right: 0.25rem !important;
}

.me-2 {
    margin-right: 0.5rem !important;
}

.ms-1 {
    margin-left: 0.25rem !important;
}

.mt-4 {
    margin-top: 1.5rem !important;
}

/* ============================================
   FORM CHECKS (CHECKBOX/RADIO)
   ============================================ */
.calendar-sidebar .form-check {
    display: flex;
    align-items: flex-start;
    padding-left: 0;
    margin-bottom: 8px;
}

.calendar-sidebar .form-check-input {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    margin-right: 8px;
    flex-shrink: 0;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    border: 1px solid #6c757d;
    border-radius: 3px;
    background-color: #fff;
    position: relative;
}

.calendar-sidebar .form-check-input:checked {
    background-color: #6c757d !important;
    border-color: #6c757d !important;
}

.calendar-sidebar .form-check-input:checked::after {
    content: '\2713';
    position: absolute;
    top: 0px;
    left: 4px;
    color: #fff;
    font-size: 12px;
    font-weight: bold;
}

.calendar-sidebar .form-check-label {
    cursor: pointer;
    margin-bottom: 0;
    font-size: 13px;
    line-height: 1.5;
    flex: 1;
    word-break: break-word;
    font-weight: normal;
}

/* ============================================
   BTN-GROUP
   ============================================ */
.calendar-container .btn-group {
    position: relative;
    display: inline-flex;
    vertical-align: middle;
}

.calendar-container .btn-group > .btn {
    position: relative;
    flex: 0 1 auto;
}

.calendar-container .btn-group > .btn:first-child {
    border-top-left-radius: 0.25rem;
    border-bottom-left-radius: 0.25rem;
}

.calendar-container .btn-group > .btn:last-child {
    border-top-right-radius: 0.25rem;
    border-bottom-right-radius: 0.25rem;
}

.calendar-container .btn-group > .btn:not(:last-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: 0 !important;
}

.calendar-container .btn-group > .btn:not(:first-child) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.calendar-container .btn-group > .btn:hover,
.calendar-container .btn-group > .btn:focus,
.calendar-container .btn-group > .btn:active,
.calendar-container .btn-group > .btn.active {
    z-index: 1;
}

/* ============================================
   BADGE
   ============================================ */
.btn .badge {
    display: inline-block;
    padding: 0.25em 0.4em;
    font-size: 75%;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 0.25rem;
}

.badge.bg-secondary {
    background-color: #6c757d !important;
    color: #fff !important;
}

/* ============================================
   BTN VARIANTS
   ============================================ */
.calendar-container .btn-outline-primary {
    color: #0d6efd;
    border: 1px solid #0d6efd !important;
    background-color: transparent;
}

.calendar-container .btn-outline-primary:hover,
.calendar-container .btn-outline-primary:focus {
    color: #fff;
    background-color: #0d6efd;
    border-color: #0d6efd !important;
}

.calendar-container .btn-outline-secondary {
    color: #6c757d;
    border: 1px solid #6c757d !important;
    background-color: transparent;
}

.calendar-container .btn-outline-secondary:hover,
.calendar-container .btn-outline-secondary:focus {
    color: #fff;
    background-color: #6c757d;
    border-color: #6c757d !important;
}

.calendar-container .btn-outline-secondary.active {
    color: #fff;
    background-color: #6c757d;
    border-color: #6c757d !important;
}

/* ============================================
   BTN SIZES
   ============================================ */
.calendar-container .btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    line-height: 1.5;
    border-radius: 0.25rem;
}

.calendar-container .btn {
    display: inline-block;
    font-weight: 400;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    user-select: none;
    border: 1px solid #6c757d;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    line-height: 1.5;
    border-radius: 0.25rem;
    transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

/* ============================================
   DATEPICKER & INPUT-GROUP
   ============================================ */
/* Le regole per il datepicker sono già definite sopra (linee 387-420) */
