/* ============================================
   CSS UNIFICATO PER PAGINE AUTENTICAZIONE
   Stile pulito e minimale ispirato a Metronic
   Uso: <link rel="stylesheet" href="css/auth-styles.css">
   ============================================ */

/* Variabili CSS per consistenza */
:root {
    --primary-color: #009ef7;
    --primary-dark: #0077b3;
    --primary-light: #e1f5fe;
    --secondary-color: #7239ea;
    --success-color: #50cd89;
    --warning-color: #ffc700;
    --danger-color: #f1416c;
    --dark-color: #181c32;
    --gray-100: #f9f9f9;
    --gray-200: #eff2f5;
    --gray-300: #e4e6ea;
    --gray-400: #b5b5c3;
    --gray-500: #a1a5b7;
    --gray-600: #7e8299;
    --gray-700: #5e6278;
    --gray-800: #3f4254;
    --gray-900: #181c32;

    /* Shadows */
    --shadow-sm: 0 0.1rem 1rem 0.25rem rgba(0, 0, 0, 0.05);
    --shadow-md: 0 0.5rem 2rem 0.25rem rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 1rem 3rem 0.5rem rgba(0, 0, 0, 0.15);

    /* Radiuses */
    --border-radius-sm: 0.475rem;
    --border-radius-md: 0.75rem;
    --border-radius-lg: 1rem;
}

/* Reset e base per pagine auth */
.auth-page {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    /*
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #667eea 100%);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
     */
    min-height: 100vh;
    margin: 0;
    padding: 0;
    line-height: 1.6;
    color: var(--gray-700);
    box-sizing: border-box;
}

.auth-page *,
.auth-page *::before,
.auth-page *::after {
    box-sizing: border-box;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Container principale per auth */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Card principale */
.auth-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    width: 100%;
    max-width: 500px;
    position: relative;
}

.auth-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
}

/* Header della card */
.auth-header {
    padding: 40px 40px 30px;
    text-align: center;
    border-bottom: 1px solid var(--gray-200);
}

.auth-header .logo {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: var(--border-radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.auth-header .logo i {
    font-size: 24px;
    color: white;
}

.auth-header h1,
.auth-header .auth-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 8px;
    letter-spacing: -0.025em;
}

.auth-header p,
.auth-header .auth-subtitle {
    color: var(--gray-600);
    font-size: 16px;
    margin: 0;
    line-height: 1.5;
}

/* Body della card */
.auth-body {
    padding: 40px;
}

/* Form elements */
.auth-form .form-group {
    margin-bottom: 24px;
}

.auth-form .form-label {
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 8px;
    font-size: 14px;
    letter-spacing: 0.025em;
    display: block;
}

.auth-form .form-control {
    border: 2px solid var(--gray-300);
    border-radius: var(--border-radius-sm);
    padding: 12px 16px;
    font-size: 16px;
    transition: all 0.2s ease;
    background: white;
    color: var(--gray-800);
    width: 100%;
}

.auth-form .form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(0, 158, 247, 0.1);
    outline: none;
}

.auth-form .form-control::placeholder {
    color: var(--gray-500);
}

/* Input groups con icone */
.input-group-icon {
    position: relative;
}

.input-group-icon .form-control {
    padding-left: 45px;
}

.input-group-icon .input-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-500);
    z-index: 5;
}

/* Toggle password */
.password-toggle {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--gray-500);
    cursor: pointer;
    padding: 0;
    z-index: 5;
}

.password-toggle:hover {
    color: var(--gray-700);
}

/* Buttons */
.auth-btn,
.auth-form .btn {
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    font-size: 16px;
    padding: 12px 24px;
    border: none;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
}

.auth-btn.btn-primary,
.auth-form .btn-primary {
    background: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-sm);
}

.auth-btn.btn-primary:hover,
.auth-form .btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    color: white;
}

.auth-btn.btn-success,
.auth-form .btn-success {
    background: var(--success-color);
    color: white;
}

.auth-btn.btn-success:hover,
.auth-form .btn-success:hover {
    background: #45b078;
    color: white;
}

.auth-btn.btn-secondary,
.auth-form .btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.auth-btn.btn-secondary:hover,
.auth-form .btn-secondary:hover {
    background: var(--gray-300);
    color: var(--gray-800);
}

.auth-btn.btn-link,
.auth-form .btn-link {
    background: none;
    color: var(--primary-color);
    text-decoration: none;
    padding: 8px 0;
    font-weight: 500;
}

.auth-btn.btn-link:hover,
.auth-form .btn-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.auth-btn.w-100,
.auth-form .w-100 {
    width: 100%;
}

/* Alerts */
.auth-alert {
    border-radius: var(--border-radius-sm);
    border: none;
    font-weight: 500;
    margin-bottom: 24px;
    padding: 16px 20px;
}

.auth-alert.alert-success {
    background: rgba(80, 205, 137, 0.1);
    color: #1e7e34;
    border-left: 4px solid var(--success-color);
}

.auth-alert.alert-danger {
    background: rgba(241, 65, 108, 0.1);
    color: #721c24;
    border-left: 4px solid var(--danger-color);
}

.auth-alert.alert-info {
    background: rgba(0, 158, 247, 0.1);
    color: #004085;
    border-left: 4px solid var(--primary-color);
}

.auth-alert.alert-warning {
    background: rgba(255, 199, 0, 0.1);
    color: #856404;
    border-left: 4px solid var(--warning-color);
}

/* Progress bars per password strength */
.password-strength {
    margin-top: 8px;
}

