/* =====================================================
   ONDA CRM FORM - MARCO OSNATO
   Palette blu istituzionale / oro
   ===================================================== */

.onda-crm-form-container {
    --onda-bg-primary: #ffffff;
    --onda-bg-secondary: #f8f9fa;
    --onda-bg-input: #fbfcfe;
    --onda-bg-input-hover: #f1f3f5;
    --onda-border: #d4dae6;
    --onda-border-focus: #ffc83a;
    --onda-text-primary: #022d58;
    --onda-text-secondary: #333333;
    --onda-text-muted: #666666;
    --onda-accent-purple: #022d58;
    --onda-accent-indigo: #132248;
    --onda-accent-blue: #022d58;
    --onda-success: #059669;
    --onda-error: #dc2626;
    --onda-font: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
    --onda-radius: 20px;
    --onda-radius-sm: 10px;
    --onda-shadow-focus: 0 0 0 3px rgba(255, 200, 58, 0.35);
    --onda-transition: 300ms ease;
    
    max-width: 100%;
    margin: 0;
    font-family: var(--onda-font);
}

.onda-crm-form {
    max-width: 100%;
    margin: 0;
    background: transparent;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    border: none;
}

.onda-form-title {
    display: none; /* Nascosto perché usiamo il titolo del template */
    text-align: left;
    margin: 0 0 24px;
    color: var(--onda-text-primary);
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #022d58, #132248);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Form Groups */
.onda-form-fields {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.onda-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 768px) {
    .onda-form-row {
        grid-template-columns: 1fr;
    }
}

.onda-form-group {
    margin-bottom: 0;
    position: relative;
}

/* Labels */
.onda-form-label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--onda-text-secondary);
    letter-spacing: 0.01em;
}

.onda-form-label .required {
    color: var(--onda-accent-purple);
    font-weight: 700;
}

/* Inputs & Textareas */
.onda-form-input,
.onda-form-select,
.onda-form-textarea {
    width: 100%;
    padding: 14px 18px;
    font-family: var(--onda-font);
    font-size: 15px;
    color: var(--onda-text-primary);
    background-color: var(--onda-bg-input);
    border: 1px solid var(--onda-border);
    border-radius: var(--onda-radius-sm);
    transition: all var(--onda-transition);
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
}

.onda-form-input::placeholder,
.onda-form-textarea::placeholder {
    color: var(--onda-text-muted);
}

.onda-form-input:hover,
.onda-form-select:hover,
.onda-form-textarea:hover {
    background-color: var(--onda-bg-input-hover);
}

.onda-form-input:focus,
.onda-form-select:focus,
.onda-form-textarea:focus {
    outline: none;
    background-color: var(--onda-bg-input-hover);
    border-color: var(--onda-border-focus);
    box-shadow: var(--onda-shadow-focus);
}

.onda-form-textarea {
    resize: vertical;
    min-height: 150px;
    line-height: 1.6;
}

/* Select Dropdown */
.onda-form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23999999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 18px;
    padding-right: 48px;
    cursor: pointer;
}

.onda-form-select:focus {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23022d58' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

.onda-form-select option {
    background: var(--onda-bg-secondary);
    color: var(--onda-text-primary);
}

/* Radio Buttons - Card Style Light */
.onda-radio-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.onda-radio-option {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: var(--onda-bg-input);
    border: 1px solid var(--onda-border);
    border-radius: var(--onda-radius-sm);
    cursor: pointer;
    transition: all var(--onda-transition);
}

.onda-radio-option:hover {
    background: var(--onda-bg-input-hover);
    border-color: rgba(2, 45, 88, 0.25);
}

.onda-radio-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.onda-radio-option .radio-indicator {
    width: 22px;
    height: 22px;
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--onda-transition);
    flex-shrink: 0;
}

.onda-radio-option .radio-indicator::after {
    content: '';
    width: 10px;
    height: 10px;
    background: var(--onda-accent-purple);
    border-radius: 50%;
    transform: scale(0);
    transition: transform var(--onda-transition);
}

.onda-radio-option input:checked + .radio-indicator {
    border-color: var(--onda-accent-purple);
}

.onda-radio-option input:checked + .radio-indicator::after {
    transform: scale(1);
}

.onda-radio-option:has(input:checked) {
    background: rgba(2, 45, 88, 0.06);
    border-color: var(--onda-accent-purple);
}

.onda-radio-option .radio-text {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--onda-text-secondary);
    transition: color var(--onda-transition);
}

.onda-radio-option:has(input:checked) .radio-text {
    color: var(--onda-text-primary);
}

/* File Upload - Light Style */
.onda-file-wrapper {
    position: relative;
}

.onda-form-file {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
}

.onda-file-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 32px 24px;
    background: var(--onda-bg-input);
    border: 2px dashed var(--onda-border);
    border-radius: var(--onda-radius);
    cursor: pointer;
    transition: all var(--onda-transition);
    text-align: center;
}

.onda-file-label:hover {
    background: var(--onda-bg-input-hover);
    border-color: var(--onda-accent-purple);
}

.onda-file-label.has-file {
    background: rgba(5, 150, 105, 0.08);
    border-color: var(--onda-success);
    border-style: solid;
}

