/*
====================================================================
ETRUSCAFORM v3.3.1 - CHECKOUT A BLOCCHI: CAMPI FISCALI
====================================================================
Data: 2026-02-26

Stile per i campi fiscali italiani nel checkout a blocchi WooCommerce.
Include: titolo sezione, campi condizionali, focus states, dark mode.
====================================================================
*/

/* ============================================
   1. SEZIONE DATI FISCALI — Titolo
   ============================================ */

.ef-fiscal-section-title {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 700;
    font-size: 1.05rem;
    color: #39110e;
    padding: 0.8rem 0 0.6rem;
    margin-top: 1rem;
    margin-bottom: 0.4rem;
    border-top: 2px solid rgba(208, 124, 57, 0.25);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.ef-fiscal-section-title .ef-fiscal-icon {
    font-size: 1.1rem;
}

/* ============================================
   2. CHECKOUT A BLOCCHI — Override font Outfit
   ============================================ */

.wc-block-checkout,
.wc-block-checkout * {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ============================================
   3. CAMPI FISCALI — Styling specifico
   ============================================ */

/*
 * WC Blocks usa le classi:
 *   .wc-block-components-text-input
 *   .wc-block-components-select-input
 *   .wc-block-components-combobox
 *
 * I nostri campi si riconoscono dal contenuto ID che inizia
 * con "etruscaform/"
 */

/* Focus state: bordo terracotta */
.wc-block-checkout input:focus,
.wc-block-checkout select:focus,
.wc-block-checkout textarea:focus {
    border-color: #d07c39 !important;
    box-shadow: 0 0 0 2px rgba(208, 124, 57, 0.15) !important;
    outline: none !important;
}

/* WC Blocks text input focus underline → terracotta */
.wc-block-components-text-input.is-active input,
.wc-block-components-text-input input:focus {
    border-color: #d07c39 !important;
    box-shadow: 0 0 0 2px rgba(208, 124, 57, 0.12) !important;
}

/* Label attivo → colore primario */
.wc-block-components-text-input.is-active label,
.wc-block-components-text-input input:focus + label {
    color: #d07c39 !important;
}

/* Combobox / Select focus */
.wc-block-components-combobox.is-active .components-combobox-control input,
.wc-block-components-combobox.is-active .components-combobox-control__button {
    border-color: #d07c39 !important;
}

/* ============================================
   4. CAMPO CODICE FISCALE — Uppercase + monospace
   ============================================ */

input[id*="codice-fiscale"],
input[name*="codice-fiscale"],
input[id*="codice_fiscale"],
input[name*="codice_fiscale"] {
    text-transform: uppercase !important;
    letter-spacing: 0.8px !important;
    font-family: 'Outfit', monospace !important;
}

/* ============================================
   5. CAMPO PARTITA IVA — Monospace
   ============================================ */

input[id*="partita-iva"],
input[name*="partita-iva"],
input[id*="partita_iva"],
input[name*="partita_iva"] {
    letter-spacing: 1px !important;
    font-family: 'Outfit', monospace !important;
}

/* ============================================
   6. ASTERISCO OBBLIGATORIETÀ
   ============================================ */

.ef-required-mark {
    color: #d07c39 !important;
    font-weight: 700;
    text-decoration: none !important;
    margin-left: 2px;
}

/* ============================================
   7. SEZIONE INFORMAZIONI AGGIUNTIVE — Wrapper fiscale
   ============================================ */

/*
 * I campi registrati con location 'order' finiscono nella
 * sezione "Additional information" del checkout a blocchi.
 * Applichiamo sfondo leggero per distinguerli.
 */

.wc-block-checkout__additional-information,
.wc-block-components-checkout-step--with-step-number:has([id*="etruscaform"]) {
    background: rgba(208, 124, 57, 0.03);
    border: 1px solid rgba(208, 124, 57, 0.12);
    border-radius: 12px;
    padding: 0.5rem;
    margin-top: 0.5rem;
}

/* Titolo sezione "Informazioni aggiuntive" → nascondiamo il default
   e usiamo il nostro "Dati Fiscali" */
.wc-block-checkout__additional-information .wc-block-components-checkout-step__heading .wc-block-components-title {
    font-family: 'Outfit', sans-serif !important;
    font-weight: 700 !important;
    color: #39110e !important;
    font-size: 1.1rem !important;
}

/* ============================================
   8. CAMPI NASCOSTI — Transizione smooth
   ============================================ */

.wc-block-components-text-input[style*="display: none"],
.wc-block-components-select-input[style*="display: none"],
.wc-block-components-combobox[style*="display: none"] {
    max-height: 0 !important;
    opacity: 0 !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
}

/* ============================================
   9. VALIDAZIONE — Errore visivo
   ============================================ */

.wc-block-components-text-input.has-error input,
.wc-block-components-validation-error + .wc-block-components-text-input input {
    border-color: #c62828 !important;
    box-shadow: 0 0 0 2px rgba(198, 40, 40, 0.1) !important;
}

.wc-block-components-validation-error {
    color: #c62828 !important;
    font-size: 0.8rem !important;
    font-family: 'Outfit', sans-serif !important;
}

/* ============================================
   10. CHECKOUT A BLOCCHI — Bottone "Procedi"
   ============================================ */

.wc-block-components-checkout-place-order-button,
.wc-block-checkout__actions .wc-block-components-button {
    background: #d07c39 !important;
    color: #fff !important;
    border: none !important;
    border-radius: 10px !important;
    font-family: 'Outfit', sans-serif !important;
    font-weight: 700 !important;
    font-size: 1rem !important;
    text-transform: uppercase !important;
    letter-spacing: 0.8px !important;
    padding: 0.9rem 2rem !important;
    transition: all 0.25s ease !important;
    box-shadow: 0 4px 16px rgba(208, 124, 57, 0.3) !important;
}

.wc-block-components-checkout-place-order-button:hover,
.wc-block-checkout__actions .wc-block-components-button:hover {
    background: #c06f33 !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 24px rgba(208, 124, 57, 0.4) !important;
}

.wc-block-components-checkout-place-order-button:active,
.wc-block-checkout__actions .wc-block-components-button:active {
    transform: translateY(0) !important;
}

/* ============================================
   11. METODI DI PAGAMENTO — Stile card
   ============================================ */

.wc-block-checkout__payment-method .wc-block-components-radio-control__option {
    border: 1.5px solid #f0ebe6 !important;
    border-radius: 10px !important;
    padding: 0.8rem 1rem !important;
    margin-bottom: 0.5rem !important;
    transition: border-color 0.25s ease !important;
}

.wc-block-checkout__payment-method .wc-block-components-radio-control__option:hover {
    border-color: rgba(208, 124, 57, 0.3) !important;
}

.wc-block-checkout__payment-method .wc-block-components-radio-control__option--checked {
    border-color: #d07c39 !important;
    background: rgba(208, 124, 57, 0.03) !important;
}

/* Radio button accent */
.wc-block-checkout .wc-block-components-radio-control__input {
    accent-color: #d07c39 !important;
}

/* ============================================
   12. RIEPILOGO ORDINE — Tabella prodotti
   ============================================ */

.wc-block-components-order-summary__button-text {
    font-family: 'Outfit', sans-serif !important;
    font-weight: 700 !important;
    color: #39110e !important;
}

.wc-block-components-totals-item__value {
    font-weight: 600 !important;
    color: #39110e !important;
}

.wc-block-components-totals-footer-item .wc-block-components-totals-item__value {
    color: #d07c39 !important;
    font-size: 1.2rem !important;
    font-weight: 700 !important;
}

/* ============================================
   13. NASCONDI CAMPI PLUGIN ESTERNO
   ============================================ */

/* Plugin "Fiscalità ITA" / "Partita IVA e Codice Fiscale" etc.
   Nel checkout a blocchi alcuni elementi spurii potrebbero apparire */
[id*="billing_tipo_cliente"],
[id*="billing_cf_field"],
[id*="billing_piva_field"],
[id*="billing_pec_field"],
[id*="billing_sdi_field"],
[class*="piva-cf-field"],
[class*="tipo-contribuente"] {
    display: none !important;
}

/* ============================================
   14. DARK MODE
   ============================================ */

[data-theme="dark"] .ef-fiscal-section-title {
    color: #f0f0f0;
    border-top-color: rgba(232, 152, 72, 0.3);
}

[data-theme="dark"] .wc-block-checkout__additional-information,
[data-theme="dark"] .wc-block-components-checkout-step--with-step-number:has([id*="etruscaform"]) {
    background: rgba(232, 152, 72, 0.04);
    border-color: rgba(232, 152, 72, 0.15);
}

/* Inputs dark mode */
[data-theme="dark"] .wc-block-checkout input,
[data-theme="dark"] .wc-block-checkout select,
[data-theme="dark"] .wc-block-checkout textarea {
    background: #1e1e1e !important;
    border-color: #333 !important;
    color: #f0f0f0 !important;
}

[data-theme="dark"] .wc-block-checkout input:focus,
[data-theme="dark"] .wc-block-checkout select:focus {
    border-color: #e89848 !important;
    box-shadow: 0 0 0 2px rgba(232, 152, 72, 0.15) !important;
}

[data-theme="dark"] .wc-block-checkout input::placeholder {
    color: rgba(255, 255, 255, 0.3) !important;
}

/* Labels dark mode */
[data-theme="dark"] .wc-block-components-text-input label,
[data-theme="dark"] .wc-block-components-select-input label,
[data-theme="dark"] .wc-block-checkout label {
    color: #ccc !important;
}

[data-theme="dark"] .wc-block-components-text-input.is-active label {
    color: #e89848 !important;
}

/* Titoli dark mode */
[data-theme="dark"] .wc-block-components-checkout-step__heading .wc-block-components-title,
[data-theme="dark"] .wc-block-checkout h2 {
    color: #f0f0f0 !important;
}

/* Bottone procedi dark mode */
[data-theme="dark"] .wc-block-components-checkout-place-order-button {
    background: #e89848 !important;
}

[data-theme="dark"] .wc-block-components-checkout-place-order-button:hover {
    background: #d07c39 !important;
}

/* Pagamento dark mode */
[data-theme="dark"] .wc-block-checkout__payment-method .wc-block-components-radio-control__option {
    border-color: #2c2c2c !important;
    background: #1a1a1a !important;
}

[data-theme="dark"] .wc-block-checkout__payment-method .wc-block-components-radio-control__option:hover {
    border-color: rgba(232, 152, 72, 0.3) !important;
}

[data-theme="dark"] .wc-block-checkout__payment-method .wc-block-components-radio-control__option--checked {
    border-color: #e89848 !important;
    background: rgba(232, 152, 72, 0.04) !important;
}

/* Riepilogo ordine dark mode */
[data-theme="dark"] .wc-block-components-order-summary__button-text,
[data-theme="dark"] .wc-block-components-totals-item__label,
[data-theme="dark"] .wc-block-components-totals-item__value {
    color: #e0e0e0 !important;
}

[data-theme="dark"] .wc-block-components-totals-footer-item .wc-block-components-totals-item__value {
    color: #e89848 !important;
}

/* Errori dark mode */
[data-theme="dark"] .wc-block-components-validation-error {
    color: #ff6b6b !important;
}

/* ============================================
   15. RESPONSIVE — Mobile
   ============================================ */

@media screen and (max-width: 768px) {

    .ef-fiscal-section-title {
        font-size: 0.95rem;
        margin-top: 0.8rem;
    }

    .wc-block-checkout__additional-information,
    .wc-block-components-checkout-step--with-step-number:has([id*="etruscaform"]) {
        padding: 0.4rem;
        border-radius: 8px;
    }

    .wc-block-components-checkout-place-order-button {
        font-size: 0.9rem !important;
        padding: 0.8rem 1.5rem !important;
    }
}

@media screen and (max-width: 480px) {

    .ef-fiscal-section-title {
        font-size: 0.9rem;
    }
}
