/* ============================================
   LOGIN MODAL - CDM86
   Modal completo per login/registrazione
   ============================================ */

/* ============================================
   SELECTION MODAL - Prima schermata
   ============================================ */

.selection-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 20px;
}

.selection-modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.selection-modal {
    background: white;
    border-radius: 24px;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.4);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9) translateY(30px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

.selection-modal-overlay.active .selection-modal {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.selection-modal-header {
    padding: 40px 40px 30px;
    text-align: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 24px 24px 0 0;
    color: white;
    position: relative;
}

.selection-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: white;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10;
}

.selection-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.selection-modal-icon {
    font-size: 64px;
    margin-bottom: 16px;
    animation: float 3s ease-in-out infinite;
}

.selection-modal-title {
    font-size: 32px;
    font-weight: 800;
    margin: 0 0 12px;
}

.selection-modal-subtitle {
    font-size: 16px;
    opacity: 0.95;
    margin: 0;
}

.selection-modal-body {
    padding: 40px;
}

.selection-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.selection-option {
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 16px;
    padding: 32px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
}

.selection-option::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.selection-option:hover {
    transform: translateY(-8px);
    border-color: #667eea;
    box-shadow: 0 12px 30px rgba(102, 126, 234, 0.3);
}

.selection-option:hover::before {
    opacity: 0.05;
}

.selection-option-content {
    position: relative;
    z-index: 1;
}

.selection-option-icon {
    font-size: 56px;
    margin-bottom: 16px;
    display: block;
}

.selection-option-title {
    font-size: 20px;
    font-weight: 700;
    color: #2d3748;
    margin: 0 0 8px;
}

.selection-option-description {
    font-size: 14px;
    color: #718096;
    margin: 0;
}

.selection-option-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.selection-login-section {
    text-align: center;
    padding-top: 24px;
    border-top: 1px solid #e9ecef;
}

.selection-login-section p {
    color: #6c757d;
    font-size: 15px;
    margin: 0 0 12px;
}

.selection-login-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    color: #667eea;
    border: 2px solid #667eea;
    padding: 12px 32px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.selection-login-btn:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
}

/* ============================================
   COMPANY REQUEST MODAL
   ============================================ */

.company-request-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 20px;
}

.company-request-modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.company-request-modal {
    background: white;
    border-radius: 24px;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.5);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.company-request-modal-overlay.active .company-request-modal {
    transform: scale(1);
    opacity: 1;
}

.company-request-header {
    padding: 40px 40px 30px;
    text-align: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 24px 24px 0 0;
    color: white;
    position: relative;
}

.company-request-header h2 {
    font-size: 28px;
    font-weight: 800;
    margin: 0 0 8px;
}

.company-request-header p {
    font-size: 15px;
    margin: 0;
    opacity: 0.95;
}

.company-request-body {
    padding: 40px;
}

.referral-question-box {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    text-align: center;
}

.referral-question-box h3 {
    font-size: 20px;
    color: #2d3748;
    margin: 0 0 16px;
}

.referral-question-buttons {
    display: flex;
    gap: 12px;
}

.referral-question-btn {
    flex: 1;
    padding: 14px 20px;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.referral-question-btn.yes {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.referral-question-btn.no {
    background: #e9ecef;
    color: #495057;
}

.referral-question-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.company-form-section {
    display: none;
}

.company-form-section.active {
    display: block;
    animation: fadeInUp 0.4s ease;
}

/* ============================================
   LOGIN MODAL
   ============================================ */

.login-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 20px;
}

.login-modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.login-modal {
    background: white;
    border-radius: 24px;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.4);
    max-width: 440px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9) translateY(30px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.login-modal-overlay.active .login-modal {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.login-modal-header {
    padding: 40px 40px 30px;
    text-align: center;
    position: relative;
}

.login-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: #f5f5f5;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: #666;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10;
}

.login-modal-close:hover {
    background: #e0e0e0;
    color: #333;
    transform: rotate(90deg);
}

.login-modal-logo {
    font-size: 52px;
    margin-bottom: 16px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.login-modal-title {
    font-size: 28px;
    font-weight: 800;
    color: #667eea;
    margin: 0 0 8px;
}

.login-modal-subtitle {
    font-size: 15px;
    color: #666;
    margin: 0;
}

.login-modal-body {
    padding: 0 40px 40px;
}

/* Tabs */
.login-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 30px;
    border-bottom: 2px solid #f0f0f0;
}

.login-tab {
    flex: 1;
    padding: 12px 16px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    color: #999;
    transition: all 0.3s;
    border-bottom: 3px solid transparent;
    position: relative;
}

.login-tab.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.login-tab:hover:not(.active) {
    color: #764ba2;
}

/* Form */
.login-form-panel {
    display: none;
}

.login-form-panel.active {
    display: block;
    animation: fadeInUp 0.4s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.form-group {
    margin-bottom: 20px;
}

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

.form-group input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 15px;
    transition: all 0.3s;
    font-family: inherit;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.form-group input.uppercase-input {
    text-transform: uppercase;
}

.form-btn {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 8px;
    font-family: inherit;
}

.form-btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.form-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(102, 126, 234, 0.4);
}

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

/* Alert */
.form-alert {
    padding: 14px 16px;
    border-radius: 12px;
    margin-bottom: 20px;
    font-size: 14px;
    display: none;
    animation: slideDown 0.3s ease;
}

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

.form-alert.show {
    display: block;
}

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

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

/* Referral Note */
.referral-note {
    background: #fff3cd;
    border: 1px solid #ffc107;
    padding: 14px 16px;
    border-radius: 12px;
    margin-bottom: 20px;
    font-size: 13px;
    color: #856404;
}

.referral-note strong {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
}

.referral-note code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
}