.onda-file-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--onda-accent-purple), var(--onda-accent-indigo));
    border-radius: 12px;
    color: white;
}

.onda-file-icon svg {
    width: 24px;
    height: 24px;
}

.onda-file-text {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--onda-text-muted);
}

.onda-file-text span {
    color: var(--onda-accent-purple);
    text-decoration: underline;
}

.onda-file-name {
    font-size: 0.85rem;
    color: var(--onda-success);
    font-weight: 600;
    margin-top: 4px;
}

.onda-form-help {
    font-size: 0.8rem;
    color: var(--onda-text-muted);
    margin: 8px 0 0;
}

/* Checkbox - Light Style */
.onda-checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    cursor: pointer;
    padding: 16px 20px;
    background: var(--onda-bg-input);
    border-radius: var(--onda-radius-sm);
    border: 1px solid var(--onda-border);
    transition: all var(--onda-transition);
}

.onda-checkbox-label:hover {
    background: var(--onda-bg-input-hover);
}

.onda-checkbox-label:has(input:checked) {
    background: rgba(2, 45, 88, 0.06);
    border-color: var(--onda-accent-purple);
}

.onda-checkbox-label input[type="checkbox"] {
    position: relative;
    width: 22px;
    height: 22px;
    margin: 0;
    flex-shrink: 0;
    appearance: none;
    -webkit-appearance: none;
    background: var(--onda-bg-secondary);
    border: 2px solid rgba(0, 0, 0, 0.15);
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--onda-transition);
}

.onda-checkbox-label input[type="checkbox"]:checked {
    background: var(--onda-accent-purple);
    border-color: var(--onda-accent-purple);
}

.onda-checkbox-label input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 7px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.onda-checkbox-label span {
    font-size: 0.9rem;
    color: var(--onda-text-muted);
    line-height: 1.5;
}

.onda-checkbox-label span a {
    color: var(--onda-accent-purple);
    text-decoration: underline;
    font-weight: 500;
    transition: color var(--onda-transition);
}

.onda-checkbox-label span a:hover {
    color: var(--onda-accent-indigo);
}

/* Submit Button - Gradient Style */
.onda-form-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 16px 40px;
    font-family: var(--onda-font);
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #022d58;
    background: #ffc83a;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    transition: all var(--onda-transition);
    box-shadow: 0 4px 14px rgba(2, 45, 88, 0.25);
    position: relative;
    overflow: hidden;
}

.onda-form-submit::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fade48;
    opacity: 0;
    transition: opacity var(--onda-transition);
}

.onda-form-submit span {
    position: relative;
    z-index: 1;
}

.onda-form-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(2, 45, 88, 0.35);
}

.onda-form-submit:hover::before {
    opacity: 1;
}

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

.onda-form-submit svg {
    width: 20px;
    height: 20px;
    position: relative;
    z-index: 1;
    transition: transform var(--onda-transition);
}

.onda-form-submit:hover svg {
    transform: translateX(4px);
}

/* Loading State */
.onda-form-loading {
    display: none;
    text-align: center;
    padding: 60px 40px;
}

.onda-spinner {
    width: 56px;
    height: 56px;
    border: 3px solid rgba(2, 45, 88, 0.1);
    border-top-color: var(--onda-accent-purple);
    border-radius: 50%;
    animation: onda-spin 0.8s linear infinite;
    margin: 0 auto 24px;
}

@keyframes onda-spin {
    to { transform: rotate(360deg); }
}

.onda-form-loading p {
    font-size: 1rem;
    color: var(--onda-text-muted);
    margin: 0;
}

/* Success State */
.onda-form-response {
    display: none;
    text-align: center;
    padding: 60px 40px;
}

.onda-success-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    background: rgba(5, 150, 105, 0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: onda-success-pop 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes onda-success-pop {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}

.onda-success-icon::after {
    content: '';
    width: 24px;
    height: 40px;
    border: solid var(--onda-success);
    border-width: 0 4px 4px 0;
    transform: rotate(45deg) translateY(-4px);
}

.onda-response-message {
    font-size: 1.1rem;
    color: var(--onda-text-secondary);
    line-height: 1.7;
    margin-bottom: 30px;
}

.onda-response-message strong {
    color: var(--onda-text-primary);
    display: block;
    font-size: 1.4rem;
    margin-bottom: 8px;
}

.onda-reset-form {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    font-family: var(--onda-font);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--onda-text-secondary);
    background: var(--onda-bg-input);
    border: 1px solid var(--onda-border);
    border-radius: var(--onda-radius-sm);
    cursor: pointer;
    transition: all var(--onda-transition);
}

.onda-reset-form:hover {
    background: var(--onda-bg-input-hover);
    color: var(--onda-text-primary);
    border-color: var(--onda-accent-purple);
}

.onda-reset-form svg {
    transition: transform 0.4s ease;
}

.onda-reset-form:hover svg {
    transform: rotate(-360deg);
}

/* Error State */
.onda-form-error {
    padding: 16px 20px;
    background: rgba(220, 38, 38, 0.08);
    border: 1px solid rgba(220, 38, 38, 0.3);
    border-radius: var(--onda-radius-sm);
    color: var(--onda-error);
    margin-bottom: 20px;
    font-weight: 500;
}
