/**
 * Recesso Click — Frontend CSS
 * Layout centrato con box, step indicator, ispirato al reference screenshot.
 */

/* ── Wrapper principale centrato ─────────────────────────────────────────── */
.recesso-form-wrapper {
    max-width: 680px;
    margin: 32px auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Box principale ──────────────────────────────────────────────────────── */
.recesso-form-box {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 32px;
    box-shadow: 0 2px 12px rgba(0,0,0,.06);
}

.recesso-form-box h2.recesso-form-title {
    margin: 0 0 24px;
    font-size: 1.3em;
    font-weight: 700;
    color: #1a202c;
}

/* ── Step indicator ──────────────────────────────────────────────────────── */
.recesso-steps-indicator {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e2e8f0;
}

.recesso-step-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    border-radius: 999px;
    border: 1.5px solid #cbd5e0;
    font-size: 13px;
    font-weight: 500;
    color: #718096;
    background: #fff;
    white-space: nowrap;
}

.recesso-step-pill.active {
    border-color: #2c3e50;
    color: #2c3e50;
    background: #f0f4f8;
    font-weight: 700;
}

.recesso-step-pill.completed {
    border-color: #27ae60;
    color: #27ae60;
    background: #f0faf4;
}

/* ── Intestazione step ───────────────────────────────────────────────────── */
.recesso-step-header {
    margin-bottom: 20px;
}

.recesso-step-header h3 {
    margin: 0 0 6px;
    font-size: 1.1em;
    font-weight: 700;
    color: #1a202c;
}

.recesso-intro {
    color: #718096;
    font-size: 13px;
    margin: 0 0 4px;
    line-height: 1.5;
}

/* ── Privacy note ────────────────────────────────────────────────────────── */
.recesso-privacy-note {
    font-size: 12px;
    color: #718096;
    margin: -8px 0 16px;
    line-height: 1.5;
}

.recesso-privacy-note a {
    color: #2c3e50;
    text-decoration: underline;
}

/* ── Campi ───────────────────────────────────────────────────────────────── */
.recesso-field {
    margin-bottom: 20px;
}

.recesso-field label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    color: #2d3748;
    margin-bottom: 6px;
}

.recesso-field input[type="text"],
.recesso-field input[type="email"],
.recesso-field input[type="number"],
.recesso-field select,
.recesso-field textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #cbd5e0;
    border-radius: 8px;
    font-size: 14px;
    color: #2d3748;
    background: #fff;
    box-sizing: border-box;
    transition: border-color 0.15s;
    outline: none;
}

.recesso-field input:focus,
.recesso-field select:focus,
.recesso-field textarea:focus {
    border-color: #2c3e50;
    box-shadow: 0 0 0 3px rgba(44,62,80,.08);
}

.recesso-field select {
    height: 44px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23718096' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

.recesso-field textarea {
    resize: vertical;
    min-height: 80px;
}

.recesso-field-note {
    display: block;
    font-size: 12px;
    color: #718096;
    margin-top: 5px;
}

.recesso-field .required {
    color: #e53e3e;
}

/* ── Errori ──────────────────────────────────────────────────────────────── */
.recesso-error-message {
    background: #fff5f5;
    border: 1px solid #fed7d7;
    border-radius: 8px;
    color: #c53030;
    padding: 10px 14px;
    margin-bottom: 16px;
    font-size: 14px;
    display: none !important;
}

.recesso-error-message.recesso-visible {
    display: block !important;
}

/* ── Azioni step (bottoni) ───────────────────────────────────────────────── */
.recesso-step-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #e2e8f0;
}

.recesso-step2-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #e2e8f0;
    gap: 12px;
}

.recesso-button,
.recesso-button.button,
.recesso-button.button.alt,
#recesso-step1-submit,
#recesso-step2-submit {
    display: inline-block;
    padding: 11px 28px;
    border: none !important;
    border-radius: 999px !important;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: opacity 0.15s, transform 0.1s;
    line-height: 1.4;
    box-shadow: none !important;
}

.recesso-button:hover {
    opacity: 0.88;
    transform: translateY(-1px);
}

