/* ============================================
   SCADENZIARIO - CSS OTTIMIZZATO CON BOOTSTRAP
   ============================================
   Solo stili necessari non coperti da Bootstrap
   ============================================ */

/* ===== VARIABILI CSS PERSONALIZZATE ===== */
:root {
    --bs-primary: #a62754;
    --bs-primary-rgb: 166, 39, 84;
    --bs-primary-dark: #8c1e42;
}

/* ===== OVERRIDE COLORE PRIMARY BOOTSTRAP ===== */
.btn-primary {
    background-color: var(--bs-primary) !important;
    border-color: var(--bs-primary) !important;
}

.btn-primary:hover, 
.btn-primary:focus {
    background-color: var(--bs-primary-dark) !important;
    border-color: var(--bs-primary-dark) !important;
}

.btn-outline-primary {
    color: var(--bs-primary) !important;
    border-color: var(--bs-primary) !important;
}

.btn-outline-primary:hover {
    background-color: var(--bs-primary) !important;
    color: white !important;
}

.text-primary {
    color: var(--bs-primary) !important;
}

.bg-primary {
    background-color: var(--bs-primary) !important;
}

/* ===== SCROLL VERTICALE TABELLE (globale) ===== */
.table-responsive.table-scroll-vertical {
    max-height: 70vh;
    overflow-y: auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.table-responsive.table-scroll-vertical .table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #e9ecef;
    box-shadow: 0 1px 0 0 #dee2e6;
    white-space: nowrap;
}
.table-responsive.table-scroll-vertical .table thead.table-light th {
    background: #e9ecef;
}

/* ===== LAYOUT FISSO PERSONALIZZATO ===== */
body {
    padding-top: 56px;
    padding-bottom: 60px;
    background-color: #f8f9fa;
    overflow: hidden;
}

body.modal-open {
    overflow: hidden;
}

/* Componenti fissi - Layout specifico non in Bootstrap */
.fixed-navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    height: 61px;
    overflow: visible;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    margin: 0 !important;
}

.fixed-navbar .container-fluid {
    height: 61px;
    display: flex;
    align-items: center;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    margin: 0 !important;
}

/* Centra verticalmente tutti gli elementi della navbar */
.fixed-navbar .d-flex,
.fixed-navbar .navbar-brand,
.fixed-navbar .navbar-toggler {
    display: flex;
    align-items: center;
}

/* Fix per pulsante Install App e dropdown - mantiene posizione quando dropdown è aperto */
.navbar-nav.flex-row {
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    height: 100% !important;
}

.navbar-nav.flex-row .nav-item {
    white-space: nowrap;
    height: 100% !important;
    display: flex !important;
    align-items: center !important;
    position: relative !important;
    transform: none !important;
}

#headerInstallBtn {
    flex-shrink: 0;
    margin-right: 0.5rem;
    display: flex !important;
    align-items: center !important;
    height: 100% !important;
}

#headerInstallBtn .btn {
    display: inline-flex;
    align-items: center;
}

.nav-item.dropdown {
    flex-shrink: 0;
    display: flex !important;
    align-items: center !important;
    height: 100% !important;
}

.nav-item.dropdown .nav-link {
    height: 100% !important;
    display: flex !important;
    align-items: center !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

.nav-item.dropdown .dropdown-menu {
    position: absolute !important;
    top: 100% !important;
    right: 0 !important;
    margin-top: 0 !important;
}

/* Previene spostamento quando dropdown è aperto */
.nav-item.dropdown.show,
.nav-item.dropdown.show .nav-link,
.nav-item.dropdown.show .nav-link i {
    transform: none !important;
    position: relative !important;
}


.fixed-sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    bottom: 60px;
    width: 15%;
    background: white;
    overflow-y: auto;
    z-index: 1020;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
}

.main-content {
    position: fixed;
    top: 56px;
    left: 15%;
    right: 0;
    bottom: 60px;
    overflow-y: auto;
    background: white;
    padding: 20px;
    z-index: 1010;
}

.fixed-footer,
.mobile-toolbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: white;
    z-index: 1030;
    box-shadow: 0 -2px 5px rgba(0,0,0,0.1);
}

/* ===== COMPONENTI UI - SOLO PERSONALIZZAZIONI ===== */
/* Cards - Aggiunge solo animazioni hover personalizzate */
.card {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
    border: none;
    box-shadow: 0 2px 8px rgba(166, 39, 84, 0.1);
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 24px rgba(166, 39, 84, 0.2);
}

