/**
 * Stili Frontend Form Registrazione B2B
 */

/* Container principale form */
.wc-b2b-registration-form {
    max-width: 800px;
    margin: 0 auto;
    padding: 30px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.wc-b2b-registration-form h2 {
    margin-top: 0;
    margin-bottom: 30px;
    color: #333;
    font-size: 28px;
    text-align: center;
    border-bottom: 2px solid #0073aa;
    padding-bottom: 15px;
}

/* Sezioni form */
.form-section {
    margin-bottom: 30px;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 6px;
    border: 1px solid #e5e5e5;
}

.form-section h3 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #0073aa;
    font-size: 20px;
    border-bottom: 1px solid #ddd;
    padding-bottom: 10px;
}

/* Righe form */
.form-row {
    margin-bottom: 20px;
}

.form-row:last-child {
    margin-bottom: 0;
}

.form-row label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.form-row label .required {
    color: #dc3232;
    font-weight: bold;
}

/* Input fields */
.input-text,
.input-file {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s, box-shadow 0.3s;
    box-sizing: border-box;
}

.input-text:focus {
    border-color: #0073aa;
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

textarea.input-text {
    resize: vertical;
    min-height: 100px;
}

/* File input */
.input-file {
    padding: 8px;
    cursor: pointer;
}

.form-row .description {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    color: #666;
    font-style: italic;
}

/* Checkbox styling */
.form-row input[type="checkbox"] {
    width: auto;
    margin-right: 8px;
    vertical-align: middle;
}

.form-row label input[type="checkbox"] {
    display: inline-block;
    width: auto;
    margin-right: 8px;
}

/* Buttons */
.button {
    display: inline-block;
    padding: 12px 30px;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s;
    text-align: center;
}

.button-primary {
    background: #0073aa;
    color: #fff;
}

.button-primary:hover {
    background: #005a87;
    transform: translateY(-2px);
}

.button-primary:active {
    transform: translateY(0);
}

/* Messaggi */
.wc-b2b-message {
    padding: 15px 20px;
    margin-bottom: 25px;
    border-radius: 6px;
    font-size: 14px;
    line-height: 1.6;
}

.wc-b2b-message.success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.wc-b2b-message.error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.wc-b2b-message.info {
    background: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
}

.wc-b2b-message strong {
    display: block;
    margin-bottom: 5px;
    font-size: 16px;
}

/* Errori Form - Box evidenziato sotto il pulsante */
.wc-b2b-form-errors {
    display: flex;
    gap: 15px;
    padding: 20px;
    margin: 20px 0;
    background: #fff3cd;
    border: 3px solid #dc3232;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(220, 50, 50, 0.2);
    animation: shake 0.5s, fadeIn 0.3s;
}

.wc-b2b-form-errors .error-icon {
    flex-shrink: 0;
}

.wc-b2b-form-errors .error-icon .dashicons {
    width: 40px;
    height: 40px;
    font-size: 40px;
    color: #dc3232;
    animation: pulse 1.5s infinite;
}

.wc-b2b-form-errors .error-content {
    flex: 1;
}

.wc-b2b-form-errors strong {
    display: block;
    margin-bottom: 10px;
    color: #dc3232;
    font-size: 18px;
    font-weight: 700;
}

.wc-b2b-form-errors ul {
    margin: 10px 0;
    padding-left: 25px;
    list-style: disc;
    color: #721c24;
}

.wc-b2b-form-errors li {
    margin-bottom: 8px;
    font-size: 15px;
    line-height: 1.5;
    font-weight: 600;
}

.wc-b2b-form-errors .error-help {
    margin: 15px 0 0 0;
    padding: 10px;
    background: #fff;
    border-left: 3px solid #dc3232;
    font-size: 14px;
    color: #666;
    font-style: italic;
}

/* Animazioni per gli errori */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Link */
.wc-b2b-registration-form a {
    color: #0073aa;
    text-decoration: none;
    transition: all 0.3s ease;
}

.wc-b2b-registration-form a:hover {
    text-decoration: underline;
    color: #005a87;
}

/* Checkbox Labels con link */
.wc-b2b-registration-form .form-row label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    line-height: 1.6;
}

.wc-b2b-registration-form .form-row label input[type="checkbox"] {
    margin-top: 3px;
    flex-shrink: 0;
}

.wc-b2b-registration-form .form-row label a .dashicons {
    vertical-align: middle;
    margin-left: 2px;
    opacity: 0.7;
}

.wc-b2b-registration-form .form-row label a:hover .dashicons {
    opacity: 1;
}

/* Indicatore file caricato */
.form-row.file-loaded .input-file {
    border-color: #28a745;
    background-color: #f0fff4;
}

.form-row.file-loaded label::after {
    content: " ✓";
    color: #28a745;
    font-weight: bold;
    margin-left: 5px;
}

