/*=================================================
ELMAK FORM BUILDER STYLES - DESIGN ESATTO
=================================================== */

.elmak-form-wrapper {
    position: relative;
}

.elmak-form {
    font-family: var(--e-global-typography-text-font-family), Sans-serif;
    color: var(--e-global-color-text);
}

/*=================================================
FIELD GROUPS - FLOATING LABELS
=================================================== */
.elmak-field-group {
    position: relative;
    margin-bottom: 0;
}

.elmak-field-group .form-label {
    display: none; /* Nascondiamo le label tradizionali */
}

/*=================================================
INPUT GROUPS - STILE FLOATING LABEL
=================================================== */
.elmak-form .input-group {
    position: relative;
    background: var(--e-global-color-adb330f);
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: visible;
    z-index: 1;
    transition: all 0.3s ease;
}

.elmak-form .input-group:focus-within {
    border-color: var(--e-global-color-secondary);
}

.elmak-form .input-group-text {
    background: transparent;
    border: none;
    color: var(--e-global-color-secondary);
    min-width: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    padding: 0.75rem;
}

.elmak-form .form-control {
    border: none;
    padding: 1rem 1rem 1rem 0;
    font-size: var(--e-global-typography-text-font-size);
    background: transparent;
    color: var(--e-global-color-text);
    font-family: var(--e-global-typography-text-font-family);
    text-align: left;
    /* display: flex; */
    align-items: center;
}

.elmak-form .form-select {
    border: none;
    padding: 1rem 1rem 1rem 0rem;
    font-size: var(--e-global-typography-text-font-size);
    background: transparent;
    color: var(--e-global-color-text);
    font-family: var(--e-global-typography-text-font-family);
    display: flex;
    align-items: center;
}

.elmak-form .form-control:focus,
.elmak-form .form-select:focus {
    box-shadow: none;
    border: none;
    background: transparent;
    outline: none;
}

/* Floating Label */
.elmak-form .floating-label {
    position: absolute;
    left: 50px;
    transform: translateY(-50%);
    top: 50%;
    color: var(--e-global-color-acb81eb);
    font-size: 12px;
    font-family: var(--e-global-typography-secondary-font-family);
    font-weight: 600;
    text-transform: uppercase;
    transition: all 0.3s ease;
    pointer-events: none;
    z-index: 1;
}

.elmak-form .floating-label.active,
.elmak-form .input-group:focus-within .floating-label {
    top: -0.3rem;
    left: 10px;
    font-size: 0.6rem;
    color: var(--e-global-color-acb81eb);
    font-family: var(--e-global-typography-secondary-font-family);
    transform: translateY(0);
    background: var(--e-global-color-adb330f);
    padding: 0 0.25rem;
}

.elmak-form .required {
    color: #e74c3c;
}

/*=================================================
TEXTAREA
=================================================== */
.elmak-form textarea.form-control {
    resize: vertical;
    min-height: 120px;
    font-family: var(--e-global-typography-text-font-family);
    line-height: 1.5;
    padding: 1rem;
    text-align: left;
    display: block;
    align-items: flex-start;
}

/*=================================================
SELECT FIELDS
=================================================== */
.elmak-form .form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%234DA6B8' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m1 6 7 7 7-7'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 16px 12px;
    cursor: pointer;
}

/*=================================================
CHECKBOX & RADIO - CUSTOM DESIGN
=================================================== */
.elmak-form .form-check {
    padding: 0;
    margin-bottom: 0;
    position: relative;
    display: flex;
    align-items: flex-start;
    border: 1px solid #e0e0e0;
    background-color: white;
    border-radius: 8px;
    z-index: 1;
}

/* Hide default checkbox/radio */
.elmak-form .elmak-checkbox .form-check-input,
.elmak-form .elmak-radio .form-check-input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
    margin: 0;
}

/* Custom checkbox */
.elmak-form .elmak-checkbox .form-check-label {
    position: relative;
    cursor: pointer;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    color: var(--e-global-color-acb81eb);
    line-height: 1.4;
    transition: all 0.3s ease;
    padding: 0.75rem 0.75rem 0.75rem 50px;
    font-weight: 600;
}

.elmak-form .elmak-checkbox .form-check-label::before {
    content: '';
    position: absolute;
    left: 16px;
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid #e0e0e0;
    border-radius: 4px;
    background: var(--e-global-color-adb330f);
    transition: all 0.3s ease;
    transform: translateY(-50%);
    top: 50%;
}

