/**
 * SAMI Sync Badge & Modal Styles
 *
 * Stili per:
 * - Badge "!" lampeggiante su immobili SAMI non collegati a LANA vault
 * - Toolbar di selezione e sincronizzazione
 * - Modal agente incaricato (avviso e selezione)
 * - Modal batch progress con barra verbosa
 *
 * @version 1.0.0
 */

/* ===========================================
   BADGE LAMPEGGIANTE "!"
   =========================================== */

@keyframes sami-badge-blink {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.35; transform: scale(0.85); }
}

.sami-sync-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 17px;
    height: 17px;
    background: var(--danger, #dc3545);
    color: #fff;
    border-radius: 50%;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    animation: sami-badge-blink 1.4s ease-in-out infinite;
    cursor: help;
    margin-left: 5px;
    vertical-align: middle;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.25);
    user-select: none;
}

.sami-sync-badge:hover {
    animation-play-state: paused;
    opacity: 1 !important;
    transform: scale(1.1) !important;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.4);
}

/* Riga non collegata — highlight leggero */
tr.sami-row--unlinked {
    background-color: rgba(220, 53, 69, 0.03) !important;
}

tr.sami-row--unlinked:hover {
    background-color: rgba(220, 53, 69, 0.07) !important;
}

/* Checkbox selezione nelle righe */
.sami-sync-check {
    width: 16px;
    height: 16px;
    accent-color: var(--accent, #4e73df);
    cursor: pointer;
    margin: 0;
    display: block;
}

td.sami-sync-select-cell {
    width: 38px;
    text-align: center;
    padding: 0 8px !important;
    vertical-align: middle;
}

th.sami-sync-select-header {
    width: 38px;
    text-align: center;
    padding: 0 8px !important;
}

/* ===========================================
   TOOLBAR SINCRONIZZAZIONE
   =========================================== */

.sami-sync-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--bg-panel, #fff);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.sami-sync-toolbar-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 180px;
}

.sami-sync-toolbar-info .badge-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    background: var(--danger, #dc3545);
    color: #fff;
    border-radius: 11px;
    font-size: 11px;
    font-weight: 700;
    padding: 0 5px;
}