.recesso-button:disabled,
.recesso-button.recesso-btn-disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.recesso-button-secondary {
    background: transparent;
    border: 1.5px solid #cbd5e0;
    color: #4a5568;
    padding: 10px 20px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

.recesso-button-secondary:hover {
    background: #f7fafc;
}

/* ── Lista prodotti ──────────────────────────────────────────────────────── */
.recesso-items-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
}

.recesso-item {
    border-bottom: 1px solid #e2e8f0;
}

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

/*
 * Struttura HTML:
 * .recesso-item-row
 *   .recesso-item-check  → checkbox
 *   .recesso-item-label  → img + nome + badge
 *
 * Separare la checkbox dalla label risolve il conflitto
 * con i temi che impostano label { display: block } o label img { display: block }
 */
.recesso-item-row {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* Colonna checkbox */
.recesso-item-check {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 14px 0 14px 16px !important;
    flex-shrink: 0 !important;
}

.recesso-item-check input[type="checkbox"] {
    display: block !important;
    width: 18px !important;
    height: 18px !important;
    min-width: 18px !important;
    margin: 0 !important;
    padding: 0 !important;
    cursor: pointer !important;
    accent-color: #2c3e50;
    flex-shrink: 0 !important;
}

/* Label = img + nome + badge, occupa tutto lo spazio rimanente */
.recesso-item-label {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 12px !important;
    padding: 12px 16px !important;
    cursor: pointer !important;
    font-weight: normal !important;
    flex: 1 !important;
    min-width: 0 !important;
    margin: 0 !important;
    box-sizing: border-box !important;
}

/* Thumbnail */
.recesso-item-thumb {
    display: block !important;
    width: 52px !important;
    height: 52px !important;
    min-width: 52px !important;
    max-width: 52px !important;
    object-fit: cover !important;
    border-radius: 6px !important;
    flex-shrink: 0 !important;
}

/* Nome */
.recesso-item-name {
    display: block !important;
    flex: 1 !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    color: #2d3748 !important;
    min-width: 0 !important;
    word-break: break-word !important;
    white-space: normal !important;
}

/* Badge quantità */
.recesso-item-badge {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: #2c3e50 !important;
    color: #fff !important;
    font-size: 12px !important;
    font-weight: bold !important;
    padding: 3px 10px !important;
    border-radius: 999px !important;
    flex-shrink: 0 !important;
    white-space: nowrap !important;
    margin-left: auto !important;
}

.recesso-item.recesso-item-unchecked {
    opacity: 0.45;
    transition: opacity 0.2s ease;
}

/* Riga select quantità */
.recesso-item-qty-row {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 8px 16px 12px 50px !important;
    background: #f7fafc !important;
    border-top: 1px dashed #e2e8f0 !important;
}

.recesso-item-qty-label {
    font-size: 13px !important;
    color: #718096 !important;
    white-space: nowrap !important;
    margin: 0 !important;
    font-weight: normal !important;
}

.recesso-item-qty-select {
    display: inline-block !important;
    width: auto !important;
    max-width: 80px !important;
    padding: 4px 8px !important;
    font-size: 13px !important;
    height: auto !important;
    border: 1.5px solid #cbd5e0 !important;
    border-radius: 6px !important;
    background: #fff !important;
}

.recesso-item-qty-max {
    font-size: 12px !important;
    color: #a0aec0 !important;
    white-space: nowrap !important;
}

/* ── Riepilogo ordine (step 2) ───────────────────────────────────────────── */
.recesso-riepilogo-ordine {
    background: #f7fafc;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 20px;
}

.recesso-riepilogo-ordine h4 {
    margin: 0 0 4px;
    font-size: 14px;
    color: #2d3748;
}

.recesso-riepilogo-ordine p {
    margin: 0;
    color: #718096;
    font-size: 13px;
}

/* ── Riepilogo finale ────────────────────────────────────────────────────── */
.recesso-riepilogo-finale {
    background: #f7fafc;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px;
}

.recesso-riepilogo-finale h4 {
    margin: 0 0 10px;
    font-size: 14px;
    color: #2d3748;
}

.recesso-riepilogo-finale ul {
    margin: 0;
    padding: 0 0 0 16px;
    font-size: 13px;
    color: #4a5568;
}

.recesso-riepilogo-finale li {
    margin-bottom: 4px;
}

.recesso-timestamp {
    font-weight: 600;
    color: #2c3e50;
}

/* ── Nessun ordine eligibile ─────────────────────────────────────────────── */
.recesso-no-orders {
    color: #718096;
    font-size: 14px;
    padding: 12px;
}

/* ── Successo ────────────────────────────────────────────────────────────── */
#recesso-success .woocommerce-message {
    border-radius: 8px;
    padding: 20px 24px;
}