.elmak-form .elmak-checkbox .form-check-label::after {
    content: '';
    position: absolute;
    left: 20px;
    top: 50%;
    width: 0.75rem;
    height: 0.75rem;
    background: var(--e-global-color-secondary);
    border-radius: 2px;
    opacity: 0;
    transform: scale(0) translateY(-50%);
    transition: all 0.3s ease;
    perspective-origin: center;
}

.elmak-form .elmak-checkbox .form-check-label a {
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    color: var(--e-global-color-secondary);
    transition: all 0.3s ease;
    font-weight: 600;
}

.elmak-form .elmak-checkbox .form-check-label a:hover {
    color: var(--e-global-color-acb81eb);
}

.elmak-form .elmak-checkbox .form-check-input:checked + .form-check-label::before {
    border-color: var(--e-global-color-secondary);
    background: var(--e-global-color-adb330f);
}

.elmak-form .elmak-checkbox .form-check-input:checked + .form-check-label::after {
    opacity: 1;
    transform: scale(1) translateY(-50%);
}

.elmak-form .elmak-checkbox .form-check-label:hover::before {
    border-color: var(--e-global-color-secondary);
}

/* Custom radio */
.elmak-form .elmak-radio:before {
    content: '' !important;
}
.elmak-form .elmak-radio .form-check-label {
    cursor: pointer;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    color: var(--e-global-color-acb81eb);
    line-height: 1.4;
    transition: all 0.3s ease;
    padding: 0.75rem 0.75rem 0.75rem 50px;
    font-weight: 600;
}

.elmak-form .elmak-radio .form-check-label::before {
    content: '';
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid #e0e0e0;
    border-radius: 50%;
    background: var(--e-global-color-adb330f);
    transition: all 0.3s ease;
    display: block;
}

.elmak-form .elmak-radio .form-check-label::after {
    content: '';
    position: absolute;
    left: 22px;
    top: 50%;
    width: 0.5rem;
    height: 0.5rem;
    background: var(--e-global-color-secondary);
    border-radius: 50%;
    opacity: 0;
    transform: scale(0) translateY(-50%);
    transition: all 0.3s ease;
    display: block;
    perspective-origin: center;
}

.elmak-form .elmak-radio .form-check-input:checked + .form-check-label::before {
    border-color: var(--e-global-color-secondary);
}

.elmak-form .elmak-radio .form-check-input:checked + .form-check-label::after {
    opacity: 1;
    transform: scale(1) translateY(-50%);
}

.elmak-form .elmak-radio .form-check-label:hover::before {
    border-color: var(--e-global-color-secondary);
}

/* Fallback for standard checkboxes/radios */
.elmak-form .form-check:not(.elmak-checkbox):not(.elmak-radio) .form-check-input {
    margin-top: 0.25rem;
    transition: all 0.3s ease;
    border-color: #e0e0e0;
}

.elmak-form .form-check:not(.elmak-checkbox):not(.elmak-radio) .form-check-input:checked {
    background-color: var(--e-global-color-secondary);
    border-color: var(--e-global-color-secondary);
}

.elmak-form .form-check:not(.elmak-checkbox):not(.elmak-radio) .form-check-label {
    cursor: pointer;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    color: var(--e-global-color-acb81eb);
    line-height: 1.4;
    transition: all 0.3s ease;
    padding: 0.75rem 0.75rem 0.75rem 50px;
    font-weight: 600;
}

.elmak-form .form-check:not(.elmak-checkbox):not(.elmak-radio) .form-check-label:hover {
    color: var(--e-global-color-secondary);
}

/* Grouped Checkboxes */
.elmak-form .elmak-field-group:has(.form-check + .form-check) {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 0.75rem 0;
    background: var(--e-global-color-adb330f);
}

.elmak-form .elmak-field-group:has(.form-check + .form-check) .form-check {
    margin-bottom: 0.5rem;
    padding: 0;
    border: none;
}

.elmak-form .elmak-field-group:has(.form-check + .form-check) .form-check:last-child {
    margin-bottom: 0;
}

/* Focus state for grouped checkboxes */
.elmak-form .elmak-field-group:has(.form-check + .form-check):focus-within {
    border-color: var(--e-global-color-secondary);
}

/* Error state for grouped checkboxes */
.elmak-form .elmak-field-group:has(.form-check + .form-check.is-invalid) {
    border-color: #e74c3c;
}

