* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f5f5f5;
    color: #000;
    line-height: 1.5;
    padding: 15px;
}

.container {
    max-width: 800px;
    margin: 0 auto;
}

.form-wrapper {
    background-color: #f2f2f2;
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.form-title {
    color: #8B0000;
    font-size: 28px;
    font-weight: bold;
    margin-bottom: 20px;
    text-align: center;
}

.form-group {
    margin-bottom: 10px;
    position: relative;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #000;
    font-size: 14px;
}

label.required::after {
    content: " *";
    color: #8B0000;
}

input[type="text"],
input[type="email"],
input[type="tel"],
select {
    width: 100%;
    padding: 12px 15px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-family: inherit;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    background-color: #fff;
    color: #000;
}

/* Phone input with country code */
.phone-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.custom-country-select {
    position: relative;
    width: auto;
    min-width: 180px;
    flex-shrink: 0;
}

.country-select-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 15px;
    background-color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-family: inherit;
    transition: box-shadow 0.3s ease;
    width: 100%;
}

.country-select-trigger:hover {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.country-flag {
    font-size: 18px;
    line-height: 1;
}

.country-name {
    flex: 1;
    text-align: left;
    color: #000;
}

.country-code-display {
    color: #999;
    font-size: 14px;
}

.dropdown-arrow {
    color: #999;
    font-size: 10px;
    transition: transform 0.3s ease;
}

.custom-country-select.open .dropdown-arrow {
    transform: rotate(180deg);
}

.country-select-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background-color: #fff;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    max-height: 300px;
    overflow: hidden;
    display: none;
    flex-direction: column;
}

.custom-country-select.open .country-select-dropdown {
    display: flex;
}

.country-search {
    padding: 10px;
    border-bottom: 1px solid #eee;
}

.country-search input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
}

.country-search input:focus {
    outline: none;
    border-color: #8B0000;
}

.country-list {
    max-height: 250px;
    overflow-y: auto;
    padding: 4px 0;
}

.country-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.country-item:hover {
    background-color: #f5f5f5;
}

.country-item .country-flag {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.country-item .country-name {
    flex: 1;
    color: #000;
    font-size: 14px;
}

.country-item .country-code {
    color: #999;
    font-size: 13px;
}

#cellulare {
    flex: 1;
}

/* Provincia select styling */
.custom-provincia-select {
    position: relative;
    width: 100%;
}

.provincia-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 15px;
    background-color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-family: inherit;
    transition: box-shadow 0.3s ease;
    width: 100%;
    color: #000;
}

.provincia-select-trigger:hover {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.provincia-name {
    flex: 1;
    text-align: left;
    color: #999;
}

.custom-provincia-select.open .provincia-name {
    color: #000;
}

.provincia-select-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background-color: #fff;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    max-height: 300px;
    overflow: hidden;
    display: none;
    flex-direction: column;
}

.custom-provincia-select.open .provincia-select-dropdown {
    display: flex;
}

.provincia-search {
    padding: 10px;
    border-bottom: 1px solid #eee;
}

.provincia-search input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
}

.provincia-search input:focus {
    outline: none;
    border-color: #8B0000;
}

.provincia-list {
    max-height: 250px;
    overflow-y: auto;
    padding: 4px 0;
}

