@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

body {
    font-family: 'Inter', sans-serif;
    background-color: #f3f4f6;
    color: #1f2D37;
    transition: background-color 0.3s, color 0.3s;
    font-size: 16px;
}
.container { max-width: 600px; }
.page-content { animation: fadeIn 0.5s ease-in-out; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* MC 2025-10-08: Animazioni per validazione real-time */
@keyframes fade-in {
    from { 
        opacity: 0; 
        transform: translateY(-4px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

.animate-fade-in {
    animation: fade-in 0.2s ease-out;
}

/* Stili validazione campi */
.field-container {
    position: relative;
}

.field-error {
    position: relative;
}

/* Migliore visualizzazione stato valido */
input.border-green-500:focus {
    outline: none;
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Migliore visualizzazione stato errore */
input.border-red-500:focus {
    outline: none;
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* --- STILI PER NAVIGAZIONE ATTIVA --- */
.page-nav-btn {
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-weight: 600;
    transition: background-color 0.2s, color 0.2s;
    background-color: #e5e7eb; /* Default: grigio chiaro */
    color: #1f2937;
}
.page-nav-btn:hover {
    background-color: #d1d5db;
}
.page-nav-btn.active {
    background-color: #2563eb; /* Attivo: blu */
    color: white;
}
/* Stile per il menu mobile */
#mobile-menu .page-nav-btn {
    background-color: transparent;
    color: #1f2937;
    text-align: left;
    width: 100%;
}
#mobile-menu .page-nav-btn.active {
    background-color: #eff6ff; /* Blu molto chiaro */
    color: #1d4ed8;
}


/* Filter Indicators - Responsive */
#filter-indicator, 
#sospesi-filter-indicator {
    display: inline-flex;
    align-items: center;
    font-size: 0.75rem;
    line-height: 1rem;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
}

@media (max-width: 640px) {
    #filter-indicator, 
    #sospesi-filter-indicator {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
        margin-top: 0.25rem;
    }
    #filter-indicator span:first-child,
    #sospesi-filter-indicator span:first-child {
        margin-right: 0.25rem;
    }
}

/* Toast Messages */
#message-box {
    position: fixed; top: 1rem; left: 50%; z-index: 100;
    transform: translate(-50%, -150%);
    padding: 1rem 1.5rem; border-radius: 0.5rem; color: white;
    opacity: 0; transition: opacity 0.3s ease, transform 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); font-weight: 500;
    max-width: 480px; width: calc(100% - 2rem);
}
#message-box.show { opacity: 1; transform: translate(-50%, 0); }
#message-box.bg-success { background-color: #28a745; }
#message-box.bg-error { background-color: #dc3545; }
#message-box.bg-info { background-color: #007bff; }

