/**
 * Componenti: .event-card, .glass, .modern-button, animazioni
 */
.drag-ghost {
    opacity: 0.4;
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%) !important;
    border: 2px dashed #6366f1 !important;
}

.event-card {
    transition: transform 0.06s ease-out, box-shadow 0.06s ease-out;
    will-change: transform;
    contain: layout style;
    opacity: 1;
}
.event-card.visible {
    opacity: 1;
}
.event-card:hover {
    transform: translateY(-6px) scale(1.02);
    box-shadow:
        0 25px 50px -12px rgba(0, 0, 0, 0.25),
        0 0 0 2px rgba(59, 130, 246, 0.3),
        0 0 30px rgba(59, 130, 246, 0.1);
    z-index: 10;
}
.event-card:active {
    transform: translateY(-2px) scale(1.01);
}
.event-card.highlight {
    animation: highlightPulse 0.005s ease-in-out infinite;
    border: 2px solid rgba(59, 130, 246, 0.5);
}

.no-transitions,
.no-transitions *,
.no-transitions *::before,
.no-transitions *::after {
    transition: none !important;
    animation: none !important;
    transform: none !important;
}

.events-updating {
    visibility: hidden !important;
    opacity: 0 !important;
    transition: none !important;
    animation: none !important;
}

.no-transitions .event-card {
    opacity: 1 !important;
    transform: translateY(0) !important;
    transition: none !important;
    animation: none !important;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes highlightPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4), 0 20px 40px -12px rgba(0, 0, 0, 0.15); }
    50% { box-shadow: 0 0 0 10px rgba(59, 130, 246, 0), 0 20px 40px -12px rgba(0, 0, 0, 0.15); }
}

@keyframes shimmer {
    0% { background-position: -1000px 0; }
    100% { background-position: 1000px 0; }
}

.shimmer {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.3) 50%, rgba(255, 255, 255, 0) 100%);
    background-size: 1000px 100%;
    animation: shimmer 0.005s infinite;
}

@keyframes ripple {
    0% { transform: scale(0); opacity: 1; }
    100% { transform: scale(4); opacity: 0; }
}

.ripple-effect {
    position: relative;
    overflow: hidden;
}
.ripple-effect::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    width: 100px;
    height: 100px;
    margin-top: -50px;
    margin-left: -50px;
    top: 50%;
    left: 50%;
    opacity: 0;
    transform: scale(0);
    transition: transform 0.0015s, opacity 0.0015s;
}
.ripple-effect:active::after {
    transform: scale(4);
    opacity: 0;
    transition: 0s;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}
.bounce-on-hover:hover {
    animation: bounce 0.0015s ease-in-out;
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 5px rgba(59, 130, 246, 0.5); }
    50% { box-shadow: 0 0 20px rgba(59, 130, 246, 0.8), 0 0 30px rgba(59, 130, 246, 0.6); }
}
.glow-effect {
    animation: glow 0.005s ease-in-out infinite;
}

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 0.00375s infinite;
}

.event-card:nth-child(1) { animation-delay: 0.000125s; }
.event-card:nth-child(2) { animation-delay: 0.00025s; }
.event-card:nth-child(3) { animation-delay: 0.000375s; }
.event-card:nth-child(4) { animation-delay: 0.0005s; }
.event-card:nth-child(5) { animation-delay: 0.000625s; }
.event-card:nth-child(6) { animation-delay: 0.00075s; }
.event-card:nth-child(7) { animation-delay: 0.000875s; }
.event-card:nth-child(8) { animation-delay: 0.001s; }
.event-card:nth-child(n+9) { animation-delay: 0.001125s; }

.custom-scrollbar::-webkit-scrollbar { width: 8px; }
.custom-scrollbar::-webkit-scrollbar-track {
    background: rgba(241, 245, 249, 0.5);
    border-radius: 10px;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #cbd5e1 0%, #94a3b8 100%);
    border-radius: 10px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #94a3b8 0%, #64748b 100%);
}
.dark .custom-scrollbar::-webkit-scrollbar-track {
    background: rgba(30, 41, 59, 0.5);
}
.dark .custom-scrollbar::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #475569 0%, #334155 100%);
}
.dark .custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #334155 0%, #1e293b 100%);
}