#recesso-success .woocommerce-message h3 {
    margin-top: 0;
    margin-bottom: 8px;
    color: #ffffff;
    font-weight: 700;
}

/* ── Powered by box ──────────────────────────────────────────────────────── */
.recesso-powered-by {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 12px;
    padding: 14px 20px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    color: #4a5568;
    font-size: 13px;
    text-decoration: none;
}

.recesso-powered-by img {
    width: 32px !important;
    height: 32px !important;
    border-radius: 8px;
    margin-bottom: 0 !important;
}

.recesso-powered-by strong {
    color: #2c3e50;
}

/* ── Storico my-account ──────────────────────────────────────────────────── */
.recesso-storico-wrapper {
    margin: 24px 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.recesso-storico-card {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    font-size: 14px;
}

.recesso-storico-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #f7fafc;
    border-bottom: 1px solid #e2e8f0;
}

.recesso-storico-card-ordine {
    font-size: 15px;
}

.recesso-storico-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.recesso-storico-card-body {
    padding: 4px 0;
}

.recesso-storico-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    padding: 8px 16px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
}

.recesso-storico-row:last-child {
    border-bottom: none;
}

.recesso-storico-row > span:first-child {
    color: #718096;
    flex-shrink: 0;
    min-width: 130px;
}

.recesso-storico-row > span:last-child {
    text-align: right;
}

.recesso-storico-row-rifiuto {
    background: #fff5f5;
}

.recesso-storico-row-rifiuto > span:first-child {
    color: #c53030;
}

.recesso-storico-pdf-link {
    color: #2c3e50;
    text-decoration: underline;
    font-size: 13px;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media ( max-width: 640px ) {
    .recesso-form-box {
        padding: 20px 16px;
    }

    .recesso-steps-indicator {
        gap: 6px;
    }

    .recesso-step-pill {
        font-size: 12px;
        padding: 4px 10px;
    }

    .recesso-field input,
    .recesso-field select,
    .recesso-field textarea {
        font-size: 16px; /* evita zoom su iOS */
    }

    .recesso-step2-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .recesso-button,
    .recesso-button-secondary {
        text-align: center;
        width: 100%;
    }
}

/* ── Pulsante wrapper dettaglio ordine ───────────────────────────────────── */
.recesso-button-wrapper {
    margin-top: 16px;
}

/* ── Step disabilitato (pulsante conferma) ───────────────────────────────── */
#recesso-step2-submit:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ── Fix step 2 AJAX content ─────────────────────────────────────────────── */
#recesso-step2-content .recesso-field label {
    font-size: 14px;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 8px;
}

#recesso-step2-content .recesso-items-list {
    max-width: 100%;
}

/* Select motivo: larghezza piena */
#recesso-step2-content select#recesso-motivo,
#recesso-step2-content .recesso-field > select {
    width: 100% !important;
    max-width: 100% !important;
    height: 44px !important;
    border: 1.5px solid #cbd5e0 !important;
    border-radius: 8px !important;
    padding: 10px 36px 10px 14px !important;
    font-size: 14px !important;
    background: #fff !important;
    appearance: none !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23718096' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 14px center !important;
    box-sizing: border-box !important;
}

/* ── Fix box conferma (step 3) ───────────────────────────────────────────── */
#recesso-success .woocommerce-message {
    border-radius: 8px;
    padding: 24px 28px;
    margin: 0;
    position: relative;
}

/* Rimuove l'icona ✓ che WooCommerce aggiunge con ::before e che appare come carattere strano */
#recesso-success .woocommerce-message::before {
    content: none !important;
    display: none !important;
}

#recesso-success .woocommerce-message h3 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #fff;
    font-weight: 700;
    font-size: 1.2em;
}

#recesso-success .woocommerce-message p {
    margin: 0;
    color: rgba(255,255,255,0.92);
    font-size: 15px;
    line-height: 1.5;
}