/*=================================================
SWITCH
=================================================== */
.elmak-form .form-switch {
    padding: 0.75rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.elmak-form .form-switch .form-check-input {
    width: 3rem;
    height: 1.5rem;
    border-radius: 3rem;
    background-image: none;
    background-color: #e0e0e0;
    border: 2px solid #e0e0e0;
    transition: all 0.3s ease;
    position: relative;
    cursor: pointer;
    margin: 0;
    flex-shrink: 0;
}

.elmak-form .form-switch .form-check-label {
    cursor: pointer;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    color: var(--e-global-color-acb81eb);
    line-height: 1.4;
    transition: all 0.3s ease;
    padding: 0 !important;
    font-weight: 600;
}

.elmak-form .form-switch .form-check-input::before {
    content: '';
    position: absolute;
    top: 1px;
    left: 2px;
    width: 1.125rem;
    height: 1.125rem;
    background: white;
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.elmak-form .form-switch .form-check-input:active::before {
    transform: scaleX(1.3);
}

.elmak-form .form-switch .form-check-input:checked {
    background-color: var(--e-global-color-secondary);
    border-color: var(--e-global-color-secondary);
}

.elmak-form .form-switch .form-check-input:checked::before {
    transform: translateX(1.5rem);
}

.elmak-form .form-switch .form-check-input:checked:active::before {
    transform: translateX(1.5rem) scaleX(1.3);
}

/* Keyframe animation for stretch effect */
.elmak-form .form-switch .form-check-input:not(:checked)::before {
    animation: stretch-left 0.3s ease-out;
}

.elmak-form .form-switch .form-check-input:checked::before {
    animation: stretch-right 0.3s ease-out;
}

@keyframes stretch-right {
    0% { transform: translateX(0) scaleX(1); }
    50% { transform: translateX(0.75rem) scaleX(1.4); }
    100% { transform: translateX(1.5rem) scaleX(1); }
}

@keyframes stretch-left {
    0% { transform: translateX(1.5rem) scaleX(1); }
    50% { transform: translateX(0.75rem) scaleX(1.4); }
    100% { transform: translateX(0) scaleX(1); }
}

/*=================================================
HTML FIELD
=================================================== */
.elmak-form .elmak-field-group .alert {
    margin-bottom: 0;
    font-size: var(--e-global-typography-text-font-size);
    font-family: var(--e-global-typography-text-font-family);
    line-height: 1.6;
}

.elmak-form .elmak-field-group .alert-info {
    background-color: rgba(77, 166, 184, 0.1);
    border-color: var(--e-global-color-secondary);
    color: var(--e-global-color-text);
}

.elmak-form .elmak-field-group .alert strong {
    color: var(--e-global-color-secondary);
    font-weight: 600;
}

.elmak-form .elmak-field-group .alert a {
    color: var(--e-global-color-secondary);
    text-decoration: underline;
}

.elmak-form .elmak-field-group .alert a:hover {
    color: var(--e-global-color-primary);
    text-decoration: none;
}



/*=================================================
PASSWORD TOGGLE
=================================================== */
.elmak-form .toggle-password {
    border-left: none;
    background: transparent;
    color: var(--e-global-color-secondary);
    transition: all 0.3s ease;
    border: none;
}

.elmak-form .toggle-password:hover {
    color: var(--e-global-color-accent);
    background: transparent;
}

/*=================================================
SUBMIT BUTTON - STILE PERSONALIZZATO
=================================================== */
.elmak-form-submit {
    margin-top: 2rem;
}

.elmak-form-submit .btn {
    width: 100%;
    padding: 1rem 2rem;
    font-weight: 600;
    font-size: var(--e-global-typography-text-font-size);
    font-family: var(--e-global-typography-text-font-family);
    border-radius: 8px;
    transition: all 0.3s ease;
    background-color: var(--e-global-color-secondary);
    border: none;
    color: var(--e-global-color-adb330f);
    text-transform: none;
}

.elmak-form-submit .btn:hover {
    background-color: var(--e-global-color-accent);
    transform: translateY(-1px);
    color: white !important;
}

.elmak-form-submit .btn:active {
    transform: translateY(0);
}

/*=================================================
SELECT2 STYLES
=================================================== */
.elmak-form .select2-hidden-accessible {
    display: none !important;
}

.elmak-form .select2-container:not(.input-group .select2-container) {
    width: 100% !important;
}

.elmak-form .input-group .select2-container {
    flex: 1 1 auto;
    width: auto !important;
}

.elmak-form .input-group .select2-container .select2-selection {
    border: none;
    background: transparent;
    height: 56px;
    padding: 1rem 1rem 1rem 0;
    display: flex;
    align-content: center;
    flex-wrap: wrap;
}

.elmak-form .input-group .select2-container .select2-selection--single {
    height: 56px;
}

.elmak-form .input-group .select2-container .select2-selection__rendered {
    padding: 0;
    line-height: inherit;
    font-family: var(--e-global-typography-text-font-family);
    font-size: var(--e-global-typography-text-font-size);
    color: var(--e-global-color-text);
}

/*=================================================
VALIDATION STATES
=================================================== */
.elmak-form .input-group.is-invalid {
    border-color: #e74c3c;
}

.elmak-form .input-group.is-invalid .select2-container .select2-selection {
    border-color: #e74c3c !important;
}

.elmak-form .form-check.is-invalid .form-check-label::before {
    border-color: #e74c3c !important;
}

.elmak-form .select2-container.is-invalid .select2-selection {
    border-color: #e74c3c !important;
}

/* Custom Select2 Arrow */
.elmak-form .select2-container .select2-selection__arrow {
    height: 100%;
    right: 1rem;
    width: 20px;
}

.elmak-form .select2-container .select2-selection__arrow b {
    display: none;
}

.elmak-form .select2-container .select2-selection__arrow::after {
    content: '\e912';
    font-family: 'elmak';
    font-weight: normal;
    color: var(--e-global-color-secondary);
    font-size: 1rem;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: transform 0.3s ease;
}

.elmak-form .select2-container.select2-container--open .select2-selection__arrow::after {
    transform: translate(-50%, -50%) rotate(180deg);
}

/* Select2 Dropdown Customization - Rendered in body */
.select2-dropdown {
    background-color: var(--e-global-color-adb330f); /* Dropdown background */
    border: 1px solid #e0e0e0; /* Dropdown border */
    border-radius: 8px; /* Dropdown border radius */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); /* Dropdown shadow */
    margin-top: 1px; /* Gap between select and dropdown */
    z-index: 1051; /* Dropdown z-index */
}

.select2-results {
    padding: 0.5rem 0; /* Results container padding */
}

.select2-results__options {
    max-height: 200px; /* Max dropdown height */
    overflow-y: auto; /* Scroll behavior */
}

.select2-results__option {
    padding: 0.5rem 1rem; /* Option padding */
    font-size: 14px; /* Option font size */
    font-family: var(--e-global-typography-text-font-family); /* Option font family */
    color: var(--e-global-color-text); /* Option text color */
    cursor: pointer;
    transition: all 0.2s ease; /* Hover transition */
    border-bottom: 1px solid rgba(224, 224, 224, 0.3); /* Option separator */
}

.select2-results__option:last-child {
    border-bottom: none; /* Remove last option border */
}

.select2-results__option--highlighted {
    background-color: var(--e-global-color-secondary); /* Hover background */
    color: var(--e-global-color-adb330f); /* Hover text color */
}

.select2-results__option[aria-selected="true"] {
    background-color: rgba(77, 166, 184, 0.1) !important; /* Selected background */
    color: var(--e-global-color-secondary) !important; /* Selected text color */
    font-weight: 600; /* Selected font weight */
}

.select2-results__option[data-selected="true"]:not(.select2-results__option--highlighted) {
    background-color: rgba(77, 166, 184, 0.1); /* Selected but not hovered */
}

/* Search Box in Dropdown */
.select2-search--dropdown {
    padding: 0.5rem; /* Search container padding */
    background: var(--e-global-color-adb330f); /* Search background */
    border-bottom: 1px solid #e0e0e0; /* Search separator */
}

.select2-search__field {
    padding: 0.5rem 0.75rem; /* Search input padding */
    border: 1px solid #e0e0e0; /* Search input border */
    border-radius: 4px; /* Search input border radius */
    font-size: 0.875rem; /* Search input font size */
    font-family: var(--e-global-typography-text-font-family); /* Search input font */
    background: var(--e-global-color-adb330f); /* Search input background */
    color: var(--e-global-color-text); /* Search input text color */
    width: 100%;
    outline: none;
}

.select2-search__field:focus {
    border-color: var(--e-global-color-secondary); /* Search input focus border */
    box-shadow: 0 0 0 2px rgba(77, 166, 184, 0.2); /* Search input focus shadow */
}

/* No Results Message */
.select2-results__message {
    padding: 1rem; /* No results padding */
    text-align: center; /* No results alignment */
    color: var(--e-global-color-acb81eb); /* No results text color */
    font-style: italic; /* No results font style */
    font-size: 0.875rem; /* No results font size */
}

/* Multiple Select Tags - These stay in form */
.elmak-form .select2-selection--multiple .select2-selection__choice {
    background-color: var(--e-global-color-secondary); /* Tag background */
    border: 1px solid var(--e-global-color-secondary); /* Tag border */
    border-radius: 4px; /* Tag border radius */
    color: var(--e-global-color-adb330f); /* Tag text color */
    font-size: 0.875rem; /* Tag font size */
    padding: 0.25rem 0.5rem; /* Tag padding */
    margin: 0.25rem 0.25rem 0.25rem 0; /* Tag margin */
}

.elmak-form .select2-selection--multiple .select2-selection__choice__remove {
    color: var(--e-global-color-adb330f); /* Tag remove color */
    margin-right: 0.25rem; /* Tag remove margin */
    font-weight: bold;
}

.elmak-form .select2-selection--multiple .select2-selection__choice__remove:hover {
    color: #ff6b6b; /* Tag remove hover color */
}

.elmak-form .invalid-feedback {
    display: block;
    font-size: 11px;
    font-family: 'Inter';
    color: white;
    animation: fadeInUp 0.3s ease;
    text-transform: uppercase;
    font-weight: 600;
    background-color: #e74c3c;
    padding: 15px 10px 5px;
    text-align: center;
    margin-top: -10px;
    border-radius: 8px;
    z-index: 0;
    position: relative;
}

.elmak-form .input-group.is-valid {
    border-color: #27ae60;
}

.elmak-form .valid-feedback {
    display: block;
    font-size: var(--e-global-typography-accent-font-size);
    font-family: var(--e-global-typography-secondary-font-family);
    color: #27ae60;
    margin-top: 0.5rem;
    animation: fadeInUp 0.3s ease;
}

/*=================================================
RECAPTCHA INFO
=================================================== */
.elmak-recaptcha-info {
    text-align: left;
    margin: 1rem 0;
    font-size: 12px;
    color: var(--e-global-color-acb81eb);
    font-family: var(--e-global-typography-primary-font-family) !important;
}

.elmak-recaptcha-info a {
    color: var(--e-global-color-secondary);
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--e-global-typography-primary-font-family) !important;
}

