/* Modern Authentication Styles - Industry Standard Design */

/* Modal Overrides - Modern Slide Down Animation */
.modal.fade .modal-dialog {
    transform: translateY(-30px);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
}

.modal.show .modal-dialog {
    transform: translateY(0);
    opacity: 1;
}

.modal-backdrop {
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modern-auth-modal {
    background: transparent;
    border: none;
    box-shadow: none;
}

.modern-auth-modal .modal-content {
    border: none;
    border-radius: 16px;
    overflow: hidden;
}

.modern-auth-modal .modal-body {
    background: transparent;
    padding: 0;
}

.modern-auth-container {
    max-width: 400px;
    margin: 0 auto;
    padding: 40px 32px;
    background: #ffffff;
    border: none;
    border-radius: 16px;
    color: #1a1a1a;
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

/* Remove the top gradient line for cleaner look */
.modern-auth-container::before {
    display: none;
}

/* Header Styles */
.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo {
    margin-bottom: 16px;
}

.auth-logo-img {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 87, 255, 0.15);
}

.auth-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    color: #1a1a1a;
    letter-spacing: -0.5px;
}

.auth-subtitle {
    font-size: 16px;
    color: #6b7280;
    margin: 0;
    font-weight: 400;
}

/* Form Styles */
.auth-form {
    width: 100%;
}

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

.form-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
    transition: color 0.2s ease;
}

.label-icon {
    color: #999;
    transition: color 0.2s ease;
}

.required-asterisk {
    color: #ff6b6b;
    margin-left: 4px;
}

.modern-input, .modern-textarea {
    width: 100%;
    background: #f8f9fa;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 14px 16px;
    font-size: 16px;
    color: #1a1a1a;
    transition: all 0.2s ease;
    position: relative;
    z-index: 1;
    font-weight: 400;
}

.modern-input::placeholder, .modern-textarea::placeholder {
    color: #9ca3af;
    transition: color 0.2s ease;
    font-weight: 400;
}

.modern-input:focus, .modern-textarea:focus {
    outline: none;
    background: #ffffff;
    border-color: var(--thingvalla-primary);
    box-shadow: 0 0 0 3px rgba(0, 87, 255, 0.1);
}

.modern-form-group.focused .label-icon {
    color: var(--thingvalla-primary);
}

.modern-form-group.focused .form-label {
    color: var(--thingvalla-primary);
}

/* Input Focus Line Animation */
.input-focus-line {
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--thingvalla-primary), #4ecdc4);
    transform: translateX(-50%);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 1px;
}

.modern-form-group.focused .input-focus-line {
    width: 100%;
}

/* Password Input Container */
.password-input-container {
    position: relative;
}

.password-toggle {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: all 0.2s ease;
    z-index: 2;
}

.password-toggle:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #333;
}

/* Field Help Text */
.field-help {
    font-size: 12px;
    color: #999;
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Password Strength Indicator */
.password-strength {
    margin-top: 12px;
}

.strength-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 8px;
}

.strength-fill {
    height: 100%;
    width: 0%;
    transition: all 0.3s ease;
    border-radius: 2px;
}

.strength-text {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 8px;
}

.password-requirements {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.requirement {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    transition: color 0.2s ease;
}

.requirement.met {
    color: #4caf50;
}

.requirement .req-icon {
    opacity: 0.3;
    transition: opacity 0.2s ease;
}

.requirement.met .req-icon {
    opacity: 1;
    stroke: #4caf50;
}

/* Password Match Indicator */
.password-match {
    margin-top: 6px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}

/* Form Options */
.form-options {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 24px;
    gap: 12px;
}

/* Checkbox Styles */
.checkbox-container {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: #555;
    cursor: pointer;
    transition: color 0.2s ease;
    line-height: 1.4;
}

.checkbox-container:hover {
    color: #333;
}

.checkbox-container input[type="checkbox"] {
    display: none;
}

.checkmark {
    position: relative;
    width: 20px;
    height: 20px;
    background: #fff;
    border: 2px solid #dee2e6;
    border-radius: 4px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.checkbox-container input[type="checkbox"]:checked + .checkmark {
    background: var(--thingvalla-primary);
    border-color: var(--thingvalla-primary);
    transform: scale(1.05);
}

.checkbox-container input[type="checkbox"]:checked + .checkmark::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 4px;
    height: 8px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Links */
.forgot-password-link, .terms-link, .privacy-link {
    color: var(--thingvalla-primary);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s ease;
    position: relative;
}

.forgot-password-link:hover, .terms-link:hover, .privacy-link:hover {
    color: #4ecdc4;
    text-decoration: underline;
}

/* Submit Button */
.modern-submit-btn {
    width: 100%;
    background: var(--thingvalla-primary);
    border: none;
    border-radius: 12px;
    padding: 16px 24px;
    font-size: 16px;
    font-weight: 700;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 20px rgba(0, 87, 255, 0.25);
    letter-spacing: 0.5px;
}

.modern-submit-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0, 87, 255, 0.4);
    background: #004de6;
}

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