/* Responsive */
@media (max-width: 768px) {
    .wc-b2b-registration-form {
        padding: 20px;
        margin: 20px;
    }
    
    .wc-b2b-registration-form h2 {
        font-size: 24px;
    }
    
    .form-section {
        padding: 15px;
    }
    
    .form-section h3 {
        font-size: 18px;
    }
    
    .button {
        width: 100%;
        padding: 15px;
    }
    
    .wc-b2b-form-errors {
        flex-direction: column;
        gap: 10px;
    }
    
    .wc-b2b-form-errors .error-icon .dashicons {
        width: 30px;
        height: 30px;
        font-size: 30px;
    }
}

/* Loading state */
.b2b-form.loading {
    opacity: 0.6;
    pointer-events: none;
}

.b2b-form.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0073aa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Validazione errori */
.input-text.error {
    border-color: #dc3232;
}

.input-text.error:focus {
    box-shadow: 0 0 0 3px rgba(220, 50, 50, 0.1);
}

.field-error {
    display: block;
    margin-top: 5px;
    color: #dc3232;
    font-size: 12px;
    font-weight: 600;
}

/* Select styling */
select.input-text {
    appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg fill="%23333" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 20px;
    padding-right: 40px;
    cursor: pointer;
}

/* Privacy e Terms checkbox */
.form-row label input[type="checkbox"] + span {
    vertical-align: middle;
}

/* Accessibility */
.input-text:focus,
.button:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .wc-b2b-registration-form {
        box-shadow: none;
        border: none;
    }
    
    .button {
        display: none;
    }
}

/* ====================================
   Anti-Spam Styling
   ==================================== */

/* Honeypot Field (campo invisibile) */
.b2b-honeypot {
    position: absolute !important;
    left: -9999px !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    clip: rect(0, 0, 0, 0) !important;
    clip-path: inset(50%) !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Math CAPTCHA styling */
.wc-b2b-registration-form .form-row input[name="math_captcha"] {
    max-width: 150px;
}

.wc-b2b-registration-form .form-row label[for="math_captcha"] {
    font-weight: 600;
    color: #0073aa;
}

/* ====================================
   Prodotti B2B - Stili minimi per griglia
   ==================================== */

/* Stili base per supportare la griglia prodotti B2B
   Il CSS inline generato dinamicamente gestirà le colonne specifiche
*/

/* ====================================
   Tabella ordine B2B – minimal, margini corretti
   Selettori specifici per evitare override del tema
   Rosso 0-2, Arancione 2-15, Verde 15+
   ==================================== */

.woocommerce .wc-b2b-order-table-wrapper,
.single-product .wc-b2b-order-table-wrapper,
.wc-b2b-order-table-wrapper {
    margin: 1em 0 1.5em 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    position: relative !important;
}

.woocommerce .wc-b2b-order-table-scroll-wrap,
.wc-b2b-order-table-scroll-wrap {
    position: relative !important;
    width: 100% !important;
    max-width: 100% !important;
}

.woocommerce .wc-b2b-order-table-scroll,
.wc-b2b-order-table-scroll {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    width: 100% !important;
    max-width: 100% !important;
}

/* Freccia destra: nascosta di default, visibile solo se c'è overflow (script aggiunge .wc-b2b-scroll-hint-visible) */
.wc-b2b-order-table-scroll-wrap .wc-b2b-table-scroll-hint,
.woocommerce .wc-b2b-order-table-scroll-wrap .wc-b2b-table-scroll-hint,
.single-product .wc-b2b-order-table-scroll-wrap .wc-b2b-table-scroll-hint,
.woocommerce .wc-b2b-table-scroll-hint,
.single-product .wc-b2b-table-scroll-hint,
.wc-b2b-table-scroll-hint {
    position: absolute !important;
    right: -10px !important;
    top: 50% !important;
    margin-top: 0 !important;
    transform: translateY(-50%) !important;
    width: 32px !important;
    min-width: 32px !important;
    height: 44px !important;
    min-height: 44px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    pointer-events: none !important;
    color: #555 !important;
    background: linear-gradient(to left, rgba(255,255,255,0.95) 50%, transparent) !important;
    z-index: 10 !important;
    overflow: visible !important;
    visibility: hidden !important;
    opacity: 0 !important;
    transition: opacity 0.25s ease, visibility 0.25s ease !important;
}

.wc-b2b-table-scroll-hint.wc-b2b-scroll-hint-visible,
.wc-b2b-order-table-scroll-wrap.wc-b2b-has-overflow .wc-b2b-table-scroll-hint {
    visibility: visible !important;
    opacity: 1 !important;
}

/* Nasconde la freccia quando l'utente è arrivato in fondo a destra (tutto scrollato) */
.wc-b2b-order-table-scroll-wrap.wc-b2b-scroll-at-end .wc-b2b-table-scroll-hint {
    visibility: hidden !important;
    opacity: 0 !important;
}

.wc-b2b-order-table-scroll-wrap .wc-b2b-table-scroll-hint.wc-b2b-scroll-hint-visible svg,
.wc-b2b-order-table-scroll-wrap.wc-b2b-has-overflow .wc-b2b-table-scroll-hint svg,
.wc-b2b-table-scroll-hint.wc-b2b-scroll-hint-visible svg {
    animation: wc-b2b-arrow-slide-right 1.2s ease-in-out infinite !important;
}

.wc-b2b-order-table-scroll-wrap .wc-b2b-table-scroll-hint svg,
.wc-b2b-table-scroll-hint svg {
    width: 100% !important;
    height: 100% !important;
    display: block !important;
    object-fit: contain !important;
}

@keyframes wc-b2b-arrow-slide-right {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(6px); }
}