.elmak-recaptcha-info a:hover {
    text-decoration: underline;
}

/*=================================================
ERROR MESSAGES BOX
=================================================== */
.elmak-form .elmak-form-message {
    font-family: var(--e-global-typography-primary-font-family) !important;
    font-size: 14px;
    font-weight: 600;
    margin-top: 1.25rem;
}

.elmak-form .elmak-form-message button {
    background-color: transparent !important;
}

/*=================================================
LOADING STATE
=================================================== */
.elmak-form.loading {
    pointer-events: none;
    opacity: 0.8;
}

.elmak-form.loading .btn {
    position: relative;
    color: transparent;
}

.elmak-form.loading .btn::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    margin: auto;
    border: 2px solid transparent;
    border-top-color: var(--e-global-color-adb330f);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
}

/*=================================================
ANIMATIONS
=================================================== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/*=================================================
RESPONSIVE
=================================================== */
/*=================================================
FILE UPLOAD - STILE PERSONALIZZATO
=================================================== */
.elmak-file-upload {
    position: relative;
    border: 2px dashed #e0e0e0;
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    transition: all 0.3s ease;
    background: var(--e-global-color-adb330f);
}

.elmak-file-upload:hover {
    border-color: var(--e-global-color-secondary);
    background: #f0f8ff;
}

