/* Login Form Styling */

:root {
    /* Primary Colors */
    --primary: #652c90; /* Updated to match project guidelines */
    --primary-hover: rgba(98, 21, 125, 0.8); /* Adjusted hover color based on button hover in styles.css */
    --primary-border: rgba(101, 44, 144, 0.8); /* Adjusted border color based on new primary */
    --primary-shadow: rgba(101, 44, 144, 0.15); /* Adjusted shadow color based on new primary */
    
    /* Neutral Colors */
    --text-primary: #2c3e50;
    --text-secondary: #666;
    --border-color: #ccc;
    --background: linear-gradient(to bottom right, #ffffff, #f8fdf9);
    
    /* Spacing */
    --container-padding: 20px;
    --form-spacing: 1.5rem;
    --input-padding: 16px 24px;
    --button-padding: 12px 30px;
}

/* Login Container */
.login-container {
    max-width: 800px;
    margin: 0 auto; /* Center the container horizontally */
    padding: var(--container-padding);
    min-height: calc(100vh - 150px);
    display: flex;
    align-items: center;
}

/* Login Card */
.login-card {
    background: var(--background);
    border: 1px solid rgba(98, 42, 142, 0.1);
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--primary-shadow);
    transition: all 0.3s ease;
    overflow: hidden;
    padding: 25px;
}

.login-card:hover {
    transform: translateY(-5px); /* Added transform for hover effect */
    box-shadow: 0 4px 12px rgba(98, 42, 142, 0.15);
}

.login-card .card-header {
    border-bottom: none;
    background: transparent;
    padding-bottom: 1.5rem;
}

.login-card .card-header h3 {
    color: var(--primary);
    font-size: 1.75rem;
    margin: 0;
}

/* Form Controls */
.form-control {
    padding: var(--input-padding, 16px 24px); /* Added fallback */
    font-size: 1rem;
    width: 100%;
    border: 2px solid var(--primary-border);
    border-radius: 0; /* Removed default radius as per user preference */
    transition: all 0.3s ease;
}

.form-control:focus {
    box-shadow: 0 0 8px var(--primary-shadow);
    outline: none;
}

/* General Field Styling */
.field {
    margin-bottom: var(--form-spacing, 1.5rem);
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    display: flex;
    flex-direction: column;
}

.email-field-wrapper {
    display: flex;
    width: 100%;
}

.form-field-wrapper {
    width: 100%;
}

.form-field-wrapper input {
    width: 100%;
    padding: var(--input-padding);
    border: 2px solid var(--primary-border);
    border-radius: 0;
    box-sizing: border-box;
}

/* Reset default Silverstripe input styles that might conflict */
.field .middleColumn {
    padding: 0; 
    margin: 0; 
    width: 100%;
}

.field .middleColumn input {
    width: 100%;
    padding: var(--input-padding);
    border: 2px solid var(--primary-border);
    border-radius: 0;
    box-sizing: border-box;
    height: 40px;
}
/* Override for password input specifically - Removed width: 40px; rule */

.field .middleColumn input[type="password"] {
    width: 240px;
}

/* Password Field Styling (After JS manipulation) */
.password-field-wrapper {
    position: relative;
    max-width: 100%; 
}

/* Reverting to Flexbox with explicit widths */
.password-field-wrapper .input-group {
    display: flex; /* Use flexbox */
    align-items: center; /* Align items vertically */
    width: 100%;
    /* position: relative; */ /* Remove relative positioning */
}


/* Applying Flexbox with explicit widths */
.password-field-wrapper .input-group input#MemberLoginForm_LoginForm_Password.text.password.form-control {
    /* flex-grow: 1; */ /* Don't grow, use calc width */
    width: calc(100% - 50px); /* Input takes up most space, leaving 50px for toggle */
    min-width: 0;
    border-radius: 0 !important;
    border: 2px solid var(--primary-border) !important;
    border-right: none !important; /* Remove right border to join toggle */
    padding: var(--input-padding, 16px 24px) !important;
    /* padding-right: 40px !important; */ /* Remove padding */
    height: 40px !important;
    line-height: normal !important;
    box-sizing: border-box !important;
}

