/* =====================================================
   STILI GLOBALI PER TUTTE LE PAGINE
   ===================================================== */
/* Reset e impostazioni base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
html {
    font-size: 14px; /* Dimensione base del carattere */
}
body {
    background-color: #f8f9fa;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.5;
    color: #333;
}
/* =====================================================
   NAVBAR
   ===================================================== */
.navbar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.navbar-brand {
    color: white !important;
    font-weight: bold;
    font-size: 1.4rem;
}
.navbar-nav .nav-link {
    color: rgba(255, 255, 255, 0.8) !important;
    font-size: 0.95rem;
    transition: color 0.3s ease;
    padding: 0.5rem 1rem !important;
}
.navbar-nav .nav-link:hover,
.navbar-nav .nav-link:focus {
    color: white !important;
}
.navbar-nav .nav-link.active {
    color: white !important;
    font-weight: 600;
}
.navbar-dark .navbar-toggler {
    border-color: rgba(255, 255, 255, 0.1);
}
.navbar-dark .navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.55%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}
/* =====================================================
   CARD
   ===================================================== */
.card {
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border: none;
    border-radius: 10px;
}
.card-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white;
    border-radius: 10px 10px 0 0 !important;
    padding: 15px 20px;
}
.card-header h5 {
    margin: 0;
    font-weight: 600;
    font-size: 1.1rem;
}
.card-body {
    padding: 1.25rem;
}
.card-footer {
    background-color: transparent;
    border-top: 1px solid rgba(0, 0, 0, 0.125);
    padding: 0.75rem 1.25rem;
}
/* Card statistiche con gradiente */
.card-statistiche {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.card-statistiche:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3) !important;
}
.card-statistiche .card-title {
    font-size: 1rem !important;
    font-weight: 600;
}
.card-statistiche .card-text {
    font-size: 2rem !important;
    font-weight: 700;
}
.card-statistiche .card-title,
.card-statistiche .card-text,
.card-statistiche p {
    color: white !important;
}
.card-statistiche.bg-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
}
.card-statistiche.bg-success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%) !important;
}
.card-statistiche.bg-info {
    background: linear-gradient(135deg, #17a2b8 0%, #6f42c1 100%) !important;
}
.card-statistiche.bg-warning {
    background: linear-gradient(135deg, #ffc107 0%, #fd7e14 100%) !important;
}
/* =====================================================
   TABELLE
   ===================================================== */
.table {
    font-size: 0.9rem;
    margin-bottom: 0;
}
.table th {
    background-color: #f1f1f1;
    border-top: none;
    font-weight: 600;
    color: #495057;
    padding: 0.75rem;
}
.table td {
    padding: 0.75rem;
    vertical-align: middle;
}
.table-responsive {
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 1rem;
}
.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(0, 0, 0, 0.02);
}
.table-hover tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.05);
}
.table tfoot th {
    background-color: #f8f9fa;
    border-top: 2px solid #dee2e6;
    font-weight: 600;
}
/* =====================================================
   PULSANTI
   ===================================================== */
.btn {
    font-size: 0.9rem;
    border-radius: 8px;
    padding: 0.5rem 1rem;
    transition: all 0.3s ease;
}
.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
}
.btn-primary:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
    color: white;
}
.btn-primary:active {
    transform: translateY(0);
}
.btn-outline-primary {
    color: #667eea;
    border-color: #667eea;
}
.btn-outline-primary:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
    color: white;
}
.btn-success {
    background-color: #28a745;
    border-color: #28a745;
}
.btn-success:hover {
    background-color: #218838;
    border-color: #1e7e34;
}
.btn-outline-danger:hover {
    background-color: #dc3545;
    border-color: #dc3545;
    color: white;
}
.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    border-radius: 6px;
}
.btn-group .btn {
    margin-right: 2px;
}
.btn-group .btn:last-child {
    margin-right: 0;
}
/* =====================================================
   FORM
   ===================================================== */
.form-control, .form-select {
    font-size: 0.9rem;
    border-radius: 8px;
    border: 1px solid #ced4da;
    padding: 0.6rem 0.9rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.form-control:focus, .form-select:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 0.25rem rgba(102, 126, 234, 0.25);
}
label {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}
.form-text {
    font-size: 0.8rem;
    color: #6c757d;
    margin-top: 0.25rem;
}
.input-group {
    margin-bottom: 1rem;
}
.input-group-text {
    font-size: 0.9rem;
    background-color: #f8f9fa;
    border: 1px solid #ced4da;
    border-radius: 8px 0 0 8px;
    padding: 0 0.9rem;
}
.input-group .form-control {
    border-radius: 0 8px 8px 0;
}
.input-group .btn {
    border-radius: 0 8px 8px 0;
}
/* =====================================================
   ALERT
   ===================================================== */