.woocommerce .wc-b2b-order-table-title,
.single-product .wc-b2b-order-table-title,
.wc-b2b-order-table-title {
    margin: 0 0 0.6em 0 !important;
    font-size: 0.9em !important;
    font-weight: 600 !important;
    color: #333 !important;
}

.woocommerce .wc-b2b-order-table,
.single-product .wc-b2b-order-table,
.wc-b2b-order-table {
    width: 100% !important;
    min-width: max-content !important;
    border-collapse: collapse !important;
    margin: 0 0 0.6em 0 !important;
    font-size: 13px !important;
}

.woocommerce .wc-b2b-order-table th,
.woocommerce .wc-b2b-order-table td,
.single-product .wc-b2b-order-table th,
.single-product .wc-b2b-order-table td,
.wc-b2b-order-table th,
.wc-b2b-order-table td {
    padding: 0.5em 0.6em !important;
    text-align: center !important;
    border-bottom: 1px solid #eee !important;
    border-left: none !important;
    border-right: none !important;
}

.woocommerce .wc-b2b-order-table thead th,
.single-product .wc-b2b-order-table thead th,
.wc-b2b-order-table thead th {
    background: #fafafa !important;
    color: #444 !important;
    font-weight: 600 !important;
    font-size: 0.85em !important;
}

.woocommerce .wc-b2b-order-table .wc-b2b-col-disponibilita,
.wc-b2b-order-table .wc-b2b-col-disponibilita {
    text-align: left !important;
    min-width: 90px !important;
}

.woocommerce .wc-b2b-order-table .wc-b2b-cell-label,
.wc-b2b-order-table .wc-b2b-cell-label {
    text-align: left !important;
    font-weight: 500 !important;
    background: transparent !important;
    color: #555 !important;
}

.woocommerce .wc-b2b-order-table .wc-b2b-cell-availability,
.wc-b2b-order-table .wc-b2b-cell-availability {
    white-space: nowrap !important;
}

.woocommerce .wc-b2b-dot,
.wc-b2b-dot {
    display: inline-block !important;
    width: 8px !important;
    height: 8px !important;
    border-radius: 50% !important;
    margin-right: 5px !important;
    vertical-align: middle !important;
}

.wc-b2b-dot.red {
    background: #c0392b !important;
}

.wc-b2b-dot.orange {
    background: #e67e22 !important;
}

.wc-b2b-dot.green {
    background: #27ae60 !important;
}

.woocommerce .wc-b2b-stock-qty,
.wc-b2b-stock-qty {
    font-weight: 500 !important;
    color: #333 !important;
    font-size: 1em !important;
}

.woocommerce .wc-b2b-qty-input,
.single-product .wc-b2b-qty-input,
.wc-b2b-qty-input {
    width: 52px !important;
    padding: 0.4em 4px !important;
    text-align: center !important;
    border: 1px solid #ddd !important;
    border-radius: 2px !important;
    font-size: 15px !important;
    font-weight: 500 !important;
    color: #222 !important;
    background: #fff !important;
}

.woocommerce .wc-b2b-qty-input:focus,
.wc-b2b-qty-input:focus {
    border-color: #999 !important;
    outline: none !important;
}

.woocommerce .wc-b2b-table-actions,
.wc-b2b-table-actions {
    margin: 0.6em 0 0 0 !important;
}

.woocommerce .wc-b2b-table-add-to-cart,
.single-product .wc-b2b-table-add-to-cart,
.wc-b2b-table-add-to-cart {
    background: #444 !important;
    border: 1px solid #444 !important;
    color: #fff !important;
    padding: 0.65em 1.25em !important;
    font-size: 15px !important;
    font-weight: 500 !important;
    border-radius: 3px !important;
}

.wc-b2b-table-add-to-cart:hover {
    background: #333 !important;
    border-color: #333 !important;
}

