/* Mobile-specific fixes for login page */

/* Login box container width control */
.login-box-container {
  max-width: 400px;
}

@media (max-width: 575.98px) {
  .login-box-container {
    max-width: 100% !important;
    padding: 0 1rem;
  }
  
  /* Remove all unnecessary margins on mobile */
  .login-box-container .form-control,
  .login-box-container .btn,
  .login-box-container .input-group,
  .login-box-container .alert,
  .login-box-container .form-check,
  .login-box-container .social-auth-buttons .btn {
    margin-left: 0;
    margin-right: 0;
    width: 100%;
  }
  
  /* Fix input group to work properly */
  .login-box-container .input-group {
    display: flex;
    width: 100%;
  }
  
  /* Remove side margins from labels and text */
  .login-box-container .form-label,
  .login-box-container p,
  .login-box-container .divider {
    margin-left: 0;
    margin-right: 0;
  }
  
  /* Center logo needs no extra padding */
  .login-box-container .text-center {
    padding: 0;
  }
  
  /* Fix turnstile alignment */
  .login-box-container .cf-turnstile {
    margin-left: 0;
  }
}

/* Adjust authentication wrapper for mobile */
@media (max-width: 575.98px) {
  .authentication-wrapper {
    min-height: 100vh;
    height: auto;
  }
  
  /* Reduce padding on very small screens */
  .authentication-bg {
    padding: 0.5rem !important;
  }
  
  /* More compact form spacing - 20% height reduction */
  #formAuthentication .mb-3 {
    margin-bottom: 0.5rem !important;
  }
  
  /* Logo spacing on mobile */
  .text-center.mb-3.mb-sm-4 {
    margin-bottom: 1rem !important;
  }
  
  .text-center.mb-3.mb-sm-4 img,
  .mobile-logo,
  img.mobile-logo {
    max-height: 70px !important;
    height: 70px !important;
    width: auto !important;
  }
  
  /* Make form inputs very compact */
  .form-control {
    min-height: 36px;
    padding: 0.25rem 0.5rem;
    font-size: 16px; /* Prevents zoom on iOS */
  }
  
  /* Very small labels */
  .form-label {
    font-size: 0.8rem;
    margin-bottom: 0.125rem;
  }
  
  /* Smaller button sizing */
  .btn {
    min-height: 36px;
    font-size: 0.8rem;
    padding: 0.375rem 0.75rem;
  }
  
  /* Ultra-compact social auth buttons */
  .social-auth-buttons .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    min-height: 32px;
    margin-bottom: 0.375rem !important;
  }
  
  /* Minimal divider spacing */
  .divider {
    margin: 0.5rem 0 !important;
  }
  
  .divider-text {
    font-size: 0.75rem;
    padding: 0 0.5rem;
  }
  
  /* Very small alert boxes */
  .alert {
    padding: 0.25rem 0.375rem;
    font-size: 0.7rem;
  }
  
  /* Turnstile container even smaller */
  .cf-turnstile {
    transform: scale(0.75);
    transform-origin: 0 0;
    max-width: 100%;
    margin-bottom: -20px; /* Compensate for scale */
  }
  
  /* Minimal spacing for register link */
  .text-center.mt-4 {
    margin-top: 0.5rem !important;
  }
  
  /* Password toggle icon smaller */
  .form-password-toggle .input-group-text {
    padding: 0.25rem 0.375rem;
    font-size: 0.875rem;
    min-height: 36px;
  }
  
  /* Remove extra spacing from form */
  #formAuthentication {
    margin-bottom: 0.75rem !important;
  }
  
  /* Compress messages */
  .alert[role="alert"] {
    margin-bottom: 0.5rem !important;
  }
}

/* Medium screens adjustments */
@media (min-width: 576px) and (max-width: 767.98px) {
  .authentication-bg {
    padding: 2rem !important;
  }
}

/* Remove unnecessary vertical centering on mobile to save space */
@media (max-width: 575.98px) {
  .authentication-wrapper.authentication-cover .authentication-inner {
    height: auto !important;
    min-height: 100vh;
  }
  
  .authentication-bg.d-flex {
    align-items: flex-start !important;
    padding-top: 2rem !important;
  }
}

/* Fix for landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
  .authentication-wrapper {
    min-height: auto;
  }
  
  .mt-2.mt-sm-4 {
    margin-top: 0.5rem !important;
  }
  
  .authentication-bg.d-flex {
    padding-top: 1rem !important;
  }
}

/* Ensure form doesn't overflow on very small screens */
@media (max-width: 359px) {
  .authentication-bg {
    padding: 1rem !important;
  }
  
  .social-auth-buttons .btn {
    font-size: 0.8rem;
    padding: 0.4rem 0.5rem;
  }
}

/* Fix password toggle icon alignment */
.form-password-toggle .input-group-text {
  font-size: 1.125rem;
}