/* Dark Mode */
body.dark { background-color: #1a202c; color: #e2e8f0; }
body.dark .bg-white { background-color: #2d3748; }
body.dark h1, body.dark h2, body.dark h3, body.dark .text-gray-800, body.dark .text-gray-900 { color: #e2e8f0; }
body.dark .text-gray-700 { color: #cbd5e0; }
body.dark .text-gray-600 { color: #a0aec0; }
body.dark .border-gray-300, body.dark .divide-gray-200 > :not([hidden]) ~ :not([hidden]) { border-color: #4a5568; }
body.dark .bg-gray-200 { background-color: #4a5568; color: #e2e8f0; }
body.dark input, body.dark textarea, body.dark select { background-color: #2d3748; color: #e2e8f0; border-color: #4a5568;}
body.dark .text-blue-600 { color: #63b3ed; }
body.dark .text-green-600 { color: #68d391; }
body.dark .text-red-600 { color: #fc8181; }
body.dark .text-orange-500 { color: #f6ad55; }
body.dark .bg-gray-100 { background-color: #1f2937; }
body.dark .bg-gray-50 { background-color: #2d3748; }
body.dark .accordion-header:hover { background-color: #4a5568; }
body.dark .day-card.absent { background-color: #3f2222; border-color: #902c2c; }
body.dark .day-card.absent .absence-label { color: #fca5a5; }
body.dark .modal-content { background-color: #2d3748; }
body.dark #mobile-menu div { background-color: #2d3748; }
body.dark #mobile-menu .page-nav-btn { color: #e2e8f0; }
body.dark #mobile-menu .page-nav-btn.active { background-color: #1e3a8a; color: #e0f2fe; }

/* Flatpickr Dark Mode */
body.dark .flatpickr-time { background-color: #2d3748; border-color: #4a5568; }
body.dark .flatpickr-time .numInput, body.dark .flatpickr-time .flatpickr-am-pm { color: #e2e8f0; }
body.dark .flatpickr-time .numInput:hover, body.dark .flatpickr-time .flatpickr-am-pm:hover { background-color: #4a5568; }
body.dark .flatpickr-time .arrowUp:after { border-bottom-color: #e2e8f0; }
body.dark .flatpickr-time .arrowDown:after { border-top-color: #e2e8f0; }

/* High Contrast Mode */
body.high-contrast { background-color: #000; color: #fff; }
body.high-contrast .bg-white, body.high-contrast .appointment-card, body.high-contrast .day-card, body.high-contrast .commission-card { background-color: #000; color: #fff; border: 2px solid #fff; }
body.high-contrast h1, body.high-contrast h2, body.high-contrast h3, body.high-contrast .text-gray-800, body.high-contrast .text-gray-700, body.high-contrast .text-gray-600, body.high-contrast .text-gray-900 { color: #fff; }
body.high-contrast .border-gray-300, body.high-contrast .divide-gray-200 > :not([hidden]) ~ :not([hidden]) { border-color: #fff; }
body.high-contrast .bg-gray-200 { background-color: #000; color: #fff; }
body.high-contrast input, body.high-contrast textarea, body.high-contrast select { background-color: #000; color: #fff; border: 2px solid #fff; }
body.high-contrast button { border: 2px solid #fff; background-color: #000; color: #fff; }
body.high-contrast a, body.high-contrast .text-blue-600 { color: #63b3ed; }
body.high-contrast .bg-gray-100 { background-color: #000; border-color: #fff; }
body.high-contrast .modal-content { background-color: #000; border: 2px solid #fff; }

/* MC 2025-09-29: Animazione pulse (usata per stato firma digitale ongoing) */
.animate-pulse {
    animation: pulse-fade 1.4s ease-in-out infinite;
}
@keyframes pulse-fade {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}


/* Spinner */
.loader {
    width: 48px; height: 48px; border-radius: 50%;
    border: 5px solid #d1d5db; border-bottom-color: #4f46e5;
    display: inline-block; box-sizing: border-box;
    animation: rotation 1s linear infinite; margin: 2rem auto;
}
body.dark .loader { border-color: #4a5568; border-bottom-color: #63b3ed; }
.btn-spinner {
    width: 20px; height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.4); border-bottom-color: #FFF;
    margin: 0;
}
@keyframes rotation { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Commissions Accordion */
.accordion-header { cursor: pointer; transition: background-color 0.2s ease-in-out; }
.accordion-header:hover { background-color: #e5e7eb; }
.accordion-content { max-height: 0; overflow: hidden; transition: max-height 0.3s ease-in-out; }
.accordion-content.open { max-height: 2000px; }

/* Absence Day Card */
.day-card.absent { background-color: #fee2e2; border-color: #fca5a5; }
.day-card.absent .absence-label { font-weight: 700; color: #b91c1c; }

/* Finestra Modale */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-content {
    background-color: white;
    padding: 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    width: 90%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* MC 2025-11-16: Wizard responsive - content scrollabile con max-height */
#wizard-content {
    overflow-y: auto;
    max-height: 60vh;
    padding-right: 0.5rem;
}

/* MC 2025-11-16: Scrollbar personalizzata per wizard */
#wizard-content::-webkit-scrollbar {
    width: 8px;
}

#wizard-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

#wizard-content::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

#wizard-content::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* MC 2025-11-16: Errori wizard sticky in cima */
#wizard-errors {
    position: sticky;
    top: -1.5rem;
    z-index: 10;
    margin: -1.5rem -1.5rem 1rem -1.5rem;
    padding: 1rem 1.5rem;
    background: #fef2f2;
    border-radius: 0.5rem 0.5rem 0 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Stili per paginazione */
.pagination-nav {
    margin-top: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
}

.pagination-btn {
    padding: 0.5rem 1rem;
    border: 1px solid #d1d5db;
    background-color: white;
    color: #6b7280;
    text-decoration: none;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease-in-out;
}

.pagination-btn:hover:not(:disabled) {
    background-color: #f3f4f6;
    color: #374151;
    text-decoration: none;
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-info {
    padding: 0.5rem 1rem;
    border-top: 1px solid #d1d5db;
    border-bottom: 1px solid #d1d5db;
    background-color: white;
    color: #374151;
    font-size: 0.875rem;
    font-weight: 500;
}

/* Dark mode per paginazione */
body.dark .pagination-btn {
    background-color: #374151;
    border-color: #6b7280;
    color: #d1d5db;
}

body.dark .pagination-btn:hover:not(:disabled) {
    background-color: #4b5563;
    color: #f3f4f6;
}

body.dark .pagination-info {
    background-color: #374151;
    border-color: #6b7280;
    color: #d1d5db;
}

/* High contrast per paginazione */
body.high-contrast .pagination-btn {
    background-color: #000;
    border-color: #fff;
    color: #fff;
    border-width: 2px;
}

body.high-contrast .pagination-btn:hover:not(:disabled) {
    background-color: #fff;
    color: #000;
}

body.high-contrast .pagination-info {
    background-color: #000;
    border-color: #fff;
    color: #fff;
    border-width: 2px;
}

.hidden {
    display: none;
}

/* --- GALLERIA ALLEGATI COMPATTA --- */
.attachment-list-compact {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
}

.attachment-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    transition: all 0.15s ease;
    min-height: 60px;
}

.attachment-row:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.attachment-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 0; /* Permette il text-overflow */
}

.file-icon-wrapper {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;
}

.file-icon-compact {
    font-size: 1.25rem;
    line-height: 1;
}

.file-details {
    flex: 1;
    min-width: 0;
}

.file-name-compact {
    font-size: 0.875rem;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.25rem;
}

.file-meta-compact {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: #64748b;
}

.file-type-badge {
    background: #e0f2fe;
    color: #0369a1;
    padding: 0.125rem 0.5rem;
    border-radius: 0.375rem;
    font-weight: 500;
}

.file-size {
    color: #94a3b8;
}

.attachment-actions-compact {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}

.attachment-actions-compact button {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.15s ease;
    touch-action: manipulation;
}

.attachment-actions-compact button:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    transform: translateY(-1px);
}

.attachment-actions-compact button:active {
    transform: translateY(0);
}

.btn-preview:hover {
    background: #eff6ff;
    border-color: #3b82f6;
}

.btn-download:hover {
    background: #f0fdf4;
    border-color: #22c55e;
}

.btn-delete:hover {
    background: #fef2f2;
    border-color: #ef4444;
}

/* Dark Mode */
body.dark .attachment-row {
    background: #334155;
    border-color: #475569;
}

body.dark .attachment-row:hover {
    background: #475569;
    border-color: #64748b;
}

body.dark .file-icon-wrapper {
    background: #1e293b;
    border-color: #475569;
}

body.dark .file-name-compact {
    color: #f1f5f9;
}

body.dark .file-meta-compact {
    color: #94a3b8;
}

body.dark .file-type-badge {
    background: #1e3a8a;
    color: #bfdbfe;
}

body.dark .attachment-actions-compact button {
    background: #1e293b;
    border-color: #475569;
    color: #f1f5f9;
}

body.dark .attachment-actions-compact button:hover {
    background: #334155;
    border-color: #64748b;
}

/* High Contrast Mode */
body.high-contrast .attachment-row {
    background: #000;
    border: 2px solid #fff;
}

body.high-contrast .file-icon-wrapper {
    background: #000;
    border: 2px solid #fff;
}

body.high-contrast .file-name-compact,
body.high-contrast .file-meta-compact {
    color: #fff;
}

body.high-contrast .attachment-actions-compact button {
    background: #000;
    border: 2px solid #fff;
    color: #fff;
}
body.high-contrast .attachment-actions button { background:#000; border:1px solid #fff; }

/* Preview Modal specifico */
.attachment-preview-modal-content { max-width:600px; width:95%; }
.preview-wrapper { max-height:65vh; overflow:auto; border:1px solid #e5e7eb; border-radius:0.5rem; background:#000; display:flex; align-items:center; justify-content:center; }
.preview-wrapper img { max-width:100%; height:auto; display:block; }
body.dark .preview-wrapper { border-color:#4a5568; }
body.high-contrast .preview-wrapper { border:2px solid #fff; }

/* PDF iframe */
.preview-wrapper .preview-pdf { width:100%; height:65vh; background:#1f2937; }
body.dark .preview-wrapper .preview-pdf { background:#000; }

/* File upload status badge */
.file-uploaded-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: #dcfce7;
    color: #16a34a;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-weight: 600;
    font-size: 0.75rem;
    border: 1px solid #bbf7d0;
    line-height: 1;
}

.file-uploaded-badge svg { display:block; }

body.dark .file-uploaded-badge {
    background: #14532d;
    color: #86efac;
    border-color: #166534;
}

body.high-contrast .file-uploaded-badge {
    background: #000;
    color: #00ff00;
    border: 2px solid #00ff00;
}

/* Mobile-first optimizations */
@media (max-width: 768px) {
    /* MC 2025-11-16: Modal wizard responsive per mobile/tablet */
    .modal-content {
        width: 95%;
        max-width: 95vw;
        max-height: 95vh;
        padding: 1rem;
    }
    
    #wizard-content {
        max-height: 55vh;
    }
    
    #wizard-errors {
        margin: -1rem -1rem 1rem -1rem;
        padding: 0.75rem 1rem;
    }
    
    /* Miglioramenti touch-friendly */
    .touch-manipulation {
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }
    
    /* Input file più grandi su mobile */
    input[type="file"] {
        min-height: 48px;
        padding: 12px !important;
    }
    
    /* Pulsanti più spaziosi */
    button {
        min-height: 48px;
        padding: 12px 16px;
    }
    
    /* Select dropdown più grandi */
    select {
        min-height: 48px;
        font-size: 16px; /* Previene zoom su iOS */
    }
    
    /* Galleria allegati responsive */
    .attachment-gallery {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 8px;
    }
    
    /* Modal più responsive */
    .modal-content {
        margin: 10px;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    /* Toast messages mobile */
    /* Toast full-width stile banner su mobile */
    #message-box {
        top: 0.5rem;
        left: 0;
        right: 0;
        margin: 0 auto;
        width: 100%;
        max-width: none;
        border-radius: 0 0 0.75rem 0.75rem;
        transform: translateY(-150%);
        padding-left: calc(1rem + env(safe-area-inset-left, 0));
        padding-right: calc(1rem + env(safe-area-inset-right, 0));
    }
    #message-box.show {
        transform: translateY(0);
    }
    
    /* Attachment preview mobile */
    .attachment-preview-modal-content {
        width: 98%;
        margin: 1%;
    }
    
    .preview-wrapper {
        max-height: 50vh;
    }
}

/* --- CALENDAR VIEW --- */
/* MC 2025-11-16: Calendario responsive - vista lista su mobile */
.calendar-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.calendar-weekdays {
    display: none;
}

.calendar-day {
    padding: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: white;
}

.calendar-day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e2e8f0;
}

.calendar-day-number {
    font-weight: bold;
    font-size: 1.125rem;
}

.calendar-day-name {
    font-size: 0.875rem;
    color: #6b7280;
}

/* MC 2025-11-16: Vista griglia desktop */
@media (min-width: 768px) {
    .calendar-grid {
        display: grid;
        width: 100%;
        grid-template-columns: repeat(7, minmax(0, 1fr));
        gap: 4px;
    }
    
    .calendar-weekdays {
        display: block;
        font-weight: 600;
        text-align: center;
        padding: 6px 4px;
        background: #f1f5f9;
        border: 1px solid #e2e8f0;
        border-radius: 4px;
        font-size: 0.75rem;
        letter-spacing: .5px;
        text-transform: uppercase;
    }
    
    .calendar-day {
        min-height: 100px;
        padding: 8px;
        border-radius: 0;
    }
    
    .calendar-day-header {
        border-bottom: none;
        margin-bottom: 0;
        padding-bottom: 0;
    }
    
    .calendar-day-number {
        font-size: 1rem;
    }
    
    .calendar-day-name {
        display: none;
    }
}

.calendar-empty-day {
    background-color: #f9fafb;
}

/* MC 2025-11-16: Ottimizzazione per laptop con schermi bassi (height ridotta) */
@media (max-height: 800px) {
    .modal-content {
        max-height: 85vh;
        padding: 1rem;
    }
    
    #wizard-content {
        max-height: 50vh;
    }
    
    #wizard-title {
        font-size: 1.125rem;
        margin-bottom: 0.75rem;
    }
    
    .modal-content > div:last-child {
        margin-top: 1rem;
    }
}

/* MC 2025-11-16: Per schermi molto bassi (netbook/tablet landscape) */
@media (max-height: 650px) {
    .modal-content {
        max-height: 90vh;
        padding: 0.75rem;
    }
    
    #wizard-content {
        max-height: 45vh;
    }
    
    #wizard-title {
        font-size: 1rem;
        margin-bottom: 0.5rem;
    }
    
    #wizard-errors {
        padding: 0.5rem 0.75rem;
    }
    
    #wizard-errors h4 {
        font-size: 0.875rem;
        margin-bottom: 0.25rem;
    }
}


