/* ========================================
   GESTIONE CONSEGNE - STILI PRINCIPALI
   Versione Pulita e Ottimizzata
   ======================================== */

/* ===== RESET E BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
}

/* Body con barra di navigazione superiore (solo pagine che usano la classe) */
body.has-topnav {
    padding-top: 64px;
}

/* ===== TOP NAVIGATION ===== */
#topNav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    padding: 0 12px;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    z-index: 11000;
}

#topNav .nav-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    color: #667eea;
    white-space: nowrap;
    margin-right: 12px;
}

#topNav .nav-search {
    display: flex;
    align-items: center;
    margin: 0 12px;
    flex-shrink: 0;
}

#topNav .nav-search input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

#topNav .nav-search button:hover {
    background: #5a6fd6 !important;
}

#topNav .nav-buttons {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    overflow: hidden;
    justify-content: flex-start;
    flex: 1;
}

.nav-btn {
    font-size: 10px;
    padding: 4px 8px;
    min-height: 0;
    box-shadow: none;
    white-space: nowrap;
}

.nav-btn.active {
    box-shadow: 0 4px 14px rgba(102, 126, 234, 0.5);
    transform: translateY(-1px);
}

/* ===== SIDEBAR ===== */
#sidebar {
    width: 380px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 20px;
    overflow-y: auto;
    border-right: 2px solid rgba(102, 126, 234, 0.2);
    transition: all 0.3s ease;
    position: relative;
    z-index: 10000;
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.1);
}

#sidebar.closed {
    margin-left: -380px;
    width: 0;
    min-width: 0;
    padding: 0;
}

#sidebar h2 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 1.5em;
    font-weight: 600;
    text-align: center;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}

/* ===== SEZIONI ===== */
.section {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(102, 126, 234, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.section:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.section h3 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.2em;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section h4 {
    color: #555;
    margin-bottom: 12px;
    font-size: 1.1em;
    font-weight: 500;
    border-left: 4px solid #667eea;
    padding-left: 10px;
}

/* ===== PULSANTI ===== */
.btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    min-height: 44px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.pulse-highlight {
    animation: pulse-highlight 1s ease-in-out 0s 3;
    box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.6);
}

@keyframes pulse-highlight {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.6);
    }
    50% {
        transform: scale(1.03);
        box-shadow: 0 0 0 10px rgba(40, 167, 69, 0);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0);
    }
}

/* Varianti pulsanti */
.btn-success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.3);
}

.btn-danger {
    background: linear-gradient(135deg, #dc3545 0%, #e83e8c 100%);
    box-shadow: 0 4px 15px rgba(220, 53, 69, 0.3);
}

.btn-warning {
    background: linear-gradient(135deg, #ffc107 0%, #fd7e14 100%);
    box-shadow: 0 4px 15px rgba(255, 193, 7, 0.3);
    color: #333;
}

.btn-info {
    background: linear-gradient(135deg, #17a2b8 0%, #6f42c1 100%);
    box-shadow: 0 4px 15px rgba(23, 162, 184, 0.3);
}

.btn-secondary {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
    box-shadow: 0 4px 15px rgba(108, 117, 125, 0.3);
}

/* ===== INPUT E FORM ===== */
input[type="text"], 
input[type="date"], 
input[type="file"], 
select, 
textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
    background: white;
    color: #333;
}

input[type="text"]:focus, 
input[type="date"]:focus, 
input[type="file"]:focus, 
select:focus, 
textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    transform: translateY(-1px);
}

/* ===== MAPPA ===== */
#map {
    flex: 1;
    height: 100vh;
    position: relative;
}

/* Altezza mappa corretta quando è presente la top-nav */
body.has-topnav #map {
    height: calc(100vh - 64px);
}

/* ===== TOGGLE SIDEBAR ===== */
#toggleSidebar {
    position: fixed;
    top: 84px;
    left: 20px;
    z-index: 10001;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #667eea;
}