.provincia-item {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.provincia-item:hover {
    background-color: #f5f5f5;
}

.provincia-item .provincia-name-text {
    color: #000;
    font-size: 14px;
}

.custom-provincia-select.open .dropdown-arrow {
    transform: rotate(180deg);
}

.custom-provincia-select:focus-within .provincia-select-trigger {
    border: 2px solid #8B0000;
    box-shadow: 0 0 0 3px rgba(139, 0, 0, 0.1);
}

.custom-provincia-select.error .provincia-select-trigger {
    border: 2px solid #8B0000;
    background-color: #fff !important;
}

.custom-provincia-select.valid .provincia-select-trigger {
    border: 2px solid #28a745;
}

input[type="text"]::placeholder,
input[type="email"]::placeholder,
input[type="tel"]::placeholder {
    color: #999;
    opacity: 1;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
select:focus {
    outline: none;
    border: 2px solid #8B0000;
    box-shadow: 0 0 0 3px rgba(139, 0, 0, 0.1);
}

.phone-input-wrapper:focus-within #cellulare {
    border: 2px solid #8B0000;
    box-shadow: 0 0 0 3px rgba(139, 0, 0, 0.1);
}

input[type="text"].error,
input[type="email"].error,
input[type="tel"].error,
select.error {
    border: 2px solid #8B0000;
    background-color: #fff !important;
}

.phone-input-wrapper #cellulare.error {
    border: 2px solid #8B0000;
    background-color: #fff !important;
}

input[type="text"].valid,
input[type="email"].valid,
input[type="tel"].valid,
select.valid {
    border: 2px solid #28a745;
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23999' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    padding-right: 40px;
    color: #000;
}

select:invalid {
    color: #999;
}

select option {
    color: #000;
}

select option[value=""] {
    color: #999;
}

.error-message {
    display: block;
    color: #8B0000;
    font-size: 13px;
    margin-top: 4px;
    min-height: 18px;
    opacity: 0;
    transform: translateY(-5px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.error-message.show {
    opacity: 1;
    transform: translateY(0);
}

.submit-btn {
    width: 100%;
    padding: 14px 30px;
    background-color: #8B0000;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
    font-family: inherit;
}

.submit-btn:hover {
    background-color: #700000;
    transform: translateY(-1px);
}

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

.submit-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* Conditional fields container */
#conditionalFields {
    margin: 0;
    padding: 0;
}

/* Conditional fields animation */
.conditional-field {
    animation: fadeIn 0.3s ease;
    margin-bottom: 10px;
}

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

/* CAPTCHA styling */
.g-recaptcha {
    margin: 8px 0;
    display: flex;
    justify-content: flex-start;
}

#recaptcha-error {
    margin-top: 10px;
}

/* Privacy Checkbox styling */
.checkbox-group {
    margin-top: 8px;
    margin-bottom: 10px;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    cursor: pointer;
    font-weight: normal;
    margin-bottom: 0;
    color: #000;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    margin-right: 10px;
    margin-top: 3px;
    cursor: pointer;
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    accent-color: #8B0000;
}

.checkbox-text {
    flex: 1;
    line-height: 1.5;
    font-size: 14px;
}

.checkbox-text a {
    color: #8B0000;
    text-decoration: underline;
    transition: color 0.3s ease;
}

.checkbox-text a:hover {
    color: #700000;
    text-decoration: underline;
}

.checkbox-label input[type="checkbox"].error {
    outline: 2px solid #8B0000;
    outline-offset: 2px;
}

/* Success and Error Messages */
.success-message,
.form-error-message {
    margin-bottom: 25px;
    padding: 20px;
    border-radius: 4px;
    animation: fadeIn 0.3s ease;
    transition: opacity 0.3s ease;
}

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

.success-message h3 {
    color: #155724;
    margin-bottom: 10px;
    font-size: 18px;
}

.success-message p {
    color: #155724;
    margin: 0;
}

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

.form-error-message h3 {
    color: #721c24;
    margin-bottom: 10px;
    font-size: 18px;
}

.form-error-message p {
    color: #721c24;
    margin: 0;
}

/* Responsive design */
@media (max-width: 768px) {
    .form-wrapper {
        padding: 25px 20px;
    }

    .form-title {
        font-size: 24px;
    }

    body {
        padding: 10px;
    }

    .g-recaptcha {
        transform: scale(0.85);
        transform-origin: 0 0;
    }

    .phone-input-wrapper {
        flex-direction: column;
        gap: 8px;
    }

    .country-code-select {
        width: 100%;
        min-width: 100%;
    }
}