.password-toggle {
    /* position: absolute; */ /* Remove absolute positioning */
    /* right: 10px; */
    /* top: 50%; */
    /* transform: translateY(-50%); */
    /* height: 38px; */
    flex-shrink: 0; /* Prevent toggle from shrinking */
    width: 50px; /* Explicit width for the toggle button */
    border: 2px solid var(--primary-border) !important; /* Restore border */
    border-left: none !important; /* Remove left border to join input */
    border-radius: 0 !important; /* Ensure sharp corners */
    padding: 0; /* Remove padding if width is fixed */
    background: white; /* Restore background */
    color: var(--text-secondary);
    transition: all 0.3s ease;
    height: 40px !important; /* Match input height */
    display: flex;
    align-items: center;
    justify-content: center; /* Center icon within the button */
    cursor: pointer;
    /* z-index: 3; */ /* Remove z-index */
    box-sizing: border-box; /* Include border in width calculation */
}

.password-toggle:hover {
    background-color: var(--background);
    color: var(--primary);
}

.password-toggle:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.form-control.is-invalid {
    border-color: #dc3545;
    padding-right: calc(1.5em + .75rem);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23dc3545' stroke='none'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(.375em + .1875rem) center;
    background-size: calc(.75em + .375rem) calc(.75em + .375rem);
}

/* Checkbox styling */
.form-check {
    padding-left: 2rem;
}

.form-check-input {
    width: 1.25rem;
    height: 1.25rem;
    margin-left: -2rem;
    border: 2px solid var(--primary-border);
    cursor: pointer;
}

.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.form-check-label {
    cursor: pointer;
    color: var(--text-secondary);
}

 /* Custom button styles */

/* Ensure the login button is purple */
.login-form .btn-primary {
    background-color: #652c90 !important; /* Explicitly set background to primary purple */
    border-color: #652c90 !important; /* Explicitly set border to primary purple */
}

/* Ensure hover and active states also use the explicit color or variables */
.login-form .btn-primary:hover {
    background-color: var(--primary-hover) !important; /* Use hover variable */
    border-color: var(--primary-hover) !important; /* Use hover variable for border */
}

.login-form .btn-primary:active {
    background-color: var(--primary) !important; /* Use primary variable */
    border-color: var(--primary) !important; /* Use primary variable for border */
}


.btn-toolbar .action {
    width: 100%; /* Ensure the button inside toolbar is full width */
    margin-bottom: 0.5rem; /* Add space below the button */
}


/* Loading State */
.loading-spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s ease infinite;
    margin-left: 8px;
}

.btn-primary.loading {
    position: relative;
}

.btn-primary.loading .loading-spinner {
    display: inline-block;
}

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

/* Error Messages */
.alert {
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 1rem;
    border: 1px solid transparent;
}

.alert-danger {
    color: #842029;
    background-color: #f8d7da;
    border-color: #f5c2c7;
}

.invalid-feedback {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875em;
    color: #dc3545;
}

/* Links */
a {
    color: var(--primary);
    transition: color 0.3s ease;
}

a:hover {
    color: var(--primary-hover);
    text-decoration: none;
}

/* Style for the "Forgot password?" link */
.text-center.mt-4 {
    margin-top: var(--form-spacing, 1.5rem) !important; /* Adjust top margin */
}

/* Style for the "I've lost my password" link next to the button */
#ForgotPassword {
    margin-top: 0.5rem; /* Add some space below the button */
    text-align: center; /* Center the link */
    display: block; /* Ensure it's a block element */
}


/* Responsive Design */
@media (max-width: 767px) {
    .login-container {
        padding: 15px;
    }
    
    .login-card {
        padding: 20px;
    }
    
    .form-control {
        padding: 12px 20px;
    }
    
    .btn-primary {
        padding: 10px 24px;
    }
}

/* Desktop Styles */
@media (min-width: 992px) {
    .login-container {
        max-width: 800px;
        padding: 30px;
    }
    
    .login-card {
        padding: 35px;
    }

    .form-control {
        font-size: 1.125rem;
    }

    .btn-primary {
        font-size: 1.125rem;
    }
}

/* Focus Ring for Better Accessibility */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Improved Form Validation States */
.form-control.is-invalid:focus {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25);
    outline: none; /* Ensure no default outline */
}

.form-control.is-valid {
    border-color: #198754;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%23198754' d='M2.3 6.73L.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(.375em + .1875rem) center;
    background-size: calc(.75em + .375rem) calc(.75em + .375rem);
}

.form-control.is-valid:focus {
    border-color: #198754;
    box-shadow: 0 0 0 0.25rem rgba(25, 135, 84, 0.25);
    outline: none; /* Ensure no default outline */
}
