/* Fix filtri - Versione Dark Theme Coerente */

/* Rimuovi solo l'header "Filtri Avanzati" mantenendo il tema dark */
.filters-header {
    display: none !important;
}

/* Mantieni il pannello con tema dark */
#filtersPanel {
    /* Usa le variabili CSS del tema esistente */
    background: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 20px;
    margin-bottom: 0;
}

/* Contenitore filtri orizzontale con wrap */
.filters-content {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    max-height: 150px; /* Aumentato per più campi */
    overflow-y: auto; /* Scroll se necessario */
    padding: 5px 0;
}

/* Scrollbar personalizzata per filtri */
.filters-content::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.filters-content::-webkit-scrollbar-track {
    background: var(--surface-hover);
    border-radius: 3px;
}

.filters-content::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 3px;
    opacity: 0.7;
}

.filters-content::-webkit-scrollbar-thumb:hover {
    opacity: 1;
}

/* Gruppo filtro inline compatto */
.filter-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
    min-width: 180px; /* Larghezza minima per leggibilità */
}

.filter-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    margin: 0;
}

.filter-group input,
.filter-input {
    padding: 5px 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 12px;
    height: 28px;
    width: 120px; /* Ridotto per più filtri */
    background-color: var(--surface-hover);
    color: var(--text-primary);
    transition: var(--transition);
}

.filter-group input:focus,
.filter-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgb(59 130 246 / 0.2);
    background-color: var(--surface-color);
}

/* Footer filtri */
.filters-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.record-count {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

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

.filter-actions button {
    padding: 6px 12px;
    font-size: 13px;
    height: 30px;
}

/* Placeholder */
.filter-group input::placeholder,
.filter-input::placeholder {
    color: var(--text-muted);
    font-size: 12px;
}

/* Messaggio filtri vuoti */
.filters-content:empty::before {
    content: "Nessun filtro disponibile per questa query";
    color: var(--text-muted);
    font-size: 13px;
    font-style: italic;
}

/* === CUSTOM BUTTONS === */

.custom-buttons-container {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    flex: 1;
    justify-content: center;
    padding: 0 15px;
}

.custom-action-btn {
    white-space: nowrap;
    font-size: 13px;
    padding: 6px 14px;
    transition: all 0.2s ease;
}

.custom-action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.custom-action-btn i {
    margin-right: 5px;
}

/* Colori pulsanti */
.btn-warning {
    background: #f59e0b;
    color: #000;
    border: 1px solid #f59e0b;
}

.btn-warning:hover:not(:disabled) {
    background: #d97706;
    border-color: #d97706;
}

.btn-danger {
    background: #ef4444;
    color: #fff;
    border: 1px solid #ef4444;
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
    border-color: #dc2626;
}

.btn-success {
    background: #22c55e;
    color: #fff;
    border: 1px solid #22c55e;
}

.btn-success:hover:not(:disabled) {
    background: #16a34a;
    border-color: #16a34a;
}

/* === CHECKBOX SELEZIONE RIGHE === */

.checkbox-column {
    width: 40px;
    min-width: 40px;
    max-width: 40px;
    text-align: center;
    padding: 4px !important;
}

.checkbox-column input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

/* Riga selezionata */
tr.row-selected {
    background: rgba(59, 130, 246, 0.15) !important;
}

tr.row-selected:hover {
    background: rgba(59, 130, 246, 0.25) !important;
}

/* === Pulsanti azione "solo icona" === */
/* Usato dai custom_buttons con flag JSON `icon_only: true`.
   Mantiene il colore del .btn-* sottostante, ma rimuove il testo e
   rende il pulsante compatto/quadrato. Il testo del label resta come
   tooltip nativo (attributo title). */
.btn.btn-icon-only {
    padding: 0;
    width: 38px;
    height: 38px;
    min-width: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
}
.btn.btn-icon-only i {
    margin: 0;
    font-size: 14px;
}

/* === FILTRI TIPIZZATI: bool tri-stato + data con modalità (dark) === */

/* Select dei filtri (bool tri-stato e modalità data) coerenti col tema scuro */
select.filter-input {
    width: auto;
    min-width: 92px;
    cursor: pointer;
    background-color: var(--surface-hover);
    color: var(--text-primary);
    color-scheme: dark;
    appearance: none;
    -webkit-appearance: none;
    padding-right: 22px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%2394a3b8' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

select.filter-input option {
    background-color: var(--surface-color);
    color: var(--text-primary);
}

/* Contenitore filtro data: modalità + input */
.filter-date {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
}

.filter-date-inputs {
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-date-mode {
    min-width: 86px;
}

/* Input data nativo in stile dark: forza il picker/calendario su tema scuro */
input[type="date"].filter-input {
    width: 130px;
    color-scheme: dark;
}

input[type="date"].filter-input::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.7;
    filter: invert(0.8);
}

input[type="date"].filter-input::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

.filter-date-sep {
    color: var(--text-muted);
    font-size: 13px;
    user-select: none;
}