#toggleSidebar:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* ===== STATISTICHE ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.stat-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 15px;
    border-radius: 10px;
    text-align: center;
    border: 1px solid rgba(102, 126, 234, 0.1);
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.stat-number {
    font-size: 1.8em;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.9em;
    color: #666;
    font-weight: 500;
}

/* ===== PROGRESS BAR ===== */
.progress-container {
    background: #e9ecef;
    border-radius: 10px;
    overflow: hidden;
    margin: 10px 0;
    height: 8px;
}

.progress-fill {
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    height: 100%;
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 10px;
}

/* ===== MESSAGGI ===== */
.message {
    padding: 12px 16px;
    border-radius: 8px;
    margin: 10px 0;
    font-weight: 500;
    border-left: 4px solid;
    animation: slideIn 0.3s ease;
}

.message.success {
    background: #d4edda;
    color: #155724;
    border-color: #28a745;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
    border-color: #dc3545;
}

.message.warning {
    background: #fff3cd;
    color: #856404;
    border-color: #ffc107;
}

.message.info {
    background: #d1ecf1;
    color: #0c5460;
    border-color: #17a2b8;
}

.message.loading {
    background: #e2e3e5;
    color: #383d41;
    border-color: #6c757d;
}

/* ===== CHAT ===== */
#chatMessages {
    max-height: 200px;
    overflow-y: auto;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
}

.chat-message {
    margin-bottom: 8px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.4;
}

.chat-message.user {
    background: #e3f2fd;
    border-left: 3px solid #2196f3;
}

.chat-message.success {
    background: #e8f5e8;
    border-left: 3px solid #4caf50;
}

.chat-message.error {
    background: #ffebee;
    border-left: 3px solid #f44336;
}

.chat-message.info {
    background: #f5f5f5;
    border-left: 3px solid #9e9e9e;
}

/* ===== STATISTICHE CARICO DI LAVORO ===== */
#workload-stats {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.stat-label {
    font-weight: 600;
    color: #333;
    font-size: 0.9em;
}

.stat-value {
    font-weight: bold;
    color: #667eea;
    font-size: 1em;
}

.operator-stats {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 10px 0;
}

.operator-stat {
    background: rgba(255, 255, 255, 0.8);
    border-radius: 10px;
    padding: 12px;
    border: 2px solid rgba(102, 126, 234, 0.1);
    transition: all 0.3s ease;
}

.operator-stat:hover {
    border-color: rgba(102, 126, 234, 0.3);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.operator-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.operator-name {
    font-weight: 600;
    color: #333;
    font-size: 0.95em;
}

.operator-count {
    font-weight: bold;
    font-size: 1.1em;
    color: #667eea;
}

.operator-details {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.workload-info {
    font-size: 0.85em;
    color: #666;
    font-weight: 500;
}

.operator-metrics {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(102, 126, 234, 0.1);
}

.metric-item {
    font-size: 0.8em;
    color: #555;
    font-weight: 500;
}

.color-legend {
    margin-top: 15px;
    padding: 10px;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(102, 126, 234, 0.1);
}

.legend-items {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.legend-item-small {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8em;
    color: #666;
}

.legend-item-small .legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ===== LEGENDA ===== */
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #666;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    #topNav .nav-search input {
        width: 120px !important;
    }

    #sidebar {
        width: 100%;
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 10000;
    }
    
    #sidebar.closed {
        transform: translateX(-100%);
        margin-left: 0;
    }
    
    #toggleSidebar {
        display: block;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ===== ANIMAZIONI ===== */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

/* ===== UTILITY CLASSES ===== */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mb-10 { margin-bottom: 10px; }
.mb-15 { margin-bottom: 15px; }
.mb-20 { margin-bottom: 20px; }

.mt-10 { margin-top: 10px; }
.mt-15 { margin-top: 15px; }
.mt-20 { margin-top: 20px; }

.hidden { display: none; }
.visible { display: block; }

.flex { display: flex; }
.flex-column { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.justify-center { justify-content: center; }
.align-center { align-items: center; }
.gap-10 { gap: 10px; }
.gap-15 { gap: 15px; }

/* ===== SCROLLBAR PERSONALIZZATA ===== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #5a6fd8;
}