.sami-sync-toolbar-info .info-text {
    font-size: 13px;
    color: var(--text-muted, #6c757d);
}

.sami-sync-toolbar .sami-sync-selected-count {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 500;
    white-space: nowrap;
}

.btn-sami-sync {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 15px;
    background: var(--accent);
    color: var(--text-secondary);
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
    white-space: nowrap;
}

.btn-sami-sync:hover:not(:disabled) {
    background: var(--accent-dim-2);
}

.btn-sami-sync:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ===========================================
   MODAL AVVISO AGENTE
   =========================================== */

.sami-agent-modal-body {
    padding: 4px 0;
}

.sami-agent-warning {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid rgba(255, 193, 7, 0.4);
    border-radius: 10px;
    margin-bottom: 18px;
}

.sami-agent-warning i {
    color: #f6c23e;
    font-size: 20px;
    flex-shrink: 0;
    margin-top: 1px;
}

.sami-agent-warning p {
    margin: 0;
    font-size: 13.5px;
    color: var(--text-main, #2d3748);
    line-height: 1.5;
}

.sami-agent-select-wrap {
    margin-top: 4px;
}

.sami-agent-select-wrap label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted, #6c757d);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 7px;
}

.sami-agent-search {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 8px;
    font-size: 13.5px;
    background: var(--bg-lighter);
    color: var(--text-main, #2d3748);
    box-sizing: border-box;
    margin-bottom: 8px;
    transition: border-color 0.15s;
}

.sami-agent-search:focus {
    outline: none;
    border-color: var(--accent, #4e73df);
    box-shadow: 0 0 0 3px rgba(78, 115, 223, 0.15);
}

.sami-agent-list {
    max-height: 180px;
    overflow-y: auto;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 8px;
    background: var(--bg-panel, #fff);
}

.sami-agent-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 13px;
    cursor: pointer;
    transition: background 0.12s;
    border-bottom: 1px solid var(--border, #e2e8f0);
}

.sami-agent-option:last-child {
    border-bottom: none;
}

.sami-agent-option:hover,
.sami-agent-option.selected {
    background: var(--bg-highlight, rgba(78, 115, 223, 0.08));
}

.sami-agent-option.selected {
    background: var(--bg-highlight, rgba(78, 115, 223, 0.12));
}

.sami-agent-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--accent, #4e73df);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
    text-transform: uppercase;
}

.sami-agent-name {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-main, #2d3748);
}

.sami-agent-email {
    font-size: 11.5px;
    color: var(--text-muted, #6c757d);
}

.sami-agent-role {
    font-size: 10.5px;
    background: var(--bg-tertiary, #f0f4f8);
    color: var(--text-muted, #6c757d);
    padding: 2px 7px;
    border-radius: 10px;
    margin-left: auto;
    white-space: nowrap;
}

.sami-agent-none-option {
    font-size: 13px;
    color: var(--text-muted, #6c757d);
    font-style: italic;
    padding: 9px 13px;
    border-bottom: 1px solid var(--border, #e2e8f0);
    cursor: default;
}

.sami-selected-agent {
    margin-top: 10px;
    padding: 8px 12px;
    background: rgba(78, 115, 223, 0.08);
    border: 1px solid rgba(78, 115, 223, 0.25);
    border-radius: 8px;
    font-size: 13px;
    color: var(--accent, #4e73df);
    display: none;
}

.sami-selected-agent.visible {
    display: block;
}

/* ===========================================
   MODAL BATCH PROGRESS
   =========================================== */

.sami-batch-modal-body {
    padding: 4px 0;
}

/* Barra di progresso */
.sami-progress-bar-wrap {
    margin-bottom: 16px;
}

.sami-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.sami-progress-label {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-main, #2d3748);
}

.sami-progress-fraction {
    font-size: 13px;
    color: var(--text-muted, #6c757d);
    font-variant-numeric: tabular-nums;
}

.sami-progress-track {
    width: 100%;
    height: 8px;
    background: var(--bg-tertiary, #e2e8f0);
    border-radius: 4px;
    overflow: hidden;
}

.sami-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent, #4e73df), #60a5fa);
    border-radius: 4px;
    transition: width 0.35s ease;
    width: 0%;
}

.sami-progress-step-label {
    margin-top: 6px;
    font-size: 12px;
    color: var(--accent, #4e73df);
    min-height: 18px;
    transition: opacity 0.2s;
}

/* Lista items con status */
.sami-batch-item-list {
    max-height: 260px;
    overflow-y: auto;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 10px;
    background: var(--bg-panel, #fff);
}

.sami-batch-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    border-bottom: 1px solid var(--border, #e2e8f0);
    font-size: 13px;
    transition: background 0.15s;
}

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

.sami-batch-item-icon {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
}

.sami-batch-item-icon.status-pending  { color: var(--text-muted, #6c757d); }
.sami-batch-item-icon.status-running  { color: #f6c23e; }
.sami-batch-item-icon.status-ok       { color: var(--success, #28a745); }
.sami-batch-item-icon.status-error    { color: var(--danger, #dc3545); }

.sami-batch-item-label {
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: var(--text-main, #2d3748);
}

.sami-batch-item-status {
    font-size: 11.5px;
    color: var(--text-muted, #6c757d);
    white-space: nowrap;
    text-align: right;
    min-width: 120px;
}

.sami-batch-item.running {
    background: rgba(246, 194, 62, 0.06);
}

.sami-batch-item.done-ok {
    opacity: 0.75;
}

.sami-batch-item.done-error {
    background: rgba(220, 53, 69, 0.04);
}

/* Summary dopo completamento */
.sami-batch-summary {
    display: none;
    margin-top: 14px;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 13.5px;
}

.sami-batch-summary.success {
    background: rgba(40, 167, 69, 0.08);
    border: 1px solid rgba(40, 167, 69, 0.3);
    color: var(--success, #28a745);
    display: flex;
    align-items: center;
    gap: 9px;
}

.sami-batch-summary.partial {
    background: rgba(246, 194, 62, 0.1);
    border: 1px solid rgba(246, 194, 62, 0.4);
    color: #856404;
    display: flex;
    align-items: center;
    gap: 9px;
}