#calendarGrid > div { overflow: hidden; }
#calendarGrid [data-event-id] {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
/* Contenitore colonna giorno: position relative per posizionamento assoluto degli eventi */
#weekEventsGrid > div {
    position: relative !important;
    overflow: visible;
}
/* Contenitore interno eventi: contesto per left/width in % (Griglia -> Cella -> Contenitore -> Eventi assoluti) */
.week-day-event-container {
    position: absolute !important;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100%;
    min-height: 0;
    overflow: visible;
    pointer-events: none;
}
.week-day-event-container > * {
    pointer-events: auto;
}
/* width/left/position da JS; qui nessun width/min-width/position */
#weekEventsGrid [data-event-id] {
    overflow: hidden;
    box-sizing: border-box;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
#dayEventsContainer [data-event-id] {
    overflow: hidden;
    box-sizing: border-box;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 6px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
#weekEventsGrid [data-event-id] > div {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

/* Blocchi evento: z-index e overflow; width/left/position non impostati (gestiti da JS in vista settimana) */
.calendar-event-block {
    z-index: 10;
    overflow: hidden;
    box-sizing: border-box;
}
.calendar-event-block:hover {
    z-index: 15;
}
#weekEventsGrid .calendar-event-block,
#dayEventsContainer .calendar-event-block {
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
#weekEventsGrid .calendar-event-block > div:first-of-type,
#dayEventsContainer .calendar-event-block > div:first-of-type {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
/* Griglia 15 min: slot con border 1px, box-sizing per allineamento preciso */
.calendar-drop-slot {
    box-sizing: border-box !important;
    border-bottom-width: 1px !important;
}
/* Slot frazionari (15/30/45 min): nessun bordo visibile, stesso colore dello sfondo */
.calendar-slot-fractional,
.calendar-drop-slot.calendar-slot-fractional {
    border-bottom: none !important;
}
#weekTimeSlots > div,
#dayTimeSlots > div {
    box-sizing: border-box !important;
    border-bottom-width: 1px !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}
#weekTimeSlots > div.calendar-slot-fractional,
#dayTimeSlots > div.calendar-slot-fractional {
    border-bottom: none !important;
}

/* Evidenziazione slot durante drag & drop: riferimento visivo per la frazione sottostante */
.calendar-slot-drag-over {
    background-color: rgba(59, 130, 246, 0.2) !important;
    transition: background-color 0.1s ease;
}
.dark .calendar-slot-drag-over {
    background-color: rgba(59, 130, 246, 0.25) !important;
}

.calendar-multiday-bar {
    border-radius: 4px;
    overflow: hidden;
    min-height: 1.5rem;
}
.calendar-multiday-bar span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
#weekAllDayRow {
    position: relative;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.animate-slide-in {
    animation: slideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.animate-fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* Evidenziazione ricerca: giallo tenue e testo scuro per leggibilità */
.search-highlight {
    background: rgba(253, 230, 138, 0.55);
    color: #1e293b;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    box-shadow: 0 0 0 1px rgba(180, 83, 9, 0.2);
}
.dark .search-highlight {
    background: rgba(180, 83, 9, 0.35);
    color: #fef3c7;
    box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.25);
}

/* Box note in preview evento: nessuno sfondo, solo bordo bianco sottile; a capo leggibili */
.event-notes-content {
    background-color: transparent !important;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.5;
}
.event-notes-content br {
    display: block;
    margin-bottom: 0.35em;
}
.dark .event-notes-content {
    border: 1px solid rgba(255, 255, 255, 0.5);
    color: #f1f5f9;
}
.event-notes-content a {
    color: #1d4ed8;
    font-weight: 600;
}
.dark .event-notes-content a {
    color: #93c5fd;
}
.event-notes-content a:hover {
    text-decoration: underline;
}

#authOverlay.hidden {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    z-index: -1 !important;
}

