* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    -webkit-overflow-scrolling: touch;
}

.container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 100%;
    padding: 40px;
    overflow: hidden;
}

.header {
    text-align: center;
    margin-bottom: 30px;
}

.header .logo {
    max-width: 400px;
    width: 100%;
    height: auto;
    margin-bottom: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 15px 25px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.header h1 {
    color: #333;
    font-size: 28px;
    margin-bottom: 10px;
}

.header p {
    color: #666;
    font-size: 14px;
}

.form-group {
    margin-bottom: 25px;
}

label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 600;
    font-size: 14px;
}

input[type="text"],
input[type="password"],
input[type="file"] {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.password-wrapper {
    position: relative;
    width: 100%;
}

.password-wrapper input {
    padding-right: 45px;
}

.toggle-password {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    transition: color 0.3s ease;
}

.toggle-password:hover {
    color: #667eea;
}

.toggle-password:focus {
    outline: none;
    color: #667eea;
}

.toggle-password svg {
    width: 20px;
    height: 20px;
}

.checkbox-group {
    margin-bottom: 20px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 500;
    color: #333;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    margin-right: 10px;
    cursor: pointer;
    transform: scale(1.2);
}

.checkbox-label span {
    user-select: none;
}

.referente-fields {
    background: #f8f9ff;
    padding: 20px;
    border-radius: 8px;
    border: 2px solid #e0e0e0;
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

.referente-fields .form-group {
    margin-bottom: 15px;
}

.referente-fields .form-group:last-child {
    margin-bottom: 0;
}

input[type="email"],
input[type="tel"] {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
}

input[type="email"]:focus,
input[type="tel"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="file"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.file-upload-wrapper {
    position: relative;
    overflow: hidden;
    display: inline-block;
    width: 100%;
}

.file-upload-wrapper input[type="file"] {
    font-size: 100px;
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0;
    cursor: pointer;
}

.file-upload-label {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    border: 2px dashed #667eea;
    border-radius: 8px;
    background: #f8f9ff;
    cursor: pointer;
    transition: all 0.3s ease;
}

.file-upload-label:hover {
    background: #eef1ff;
    border-color: #5568d3;
}

.file-upload-label svg {
    width: 48px;
    height: 48px;
    margin-right: 15px;
    color: #667eea;
}

.file-info {
    text-align: center;
}

.file-info .title {
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
}

.file-info .subtitle {
    font-size: 12px;
    color: #999;
}

.file-selected {
    margin-top: 10px;
    padding: 10px;
    background: #e8f5e9;
    border-radius: 8px;
    color: #2e7d32;
    font-size: 14px;
    display: none;
}

.btn {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.btn-success {
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    color: white;
    margin-top: 15px;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(76, 175, 80, 0.3);
}

.form-group.disabled {
    opacity: 0.5;
    pointer-events: none;
    position: relative;
}

.form-group.disabled::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 8px;
    z-index: 10;
}

.status-message {
    margin-top: 20px;
    padding: 15px;
    border-radius: 8px;
    font-size: 14px;
    display: none;
}

.status-message.info {
    background: #e3f2fd;
    color: #1976d2;
    border-left: 4px solid #1976d2;
}

.status-message.success {
    background: #e8f5e9;
    color: #2e7d32;
    border-left: 4px solid #2e7d32;
}

.status-message.error {
    background: #ffebee;
    color: #c62828;
    border-left: 4px solid #c62828;
}

.status-message.warning {
    background: #fff3e0;
    color: #ef6c00;
    border-left: 4px solid #ef6c00;
}

.loader {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
    display: none;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.progress-steps {
    display: flex;
    justify-content: space-between;
    margin: 30px 0;
    display: none;
}

.step {
    flex: 1;
    text-align: center;
    padding: 10px;
    position: relative;
}

.step::before {
    content: '';
    position: absolute;
    top: 25px;
    left: 0;
    right: 0;
    height: 2px;
    background: #e0e0e0;
    z-index: 0;
}

.step:first-child::before {
    left: 50%;
}

.step:last-child::before {
    right: 50%;
}

.step-circle {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #e0e0e0;
    margin: 0 auto 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 12px;
    position: relative;
    z-index: 1;
}

.step.active .step-circle {
    background: #667eea;
}

.step.completed .step-circle {
    background: #4caf50;
}

.step-label {
    font-size: 11px;
    color: #666;
}

/* ===== RESPONSIVE DESIGN - MOBILE ===== */

/* Tablet e dispositivi medi */
@media (max-width: 768px) {
    body {
        padding: 15px;
        align-items: flex-start;
    }

    .container {
        padding: 30px 20px;
        border-radius: 15px;
        margin: 10px 0;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    }

    .header .logo {
        max-width: 280px;
        padding: 12px 20px;
        margin-bottom: 15px;
    }

    .header h1 {
        font-size: 24px;
        margin-bottom: 8px;
    }

    .header p {
        font-size: 13px;
        line-height: 1.5;
    }

    .form-group {
        margin-bottom: 20px;
    }

    label {
        font-size: 13px;
        margin-bottom: 6px;
    }

    input[type="text"],
    input[type="password"],
    input[type="file"] {
        padding: 12px 14px;
        font-size: 16px; /* Previene zoom su iOS */
    }

    .file-upload-label {
        padding: 35px 20px;
        flex-direction: column;
    }

    .file-upload-label svg {
        width: 45px;
        height: 45px;
        margin-right: 0;
        margin-bottom: 12px;
    }

    .file-info .title {
        font-size: 15px;
    }

    .file-info .subtitle {
        font-size: 12px;
    }

    .btn {
        padding: 14px;
        font-size: 16px;
    }

    .status-message {
        padding: 12px;
        font-size: 13px;
        line-height: 1.5;
    }

    /* Progress steps verticale su tablet */
    .progress-steps {
        margin: 25px 0;
    }

    .step {
        padding: 8px 5px;
    }

    .step-circle {
        width: 32px;
        height: 32px;
        font-size: 13px;
    }

    .step-label {
        font-size: 11px;
        margin-top: 5px;
    }
}

/* Smartphone e dispositivi piccoli */
@media (max-width: 480px) {
    body {
        padding: 8px;
        align-items: flex-start;
    }

    .container {
        padding: 20px 15px;
        border-radius: 12px;
        margin: 0;
    }

    .header {
        margin-bottom: 20px;
    }

    .header .logo {
        max-width: 240px;
        padding: 10px 18px;
        margin-bottom: 12px;
    }

    .header h1 {
        font-size: 20px;
        margin-bottom: 6px;
    }

    .header p {
        font-size: 12px;
        line-height: 1.4;
    }

    .form-group {
        margin-bottom: 18px;
    }

    label {
        font-size: 13px;
        margin-bottom: 6px;
    }

    input[type="text"],
    input[type="password"] {
        padding: 12px;
        font-size: 16px; /* Previene zoom automatico su iOS */
    }

    .file-upload-label {
        padding: 25px 15px;
    }

    .file-upload-label svg {
        width: 40px;
        height: 40px;
        margin-bottom: 10px;
    }

    .file-info .title {
        font-size: 14px;
    }

    .file-info .subtitle {
        font-size: 11px;
    }

    .file-selected {
        font-size: 13px;
        padding: 10px;
        word-break: break-word;
    }

    .btn {
        padding: 13px;
        font-size: 15px;
        font-weight: 600;
    }

    .btn-success {
        margin-top: 12px;
    }

    .status-message {
        padding: 12px;
        font-size: 13px;
        margin-top: 15px;
        line-height: 1.5;
    }

    .loader {
        width: 35px;
        height: 35px;
        margin: 15px auto;
    }

    /* Progress steps impilati verticalmente su mobile */
    .progress-steps {
        flex-direction: column;
        gap: 0;
        margin: 20px 0;
    }

    .step {
        padding: 10px 0;
        display: flex;
        align-items: center;
        gap: 12px;
    }

    .step::before {
        display: none;
    }

    .step-circle {
        width: 36px;
        height: 36px;
        font-size: 14px;
        margin: 0;
        flex-shrink: 0;
    }

    .step-label {
        font-size: 13px;
        text-align: left;
        margin: 0;
    }
}

/* Dispositivi molto piccoli */
@media (max-width: 360px) {
    body {
        padding: 5px;
    }

    .container {
        padding: 18px 12px;
        border-radius: 10px;
    }

    .header .logo {
        max-width: 200px;
        padding: 8px 15px;
    }

    .header h1 {
        font-size: 18px;
    }

    .header p {
        font-size: 11px;
    }

    .form-group {
        margin-bottom: 15px;
    }

    input[type="text"],
    input[type="password"] {
        padding: 11px;
        font-size: 16px;
    }

    .file-upload-label {
        padding: 20px 12px;
    }

    .file-upload-label svg {
        width: 35px;
        height: 35px;
    }

    .file-info .title {
        font-size: 13px;
    }

    .file-info .subtitle {
        font-size: 10px;
    }

    .btn {
        padding: 12px;
        font-size: 14px;
    }

    .step-circle {
        width: 32px;
        height: 32px;
        font-size: 13px;
    }

    .step-label {
        font-size: 12px;
    }
}

/* Touch device improvements */
@media (hover: none) and (pointer: coarse) {
    /* Rimuovi effetti hover su touch devices */
    .btn-primary:hover:not(:disabled),
    .btn-success:hover {
        transform: none;
        box-shadow: none;
    }

    /* Aggiungi feedback tattile su tap */
    .btn-primary:active:not(:disabled) {
        transform: scale(0.98);
        opacity: 0.9;
    }

    .btn-success:active {
        transform: scale(0.98);
        opacity: 0.9;
    }

    .file-upload-label:hover {
        background: #f8f9ff;
        border-color: #667eea;
    }

    .file-upload-label:active {
        background: #eef1ff;
        border-color: #5568d3;
        transform: scale(0.99);
    }

    /* Aumenta la dimensione delle aree toccabili */
    input[type="text"],
    input[type="password"] {
        min-height: 44px; /* iOS standard touch target */
    }

    .btn {
        min-height: 44px;
    }
}

/* Landscape mode su smartphone */
@media (max-width: 896px) and (orientation: landscape) {
    body {
        padding: 10px;
        align-items: flex-start;
    }

    .container {
        padding: 20px 25px;
        margin: 10px auto;
        max-width: 90%;
    }

    .header .logo {
        max-width: 220px;
        margin-bottom: 10px;
    }

    .header h1 {
        font-size: 20px;
        margin-bottom: 5px;
    }

    .header p {
        font-size: 12px;
    }

    .form-group {
        margin-bottom: 15px;
    }

    .progress-steps {
        margin: 15px 0;
    }

    .step {
        padding: 8px 0;
    }

    .file-upload-label {
        padding: 20px 15px;
    }

    .status-message {
        margin-top: 12px;
    }
}

/* Fix per Safari iOS */
@supports (-webkit-touch-callout: none) {
    input[type="text"],
    input[type="password"],
    input[type="file"] {
        font-size: 16px; /* Previene zoom automatico su iOS */
    }
}

/* Ottimizzazione per schermi ad alta risoluzione */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .header .logo {
        image-rendering: -webkit-optimize-contrast;
    }
}
