/* ============================================================
   TS Rewards — Registrazione vendite offline (My Account B2B)
   ============================================================ */

.ts-salon-register h2,
.ts-salon-history h2 { margin-bottom: 1rem; }

.ts-notice {
    padding: 12px 16px;
    border-radius: 6px;
    margin: 12px 0;
    font-size: 0.95em;
}
.ts-notice-error { background: #fdecea; color: #8a1c14; border: 1px solid #f5c6c2; }
.ts-notice-success { background: #e7f6ec; color: #1a6b37; border: 1px solid #b6e0c4; }

.ts-step {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}
.ts-step h3 { margin-top: 0; }
.ts-step.is-locked {
    opacity: 0.5;
    pointer-events: none;
    filter: grayscale(0.4);
}

.ts-field-row { margin-bottom: 14px; }
.ts-field-row label { display: block; font-weight: 600; margin-bottom: 6px; }
.ts-input {
    width: 100%;
    max-width: 420px;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1em;
}

.ts-btn-primary { background: #000 !important; color: #fff !important; border-color: #000 !important; }
.ts-btn-secondary { background: #f2f2f2 !important; }
.ts-btn-block { display: block; width: 100%; margin-top: 16px; }
.button[disabled] { opacity: 0.5; cursor: not-allowed; }

/* Customer card */
.ts-customer-card {
    margin-top: 16px;
    padding: 14px 16px;
    background: #e7f6ec;
    border: 1px solid #b6e0c4;
    border-radius: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    align-items: center;
}
.ts-customer-card strong { font-size: 1.05em; }
.ts-code-badge {
    background: #1a6b37;
    color: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.85em;
    letter-spacing: 0.03em;
}

/* Items table */
.ts-items-table,
.ts-history-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
}
.ts-items-table th, .ts-items-table td,
.ts-history-table th, .ts-history-table td {
    border-bottom: 1px solid #eee;
    padding: 10px 8px;
    text-align: left;
    vertical-align: middle;
}
.ts-items-table tfoot th { border-top: 2px solid #ccc; }
.ts-items-empty td { text-align: center; color: #999; padding: 18px; }

.ts-history-table th, .ts-history-table td { padding: 15px 8px !important; }
.ts-history-table thead th { border-bottom: 2px solid #ccc !important; }
.ts-history-table tbody td { border-bottom: 1px solid #ccc !important; }
.ts-history-table tbody tr:last-child td { border-bottom: 0 !important; }
.ts-history-table tbody tr:nth-child(even) { background: #fafafa !important; }

.ts-qty-cell { white-space: nowrap; }
.ts-qty-btn {
    width: 26px; height: 26px;
    border: 1px solid #ccc; background: #fafafa;
    border-radius: 4px; cursor: pointer; font-size: 1em; line-height: 1;
}
.ts-qty-val { display: inline-block; min-width: 28px; text-align: center; }
.ts-remove-btn {
    border: none; background: none; color: #c0392b;
    font-size: 1.3em; cursor: pointer; line-height: 1;
}

/* Scanner modal */
.ts-scanner-overlay {
    position: fixed; inset: 0; z-index: 99999;
    background: rgba(0,0,0,0.7);
    display: flex; align-items: center; justify-content: center;
}
.ts-scanner-modal {
    background: #fff; border-radius: 10px; overflow: hidden;
    width: min(92vw, 420px);
}
.ts-scanner-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 16px; background: #000; color: #fff;
}
.ts-scanner-close {
    background: none; border: none; color: #fff; font-size: 1.5em; cursor: pointer; line-height: 1;
}
#ts-scanner-reader { width: 100%; }

/* Status badges */
.ts-status {
    display: inline-block; padding: 3px 10px; border-radius: 999px;
    font-size: 0.82em; font-weight: 600;
}
.ts-status-completed { background: #e7f6ec; color: #1a6b37; }
.ts-status-failed { background: #fdecea; color: #8a1c14; }
.ts-status-pending { background: #fff5e0; color: #8a5a00; }
.ts-status-cancelled { background: #eeeeee; color: #555555; }

/* Pagination */
.ts-pagination { margin-top: 16px; display: flex; gap: 6px; }
.ts-pagination .ts-page {
    padding: 6px 12px; border: 1px solid #ddd; border-radius: 4px; text-decoration: none;
}
.ts-pagination .ts-page.current { background: #000; color: #fff; border-color: #000; }

@media (max-width: 600px) {
    .ts-items-table thead { display: none; }
    .ts-input { max-width: 100%; }
}

/* Codici attributivi: uno per Vigalina, tutti validi fino a fine mese */
.ts-rewards-code-actions { margin: 14px 0 6px; }
#ts-new-code-btn {
    background: #000 !important;
    color: #fff !important;
    border-color: #000 !important;
}
#ts-new-code-btn:hover, #ts-new-code-btn:focus {
    background: #222 !important;
    border-color: #222 !important;
    color: #fff !important;
}
#ts-new-code-btn.is-busy { opacity: 0.6; cursor: progress; }
.ts-rewards-code-list {
    list-style: none;
    margin: 0 0 20px;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.ts-rewards-code-list li {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: #fff;
}
.ts-rewards-code-list .ts-rewards-code-value {
    font-family: monospace;
    font-size: 1.05em;
    letter-spacing: 0.04em;
}
.ts-rewards-code-list .ts-rewards-code-period { font-size: 0.8em; color: #666; }
/* Il codice appena coniato è quello che il salone deve leggere ad alta voce. */
.ts-rewards-code-list li.is-new { border-color: #1a6b37; box-shadow: 0 0 0 2px rgba(26, 107, 55, 0.12); }

/* ============================================================
   Pannello codice attributivo — era senza un grammo di stile:
   tabelle senza bordi, sezioni senza respiro, il codice del mese
   confuso col testo intorno.
   ============================================================ */

.ts-rewards-code-panel { font-size: 0.97em; }
.ts-rewards-code-panel h3 { margin: 0 0 6px; }
.ts-rewards-code-panel h4 {
    margin: 32px 0 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #111;
    font-size: 1.05em;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.ts-rewards-code-hint { margin: 0 0 18px; color: #555; max-width: 70ch; }

/* Il codice del mese: è la cosa che il salone deve leggere ad alta voce. */
.ts-rewards-current-code {
    display: inline-flex;
    flex-direction: column;
    gap: 2px;
    padding: 16px 22px;
    border: 2px solid #111;
    border-radius: 10px;
    background: #fff;
}
.ts-rewards-current-code .ts-rewards-code-value {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 1.6em;
    font-weight: 700;
    letter-spacing: 0.08em;
}
.ts-rewards-current-code .ts-rewards-code-period { font-size: 0.8em; color: #666; }

/* Il credito, in evidenza: è il motivo per cui il salone apre questa pagina. */
.ts-rewards-credit-banner {
    margin: 24px 0;
    padding: 18px 22px;
    border: 1px solid #b6e0c4;
    border-radius: 10px;
    background: #f2faf5;
    font-size: 1.15em;
    font-weight: 600;
}
.ts-rewards-credit-banner .ts-rewards-credit-hint {
    margin: 6px 0 0;
    font-size: 0.78em;
    font-weight: 400;
    color: #40704f;
}

/* Le tabelle: bordi, intestazioni leggibili, righe alternate. */
.ts-rewards-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0 0 8px;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    overflow: hidden;
}
.ts-rewards-table th,
.ts-rewards-table td {
    padding: 15px 14px !important;
    text-align: left;
    border-bottom: 1px solid #ccc !important;
    vertical-align: middle;
}
.ts-rewards-table thead th {
    background: #f6f6f6;
    font-size: 0.82em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #444;
    border-bottom: 2px solid #ccc !important;
}
.ts-rewards-table tbody tr:last-child td { border-bottom: 0 !important; }
.ts-rewards-table tbody tr:nth-child(even) { background: #fafafa !important; }
/* Gli importi non vanno mai a capo: una cifra spezzata si legge male. */
.ts-rewards-table td .woocommerce-Price-amount { white-space: nowrap; }

@media (max-width: 782px) {
    .ts-rewards-table { display: block; overflow-x: auto; }
}
