/**
 * GRUPPO ORSO - Unioni Tavoli CSS
 * Stili per configurazione unioni e suggerimenti AI
 */

/* ============================================
   SEZIONE CONFIGURAZIONE UNIONI
   ============================================ */

.unioni-tavoli-section .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.unioni-tavoli-section .section-header h3 {
    margin: 0;
}

.unioni-tavoli-section .section-description {
    color: var(--color-text-muted);
    font-size: 13px;
    margin-bottom: 20px;
}

/* Lista combinazioni */
.unioni-lista {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.unioni-lista .empty-state {
    text-align: center;
    padding: 40px;
    color: var(--color-text-muted);
    background: var(--color-surface);
    border-radius: 8px;
    border: 1px dashed var(--color-border);
}

.unione-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.unione-card:hover {
    border-color: var(--color-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.unione-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.unione-tavoli {
    font-weight: 600;
    color: var(--color-text);
    font-size: 15px;
}

.unione-posti {
    font-size: 13px;
    color: var(--color-text-muted);
    background: var(--color-bg);
    padding: 4px 10px;
    border-radius: 12px;
}

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

.unione-actions .btn-icon {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.unione-actions .btn-icon:hover {
    background: var(--color-bg);
}

.unione-actions .btn-icon.btn-danger:hover {
    background: rgba(231, 76, 60, 0.1);
}

/* ============================================
   MODALE AGGIUNGI/MODIFICA
   ============================================ */

.tavoli-checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.tavolo-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.tavolo-checkbox:hover {
    border-color: var(--color-primary);
}

.tavolo-checkbox input[type="checkbox"] {
    accent-color: var(--color-primary);
}

.tavolo-checkbox input[type="checkbox"]:checked + .tavolo-label {
    color: var(--color-primary);
    font-weight: 600;
}

.tavolo-checkbox .tavolo-label {
    flex: 1;
}

.tavolo-checkbox .tavolo-posti {
    font-size: 11px;
    color: var(--color-text-muted);
}

.form-hint {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--color-text-muted);
}

/* ============================================
   BOTTONE SUGGERISCI NELLA RIGA PRENOTAZIONE
   ============================================ */

.btn-suggest-ai {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-suggest-ai:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

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

/* Bottone suggerisci tutti (header) */
.btn-suggest-all {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 13px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.btn-suggest-all:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
}

/* ============================================
   MODALE SUGGERIMENTO SINGOLO
   ============================================ */

.suggerimento-prenotazione {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--color-bg);
    border-radius: 8px;
    margin-bottom: 20px;
}

.suggerimento-prenotazione strong {
    font-size: 15px;
}

.suggerimento-prenotazione span {
    color: var(--color-text-muted);
    font-size: 13px;
}

.suggerimento-risultato {
    text-align: center;
    padding: 24px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.suggerimento-risultato.success {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    border: 2px solid rgba(102, 126, 234, 0.3);
}

.suggerimento-risultato.warning {
    background: rgba(243, 156, 18, 0.1);
    border: 2px solid rgba(243, 156, 18, 0.3);
}

.suggerimento-tavoli {
    font-size: 28px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 8px;
}

.suggerimento-posti {
    font-size: 14px;
    color: var(--color-text-muted);
}

.suggerimento-motivo {
    padding: 16px;
    background: var(--color-surface);
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--color-text-secondary);
}

.suggerimento-motivo strong {
    color: var(--color-text);
}

/* ============================================
   MODALE SUGGERIMENTI MULTIPLI
   ============================================ */

.suggerimenti-multipli-body {
    max-height: 60vh;
    overflow-y: auto;
}

.suggerimenti-summary {
    text-align: center;
    padding: 12px;
    background: var(--color-bg);
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
    color: var(--color-text-muted);
}

.suggerimenti-lista {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.suggerimento-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 16px;
    align-items: center;
    padding: 12px 16px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.suggerimento-row.confirmed {
    background: rgba(46, 204, 113, 0.1);
    border-color: rgba(46, 204, 113, 0.3);
}

.suggerimento-row.rejected {
    opacity: 0.5;
}

.suggerimento-row-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.suggerimento-row-orario {
    font-weight: 600;
    font-size: 14px;
    color: var(--color-primary);
    min-width: 50px;
}

.suggerimento-row-cliente {
    font-size: 14px;
    color: var(--color-text);
}

.suggerimento-row-pax {
    font-size: 12px;
    color: var(--color-text-muted);
    background: var(--color-bg);
    padding: 2px 8px;
    border-radius: 10px;
}

.suggerimento-row-tavolo {
    font-weight: 600;
    font-size: 15px;
    color: var(--color-text);
    min-width: 100px;
    text-align: center;
}

.suggerimento-row-tavolo.no-suggestion {
    color: var(--color-text-muted);
    font-weight: normal;
}

.suggerimento-row-actions {
    display: flex;
    gap: 6px;
}

.suggerimento-row-actions .btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 4px;
}

.suggerimento-row-actions .btn-success {
    background: #27ae60;
    color: white;
    border: none;
}

.suggerimento-row-actions .btn-success:hover {
    background: #219a52;
}

.text-success {
    color: #27ae60;
    font-weight: 500;
}

.text-muted {
    color: var(--color-text-muted);
}

/* ============================================
   LOADING SPINNER
   ============================================ */

.loading-spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ============================================
   REGOLE AI
   ============================================ */

.regole-ai-section {
    margin-top: 32px;
}

.regole-ai-section .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.regole-ai-section .section-header h3 {
    margin: 0;
}

.regole-ai-section .section-description {
    color: var(--color-text-muted);
    font-size: 13px;
    margin-bottom: 20px;
}

.header-buttons {
    display: flex;
    gap: 8px;
}

.regole-lista {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.regole-lista .empty-state {
    text-align: center;
    padding: 40px;
    color: var(--color-text-muted);
    background: var(--color-surface);
    border-radius: 8px;
    border: 1px dashed var(--color-border);
}

.regola-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--color-surface);
    border-radius: 8px;
    border: 1px solid var(--color-border);
    border-left: 4px solid #27ae60;
    transition: all 0.2s;
}

.regola-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.regola-card.disattiva {
    opacity: 0.6;
    border-left-color: var(--color-text-muted);
}

.regola-toggle {
    flex-shrink: 0;
}

.regola-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.regola-categoria {
    font-size: 12px;
    color: var(--color-text-muted);
    text-transform: uppercase;
}

.regola-testo {
    font-size: 14px;
    color: var(--color-text);
}

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

.regola-actions .btn-icon {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.regola-actions .btn-icon:hover {
    background: var(--color-bg);
}

.regola-actions .btn-icon.btn-danger:hover {
    background: rgba(231, 76, 60, 0.1);
}

/* Switch toggle */
.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
}

input:checked + .slider {
    background-color: #27ae60;
}

input:checked + .slider:before {
    transform: translateX(22px);
}

.slider.round {
    border-radius: 26px;
}

.slider.round:before {
    border-radius: 50%;
}

/* ============================================
   PREVIEW REGOLE AI (INPUT NATURALE)
   ============================================ */

.regole-preview {
    margin-top: 20px;
    padding: 16px;
    background: var(--color-bg);
    border-radius: 8px;
    border: 1px solid var(--color-border);
}

.regole-preview.hidden {
    display: none;
}

.regole-preview .form-label {
    display: block;
    margin-bottom: 12px;
    font-weight: 600;
    color: var(--color-text);
}

#regole-preview-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.regola-preview-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.regola-preview-item:hover {
    border-color: var(--color-primary);
}

.regola-preview-item input[type="checkbox"] {
    margin-top: 3px;
    accent-color: var(--color-primary);
    width: 18px;
    height: 18px;
}

.regola-preview-cat {
    font-size: 11px;
    color: var(--color-text-muted);
    text-transform: uppercase;
    white-space: nowrap;
    background: var(--color-bg);
    padding: 2px 8px;
    border-radius: 4px;
}

.regola-preview-testo {
    flex: 1;
    font-size: 14px;
    line-height: 1.4;
    color: var(--color-text);
}

/* Bottone success */
.btn-success {
    background: #27ae60;
    color: white;
    border: none;
}

.btn-success:hover {
    background: #219a52;
}

.btn-success:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

/* Bottone warning */
.btn-warning {
    background: #f39c12;
    color: white;
    border: none;
}

.btn-warning:hover {
    background: #d68910;
}

/* Preview regole attuali (riorganizza) */
.regole-attuali-preview {
    max-height: 200px;
    overflow-y: auto;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 12px;
}

.regola-attuale-item {
    display: flex;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--color-border);
    font-size: 13px;
}

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

.regola-attuale-cat {
    font-size: 11px;
    color: var(--color-text-muted);
    text-transform: uppercase;
    white-space: nowrap;
}

.regola-attuale-testo {
    color: var(--color-text);
}

/* Summary riorganizzazione */
.riorganizza-summary {
    text-align: center;
    padding: 12px;
    background: linear-gradient(135deg, rgba(243, 156, 18, 0.1) 0%, rgba(230, 126, 34, 0.1) 100%);
    border: 1px solid rgba(243, 156, 18, 0.3);
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 14px;
    font-weight: 500;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .tavoli-checkbox-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .suggerimento-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .suggerimento-row-info {
        flex-wrap: wrap;
    }

    .suggerimento-row-tavolo {
        text-align: left;
    }

    .suggerimento-row-actions {
        justify-content: flex-end;
    }

    .header-buttons {
        flex-direction: column;
        gap: 4px;
    }

    .regola-card {
        flex-wrap: wrap;
    }

    .regola-preview-item {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .tavoli-checkbox-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