.modern-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    box-shadow: 0 1px 3px 0 var(--shadow), 0 4px 6px -1px var(--shadow), 0 0 0 1px var(--border-color);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}
.modern-card:hover {
    box-shadow: 0 20px 25px -5px var(--shadow-hover), 0 10px 10px -5px var(--shadow), 0 0 0 1px rgba(59, 130, 246, 0.3);
    transform: translateY(-2px);
    background: var(--bg-card);
}
.dark .modern-card {
    background: rgba(30, 41, 59, 0.95);
    border: 1px solid rgba(51, 65, 85, 0.6);
}
.dark .modern-card:hover {
    background: rgba(30, 41, 59, 1);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(59, 130, 246, 0.4);
}

.modern-button {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05), 0 0 0 1px rgba(0, 0, 0, 0.02);
    position: relative;
    overflow: hidden;
}
.modern-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.6s;
}
.modern-button:hover::before { left: 100%; }
.modern-button:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05), 0 0 0 1px rgba(0, 0, 0, 0.05), 0 0 20px rgba(59, 130, 246, 0.2);
    transform: translateY(-3px) scale(1.02);
}
.modern-button:active {
    transform: translateY(-1px) scale(1);
    box-shadow: 0 5px 10px -3px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.05);
}
.modern-button.ripple-effect::after {
    background: rgba(255, 255, 255, 0.5);
}

.modern-input {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    color: var(--text-primary);
    border-color: var(--border-color);
}
.modern-input:focus {
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1), 0 0 0 1px rgba(59, 130, 246, 0.3);
    background: rgba(255, 255, 255, 1);
    transform: translateY(-1px);
}
.dark .modern-input {
    background: rgba(30, 41, 59, 0.9);
    color: var(--text-primary);
    border-color: rgba(51, 65, 85, 0.6);
}
.dark .modern-input:focus {
    background: rgba(30, 41, 59, 1);
    border-color: rgba(59, 130, 246, 0.5);
}

.glass {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: background 0.3s ease, border-color 0.3s ease;
}
.dark .glass {
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(51, 65, 85, 0.5);
}

.gradient-text {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#darkModeIcon, #darkModeIconCompact {
    transition: transform 0.3s ease;
}

.dark .bg-slate-50 {
    background-color: rgba(30, 41, 59, 0.5) !important;
}

/* =========================================
   UI/UX POLISH & DARK MODE FIXES
   ========================================= */

/* Fix icone topbar in dark mode */
.dark #mainHeader button i.text-slate-700 {
    color: #e2e8f0 !important; /* slate-200 */
}

/* Inverti icona calendario nei datepicker in dark mode */
.dark input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    opacity: 0.7;
    cursor: pointer;
}

/* Fix colori filtri in dark mode (contrasto) */
.dark #filtersBar select, 
.dark #filtersBar input {
    background-color: #1e293b !important;
    color: #f1f5f9 !important;
    border-color: #334155 !important;
}
.dark #filtersBar button.bg-white {
    background-color: #1e293b !important;
    color: #f1f5f9 !important;
    border-color: #334155 !important;
}
.dark #filtersBar button.bg-indigo-50 {
    background-color: rgba(49, 46, 129, 0.5) !important; /* indigo-900/50 */
    color: #e0e7ff !important;
    border-color: #3730a3 !important;
}
.dark #filtersBar button.bg-indigo-50 i {
    color: #818cf8 !important;
}
.dark #filtersBar i.text-slate-400,
.dark #filtersBar i.text-slate-500,
.dark #filtersBar i.text-slate-600 {
    color: #94a3b8 !important;
}

/* Fix state Empty e testi in dark mode */
.dark #emptyState {
    background: linear-gradient(to bottom right, #1e293b, #0f172a) !important;
    border-color: #334155 !important;
}
.dark #emptyState p, 
.dark #emptyState span {
    color: #cbd5e1 !important;
}
.dark #emptyState i.text-slate-300,
.dark #emptyState i.text-slate-400,
.dark #emptyState i.text-emerald-100 {
    color: #64748b !important; /* Meno invasivo */
}
