/* ===================================================================
   ORDINI ATTIVI - PizzaFactory 2.0
   CSS per scheda ordini attivi con filtri, search, urgenza e reminder
   =================================================================== */

/* ===== TOOLBAR FILTRI ===== */
.toolbar {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 25px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* Search bar */
.search-bar {
    margin-bottom: 20px;
}

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

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

/* Filtri tipo */
.filtri-tipo {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.btn-filtro {
    padding: 12px 20px;
    border: 2px solid #e9ecef;
    background: white;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-filtro:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

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

.filtro-count {
    background: rgba(0,0,0,0.1);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.9em;
}

.btn-filtro.active .filtro-count {
    background: rgba(255,255,255,0.3);
}

/* Controlli ordinamento */
.controlli {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.select-ordina {
    padding: 10px 15px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 1em;
    cursor: pointer;
    background: white;
}

.toggle-completati {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

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

/* ===== ORDINI LISTA (con margini laterali) ===== */
.ordini-lista {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-width: 1400px;  /* Larghezza massima */
    margin: 0 auto;     /* Centra */
    padding: 0 20px;    /* Margini laterali */
}

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

/* ===== CARD ORDINE (tutta larghezza) ===== */
.ordine-card {
    background: white;
    border-radius: 20px;  /* Più stondato (era 12px) */
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    border-left: 6px solid;
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 20px;
    align-items: center;
    overflow: hidden; /* ⭐ FIX: contiene badge urgente */
}

.ordine-card:hover {
    box-shadow: 0 6px 16px rgba(0,0,0,0.15);
}

/* Colori bordo per tipo */
.ordine-card.tipo-tavolo { border-left-color: #ec676c; }
.ordine-card.tipo-delivery { border-left-color: #71a894; }
.ordine-card.tipo-ritiro { border-left-color: #f4c063; }

/* Colori background per stato (normale) */
.ordine-card.stato-1 { background: #ecdbbc; }
.ordine-card.stato-2 { background: #f4c063; }
.ordine-card.stato-3 { background: #71a894; color: white; }
.ordine-card.stato-4 {
    background: #71a894;
    color: white;
    opacity: 0.8;
}

/* STATO 3 ROSSO solo per delivery e ritiro (In Consegna / Pronto al banco) */
/* Tavolo stato 3 resta VERDE */
.ordine-card.stato-3.tipo-delivery,
.ordine-card.stato-3.tipo-ritiro {
    background: #ec676c !important;
    color: white;
    animation: pulse-urgente 2s infinite;
    border-left-width: 8px;
}

/* URGENZA - sovrascrive colori stato (solo per stati 1-2) */
.ordine-card.urgenza-attenzione:not(.stato-3):not(.stato-4) {
    background: #ff9500 !important;
    color: white;
}

.ordine-card.urgenza-critica:not(.stato-3):not(.stato-4) {
    background: #ec676c !important;
    color: white;
    animation: pulse-urgente 2s infinite;
    border-left-width: 8px;
}

@keyframes pulse-urgente {
    0%, 100% { 
        box-shadow: 0 4px 12px rgba(236, 103, 108, 0.4);
    }
    50% { 
        box-shadow: 0 8px 24px rgba(236, 103, 108, 0.6);
    }
}

/* Badge urgenza - FIX posizione */
.badge-urgenza {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255,255,255,0.3);
    padding: 6px 12px; /* ⭐ ridotto padding */
    border-radius: 15px; /* ⭐ ridotto radius */
    font-weight: bold;
    font-size: 0.95em; /* ⭐ ridotto font */
    animation: shake 0.5s infinite;
    z-index: 10;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); } /* ⭐ ridotto movimento */
    75% { transform: translateX(3px); }
}

/* Card completate più piccole e trasparenti */
.ordine-card.completato {
    padding: 15px;
    font-size: 0.9em;
    grid-template-columns: auto 1fr auto;
}

/* Header card (colonna sinistra) */
.card-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 120px;
    padding: 15px;
    border-radius: 15px;  /* Stondato */
    background: inherit;  /* Eredita colore dalla card */
}

/* Specifica background per ogni stato (opzionale se inherit non funziona) */
.stato-1 .card-header { background: #ecdbbc; }
.stato-2 .card-header { background: #f4c063; }
.stato-3 .card-header { background: #71a894; }
.stato-4 .card-header { background: #71a894; }

.card-tipo {
    font-size: 1.3em;
    font-weight: bold;
}

.card-codice {
    font-size: 0.9em; /* ⭐ ridotto */
    font-weight: 600;
    opacity: 0.9;
    word-break: break-word; /* ⭐ evita overflow */
}

.card-totale {
    font-size: 1.5em;
    font-weight: bold;
    margin-top: 5px;
}

/* Body card (colonna centrale) */
.card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0; /* ⭐ permette shrink */
}

.card-cliente {
    font-size: 1.3em;
    font-weight: 700;
}

.card-indirizzo {
    font-size: 1em;
    opacity: 0.9;
    overflow: hidden; /* ⭐ FIX */
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-orario {
    font-size: 1.1em;
    padding: 8px 12px;
    background: rgba(255,255,255,0.2);
    border-radius: 8px;
    display: inline-block;
    margin-top: 5px;
    font-weight: 600;
    width: fit-content; /* ⭐ FIX */
}

/* EMOJI REMINDER */
.card-reminder {
    display: flex;
    gap: 15px;
    margin-top: 10px;
    padding: 8px 12px;
    background: rgba(255,255,255,0.25);
    border-radius: 8px;
    font-size: 1.1em;
    flex-wrap: wrap; /* ⭐ FIX wrap */
}

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

.reminder-emoji {
    font-size: 1.3em;
    animation: bounce 1s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

/* Footer card (colonna destra) */
.card-footer {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: flex-end;
    min-width: fit-content; /* ⭐ FIX */
}

/* Pallini stato */
.stato-pallini {
    display: flex;
    gap: 10px;
    align-items: center;
}

.pallino {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    border: 2px solid rgba(255,255,255,0.5);
    transition: all 0.3s ease;
}

.pallino.attivo {
    background: white;
    box-shadow: 0 0 12px rgba(255,255,255,0.9);
    transform: scale(1.3);
    border-color: white;
}

/* Bottoni azioni */
.card-actions {
    display: flex;
    gap: 8px;
    flex-direction: row;
    flex-wrap: wrap;
}

.btn-action {
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.2s ease;
    background: rgba(255,255,255,0.3);
    color: inherit;
    font-weight: 700;
    white-space: nowrap;
}

.btn-action:hover {
    background: rgba(255,255,255,0.5);
    transform: scale(1.05);
}

.btn-action:active {
    transform: scale(0.98);
}

/* Pulsanti icona compatti */
.btn-icon {
    width: 42px;
    height: 42px;
    padding: 0;
    border: 2px solid rgba(255,255,255,0.4);
    background: rgba(255,255,255,0.25);
    border-radius: 10px;
    cursor: pointer;
    font-size: 1.4em;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.btn-icon:hover {
    background: rgba(255,255,255,0.5);
    border-color: rgba(255,255,255,0.8);
    transform: scale(1.1);
}

.btn-icon:active {
    transform: scale(0.95);
}

.btn-icon.btn-whatsapp {
    background: rgba(37, 211, 102, 0.3);
    border-color: rgba(37, 211, 102, 0.5);
}

.btn-icon.btn-whatsapp:hover {
    background: rgba(37, 211, 102, 0.5);
    border-color: #25D366;
}

.btn-icon.btn-rider {
    background: rgba(18, 140, 126, 0.3);
    border-color: rgba(18, 140, 126, 0.5);
}

.btn-icon.btn-rider:hover {
    background: rgba(18, 140, 126, 0.5);
    border-color: #128C7E;
}

.btn-icon.btn-assegna {
    background: rgba(113, 168, 148, 0.2);
    border-color: rgba(113, 168, 148, 0.4);
}

.btn-icon.btn-assegna:hover {
    background: rgba(113, 168, 148, 0.4);
    border-color: #71A894;
}

.btn-icon.btn-avanza {
    background: rgba(76, 175, 80, 0.3);
    border-color: rgba(76, 175, 80, 0.5);
}

.btn-icon.btn-avanza:hover {
    background: rgba(76, 175, 80, 0.5);
    border-color: #4CAF50;
}

.btn-modifica {
    background: rgba(255,255,255,0.25);
}

.btn-avanza {
    background: white;
    color: #71a894;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.btn-avanza:hover {
    background: #f8f9fa;
}

/* Badge tipo ordine */
.badge-tipo {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 600;
    background: rgba(255,255,255,0.3);
}

/* ===== HEADER INCASSO SERATA ===== */
.header-incasso {
    background: white;
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

.header-incasso h2 {
    color: #71a894;
    margin-bottom: 15px;
    font-size: 1.8em;
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.stat-box {
    text-align: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
}

.stat-label {
    font-size: 0.9em;
    color: #666;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 1.8em;
    font-weight: bold;
}

.stat-value.totale { color: #71a894; }
.stat-value.pagato { color: #28a745; }
.stat-value.da-pagare { color: #dc3545; }
.stat-value.ordini { color: #f4c063; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .ordine-card {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .card-footer {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    
    .card-actions {
        flex-direction: row;
    }
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .filtri-tipo {
        gap: 8px;
    }
    
    .btn-filtro {
        font-size: 0.9em;
        padding: 10px 15px;
    }
}

/* ===== ESPANSIONE CARD ===== */
.card-dettagli {
    display: none;
    grid-column: 1 / -1;
    margin-top: 15px;
    padding: 15px;
    background: rgba(255,255,255,0.2);
    border-radius: 8px;
}

.ordine-card.espansa .card-dettagli {
    display: block;
}

.ordine-card.espansa {
    cursor: default;
}

.ordine-card:not(.espansa) {
    cursor: pointer;
}

.card-dettagli h4 {
    margin: 0 0 10px 0;
    font-size: 1.1em;
}

.dettaglio-item {
    padding: 5px 0;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.dettaglio-item:last-child {
    border-bottom: none;
}

/* ===== VISTA COMPATTA ===== */
.modalita-compatta .ordine-card {
    padding: 12px;
    font-size: 0.85em;
    grid-template-columns: auto 1fr auto;
    gap: 12px;
}

.modalita-compatta .card-header {
    gap: 5px;
    min-width: 90px;
}

.modalita-compatta .card-tipo {
    font-size: 1.1em;
}

.modalita-compatta .card-codice {
    font-size: 0.85em;
}

.modalita-compatta .card-totale {
    font-size: 1.2em;
}

.modalita-compatta .card-body {
    gap: 5px;
}

.modalita-compatta .card-cliente {
    font-size: 1.1em;
}

.modalita-compatta .card-indirizzo,
.modalita-compatta .card-orario {
    font-size: 0.9em;
}

.modalita-compatta .card-reminder {
    font-size: 0.95em;
    padding: 5px 8px;
}

.modalita-compatta .pallino {
    width: 14px;
    height: 14px;
}

.modalita-compatta .btn-action {
    padding: 6px 12px;
    font-size: 0.9em;
}

.modalita-compatta .badge-urgenza {
    font-size: 0.85em;
    padding: 4px 8px;
}

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

/* Modal container specifico per dividi */
.modal-dividi {
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
}

/* Header info ordine */
.dividi-header-info {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    margin-bottom: 20px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

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

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

/* Istruzioni */
.dividi-istruzioni {
    background: #e7f3ff;
    border-left: 4px solid #007bff;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.dividi-istruzioni p {
    margin: 0 0 10px 0;
}

.dividi-istruzioni ol {
    margin: 0;
    padding-left: 20px;
}

.dividi-istruzioni ol li {
    margin-bottom: 5px;
}

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

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

.prodotti-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

/* Grid prodotti scomposti */
.prodotti-dividi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 10px;
}

/* Card prodotto singolo */
.prodotto-dividi-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

/* ===== MODALE SELEZIONE RIDER ===== */
.rider-lista {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.rider-item {
    padding: 18px 24px;
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.rider-item:hover {
    border-color: #25D366;
    background: #f0fff4;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.2);
}

.rider-nome {
    font-size: 1.1em;
    font-weight: 700;
    color: #2c3e50;
}

.rider-tel {
    font-size: 0.95em;
    color: #7f8c8d;
    font-family: 'Courier New', monospace;
}

.rider-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f5f5f5;
}

.rider-item.disabled:hover {
    border-color: #e9ecef;
    background: #f5f5f5;
    transform: none;
    box-shadow: none;
}

/* Modale assegnazione rider */
.rider-item-assegna {
    padding: 18px 24px;
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.rider-item-assegna:hover {
    border-color: #71A894;
    background: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(113, 168, 148, 0.2);
}

.rider-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.rider-stats {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.badge-consegne,
.badge-km {
    background: linear-gradient(135deg, rgba(113, 168, 148, 0.15), rgba(113, 168, 148, 0.05));
    color: var(--primary-color);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 600;
    border: 1px solid rgba(113, 168, 148, 0.3);
}

.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 */
.dividi-riepilogo {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #fff3cd;
    border: 2px solid #ffc107;
    border-radius: 10px;
    margin-top: 15px;
}

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

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

/* Bottoni */
.btn-dividi {
    background: #ffc107;
    color: #212529;
}

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

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

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

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

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: #6c757d;
    font-style: italic;
}

/* Dettagli ordine espanso - Modifiche ingredienti */
.dettaglio-item-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.badge-formato {
    background: var(--primary-color);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75em;
    font-weight: 600;
}

.dettaglio-modifica-add,
.dettaglio-modifica-remove,
.dettaglio-note {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    padding: 4px 8px;
    margin-top: 4px;
    border-radius: 4px;
    font-size: 0.9em;
}

.dettaglio-modifica-add {
    background: rgba(76, 175, 80, 0.1);
    color: #2e7d32;
    border-left: 3px solid #4caf50;
}

.dettaglio-modifica-remove {
    background: rgba(244, 67, 54, 0.1);
    color: #c62828;
    border-left: 3px solid #f44336;
}

.dettaglio-note {
    background: rgba(255, 193, 7, 0.1);
    color: #f57c00;
    border-left: 3px solid #ffc107;
    font-style: italic;
}

.modifica-icon {
    flex-shrink: 0;
    font-size: 1.1em;
}

/* Responsive */
@media (max-width: 768px) {
    .dividi-header-info {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .prodotti-dividi-grid {
        grid-template-columns: 1fr;
    }

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