/* ==========================================
   Stili per tabella OnOrder
   ========================================== */

.onorder-table th {
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
}

.onorder-table td {
    vertical-align: middle;
}

.onorder-table code {
    background: #f8f9fa;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.85rem;
}

.onorder-table .btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
}

/* Animazione caricamento */
@keyframes onorder-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.onorder-container .material-icons.spin {
    animation: onorder-spin 1s linear infinite;
    display: inline-block;
    vertical-align: middle;
    margin-right: 5px;
}

/* ==========================================
   Filtro categoria
   ========================================== */

.onorder-filter {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.onorder-filter label {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0;
}

.onorder-filter select {
  cursor: pointer;
}

/* Animazione filtraggio */
.onorder-table tbody tr {
  transition: opacity 0.2s ease;
}

.onorder-table tbody tr[style*="display: none"] {
  opacity: 0;
}

/* Contatore risultati */
#onorder-results-count {
  font-weight: 500;
  color: #6c757d;
}

/* ==========================================
   ✅ ORDINAMENTO PREZZO - NUOVI STILI
   ========================================== */

/* Header ordinabile: cursor e transizioni */
.onorder-sortable {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s ease;
    position: relative;
}

/* Hover effect sull'header ordinabile */
.onorder-sortable:hover {
    background-color: rgba(0, 0, 0, 0.08) !important;
}

/* Icona di ordinamento: stile base */
.onorder-sort-icon {
    font-size: 14px !important;
    vertical-align: middle;
    margin-left: 4px;
    opacity: 0.5;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
}

/* Hover sull'icona: diventa più visibile */
.onorder-sortable:hover .onorder-sort-icon {
    opacity: 1;
}

/* Icona attiva: stato ASC (verde) */
.onorder-sortable[data-sort-order="asc"] .onorder-sort-icon {
    opacity: 1;
    color: #4caf50;
}

/* Icona attiva: stato DESC (rosso) */
.onorder-sortable[data-sort-order="desc"] .onorder-sort-icon {
    opacity: 1;
    color: #f44336;
}

/* Icona inattiva: stato none (grigio) */
.onorder-sortable[data-sort-order="none"] .onorder-sort-icon,
.onorder-sortable:not([data-sort-order]) .onorder-sort-icon {
    opacity: 0.5;
    color: inherit;
}

/* Colonna prezzo: allineamento e stile */
.onorder-price {
    font-weight: 500;
    white-space: nowrap;
}

/* Evidenzia righe al passaggio mouse */
.onorder-table tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

/* ==========================================
   Dropdown filtro nell'header (Categoria)
   ========================================== */

/* Stile per il select dentro l'header della tabella */
#onorder-table-body thead th:nth-child(3) {
    min-width: 150px;
    padding: 0.5rem !important;
}

#onorder-category-filter {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s ease;
    cursor: pointer;
    min-width: 130px;
    max-width: 180px;
}

#onorder-category-filter:hover,
#onorder-category-filter:focus {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.6);
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.15);
}

#onorder-category-filter option {
    background: #fff;
    color: #333;
    padding: 8px;
}

/* ==========================================
   Responsive
   ========================================== */

/* Mobile: filtro sotto su schermi piccoli */
@media (max-width: 576px) {
  .onorder-filter {
    flex-direction: column;
    align-items: flex-start;
  }
  .onorder-filter select {
    width: 100%;
    max-width: none;
  }
  
  /* Header tabella: riduci padding su mobile */
  .onorder-table th,
  .onorder-table td {
    padding: 0.5rem !important;
    font-size: 0.85rem;
  }
  
  /* Dropdown filtro: full width su mobile */
  #onorder-category-filter {
    min-width: 100%;
    max-width: 100%;
    font-size: 0.9rem;
  }
  
  /* Icona ordinamento: più piccola su mobile */
  .onorder-sort-icon {
    font-size: 12px !important;
    margin-left: 2px;
  }
}

/* Tablet: aggiustamenti intermedi */
@media (min-width: 577px) and (max-width: 991px) {
  #onorder-category-filter {
    min-width: 120px;
    font-size: 0.75rem;
  }
  
  .onorder-table img {
    max-width: 50px;
  }
}

/* ==========================================
   Accessibilità & Focus
   ========================================== */

/* Focus visibile per tastiera */
.onorder-sortable:focus,
#onorder-category-filter:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Riduci animazioni per utenti che preferiscono movimento ridotto */
@media (prefers-reduced-motion: reduce) {
    .onorder-table tbody tr,
    .onorder-sort-icon,
    #onorder-category-filter {
        transition: none !important;
    }
    
    .onorder-container .material-icons.spin {
        animation: none;
    }
}

/* Badge ultimo aggiornamento */
#onorder-last-update {
    display: inline-flex;
    align-items: center;
    background: rgba(102, 126, 234, 0.1);
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 0.75rem;
    color: #666;
}

#onorder-last-update .material-icons {
    font-size: 14px !important;
    color: #667eea;
    margin-right: 4px !important;
}

/* Animazione sottile al caricamento */
#onorder-last-update {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ✅ FORZA ICONA E TESTO SULLA STESSA RIGA */
.onorder-sortable {
    white-space: nowrap !important;
    display: inline-flex !important;
    align-items: center;
    gap: 4px;
}

/* ✅ ASSICURA CHE L'ICONA RESTI INLINE */
.onorder-sort-icon {
    display: inline-flex !important;
    vertical-align: middle !important;
    margin-left: 4px;
    flex-shrink: 0; /* Evita che l'icona si schiacci */
}

/* ✅ ASSICURA LARGHEZZA MINIMA ALLA COLONNA PREZZO */
#onorder-table-body thead th:nth-child(4) {
    min-width: 120px;
}