/* Loading */
.form-loading {
    display: none;
    text-align: center;
    padding: 20px 0;
}

.form-loading.show {
    display: block;
}

.form-spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 12px;
}

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

.form-loading p {
    color: #666;
    font-size: 14px;
}

/* Referral Modal */
.referral-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 20px;
}

.referral-modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.referral-modal {
    background: white;
    border-radius: 24px;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.5);
    max-width: 520px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.referral-modal-overlay.active .referral-modal {
    transform: scale(1);
    opacity: 1;
}

.referral-modal-header {
    padding: 40px 40px 30px;
    text-align: center;
}

.referral-modal-header h2 {
    color: #667eea;
    font-size: 28px;
    margin-bottom: 12px;
}

.referral-modal-header p {
    color: #666;
    font-size: 15px;
}

.referral-modal-body {
    padding: 0 40px 40px;
}

.referral-modal-buttons {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.referral-modal-btn {
    flex: 1;
    padding: 16px 24px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
}

.referral-modal-btn-yes {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.referral-modal-btn-yes:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.referral-modal-btn-no {
    background: #f5f5f5;
    color: #666;
}

.referral-modal-btn-no:hover {
    background: #e0e0e0;
    color: #333;
}

/* Wizard */
.wizard-container {
    display: none;
}

.wizard-container.active {
    display: block;
}

.wizard-progress {
    display: flex;
    gap: 8px;
    margin-bottom: 30px;
}

.wizard-progress-step {
    flex: 1;
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    transition: all 0.3s;
}

.wizard-progress-step.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.wizard-step-content {
    display: none;
}

.wizard-step-content.active {
    display: block;
    animation: fadeInUp 0.4s ease;
}

.wizard-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.wizard-btn {
    flex: 1;
    padding: 14px 20px;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
}

.wizard-btn-back {
    background: #f5f5f5;
    color: #666;
}

.wizard-btn-back:hover {
    background: #e0e0e0;
}

.wizard-btn-next {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.wizard-btn-next:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(102, 126, 234, 0.4);
}

.wizard-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.wizard-confirm {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 16px;
}

.wizard-confirm p {
    margin: 8px 0;
    color: #495057;
}

.wizard-confirm strong {
    color: #212529;
    font-weight: 600;
}

.wizard-success {
    text-align: center;
    padding: 30px 0;
}

.wizard-success-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.wizard-success h3 {
    color: #667eea;
    font-size: 24px;
    margin-bottom: 12px;
}

.wizard-success p {
    color: #666;
    font-size: 15px;
}

/* ============================================
   FORGOT PASSWORD MODAL
   ============================================ */

.forgot-password-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 20px;
}

.forgot-password-overlay.active {
    opacity: 1;
    pointer-events: all;
    animation: fadeIn 0.3s ease;
}

.forgot-password-modal {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(220, 38, 38, 0.2);
    max-width: 460px;
    width: 100%;
    padding: 0;
    transform: scale(0.9) translateY(20px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
}

.forgot-password-overlay.active .forgot-password-modal {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.forgot-password-header {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    color: white;
    padding: 32px 28px;
    text-align: center;
    position: relative;
}

.forgot-password-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    opacity: 0.4;
}

.forgot-password-icon {
    font-size: 48px;
    margin-bottom: 12px;
    animation: bounceIn 0.6s ease;
    position: relative;
    z-index: 1;
}

.forgot-password-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    position: relative;
    z-index: 1;
}

.forgot-password-subtitle {
    font-size: 14px;
    opacity: 0.95;
    font-weight: 400;
    position: relative;
    z-index: 1;
}

.forgot-password-body {
    padding: 28px;
}

.forgot-password-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.forgot-password-input {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 15px;
    transition: all 0.3s ease;
    background: white;
    font-family: inherit;
}

.forgot-password-input:focus {
    outline: none;
    border-color: #dc2626;
    box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.1);
    transform: translateY(-2px);
}

.forgot-password-input::placeholder {
    color: #9ca3af;
}

.forgot-password-buttons {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.forgot-password-btn {
    flex: 1;
    padding: 14px 24px;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.forgot-password-btn-primary {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

.forgot-password-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(220, 38, 38, 0.4);
}

.forgot-password-btn-primary:active {
    transform: translateY(0);
}

.forgot-password-btn-secondary {
    background: white;
    color: #6b7280;
    border: 2px solid #e5e7eb;
}

.forgot-password-btn-secondary:hover {
    background: #f9fafb;
    border-color: #d1d5db;
    transform: translateY(-2px);
}

.forgot-password-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 24px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 2;
    line-height: 1;
}

.forgot-password-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes bounceIn {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }
    50% {
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 640px) {
    .login-modal,
    .referral-modal {
        max-width: 100%;
        border-radius: 20px;
    }

    .login-modal-header,
    .referral-modal-header {
        padding: 30px 24px 24px;
    }

    .login-modal-body,
    .referral-modal-body {
        padding: 0 24px 30px;
    }

    .login-modal-title {
        font-size: 24px;
    }

    .form-group input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .forgot-password-modal {
        max-width: 100%;
        margin: 0 12px;
    }
}
