/**
 * Mobile-specific fixes for social login on iOS Safari and other mobile browsers
 */

/* Mobile-specific fixes for registration form */
@media (max-width: 768px) {

    /* Prevent zoom on input focus for iOS */
    input[type="tel"],
    input[type="text"],
    input[type="email"],
    input[type="password"] {
        font-size: 16px !important;
        -webkit-appearance: none;
        appearance: none;
        -webkit-border-radius: 0;
        border-radius: 4px;
    }

    /* Better touch targets for mobile */
    .btn-regis-option {
        min-height: 48px !important;
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }

    /* Loading state for social login buttons */
    .social-login-loading {
        opacity: 0.7;
        pointer-events: none;
        position: relative;
    }

    .social-login-loading::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 20px;
        height: 20px;
        margin: -10px 0 0 -10px;
        border: 2px solid #ffffff;
        border-top: 2px solid transparent;
        border-radius: 50%;
        animation: spin 1s linear infinite;
    }

    @keyframes spin {
        0% {
            transform: rotate(0deg);
        }

        100% {
            transform: rotate(360deg);
        }
    }

    /* Form validation feedback improvements */
    .form-control.is-invalid,
    .form-control.is-valid {
        background-position: right 12px center;
        background-size: 16px 16px;
    }

    /* Better SweetAlert2 mobile display */
    .swal2-container {
        padding: 10px !important;
    }

    .swal2-popup {
        width: 90% !important;
        max-width: 400px !important;
        font-size: 14px !important;
    }

    .swal2-title {
        font-size: 18px !important;
        padding: 20px 20px 10px !important;
    }

    .swal2-content {
        padding: 0 20px 20px !important;
    }

    /* Mobile form spacing improvements */
    .mb-4 {
        margin-bottom: 1.5rem !important;
    }

    .form-text {
        font-size: 13px !important;
        margin-top: 0.5rem !important;
    }
}

/* iOS Safari specific fixes */
@media screen and (-webkit-min-device-pixel-ratio: 2) {

    /* Prevent zoom on form inputs */
    input[type="email"],
    input[type="password"],
    input[type="text"],
    input[type="tel"] {
        font-size: 16px !important;
        -webkit-appearance: none;
        appearance: none;
        border-radius: 0;
    }

    /* Fix SweetAlert2 modals on mobile */
    .swal2-container {
        padding: 10px !important;
        z-index: 9999 !important;
    }

    .swal2-popup {
        font-size: 14px !important;
        width: 90% !important;
        max-width: 400px !important;
        margin: 20px auto !important;
    }

    .swal2-title {
        font-size: 18px !important;
        margin-bottom: 15px !important;
    }

    .swal2-content {
        font-size: 14px !important;
        line-height: 1.4 !important;
    }

    .swal2-input {
        font-size: 16px !important;
        padding: 12px !important;
        margin: 8px 0 !important;
        border: 1px solid #ddd !important;
        border-radius: 4px !important;
    }

    .swal2-actions {
        margin-top: 20px !important;
    }

    .swal2-confirm,
    .swal2-cancel {
        font-size: 14px !important;
        padding: 10px 20px !important;
        margin: 0 5px !important;
    }
}

/* General mobile fixes */
@media (max-width: 768px) {

    /* Restore professional social login buttons with mobile enhancements */
    .btn-regis-option {
        border: solid 1px #D0D5DD !important;
        background-color: white !important;
        font-weight: 300 !important;
        padding: 12px !important;
        margin: 10px 0 !important;
        font-size: 16px !important;
        border-radius: 6px !important;
        text-align: center !important;
        text-decoration: none !important;
        cursor: pointer !important;
        transition: all 0.3s ease !important;
        color: #333 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 10px !important;
        min-height: 48px !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1) !important;
    }

    .btn-regis-option:hover {
        background-color: #f8f9fa !important;
        border-color: #adb5bd !important;
        color: #333 !important;
    }

    .btn-regis-option:active {
        background-color: #e9ecef !important;
        border-color: #6c757d !important;
        transform: translateY(1px) !important;
    }

    /* Professional login icons styling for login page */
    .login-icon {
        height: 48px !important;
        width: 48px !important;
        border: solid 1px #D0D5DD !important;
        border-radius: 6px !important;
        padding: 8px !important;
        background-color: white !important;
        cursor: pointer !important;
        transition: all 0.3s ease !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1) !important;
    }

    .login-icon:hover {
        background-color: #f8f9fa !important;
        border-color: #adb5bd !important;
        transform: translateY(-1px) !important;
    }

    .login-icon:active {
        background-color: #e9ecef !important;
        border-color: #6c757d !important;
        transform: translateY(1px) !important;
    }

    /* Icon styling within buttons */
    .btn-regis-option .regis-icon {
        height: 24px !important;
        width: 24px !important;
        flex-shrink: 0 !important;
    }

    /* Loading states */
    .social-login-loading {
        opacity: 0.7 !important;
        pointer-events: none !important;
        position: relative !important;
    }

    .social-login-loading::after {
        content: '' !important;
        position: absolute !important;
        top: 50% !important;
        left: 50% !important;
        width: 20px !important;
        height: 20px !important;
        margin: -10px 0 0 -10px !important;
        border: 2px solid transparent !important;
        border-top-color: #fff !important;
        border-radius: 50% !important;
        animation: spin 1s linear infinite !important;
    }

    @keyframes spin {
        to {
            transform: rotate(360deg);
        }
    }

    /* Form improvements */
    .form-control {
        font-size: 16px !important;
        padding: 12px !important;
        border-radius: 4px !important;
        border: 1px solid #ddd !important;
    }

    .form-control:focus {
        border-color: #007bff !important;
        box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25) !important;
    }

    /* Error and success messages */
    .alert {
        padding: 12px !important;
        margin: 15px 0 !important;
        border-radius: 4px !important;
        font-size: 14px !important;
    }

    .alert-success {
        background-color: #d4edda !important;
        border-color: #c3e6cb !important;
        color: #155724 !important;
    }

    .alert-danger {
        background-color: #f8d7da !important;
        border-color: #f5c6cb !important;
        color: #721c24 !important;
    }

    /* Prevent iOS Safari bounce */
    body {
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
    }

    /* Fix modal backdrop issues */
    .modal-backdrop {
        z-index: 1040 !important;
    }

    .modal {
        z-index: 1050 !important;
    }
}