.modern-submit-btn:disabled, .modern-submit-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 4px 16px rgba(0, 87, 255, 0.2);
}

.modern-submit-btn .btn-loading {
    display: flex;
    align-items: center;
    gap: 8px;
}

.spinner {
    animation: spin 1s linear infinite;
}

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

/* Social Divider */
.social-divider {
    position: relative;
    text-align: center;
    margin: 24px 0 20px;
}

.social-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: #e5e7eb;
}

.divider-text {
    background: #ffffff;
    padding: 0 16px;
    font-size: 14px;
    color: #6b7280;
    position: relative;
    z-index: 1;
    font-weight: 500;
}

/* Social Login Buttons */
.social-login-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.social-btn {
    width: 100%;
    background: #ffffff;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 14px 16px;
    color: #374151;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.social-btn:hover {
    background: #f9fafb;
    border-color: #d1d5db;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

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

/* Provider-specific styling */
.social-btn.google {
    border-color: #dadce0;
}

.social-btn.google:hover {
    background: #f8f9fa;
    border-color: #dadce0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.social-btn.facebook {
    background: #1877f2;
    border-color: #1877f2;
    color: #ffffff;
}

.social-btn.facebook:hover {
    background: #166fe5;
    border-color: #166fe5;
}

.social-btn.apple {
    background: #000000;
    border-color: #000000;
    color: #ffffff;
}

.social-btn.apple:hover {
    background: #333333;
    border-color: #333333;
}

/* Social button icons */
.social-btn-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Loading state for social buttons */
.social-btn.loading {
    opacity: 0.7;
    cursor: not-allowed;
    pointer-events: none;
}

.social-btn.loading .social-btn-icon {
    animation: spin 1s linear infinite;
}

/* Error state for social buttons */
.social-btn.error {
    border-color: #ef4444;
    background: #fef2f2;
    color: #dc2626;
}

/* Mobile social button adjustments */
@media (max-width: 768px) {
    /* Progressive disclosure - simplify initial view */
    .modern-auth-container {
        padding: 24px 20px;
    }
    
    .auth-header {
        margin-bottom: 24px;
    }
    
    .auth-title {
        font-size: 24px;
        margin-bottom: 8px;
    }
    
    /* Hide less important elements initially */
    .form-options {
        margin-top: 12px;
    }
    
    .forgot-password-link {
        font-size: 13px;
        opacity: 0.8;
    }
    
    /* Streamline form fields */
    .modern-form-group {
        margin-bottom: 16px;
    }
    
    .form-label {
        font-size: 13px;
        margin-bottom: 6px;
    }
    
    .modern-input {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 14px 16px;
    }
    
    /* Primary action prominence */
    .modern-submit-btn {
        margin-top: 20px;
        min-height: 52px;
        font-size: 17px;
        font-weight: 600;
        box-shadow: 0 4px 12px rgba(0, 87, 255, 0.3);
    }
    
    /* Deemphasize secondary actions */
    .auth-switch {
        margin-top: 16px;
        font-size: 14px;
        opacity: 0.9;
    }
    
    .guest-btn {
        font-size: 13px;
        padding: 10px 16px;
        opacity: 0.8;
    }
}

/* Auth Switch */
.auth-switch {
    text-align: center;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid #e9ecef;
}

.auth-switch span {
    color: #666;
    font-size: 14px;
    margin-right: 8px;
}

.auth-switch-btn {
    background: none;
    border: none;
    color: var(--thingvalla-primary);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    border-radius: 6px;
    padding: 8px 12px;
    margin: 0 -12px;
}

.auth-switch-btn:hover {
    background: rgba(0, 87, 255, 0.05);
    color: #004de6;
}

/* Guest Access */
.guest-access {
    text-align: center;
    margin-top: 16px;
}

.guest-btn {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    color: #666;
    border-radius: 8px;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-direction: column;
    width: 100%;
}

.guest-btn:hover {
    background: #e9ecef;
    border-color: #ced4da;
    color: #333;
    transform: translateY(-1px);
}

.guest-btn small {
    font-size: 11px;
    opacity: 0.7;
    font-weight: 400;
}

/* Optional Section */
.optional-section {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 24px;
    margin-top: 24px;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 20px;
}

.section-title small {
    font-size: 12px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.5);
    margin-left: auto;
}