/*=================================================
RESPONSIVE
=================================================== */
/* Select Label Statica */
.elmak-form .select-label {
    position: absolute;
    top: -0.3rem;
    left: 10px;
    font-size: 0.6rem;
    color: var(--e-global-color-acb81eb);
    font-family: var(--e-global-typography-secondary-font-family);
    font-weight: 600;
    background: var(--e-global-color-adb330f);
    padding: 0 0.25rem;
    z-index: 1;
    text-transform: uppercase;
}

@media (max-width: 768px) {
    .elmak-form .input-group-text {
        min-width: 45px;
    }
    
    .elmak-form .form-select {
        padding: 1.25rem 0.875rem 0.5rem 0.875rem;
    }
    
    .elmak-form .floating-label.active,
    .elmak-form .input-group:focus-within .floating-label {
        left: 10px;
    }
    
    .elmak-form .select-label {
        left: 10px;
    }
    
    .elmak-file-upload {
        padding: 1.5rem 1rem;
    }
}

@media (max-width: 576px) {
    .elmak-field-group {
        margin-bottom: 0.5rem;
    }
    
    .elmak-form .form-select {
        padding: 1.25rem 0.75rem 0.5rem 0.75rem;
    }
    
    .elmak-form .floating-label.active,
    .elmak-form .input-group:focus-within .floating-label {
        left: 10px;
    }
    
    .elmak-form .select-label {
        left: 10px;
    }
}