.alert {
    font-size: 0.9rem;
    border-radius: 8px;
    padding: 0.9rem 1.25rem;
    margin-bottom: 1rem;
}
.alert-info {
    background-color: #d1ecf1;
    border-color: #bee5eb;
    color: #0c5460;
}
.alert-success {
    background-color: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}
.alert-danger {
    background-color: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}
.alert-warning {
    background-color: #fff3cd;
    border-color: #ffeeba;
    color: #856404;
}
/* =====================================================
   MODAL
   ===================================================== */
.modal-content {
    border: none;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}
.modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 10px 10px 0 0;
    padding: 1rem 1.5rem;
}
.modal-header .btn-close {
    filter: invert(1);
    opacity: 0.8;
}
.modal-header .btn-close:hover {
    opacity: 1;
}
.modal-title {
    font-size: 1.2rem;
    font-weight: 600;
}
.modal-body {
    padding: 1.5rem;
    font-size: 0.95rem;
}
.modal-footer {
    background-color: transparent;
    border-top: 1px solid rgba(0, 0, 0, 0.125);
    padding: 1rem 1.5rem;
}
/* =====================================================
   BADGE
   ===================================================== */
.badge {
    font-size: 0.75rem;
    padding: 0.35em 0.65em;
    font-weight: 600;
}
.badge.bg-primary {
    background-color: #667eea !important;
}
.badge-position {
    min-width: 25px;
    text-align: center;
}
/* =====================================================
   PAGINAZIONE
   ===================================================== */
.pagination {
    margin-bottom: 0;
}
.page-link {
    color: #667eea;
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
}
.page-item.active .page-link {
    background-color: #667eea;
    border-color: #667eea;
    color: white;
}
.page-link:hover {
    color: #764ba2;
}
/* =====================================================
   ELEMENTI SPECIFICI
   ===================================================== */
/* Top machine */
.top-machine {
    font-weight: 600;
    color: #495057;
}
/* Spinner */
.spinner-border {
    width: 1.2rem;
    height: 1.2rem;
}
.spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

/* =====================================================
   STILI PER DRAG AND DROP
   ===================================================== */
/* Placeholder durante il trascinamento */
.sortable-placeholder {
    background-color: #f8f9fa;
    border: 2px dashed #dee2e6;
    height: 50px;
    visibility: visible !important;
    border-radius: 8px;
    margin: 4px 0;
}

/* Stato di caricamento durante l'aggiornamento dell'ordine */
.sortable-loading {
    opacity: 0.5;
    pointer-events: none;
}

/* Icona di trascinamento */
.drag-handle {
    cursor: move;
    color: #6c757d;
    transition: color 0.2s ease;
}

.drag-handle:hover {
    color: #495057;
}

/* Righe trascinabili */
.draggable-row {
    transition: background-color 0.2s ease;
}

.draggable-row:hover {
    background-color: #f8f9fa;
}

/* Effetto di rilascio */
.draggable-row.ui-sortable-helper {
    background-color: white;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid #dee2e6;
    border-radius: 8px;
}

/* Toast notification per conferma */
.toast {
    z-index: 1050;
}

.toast-container {
    position: fixed;
    z-index: 1055;
}

/* =====================================================
   CELLE EDITABILI MIGLIORATE
   ===================================================== */
.editable {
    cursor: pointer;
    position: relative;
    transition: background-color 0.2s ease;
}

.editable:hover {
    background-color: #f0f7ff;
}