/* Terms Group */
.terms-group {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
}

/* Modern Alert */
.modern-alert {
    background: #f8d7da;
    border: 1px solid #f5c2c7;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    color: #721c24;
}

.alert-icon {
    flex-shrink: 0;
    margin-top: 2px;
}

.alert-content {
    flex: 1;
}

.alert-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.alert-message {
    font-size: 14px;
    opacity: 0.9;
}

.error-list {
    margin: 8px 0 0 16px;
    font-size: 13px;
}

.error-list li {
    margin-bottom: 4px;
}

/* Guest Notification */
.guest-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(13, 110, 253, 0.95);
    border: 1px solid rgba(13, 110, 253, 0.3);
    border-radius: 12px;
    padding: 16px 20px;
    color: #fff;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    max-width: 350px;
    z-index: 9999;
    backdrop-filter: blur(20px);
    box-shadow: 0 8px 32px rgba(13, 110, 253, 0.3);
    animation: slideInRight 0.3s ease-out;
}

.guest-notification .btn-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    margin-left: auto;
    flex-shrink: 0;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    /* Mobile modal optimizations for gestures */
    .modal-dialog-centered {
        min-height: auto;
        margin: 0;
        padding: 0;
    }
    
    .modal-dialog {
        margin: 0;
        width: 100%;
        max-width: none;
        height: 100vh;
        /* Enable hardware acceleration for smooth gestures */
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
        will-change: transform;
    }
    
    .modal-content {
        height: 100vh;
        border-radius: 0;
        border: none;
        /* Improve touch responsiveness */
        touch-action: pan-y;
    }
    
    .modal-body {
        height: 100vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 0;
        /* Optimize scrolling performance */
        overscroll-behavior: contain;
    }
    
    .modern-auth-container {
        margin: 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
        min-height: 100vh;
        padding: 24px 20px;
        max-height: none;
        overflow-y: auto;
        position: relative;
    }
    
    /* Swipe indicator for mobile */
    .modern-auth-container::after {
        content: '';
        position: absolute;
        top: 12px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background: rgba(0, 87, 255, 0.3);
        border-radius: 2px;
        opacity: 0.6;
    }
    
    .auth-title {
        font-size: 24px;
    }
    
    .password-requirements {
        grid-template-columns: 1fr;
    }
    
    .form-options {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .social-login-buttons {
        flex-direction: column;
    }
    
    .guest-notification {
        left: 20px;
        right: 20px;
        max-width: none;
    }
    
    /* Fix mobile button clickability */
    .auth-switch-btn {
        min-height: 44px; /* Apple's recommended minimum touch target */
        padding: 12px 16px;
        margin: 4px 0;
        touch-action: manipulation; /* Improve touch response */
        -webkit-tap-highlight-color: rgba(0, 87, 255, 0.1);
        display: inline-block;
        border-radius: 6px;
    }
    
    .auth-switch {
        padding: 24px 0;
        margin-top: 16px;
    }
    
    /* Ensure form elements are properly sized for touch */
    .modern-input, .modern-textarea {
        font-size: 16px; /* Prevent zoom on iOS */
        min-height: 44px;
    }
    
    .password-toggle {
        min-width: 44px;
        min-height: 44px;
    }
    
    .modern-submit-btn {
        min-height: 48px;
        font-size: 16px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .modern-auth-container {
        border-width: 2px;
    }
    
    .modern-input, .modern-textarea {
        border-width: 2px;
    }
    
    .modern-input:focus, .modern-textarea:focus {
        box-shadow: 0 0 0 3px rgba(0, 87, 255, 0.3);
    }
}

/* Gesture feedback animations */
.modal-dialog.dragging {
    transition: none !important;
    will-change: transform;
}

.modal-dialog.returning {
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-dialog.dismissing {
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Mobile slide animations */
@media (max-width: 768px) {
    .modal.fade .modal-dialog {
        transform: translateY(100%);
        transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .modal.show .modal-dialog {
        transform: translateY(0);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
    
    .modal.fade .modal-dialog {
        transform: none !important;
    }
}