/* iPhone X and newer safe area fixes */
@supports (padding: max(0px)) {

    .container-fluid,
    .container {
        padding-left: max(15px, env(safe-area-inset-left)) !important;
        padding-right: max(15px, env(safe-area-inset-right)) !important;
    }

    .fixed-bottom {
        padding-bottom: max(10px, env(safe-area-inset-bottom)) !important;
    }

    .fixed-top {
        padding-top: max(10px, env(safe-area-inset-top)) !important;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {

    .line-login,
    .google-login,
    #google-login {
        border: 2px solid currentColor !important;
    }

    .swal2-popup {
        border: 2px solid currentColor !important;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .swal2-popup {
        background-color: #2d3748 !important;
        color: #e2e8f0 !important;
    }

    .swal2-input {
        background-color: #4a5568 !important;
        color: #e2e8f0 !important;
        border-color: #718096 !important;
    }

    .swal2-input:focus {
        border-color: #63b3ed !important;
    }
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {

    /* Fix iOS Safari input styling */
    input[type="tel"],
    input[type="text"],
    input[type="email"],
    input[type="password"] {
        -webkit-appearance: none;
        appearance: none;
        -webkit-border-radius: 0;
        border-radius: 0;
    }

    /* Fix iOS Safari button styling */
    .btn-regis-option {
        -webkit-appearance: none;
        appearance: none;
        -webkit-border-radius: 4px;
        border-radius: 4px;
    }

    /* Prevent iOS Safari from highlighting tapped elements */
    .btn,
    .btn-regis-option,
    .line-login,
    #google-login {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }
}

/* Android Chrome specific fixes */
@media screen and (max-width: 768px) and (-webkit-min-device-pixel-ratio: 1) {

    /* Fix Android Chrome input autofill styling */
    input:-webkit-autofill,
    input:-webkit-autofill:hover,
    input:-webkit-autofill:focus {
        -webkit-box-shadow: 0 0 0 30px white inset !important;
        -webkit-text-fill-color: #333 !important;
    }

    /* iOS Safari specific fixes */
    @supports (-webkit-touch-callout: none) {

        /* Fix iOS Safari input styling */
        input[type="tel"],
        input[type="text"],
        input[type="email"],
        input[type="password"] {
            -webkit-appearance: none;
            appearance: none;
            -webkit-border-radius: 0;
            border-radius: 0;
        }

        /* Fix iOS Safari button styling */
        .btn-regis-option {
            -webkit-appearance: none;
            appearance: none;
            -webkit-border-radius: 6px;
            border-radius: 6px;
        }

        /* Prevent iOS Safari from highlighting tapped elements */
        .btn,
        .btn-regis-option {
            -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
            -webkit-touch-callout: none;
            -webkit-user-select: none;
            user-select: none;
        }
    }

    /* Android Chrome specific fixes */
    @media screen and (max-width: 768px) and (-webkit-min-device-pixel-ratio: 1) {

        /* Fix Android Chrome input autofill styling */
        input:-webkit-autofill,
        input:-webkit-autofill:hover,
        input:-webkit-autofill:focus {
            -webkit-box-shadow: 0 0 0 30px white inset !important;
            -webkit-text-fill-color: #333 !important;
        }
    }

    /* Desktop and tablet enhancements for professional appearance */
    @media (min-width: 769px) {
        .btn-regis-option {
            padding: 14px 16px !important;
            font-size: 15px !important;
            max-width: 400px !important;
            margin: 15px auto !important;
        }

        .login-icon {
            height: 40px !important;
            width: 40px !important;
            margin: 0 8px !important;
        }

        .btn-regis-option:hover {
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
        }
    }

    /* Focus states for accessibility */
    .btn-regis-option:focus,
    .login-icon:focus {
        outline: 2px solid #007bff !important;
        outline-offset: 2px !important;
        box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25) !important;
    }

    /* Ensure consistent spacing and alignment */
    .regis-options {
        text-align: center !important;
        position: relative !important;
        margin: 30px 0 20px !important;
    }

    .regis-options span {
        background: white !important;
        padding: 0 15px !important;
        color: #6c757d !important;
        font-size: 14px !important;
    }

    .regis-options::before {
        content: '' !important;
        position: absolute !important;
        top: 50% !important;
        left: 0 !important;
        right: 0 !important;
        height: 1px !important;
        background: #dee2e6 !important;
        z-index: -1 !important;
    }
}