/* Buttons - Solo animazioni personalizzate */
.btn {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(166, 39, 84, 0.25);
}

/* Rimuove l'outline blu di default sui bottoni */
.btn:focus,
.btn:focus-visible,
.btn:active:focus {
    outline: none !important;
    box-shadow: 0 0 0 0.25rem rgba(166, 39, 84, 0.25) !important;
}

/* Per i bottoni outline, mantieni il colore del brand */
.btn-outline-primary:focus,
.btn-outline-primary:focus-visible {
    outline: none !important;
    box-shadow: 0 0 0 0.25rem rgba(166, 39, 84, 0.25) !important;
}

/* List Groups - Solo animazioni personalizzate */
.list-group-item {
    transition: all 0.3s ease;
    margin-bottom: 4px;
    border: 1px solid rgba(166, 39, 84, 0.1);
}

.list-group-item:hover {
    background-color: rgba(166, 39, 84, 0.08);
    transform: translateX(8px);
    border-color: rgba(166, 39, 84, 0.3);
}

/* Navigation - Solo animazioni personalizzate */
.nav-link {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin: 2px 0;
}

.nav-link:not(.dropdown-toggle):hover {
    background-color: rgba(166, 39, 84, 0.12);
    transform: translateX(8px);
}

.sidebar-nav .nav-link.active {
    background-color: var(--bs-primary) !important;
    color: white !important;
    transform: translateX(8px);
}

/* Tables - Solo personalizzazioni specifiche */
.table td,
.table th {
    white-space: nowrap;
}

.table-sortable th[data-sort-by] {
    cursor: pointer;
    user-select: none;
}

.table-sortable th[data-sort-by]:hover {
    background-color: #f8f9fa;
}

/* Forms - Solo personalizzazioni colore brand */
input.form-control:focus,
textarea.form-control:focus,
select.form-select:focus {
    border-color: var(--bs-primary) !important;
    box-shadow: 0 0 0 0.25rem rgba(166, 39, 84, 0.25) !important;
}

input.form-control:hover,
textarea.form-control:hover,
select.form-select:hover {
    border-color: rgba(166, 39, 84, 0.4) !important;
}

/* Chrome Autofill - Fix specifico */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0px 1000px #fff inset !important;
    -webkit-text-fill-color: #212529 !important;
    transition: background-color 5000s ease-in-out 0s !important;
}

/* Pagination - Solo personalizzazioni colore */
.pagination .page-item .page-link {
    color: var(--bs-primary);
    transition: all 0.2s ease-in-out;
}

.pagination .page-item .page-link:hover {
    color: var(--bs-primary-dark);
    background-color: rgba(166, 39, 84, 0.1);
    border-color: var(--bs-primary);
}

.pagination .page-item.active .page-link {
    background-color: var(--bs-primary) !important;
    border-color: var(--bs-primary) !important;
    color: white !important;
}

.pagination .page-item .page-link:focus {
    box-shadow: 0 0 0 0.25rem rgba(166, 39, 84, 0.25);
    border-color: var(--bs-primary);
}

/* ===== PAGINA LOGIN - STILI SPECIFICI ===== */
.login-body {
    background-color: var(--bs-primary) !important;
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    padding-top: 8%;
    position: relative;
}

.login-body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, rgba(166, 39, 84, 0.9) 0%, rgba(140, 30, 66, 0.9) 100%);
    z-index: 0;
}

.login-card {
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    padding: 2.5rem;
    border: none;
    position: relative;
    z-index: 1;
}

.brand-name {
    font-weight: 700;
    letter-spacing: 1px;
    font-size: 1.8rem;
}

.logo-placeholder {
    background: rgba(166, 39, 84, 0.1);
    border-radius: 50%;
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.login-submit-btn {
    background: linear-gradient(135deg, var(--bs-primary) 0%, var(--bs-primary-dark) 100%) !important;
    border: none !important;
    padding: 12px 24px;
    font-weight: 600;
    font-size: 1.1rem;
    border-radius: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(166, 39, 84, 0.3);
}

.login-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(166, 39, 84, 0.4);
}

.login-submit-btn:active {
    transform: translateY(0);
}