.editable-input {
    font-size: 0.9rem;
    height: 31px;
    padding: 0.25rem 0.5rem;
    border: 1px solid #667eea !important;
    border-radius: 4px;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

.editable-input:focus {
    border-color: #667eea !important;
    box-shadow: 0 0 0 0.25rem rgba(102, 126, 234, 0.5) !important;
}

/* Indicatore visivo per celle editabili */
.editable::after {
    content: '\f303';
    font-family: 'bootstrap-icons';
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    transition: opacity 0.2s ease;
    font-size: 0.8rem;
    color: #6c757d;
}

.editable:hover::after {
    opacity: 0.4;
}

/* Per schermi piccoli, nascondi l'icona per non ingombrare */
@media (max-width: 768px) {
    .editable::after {
        display: none;
    }
}

/* =====================================================
   LINK
   ===================================================== */
a {
    color: #667eea;
    text-decoration: none;
    transition: color 0.3s ease;
}
a:hover {
    color: #764ba2;
    text-decoration: underline;
}
/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 768px) {
    html {
        font-size: 13px;
    }
    
    .card-header h5 {
        font-size: 1rem;
    }
    
    .table {
        font-size: 0.8rem;
    }
    
    .table th, .table td {
        padding: 0.5rem;
    }
    
    .btn {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
    
    .form-control, .form-select {
        font-size: 0.8rem;
        padding: 0.5rem 0.75rem;
    }
    
    .card-statistiche .card-text {
        font-size: 1.5rem !important;
    }
    
    .card-statistiche .card-title {
        font-size: 0.9rem !important;
    }
    
    .navbar-nav .nav-link {
        font-size: 0.9rem;
        padding: 0.4rem 0.8rem !important;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .modal-header, .modal-footer {
        padding: 0.75rem 1rem;
    }
    
    .modal-title {
        font-size: 1.1rem;
    }
    
    /* Drag and drop su schermi piccoli */
    .sortable-placeholder {
        height: 40px;
    }
    
    .drag-handle {
        font-size: 1.1rem;
        padding: 0.25rem 0.5rem;
    }
    
    /* Celle editabili su schermi piccoli */
    .editable-input {
        height: 28px;
        font-size: 0.8rem;
        padding: 0.2rem 0.4rem;
    }
}
@media (max-width: 576px) {
    .btn-group {
        flex-direction: column;
    }
    
    .btn-group .btn {
        margin-right: 0;
        margin-bottom: 5px;
    }
    
    .btn-group .btn:last-child {
        margin-bottom: 0;
    }
    
    .table-responsive {
        font-size: 0.75rem;
    }
    
    .card-statistiche .card-text {
        font-size: 1.3rem !important;
    }
    
    /* Drag and drop su schermi molto piccoli */
    .sortable-placeholder {
        height: 35px;
        margin: 2px 0;
    }
    
    .draggable-row.ui-sortable-helper {
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
    
    /* Celle editabili su schermi molto piccoli */
    .editable-input {
        height: 26px;
        font-size: 0.75rem;
        padding: 0.15rem 0.3rem;
    }
}
/* =====================================================
   CELLE EDITABILI CON DIMENSIONI FISSE
   ===================================================== */
/* Imposta la tabella con layout fisso */
.table {
    table-layout: fixed;
    width: 100%;
}

/* Larghezza fissa per le colonne editabili */
.table th:nth-child(5), /* Colonna Bills */
.table td:nth-child(5) {
    width: 120px;
    max-width: 120px;
    min-width: 120px;
}

.table th:nth-child(6), /* Colonna Prelevato */
.table td:nth-child(6) {
    width: 120px;
    max-width: 120px;
    min-width: 120px;
}

/* Celle editabili */
.editable {
    cursor: pointer;
    position: relative;
    transition: background-color 0.2s ease;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.editable:hover {
    background-color: #f0f7ff;
}

.editable-input {
    width: 100% !important;
    height: 31px !important;
    padding: 0.25rem 0.5rem !important;
    border: 1px solid #667eea !important;
    border-radius: 4px !important;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25) !important;
    font-size: 0.9rem !important;
    margin: 0 !important;
    line-height: 1.5 !important;
}

.editable-input:focus {
    border-color: #667eea !important;
    box-shadow: 0 0 0 0.25rem rgba(102, 126, 234, 0.5) !important;
    outline: none !important;
}

/* Indicatore visivo per celle editabili */
.editable::after {
    content: '\f303';
    font-family: 'bootstrap-icons';
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    transition: opacity 0.2s ease;
    font-size: 0.8rem;
    color: #6c757d;
    pointer-events: none;
}

.editable:hover::after {
    opacity: 0.4;
}

/* Per schermi piccoli, nascondi l'icona per non ingombrare */
@media (max-width: 768px) {
    .editable::after {
        display: none;
    }
    
    .table th:nth-child(5), /* Colonna Bills */
    .table td:nth-child(5) {
        width: 100px;
        max-width: 100px;
        min-width: 100px;
    }

    .table th:nth-child(6), /* Colonna Prelevato */
    .table td:nth-child(6) {
        width: 100px;
        max-width: 100px;
        min-width: 100px;
    }
    
    .editable-input {
        height: 28px !important;
        font-size: 0.8rem !important;
        padding: 0.2rem 0.4rem !important;
    }
}

/* =====================================================
   FEEDBACK VISIVO PER AGGIORNAMENTI
   ===================================================== */
.bg-success {
    background-color: #d4edda !important;
    transition: background-color 0.5s ease;
}

/* Animazione per l'aggiornamento del prelevare */
@keyframes highlightUpdate {
    0% { background-color: #d4edda; }
    50% { background-color: #c3e6cb; }
    100% { background-color: #d4edda; }
}

.prelevare-updated {
    animation: highlightUpdate 1s ease-in-out;
}