/* Mobile password field specific fixes */
@media (max-width: 575.98px) {
  /* Fix password field width - prevent wrapping to multiple rows */
  .form-password-toggle .input-group {
    display: flex !important;
    align-items: stretch !important;
    width: 100% !important;
    max-width: 100% !important;
    flex-wrap: nowrap !important;
    box-sizing: border-box !important;
  }
  
  .form-password-toggle .form-control {
    flex: 1 1 0% !important;
    width: 0 !important;
    min-width: 0 !important;
    max-width: none !important;
    box-sizing: border-box !important;
  }
  
  .form-password-toggle .input-group-text {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0.25rem 0.375rem !important;
    font-size: 0.875rem !important;
    min-height: 36px !important;
    border-left: 0 !important;
    background-color: #fff !important;
    flex-shrink: 0 !important;
    width: auto !important;
    max-width: 40px !important;
  }
  
  /* Ensure container doesn't overflow */
  .form-password-toggle {
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden !important;
  }
  
  /* Ensure password field container has proper spacing */
  .form-password-toggle .d-flex {
    margin-bottom: 0.5rem !important;
  }
  
  /* Make sure password label and forgot password link work on mobile */
  .form-password-toggle .d-flex.justify-content-between {
    flex-wrap: wrap !important;
    gap: 0.25rem !important;
    justify-content: space-between !important;
    text-align: left !important;
  }
  
  .form-password-toggle .form-label {
    font-size: 0.875rem !important;
    margin-bottom: 0 !important;
    text-align: left !important;
    align-self: flex-start !important;
  }
  
  /* Fix input focus state on mobile */
  .form-password-toggle .form-control:focus {
    border-color: #7367f0 !important;
    box-shadow: 0 0 0 0.2rem rgba(115, 103, 240, 0.25) !important;
  }
  
  /* Fix placeholder text on mobile */
  .form-password-toggle .form-control::placeholder {
    color: #a8aaae !important;
    opacity: 1 !important;
  }
}

/* Improve divider appearance on mobile */
@media (max-width: 575.98px) {
  .divider {
    margin: 1.5rem 0;
  }
  
  .divider-text {
    font-size: 0.875rem;
  }
}

/* Two-factor form mobile optimization */
@media (max-width: 575.98px) {
  .two-factor-form {
    padding: 1rem;
  }
  
  .two-factor-form h5 {
    font-size: 1.125rem;
  }
  
  .two-factor-form p {
    font-size: 0.875rem;
  }
}

/* Ultra-compact mode for mobile */
@media (max-width: 575.98px) {
  /* HIDE social login section completely on mobile */
  .social-auth-buttons {
    display: none !important;
  }
  
  /* HIDE the divider before social buttons */
  .divider {
    display: none !important;
  }
  
  /* HIDE remember me checkbox to save space */
  .form-check {
    display: none !important;
  }
  
  /* Minimal register link spacing */
  p.text-center {
    margin-top: 1rem !important;
    margin-bottom: 0 !important;
    font-size: 0.875rem;
  }
  
  /* Make the entire form container ultra-compact */
  .mt-1.mt-sm-4 > div {
    margin-bottom: 0 !important;
  }
  
  /* Simplify labels - combine email/username label */
  label[for="email"] {
    font-size: 0.875rem !important;
  }
  
  /* Hide "or" text in email label */
  label[for="email"]:after {
    content: "" !important;
  }
  
  /* Further reduce padding on authentication bg */
  .authentication-bg.p-2.p-sm-5 {
    padding: 0.5rem !important;
  }
  
  /* Make logo bigger on mobile */
  .text-center.mb-3.mb-sm-4 img,
  .mobile-logo,
  img.mobile-logo {
    max-height: 70px !important;
    height: 70px !important;
    width: auto !important;
  }
  
  /* Show forgot password link on mobile */
  .forgot-password-link {
    display: inline !important;
    font-size: 0.75rem !important;
  }
  
  /* Keep password label left-aligned - override any centering */
  .form-password-toggle .d-flex {
    justify-content: space-between !important;
    text-align: left !important;
  }
  
  .form-password-toggle .form-label {
    text-align: left !important;
    margin-left: 0 !important;
    padding-left: 0 !important;
  }
  
  /* Increase font size for inputs to prevent zoom on iOS */
  .form-control,
  .input-group .form-control {
    font-size: 16px !important;
  }
  
  /* Fix mobile layout positioning issues */
  .authentication-wrapper .authentication-inner {
    padding: 1rem !important;
  }
  
  .authentication-wrapper .col-12 {
    justify-content: center !important;
    padding: 1rem !important;
    transform: none !important;
  }
  
  /* Ensure form container is properly centered on mobile */
  .login-box-container {
    max-width: 100% !important;
    margin: 0 auto !important;
    width: 100% !important;
  }
  
  /* Fix viewport issues on mobile */
  .authentication-bg {
    margin: 0 auto !important;
    box-shadow: none !important;
    border-radius: 8px !important;
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  
  /* Prevent all form elements from overflowing */
  .login-box-container * {
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  
  /* Specific width constraints for input elements */
  .form-control,
  .input-group,
  .btn {
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  
  /* Welcome text mobile styling */
  .welcome-text h4 {
    font-size: 1.25rem !important;
    margin-bottom: 0.25rem !important;
  }
  
  .welcome-text p {
    font-size: 0.875rem !important;
    margin-bottom: 0 !important;
  }
}