/* ===== COMPONENTI SPECIALI ===== */
/* Loading Overlay - Componente custom */
#globalLoading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-container {
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(166, 39, 84, 0.3);
    text-align: center;
    max-width: 400px;
    width: 90%;
    border: 2px solid var(--bs-primary);
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--bs-primary);
    border-radius: 50%;
    animation: spin 1.2s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
    margin: 0 auto 20px;
    position: relative;
}

.loading-spinner::after {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border: 4px solid transparent;
    border-top: 4px solid rgba(166, 39, 84, 0.3);
    border-radius: 50%;
    animation: spin 2s linear infinite;
}

.loading-text {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--bs-primary);
    margin-bottom: 10px;
    animation: pulse 2s infinite;
}

.loading-subtext {
    color: #6c757d;
    font-size: 0.9rem;
}

/* Modals - Solo z-index personalizzati */
.modal {
    z-index: 1060 !important;
}

.modal-backdrop {
    z-index: 1050 !important;
}

.modal-body.scrollable {
    max-height: 60vh;
    overflow-y: auto;
}

/* Progress Bars - Solo personalizzazioni specifiche */
[id^="compressionProgress"] {
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    height: 25px;
}

[id^="compressionProgress"] .progress-bar {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 8px;
}

.progress-text {
    font-size: 11px !important;
    font-weight: 600;
    text-shadow: 0 1px 1px rgba(0,0,0,0.3);
    color: white;
    letter-spacing: 0.3px;
}

/* Stat Cards - Utility class */
.stat-card-sm {
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Description Rows - Utility class */
.description-row td {
    border-top: 0;
    padding-top: 0;
}

.description-content {
    margin-top: 0.25rem;
    margin-left: 0.5rem;
}

/* Highlight Animation - Utility class */
.highlighted-row {
    background-color: #d4edda !important;
    border-left: 4px solid #28a745 !important;
    transition: all 0.5s ease;
    animation: pulse-highlight 2s ease-in-out;
}

.highlighted-row td {
    background-color: #d4edda !important;
}

/* Drag and Drop - Utility classes */
.draggable-file {
    transition: all 0.3s ease;
    cursor: move;
}

.draggable-file.dragging {
    opacity: 0.5;
    background-color: #f8f9fa;
}

.draggable-file:hover {
    background-color: #f8f9fa;
}

.handle {
    cursor: grab;
}

.handle:active {
    cursor: grabbing;
}

/* ===== ANIMAZIONI ===== */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes loadingFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes loadingFadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.9);
    }
}

@keyframes pulse-highlight {
    0% { background-color: #d4edda; }
    50% { background-color: #c3e6cb; }
    100% { background-color: #d4edda; }
}

.loading-fade-in {
    animation: loadingFadeIn 0.3s ease-out forwards;
}

.loading-fade-out {
    animation: loadingFadeOut 0.3s ease-in forwards;
}

/* ===== UTILITY CLASSES BOOTSTRAP-COMPATIBILI ===== */
/* Sostituiscono stili inline comuni */
.w-150 {
    width: 150px !important;
}

.cursor-grab {
    cursor: grab !important;
}

.cursor-grabbing {
    cursor: grabbing !important;
}

.cursor-move {
    cursor: move !important;
}

.object-fit-cover {
    object-fit: cover !important;
}

.h-100px {
    height: 100px !important;
}

.max-h-300 {
    max-height: 300px !important;
}

.max-h-400 {
    max-height: 400px !important;
}

.h-25px {
    height: 25px !important;
}

.z-index-1 {
    z-index: 1 !important;
}

/* ===== MEDIA QUERIES ===== */
@media (min-width: 992px) {
    .mobile-toolbar {
        display: none !important;
    }
    .fixed-footer {
        display: block !important;
    }
    .fixed-sidebar {
        display: block !important;
    }
}

@media (max-width: 991.98px) {
    .fixed-sidebar {
        display: none !important;
    }
    .main-content {
        left: 0 !important;
        bottom: 60px !important;
        padding: 15px !important;
    }
    
    .offcanvas-start {
        width: 65% !important;
        max-width: 240px !important;
    }
    
    body {
        padding-bottom: 60px !important;
    }
    .fixed-footer {
        display: none !important;
    }
    .mobile-toolbar {
        display: block !important;
    }
}

@media (max-width: 576px) {
    .login-card {
        margin: 1rem;
        padding: 1.5rem;
    }
    
    .brand-name {
        font-size: 1.5rem;
    }
}
