/* ===== ORDINI ATTIVI 2.0 - Combined V2+V3 Features ===== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #e9ecef 100%);
    padding: 20px;
    min-height: 100vh;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
}

/* ===== HEADER STATISTICHE + ANALYTICS ===== */
.header-stats {
    background: linear-gradient(135deg, #71a894 0%, #5a9178 100%);
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 20px;
    box-shadow: 0 8px 24px rgba(113, 168, 148, 0.3);
    color: white;
}

.header-stats h2 {
    font-size: 1.8em;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 20px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.stat-label {
    font-size: 0.9em;
    opacity: 0.9;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 2em;
    font-weight: 700;
}

/* Analytics Live */
.analytics-live {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    padding-top: 20px;
    border-top: 1px solid rgba(255,255,255,0.2);
}

.analytics-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.analytics-icon {
    font-size: 2em;
}

.analytics-info {
    flex: 1;
}

.analytics-info .label {
    font-size: 0.85em;
    opacity: 0.9;
}

.analytics-info .value {
    font-size: 1.3em;
    font-weight: 700;
}

/* ===== TIMELINE ORARIA ===== */
/* ✨ UNIFORMATO: Gradient timeline */
.timeline-container {
    background: linear-gradient(135deg,
        rgba(255, 255, 255, 0.98) 0%,
        rgba(113, 168, 148, 0.03) 100%
    );
    border-radius: 20px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

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

.timeline-header h3 {
    font-size: 1.2em;
    color: #2c3e50;
}

.timeline-ora-corrente {
    font-weight: 700;
    color: #71a894;
    font-size: 1.1em;
}

.timeline {
    position: relative;
    height: 80px;
    background: #f8f9fa;
    border-radius: 12px;
    overflow: hidden;
}

.timeline-axis {
    display: flex;
    justify-content: space-between;
    padding: 10px 15px;
    border-bottom: 2px solid #dee2e6;
}

.timeline-hour {
    font-size: 0.9em;
    font-weight: 600;
    color: #6c757d;
}

.timeline-markers {
    position: relative;
    height: 50px;
    padding: 10px 15px;
}

.timeline-marker {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid white;
}

.timeline-marker:hover {
    transform: scale(1.5);
    z-index: 10;
}

.timeline-marker.urgenza-normale {
    background: #71a894;
}

.timeline-marker.urgenza-attenzione {
    background: #ff9500;
    animation: pulse-marker 1.5s infinite;
}

.timeline-marker.urgenza-critica {
    background: #ec676c;
    animation: pulse-marker 1s infinite;
}

@keyframes pulse-marker {
    0%, 100% { box-shadow: 0 0 0 0 rgba(236, 103, 108, 0.7); }
    50% { box-shadow: 0 0 0 8px rgba(236, 103, 108, 0); }
}

.timeline-now {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #71a894;
    box-shadow: 0 0 8px rgba(113, 168, 148, 0.5);
}

/* ===== PROSSIMI ARRIVI BOX ===== */
.prossimi-arrivi {
    background: linear-gradient(135deg, #fff5f5 0%, #ffe8e8 100%);
    border: 3px solid #ec676c;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 16px rgba(236, 103, 108, 0.2);
}

.prossimi-arrivi h3 {
    color: #c62828;
    font-size: 1.3em;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.prossimi-lista {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.prossimo-item {
    background: white;
    padding: 12px 16px;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 4px solid #ec676c;
}

.prossimo-item strong {
    color: #2c3e50;
}

.prossimo-tempo {
    background: #ec676c;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.9em;
}

/* ===== TOOLBAR ===== */
/* ✨ UNIFORMATO: Gradient sottile per toolbar */
.toolbar {
    background: linear-gradient(135deg,
        rgba(255, 255, 255, 0.98) 0%,
        rgba(113, 168, 148, 0.03) 50%,
        rgba(244, 192, 99, 0.02) 100%
    );
    border-radius: 20px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.toolbar-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 15px;
    flex-wrap: wrap;
}

.view-toggles {
    display: flex;
    gap: 10px;
}

.btn-toggle {
    padding: 10px 20px;
    border: 2px solid #e9ecef;
    background: white;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-toggle:hover {
    border-color: #71a894;
}

.btn-toggle.active {
    background: #71a894;
    color: white;
    border-color: #71a894;
}

.btn-rush {
    padding: 10px 20px;
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 700;
    font-size: 1em;
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
    transition: all 0.3s ease;
}

.btn-rush:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(255, 107, 107, 0.4);
}

.btn-rush.active {
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

/* Search */
.search-bar {
    position: relative;
    flex: 1;
    max-width: 500px;
}

.search-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2em;
    color: #999;
}

.search-input {
    width: 100%;
    padding: 14px 20px 14px 50px;
    font-size: 1em;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    transition: all 0.3s ease;
}

.search-input:focus {
    outline: none;
    border-color: #71a894;
    box-shadow: 0 0 0 4px rgba(113, 168, 148, 0.1);
}

/* Filtri avanzati */
.filtri-avanzati {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e9ecef;
}

.filtro-chip {
    padding: 8px 16px;
    background: #f8f9fa;
    border: 2px solid transparent;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
    transition: all 0.2s ease;
    color: #6c757d;
}

.filtro-chip:hover {
    background: #e9ecef;
}

.filtro-chip.active {
    background: #71a894;
    color: white;
    border-color: #71a894;
}

/* Tab filtri */
.filtri-tabs {
    display: flex;
    gap: 8px;
    border-bottom: 2px solid #e9ecef;
    margin-bottom: 20px;
}

.tab-filtro {
    padding: 12px 24px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    color: #6c757d;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tab-filtro:hover {
    color: #71a894;
}

.tab-filtro.active {
    color: #71a894;
    border-bottom-color: #71a894;
}

.tab-badge {
    background: #e9ecef;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 700;
}

.tab-filtro.active .tab-badge {
    background: #71a894;
    color: white;
}

/* ===== MAIN GRID (Lista + GPS Sidebar) ===== */
.main-grid {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 20px;
}

/* ===== LISTA ORDINI ===== */
.ordini-lista {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.no-ordini {
    background: white;
    border-radius: 16px;
    padding: 60px 20px;
    text-align: center;
    color: #6c757d;
    font-size: 1.2em;
}

/* ✨ UNIFORMATO A KPI1/KPI2: Gradient sottile invece di bianco piatto */
.ordine-card {
    background: linear-gradient(135deg,
        rgba(255, 255, 255, 0.95) 0%,
        rgba(113, 168, 148, 0.04) 30%,
        rgba(244, 192, 99, 0.03) 60%,
        rgba(236, 103, 108, 0.03) 100%
    );
    border-radius: 16px;
    padding: 0;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    border-left: 6px solid #71a894;
    transition: all 0.3s ease;
    overflow: hidden;
    position: relative;
}

.ordine-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

.ordine-card.urgenza-critica {
    border-left-width: 14px;
    border-left-color: #ec676c;
}

.ordine-card.urgenza-attenzione {
    border-left-color: #ff9500;
}

/* Rush mode - card compatte */
body.rush-mode .ordine-card {
    padding: 0;
}

body.rush-mode .card-header {
    padding: 12px 15px;
}

body.rush-mode .card-body {
    padding: 8px 15px;
}

body.rush-mode .card-footer {
    padding: 8px 15px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.card-header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.card-id {
    font-size: 1.4em;
    font-weight: 700;
    color: #71a894;
}

.card-cliente {
    font-size: 1.1em;
    font-weight: 600;
    color: #2c3e50;
}

.card-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.badge-tipo {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 600;
}

.badge-tipo.delivery {
    background: #e3f2fd;
    color: #1976d2;
}

.badge-tipo.ritiro {
    background: #fff3e0;
    color: #f57c00;
}

.badge-tipo.tavolo {
    background: #f3e5f5;
    color: #7b1fa2;
}

.badge-stato {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 600;
}

.badge-stato.new {
    background: #e8f5e9;
    color: #2e7d32;
}

.badge-stato.waiting {
    background: #fff3e0;
    color: #f57c00;
}

.badge-stato.in-prep {
    background: #e3f2fd;
    color: #1976d2;
}

.badge-stato.out-delivery {
    background: #fce4ec;
    color: #c2185b;
}

.card-body {
    padding: 15px 25px;
    border-top: 1px solid #f0f0f0;
}

.card-indirizzo {
    color: #6c757d;
}

/* Preview items compatta */
.card-items-preview {
    color: #495057;
    font-size: 0.9em;
    margin-top: 8px;
    font-weight: 500;
    line-height: 1.4;
}

.card-items {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.item-chip {
    background: #f8f9fa;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.85em;
    color: #495057;
}

/* Card footer - !important per override ordini_attivi.css */
.ordine-card .card-footer {
    padding: 15px 25px !important;
    background: #f8f9fa !important;
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 20px !important;
}

.ordine-card .card-info-left {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
}

.card-totale {
    font-size: 1.3em;
    font-weight: 700;
    color: #71a894;
}

.card-tempo {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #6c757d;
}

.tempo-orario {
    font-weight: 600;
}

.tempo-eta {
    padding: 4px 10px;
    background: white;
    border-radius: 12px;
    font-size: 0.9em;
}

.card-actions {
    display: flex;
    gap: 8px;
}

.btn-action {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-action.primary {
    background: #71a894;
    color: white;
}

.btn-action.primary:hover {
    background: #5a9178;
}

.btn-action.secondary {
    background: #e9ecef;
    color: #495057;
}

.btn-action.secondary:hover {
    background: #dee2e6;
}

.btn-action.success {
    background: #4caf50;
    color: white;
}

.btn-action.success:hover {
    background: #45a049;
}

.btn-action.warning {
    background: #ff9800;
    color: white;
}

.btn-action.warning:hover {
    background: #f57c00;
}

/* ===== CARD DETTAGLI (COLLAPSIBLE) ===== */
.card-dettagli {
    border-top: 2px solid #e9ecef;
    background: #f8f9fa;
    padding: 20px 25px;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
    }
    to {
        opacity: 1;
        max-height: 500px;
    }
}

.dettagli-section {
    margin-bottom: 20px;
}

.dettagli-section:last-child {
    margin-bottom: 0;
}

.dettagli-section h4 {
    font-size: 1.1em;
    color: #71a894;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.items-list-dettaglio {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.item-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    gap: 15px;
}

/* ✨ NUOVO: Info prodotto con badge KPI-style */
.item-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.item-nome {
    font-weight: 600;
    color: #2c3e50;
}

.item-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.item-note {
    font-size: 0.85rem;
    color: #666;
    font-style: italic;
    margin-top: 4px;
    padding-left: 4px;
}

/* ✨ Badge modifiche ingredienti (KPI-style) */
.pf-mod-add {
    background: linear-gradient(135deg, #fff9e6, #f1d394);
    color: #8b5a00;
    border-left: 3px solid #F4C063;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
}

.pf-mod-postcottura {
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
    color: #1565c0;
    border: 2px solid #2196f3;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 700;
}

.pf-mod-impasto {
    background: linear-gradient(135deg, #f3e5f5, #e1bee7);
    color: #6a1b9a;
    border: 2px solid #9c27b0;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 700;
}

.pf-mod-remove {
    background: linear-gradient(135deg, #ffebee, #ffcdd2);
    color: #c62828;
    border-left: 3px solid #ef5350;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
}

.item-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-qty {
    width: 32px;
    height: 32px;
    border: 2px solid #71a894;
    background: white;
    color: #71a894;
    border-radius: 6px;
    font-weight: 700;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-qty:hover {
    background: #71a894;
    color: white;
}

.item-quantita {
    padding: 4px 12px;
    background: #e3f2fd;
    color: #1976d2;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.9em;
    min-width: 50px;
    text-align: center;
}

.item-prezzo {
    font-weight: 700;
    color: #71a894;
    font-size: 1.05em;
    min-width: 70px;
    text-align: right;
}

.info-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.info-grid .info-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 15px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.info-grid .info-label {
    font-weight: 600;
    color: #6c757d;
}

.info-grid .info-value {
    font-weight: 600;
    color: #2c3e50;
    text-align: right;
}

.no-items {
    text-align: center;
    color: #999;
    padding: 20px;
    font-style: italic;
}

/* ===== GPS SIDEBAR ===== */
.gps-sidebar {
    background: white;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #71a894;
}

.sidebar-header h3 {
    font-size: 1.3em;
    color: #71a894;
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.btn-expand-map {
    width: 40px;
    height: 40px;
    border: none;
    background: #71a894;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(113, 168, 148, 0.3);
}

.btn-expand-map:hover {
    background: #5a9178;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(113, 168, 148, 0.5);
}

.btn-close-sidebar {
    width: 40px;
    height: 40px;
    border: none;
    background: #ec676c;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.2em;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.btn-close-sidebar:hover {
    background: #d32f2f;
}

/* Mini mappa */
.mini-mappa {
    width: 100%;
    height: 250px;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 20px;
    border: 2px solid #e9ecef;
}

/* Lista rider */
.riders-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.rider-card-tracking {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.rider-card-tracking:hover {
    border-color: #71a894;
    box-shadow: 0 4px 12px rgba(113, 168, 148, 0.2);
    transform: translateX(-5px);
}

.rider-card-tracking.active {
    border-color: #71a894;
    background: linear-gradient(135deg, #e8f5f1 0%, #f0faf7 100%);
}

.rider-header-tracking {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.rider-nome-tracking {
    font-size: 1.1em;
    font-weight: 700;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 8px;
}

.rider-status-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 600;
}

.rider-status-badge.attivo {
    background: rgba(76, 175, 80, 0.15);
    color: #2e7d32;
}

.rider-status-badge.riposo {
    background: rgba(158, 158, 158, 0.15);
    color: #616161;
}

.rider-consegne {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.consegna-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: white;
    border-radius: 8px;
    border-left: 3px solid #71a894;
    font-size: 0.9em;
}

.consegna-item.urgente {
    border-left-color: #ec676c;
    background: #fff5f5;
}

.consegna-item.completato {
    opacity: 0.6;
    border-left-color: #9e9e9e;
}

.consegna-eta {
    font-weight: 700;
    color: #71a894;
}

.consegna-eta.urgente {
    color: #ec676c;
}

.rider-stats {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #e9ecef;
}

.stat-mini {
    flex: 1;
    text-align: center;
    font-size: 0.85em;
}

.stat-mini .value {
    font-weight: 700;
    color: #71a894;
    font-size: 1.2em;
}

.stat-mini .label {
    color: #6c757d;
    font-size: 0.9em;
}

/* Badge GPS nella card */
.badge-gps {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: linear-gradient(135deg, #2196f3 0%, #1976d2 100%);
    color: white;
    border: 2px solid transparent;
}

.badge-gps:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.4);
}

.badge-gps.vicino {
    background: linear-gradient(135deg, #ff9800 0%, #f57c00 100%);
    animation: pulse-gps 1.5s infinite;
}

.badge-gps.arrivato {
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
}

@keyframes pulse-gps {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

/* ===== MODAL MAPPA GRANDE ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal-mappa {
    background: white;
    border-radius: 20px;
    width: 90%;
    max-width: 1000px;
    height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-fullscreen-map {
    background: white;
    border-radius: 20px;
    width: 95%;
    max-width: 1400px;
    height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.fullscreen-map-container {
    flex: 1;
    position: relative;
    border-radius: 0 0 20px 20px;
    overflow: hidden;
}

.modal-header {
    padding: 20px 25px;
    border-bottom: 2px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.3em;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-close-modal {
    width: 40px;
    height: 40px;
    border: none;
    background: #ec676c;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.2em;
    transition: all 0.3s ease;
}

.btn-close-modal:hover {
    background: #d32f2f;
}

.modal-body {
    flex: 1;
    position: relative;
    display: flex;
}

.mappa-container {
    flex: 1;
    height: 100%;
    min-height: 400px;
}

.mappa-info-panel {
    width: 300px;
    padding: 20px;
    background: #f8f9fa;
    border-left: 2px solid #e9ecef;
    overflow-y: auto;
}

.info-section {
    margin-bottom: 20px;
}

.info-section h4 {
    font-size: 1.1em;
    color: #71a894;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #e9ecef;
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    color: #6c757d;
    font-size: 0.9em;
}

.info-value {
    font-weight: 700;
    color: #2c3e50;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
    .main-grid {
        grid-template-columns: 1fr;
    }

    .gps-sidebar {
        position: static;
        max-height: none;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .header-stats {
        padding: 20px;
    }

    .header-stats h2 {
        font-size: 1.4em;
    }

    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .analytics-live {
        grid-template-columns: repeat(2, 1fr);
    }

    .toolbar-top {
        flex-direction: column;
        align-items: stretch;
    }

    .search-bar {
        max-width: 100%;
    }

    .filtri-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    .modal-mappa {
        width: 100%;
        height: 90vh;
    }

    .mappa-info-panel {
        display: none;
    }
}

/* ===== RASPBERRY PI 5 OPTIMIZATIONS ===== */
/* Minimal animations for better performance */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Hardware-accelerated transforms */
.ordine-card,
.btn-rush,
.btn-action,
.rider-card-tracking,
.timeline-marker {
    will-change: transform;
    transform: translateZ(0);
}

/* ===================================================================
   MODAL DIVIDI ORDINE
   =================================================================== */

/* Modal container specifico per dividi */
.modal-dividi {
    max-width: 700px !important;
    max-height: 90vh;
    overflow: hidden;  /* Rimuove scroll esterno - solo scroll interno nella lista prodotti */
    display: flex;
    flex-direction: column;
}

/* Header info ordine - Layout compatto */
.dividi-header-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    margin-bottom: 15px;
    border: 1px solid #dee2e6;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.9em;
}

.info-label {
    font-weight: 600;
    color: #6c757d;
}

.info-value {
    font-weight: 700;
    color: #212529;
}

.info-value.highlight {
    color: #71a894;
    font-size: 1.1em;
}

/* Modal body - scrollabile internamente */
.modal-dividi .modal-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Modal footer - fisso in basso */
.modal-dividi .modal-footer {
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
    background: #f8f9fa;
    border-top: 2px solid #dee2e6;
}

/* Istruzioni - RIMOSSA per semplificare */
.dividi-istruzioni {
    display: none;  /* Nascondi per ridurre ingombro */
}

/* Sezione prodotti */
.dividi-prodotti-section {
    margin-bottom: 15px;
}

.section-title {
    font-size: 1.1em;
    font-weight: 700;
    margin-bottom: 12px;
    color: #212529;
}

.prodotti-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

/* Grid prodotti scomposti - singola colonna per layout snello */
.prodotti-dividi-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 400px;  /* Aumentato per mostrare più prodotti */
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;

    /* Scrollbar più sottile */
    scrollbar-width: thin;
    scrollbar-color: #71a894 #e9ecef;
}

/* Webkit scrollbar styling */
.prodotti-dividi-grid::-webkit-scrollbar {
    width: 8px;
}

.prodotti-dividi-grid::-webkit-scrollbar-track {
    background: #e9ecef;
    border-radius: 4px;
}

.prodotti-dividi-grid::-webkit-scrollbar-thumb {
    background: #71a894;
    border-radius: 4px;
}

.prodotti-dividi-grid::-webkit-scrollbar-thumb:hover {
    background: #5a8c79;
}

.no-prodotti {
    text-align: center;
    padding: 30px;
    color: #6c757d;
    font-size: 1.1em;
}

/* Card prodotto singolo - più compatta */
.prodotto-dividi-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    min-height: 50px;  /* Altezza minima consistente */
}

.prodotto-dividi-card:hover {
    border-color: #71a894;
    box-shadow: 0 2px 8px rgba(113, 168, 148, 0.2);
}

.prodotto-dividi-card.selezionato {
    background: #e8f5f1;
    border-color: #71a894;
    box-shadow: 0 2px 8px rgba(113, 168, 148, 0.3);
}

.card-checkbox {
    flex-shrink: 0;
}

.card-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.card-content {
    flex: 1;
}

.prodotto-nome {
    font-weight: 600;
    color: #212529;
    margin-bottom: 4px;
}

.prodotto-note {
    font-size: 0.85em;
    color: #6c757d;
    font-style: italic;
}

.card-prezzo {
    font-weight: 700;
    color: #71a894;
    font-size: 1.1em;
}

/* Riepilogo selezione - più compatto */
.dividi-riepilogo {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: linear-gradient(135deg, #fff3cd 0%, #ffecb3 100%);
    border: 2px solid #ffc107;
    border-radius: 8px;
    margin-top: 12px;
    box-shadow: 0 2px 4px rgba(255, 193, 7, 0.2);
}

.riepilogo-item {
    display: flex;
    gap: 10px;
    align-items: center;
    font-weight: 600;
}

.totale-highlight {
    font-size: 1.3em;
    color: #71a894;
    font-weight: 700;
}

/* Ottimizzazioni layout modale */
.modal-dividi .prodotti-controls .btn {
    flex: 1;
    justify-content: center;
}

/* Responsive - Mobile */
@media (max-width: 768px) {
    .modal-dividi {
        max-width: 95% !important;
        max-height: 95vh;
    }

    .dividi-header-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .prodotti-dividi-grid {
        max-height: 300px;
    }

    .dividi-riepilogo {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px 20px;
}

/* ===================================================================
   MODAL DIVIDI V2 - REDESIGN COMPLETO
   =================================================================== */

/* Container principale V2 */
.modal-dividi-v2 {
    max-width: 900px !important;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #ffffff;
}

/* Header ridisegnato - ultra compatto */
.modal-header-dividi {
    background: linear-gradient(135deg, #71a894 0%, #5a8c79 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 12px 12px 0 0;
    flex-shrink: 0;
}

.modal-header-dividi .header-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.modal-header-dividi h2 {
    margin: 0;
    font-size: 1.4em;
    font-weight: 700;
}

.modal-header-dividi .ordine-label {
    font-size: 0.9em;
    opacity: 0.95;
    font-weight: 500;
}

/* Stats Bar - Barra info sempre visibile */
.dividi-stats-bar {
    display: flex;
    gap: 12px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 2px solid #dee2e6;
    flex-shrink: 0;
}

.stat-chip {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 14px;
    background: white;
    border-radius: 8px;
    border: 2px solid #e9ecef;
    text-align: center;
}

.stat-chip.highlight {
    border-color: #ffc107;
    background: #fff3cd;
}

.stat-chip.success {
    border-color: #71a894;
    background: #e8f5f1;
}

.stat-chip .stat-label {
    font-size: 0.75em;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-chip .stat-value {
    font-size: 1.3em;
    font-weight: 700;
    color: #212529;
}

/* Body scrollabile */
.modal-body-dividi {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    background: #f8f9fa;
}

/* Toolbar rapida */
.dividi-toolbar {
    display: flex;
    gap: 8px;
    padding: 12px 20px;
    background: white;
    border-bottom: 1px solid #dee2e6;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.btn-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9em;
    font-weight: 600;
}

.btn-toolbar:hover {
    background: #e9ecef;
    border-color: #71a894;
}

.btn-toolbar .icon {
    font-size: 1.1em;
}

.btn-toolbar .label {
    color: #495057;
}

.toolbar-spacer {
    flex: 1;
}

.selected-total {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: linear-gradient(135deg, #fff3cd 0%, #ffecb3 100%);
    border: 2px solid #ffc107;
    border-radius: 6px;
}

.selected-total .label {
    font-size: 0.85em;
    font-weight: 600;
    color: #856404;
}

.selected-total .amount {
    font-size: 1.1em;
    font-weight: 700;
    color: #71a894;
}

/* Tabella prodotti - STILE COMPATTO */
.prodotti-table {
    padding: 12px 20px 20px 20px;
}

/* ROW prodotto - table-like */
.prodotto-row {
    display: grid;
    grid-template-columns: 40px 1fr 80px 24px;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.prodotto-row:hover {
    border-color: #71a894;
    box-shadow: 0 2px 6px rgba(113, 168, 148, 0.15);
    transform: translateY(-1px);
}

.prodotto-row.selezionato {
    background: linear-gradient(135deg, #e8f5f1 0%, #d4edda 100%);
    border-color: #71a894;
    box-shadow: 0 3px 8px rgba(113, 168, 148, 0.25);
}

.prodotto-row .checkbox-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
}

.prodotto-row .checkbox-wrapper input[type="checkbox"] {
    width: 22px;
    height: 22px;
    cursor: pointer;
    accent-color: #71a894;
}

.prodotto-row .prodotto-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.prodotto-row .prodotto-nome {
    font-weight: 600;
    color: #212529;
    font-size: 0.95em;
}

.prodotto-row .prodotto-note {
    font-size: 0.8em;
    color: #6c757d;
    font-style: italic;
}

.prodotto-row .prodotto-prezzo {
    font-weight: 700;
    color: #71a894;
    font-size: 1em;
    text-align: right;
}

.prodotto-row .prodotto-status {
    font-size: 1.2em;
}

/* Loading state */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 12px;
    color: #6c757d;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e9ecef;
    border-top-color: #71a894;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Footer ridisegnato - sticky e moderno */
.modal-footer-dividi {
    display: flex;
    gap: 10px;
    padding: 16px 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-top: 2px solid #dee2e6;
    flex-shrink: 0;
}

.btn-footer {
    flex: 1;
    padding: 14px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-footer:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

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

.btn-cancel {
    background: #6c757d;
    color: white;
}

.btn-cancel:hover {
    background: #5a6268;
}

.btn-partial {
    background: #ffc107;
    color: #212529;
}

.btn-partial:hover {
    background: #e0a800;
}

.btn-confirm {
    background: linear-gradient(135deg, #28a745 0%, #20803b 100%);
    color: white;
    flex: 1.5;
}

.btn-confirm:hover {
    background: linear-gradient(135deg, #218838 0%, #1e7e34 100%);
}

/* Responsive V2 */
@media (max-width: 768px) {
    .modal-dividi-v2 {
        max-width: 95% !important;
        max-height: 92vh;
    }

    .dividi-stats-bar {
        flex-direction: column;
        gap: 8px;
    }

    .prodotto-row {
        grid-template-columns: 36px 1fr 70px;
        gap: 10px;
        padding: 10px;
    }

    .prodotto-row .prodotto-status {
        display: none;
    }

    .modal-footer-dividi {
        flex-direction: column;
    }

    .btn-footer {
        width: 100%;
    }
}

.empty-icon {
    font-size: 4em;
    margin-bottom: 15px;
}

.empty-text {
    font-size: 1.2em;
    color: #6c757d;
    font-weight: 600;
}