.password-progress {
    height: 4px;
    background: var(--gray-200);
    border-radius: 2px;
    overflow: hidden;
}

.password-progress-bar {
    height: 100%;
    transition: width 0.3s ease;
    border-radius: 2px;
}

.strength-weak { background: var(--danger-color); }
.strength-fair { background: var(--warning-color); }
.strength-good { background: var(--primary-color); }
.strength-strong { background: var(--success-color); }

/* Lista criteri password */
.password-criteria {
    margin-top: 16px;
    font-size: 14px;
}

.criteria-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    color: var(--gray-600);
}

.criteria-item.valid {
    color: var(--success-color);
}

.criteria-item .icon {
    width: 16px;
    text-align: center;
}

/* Footer della card */
.auth-footer {
    padding: 20px 40px 40px;
    text-align: center;
    border-top: 1px solid var(--gray-200);
    background: rgba(249, 249, 249, 0.5);
}

.auth-footer p {
    color: var(--gray-600);
    margin: 0;
    font-size: 14px;
}

.auth-footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.auth-footer a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* Stati completamento */
.completion-state {
    text-align: center;
    padding: 40px 20px;
}

.completion-state .icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    font-size: 32px;
}

.completion-state.success .icon {
    background: rgba(80, 205, 137, 0.15);
    color: var(--success-color);
}

.completion-state.error .icon {
    background: rgba(241, 65, 108, 0.15);
    color: var(--danger-color);
}

.completion-state h3 {
    color: var(--gray-900);
    margin-bottom: 12px;
    font-weight: 700;
}

.completion-state p {
    color: var(--gray-600);
    margin-bottom: 24px;
}

/* Timer per token */
.token-timer {
    background: rgba(255, 199, 0, 0.1);
    border: 1px solid rgba(255, 199, 0, 0.3);
    border-radius: var(--border-radius-sm);
    padding: 12px 16px;
    margin-bottom: 20px;
    text-align: center;
    font-weight: 600;
    color: #856404;
}

/* Loading states */
.btn-loading {
    position: relative;
    color: transparent !important;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

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

/* Form checks e radio */
.auth-form .form-check {
    margin-bottom: 16px;
}

.auth-form .form-check-input {
    margin-top: 0.125rem;
}

.auth-form .form-check-label {
    font-size: 14px;
    color: var(--gray-700);
}

/* Text utilities */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-muted { color: var(--gray-600) !important; }
.text-primary { color: var(--primary-color) !important; }
.text-success { color: var(--success-color) !important; }
.text-danger { color: var(--danger-color) !important; }
.text-warning { color: var(--warning-color) !important; }

/* Spacing utilities */
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.mb-5 { margin-bottom: 32px; }

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.mt-5 { margin-top: 32px; }

/* Flexbox utilities */
.d-flex { display: flex; }
.justify-content-between { justify-content: space-between; }
.justify-content-center { justify-content: center; }
.align-items-center { align-items: center; }

/* User info display */
.user-info {
    background: rgba(0, 158, 247, 0.05);
    border: 1px solid rgba(0, 158, 247, 0.2);
    border-radius: var(--border-radius-sm);
    padding: 16px;
    margin-bottom: 24px;
}

.user-info h6 {
    color: var(--gray-900);
    margin-bottom: 4px;
    font-weight: 600;
}

.user-info p {
    color: var(--gray-600);
    margin: 0;
    font-size: 14px;
}

/* Responsive */
@media (max-width: 576px) {
    .auth-card {
        margin: 10px;
        border-radius: var(--border-radius-md);
    }

    .auth-header,
    .auth-body,
    .auth-footer {
        padding-left: 24px;
        padding-right: 24px;
    }

    .auth-header {
        padding-top: 30px;
        padding-bottom: 20px;
    }

    .auth-body {
        padding-top: 30px;
        padding-bottom: 30px;
    }

    .auth-header h1,
    .auth-header .auth-title {
        font-size: 24px;
    }

    .auth-btn,
    .auth-form .btn {
        font-size: 14px;
        padding: 10px 20px;
    }
}

/* Focus management per accessibilità */
.auth-form .form-control:focus-visible,
.auth-btn:focus-visible,
.auth-form .btn:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Animazioni smooth */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

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

/* Compatibilità con Bootstrap esistente e miglioramenti validazione */
.auth-form .form-control.is-invalid {
    border-color: var(--danger-color);
    background-image: none; /* Rimuovi icona default Bootstrap */
}

.auth-form .form-control.is-valid {
    border-color: var(--success-color);
    background-image: none; /* Rimuovi icona default Bootstrap */
}

.auth-form .invalid-feedback {
    display: block;
    color: var(--danger-color);
    font-size: 14px;
    margin-top: 6px;
    font-weight: 500;
}

.auth-form .valid-feedback {
    display: block;
    color: var(--success-color);
    font-size: 14px;
    margin-top: 6px;
    font-weight: 500;
}

/* Animazioni per feedback messages */
.auth-form .invalid-feedback,
.auth-form .valid-feedback {
    animation: fadeInUp 0.3s ease-out;
}

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

/* Migliora la transizione dei bordi dei campi */
.auth-form .form-control {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Focus migliorato per campi con errori */
.auth-form .form-control.is-invalid:focus {
    border-color: var(--danger-color);
    box-shadow: 0 0 0 0.25rem rgba(241, 65, 108, 0.15);
}

.auth-form .form-control.is-valid:focus {
    border-color: var(--success-color);
    box-shadow: 0 0 0 0.25rem rgba(80, 205, 137, 0.15);
}