/* CSS Variables are inherited from main.css (--primary-green, --primary-dark,
   --dark-grey, --white, --light-grey, --hover-green, etc.). The tokens below
   are local to this page only and mirror the site-wide premium design
   language (navy/green palette, refined shadows, tactile easing). */
:root {
    --login-ink-900: #0b1c2c;
    --login-ink-700: #33475a;
    --login-ink-600: #52697d;
    --login-ink-500: #708499;
    --login-ink-400: #96a6b6;
    --login-surface: #ffffff;
    --login-surface-soft: #f6f8fa;
    --login-border-soft: #e7ecf1;
    --login-radius-sm: 10px;
    --login-radius-lg: 20px;
    --login-shadow-lg: 0 24px 56px rgba(2, 21, 33, 0.28), 0 8px 20px rgba(2, 21, 33, 0.14);
    --login-ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
    --login-ease-tactile: cubic-bezier(0.34, 1.56, 0.64, 1);
    --login-font-display: 'Plus Jakarta Sans', system-ui, sans-serif;
}

/* Optimize background image loading */
body::before{
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url("/static/authentication/images/study_group.72c208c32fff.jpg") no-repeat center center;
    background-size: cover;
    background-attachment: fixed;
    z-index: -2;
    /* Optimize rendering */
    will-change: transform;
    transform: translateZ(0);
    /* Lazy load background on mobile */
    content-visibility: auto;
}

body::after{
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(150deg, #0a486ff7, #021521ae);
    z-index: -1;
}

/* Soft radial accent glow, echoing the site's hero treatment */
body {
    position: relative;
}

body::-webkit-scrollbar {
    display: none;
}

.login-ambient-glow {
    position: fixed;
    top: -12%;
    right: -8%;
    width: 45%;
    height: 45%;
    background: radial-gradient(circle, rgba(46, 204, 113, 0.16) 0%, rgba(46, 204, 113, 0) 70%);
    pointer-events: none;
    z-index: -1;
}

/* Preload critical background image */
@media (min-width: 768px) {
    body::before {
        background-image: url("/static/authentication/images/study_group.72c208c32fff.jpg");
    }
}


/* Auth Form Styles */

.login-shell {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height keeps this accurate on mobile browsers with collapsing toolbars */
    width: 100%;
    padding: 2.5rem 1.5rem;
    box-sizing: border-box;
    /* True vertical centering when the card fits the viewport. The plain
       `center` value is a fallback for browsers that don't understand the
       `safe` keyword; browsers that do support it (all modern engines)
       will instead fall back to top-alignment ONLY if the content is
       taller than the viewport, so long content/error states can never be
       clipped or become unreachable while scrolling. */
    justify-content: center;
    justify-content: safe center;
}

/* Auth Form Styles */
.auth-form {
    max-width: 450px;
    width: 100%;
    padding: 2.5rem;
    background-color: var(--login-surface);
    border-radius: var(--login-radius-lg);
    box-shadow: var(--login-shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.6);
}

.auth-form h2 {
    margin-bottom: 0.4rem;
    text-align: center;
    color: var(--login-ink-900);
    font-family: var(--login-font-display);
    font-weight: 800;
    letter-spacing: -0.01em;
    font-size: 1.85rem;
}

.login-subtitle {
    text-align: center;
    color: var(--login-ink-500);
    font-size: 0.95rem;
    margin-bottom: 1.75rem;
    line-height: 1.5;
}

.auth-form .form-label {
    font-weight: 600;
    color: var(--login-ink-700);
    margin-bottom: 0.45rem;
    font-size: 0.85rem;
    letter-spacing: 0.005em;
}

.auth-form .mb-3 {
    margin-bottom: 1.375rem !important;
}

.auth-form .form-control {
    border: 1.5px solid var(--login-border-soft);
    padding: 0.8rem 1rem;
    border-radius: var(--login-radius-sm);
    font-size: 0.95rem;
    color: var(--login-ink-900);
    transition: border-color 0.25s var(--login-ease-out-quart), box-shadow 0.25s var(--login-ease-out-quart), background-color 0.25s var(--login-ease-out-quart);
    background-color: var(--login-surface-soft);
}

.auth-form .form-control::placeholder {
    color: var(--login-ink-400);
}

.auth-form .form-control:hover {
    border-color: #c7d2db;
}

.auth-form .form-control:focus {
    border-color: var(--primary-green);
    box-shadow: 0 0 0 4px rgba(var(--primary-green-rgb), 0.12);
    background-color: var(--login-surface);
}

.auth-form .form-control.is-invalid {
    border-color: #ef4444;
    background-image: none;
}

.auth-form .form-control.is-invalid:focus {
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.12);
}

/* Password field + show/hide toggle, styled as one seamless pill control */
.auth-form .input-group {
    border-radius: var(--login-radius-sm);
    transition: box-shadow 0.25s var(--login-ease-out-quart);
}

.auth-form .input-group .form-control {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: none;
}

.auth-form .input-group .btn-outline-secondary {
    border: 1.5px solid var(--login-border-soft);
    border-left: none;
    background-color: var(--login-surface-soft);
    color: var(--login-ink-500);
    border-top-right-radius: var(--login-radius-sm);
    border-bottom-right-radius: var(--login-radius-sm);
    padding: 0 1rem;
    transition: color 0.25s ease, background-color 0.25s ease;
}

.auth-form .input-group .btn-outline-secondary:hover,
.auth-form .input-group .btn-outline-secondary:focus {
    color: var(--primary-green);
    background-color: var(--login-surface-soft);
    box-shadow: none;
}

.auth-form .input-group:focus-within .form-control,
.auth-form .input-group:focus-within .btn-outline-secondary {
    border-color: var(--primary-green);
    background-color: var(--login-surface);
}

.auth-form .input-group:focus-within {
    box-shadow: 0 0 0 4px rgba(var(--primary-green-rgb), 0.12);
}

.auth-form .btn-primary {
    width: 100%;
    padding: 0.9rem;
    margin-top: 0.75rem;
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--primary-dark) 100%);
    border: none;
    border-radius: var(--login-radius-sm);
    font-family: var(--login-font-display);
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.01em;
    box-shadow: 0 4px 14px rgba(var(--primary-green-rgb), 0.3);
    transition: transform 0.3s var(--login-ease-tactile), box-shadow 0.35s ease, background 0.3s ease;
    position: relative;
    overflow: hidden;
}

.auth-form .btn-primary::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.16), transparent);
    transform: translateX(-100%);
    transition: transform 0.5s ease;
}

.auth-form .btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, #052538 100%);
    border-color: transparent;
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(var(--primary-green-rgb), 0.38);
}

.auth-form .btn-primary:hover::after {
    transform: translateX(100%);
}

.auth-form .btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 4px 14px rgba(var(--primary-green-rgb), 0.3);
}

.auth-form .btn-primary:focus-visible {
    outline: 2px solid var(--primary-light);
    outline-offset: 3px;
}

.auth-form .form-check {
    margin: 1rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.auth-form .form-check-label {
    color: var(--login-ink-600);
    font-weight: 400;
    font-size: 0.9rem;
}

.auth-form .form-check-input {
    border: 1.5px solid var(--login-border-soft);
    cursor: pointer;
}

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

.auth-form .form-check-input:focus {
    border-color: var(--primary-green);
    box-shadow: 0 0 0 3px rgba(var(--primary-green-rgb), 0.15);
}

.auth-form a {
    color: var(--primary-green);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    border-bottom: 1px solid transparent;
    padding-bottom: 1px;
    transition: color 0.25s ease, border-color 0.25s ease;
}

.auth-form a:hover {
    color: var(--primary-dark);
    border-color: currentColor;
    text-decoration: none;
}

.auth-form .invalid-feedback {
    font-size: 0.8rem;
    margin-top: 0.4rem;
    font-weight: 500;
}

/* Alerts inside the login card only — scoped so the shared, global .alert
   rules used across the authenticated dashboard shell are left untouched. */
.auth-form .alert {
    margin-bottom: 1.5rem;
    border-radius: var(--login-radius-sm);
    padding: 0.8rem 1rem;
    font-size: 0.875rem;
    border-left: 3px solid transparent;
}

.auth-form .alert-success {
    border-left-color: #27ae60;
}

.auth-form .alert-danger {
    border-left-color: #ef4444;
}

.login-back-link-wrap {
    text-align: center;
    margin-bottom: 1rem;
}

.login-back-link {
    color: var(--login-ink-500);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    border-bottom: 1px solid transparent;
    padding-bottom: 1px;
    transition: color 0.25s var(--login-ease-out-quart), border-color 0.25s var(--login-ease-out-quart);
}

.login-back-link i {
    transition: transform 0.25s var(--login-ease-tactile);
}

.login-back-link:hover {
    color: var(--primary-green);
    border-color: currentColor;
}

.login-back-link:hover i {
    transform: translateX(-3px);
}

.login-logo-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 1.75rem;
}

.login-logo {
    width: 100px;
    height: 80px;
}

.login-signup-link {
    color: var(--primary-green);
    text-decoration: none;
    font-weight: 600;
    word-break: break-word;
    border-bottom: 1px solid transparent;
    padding-bottom: 1px;
    transition: color 0.25s ease, border-color 0.25s ease;
}

.login-signup-link:hover {
    color: var(--primary-dark);
    border-color: currentColor;
}

/* ============================================================================
   Responsive Design for Login Page
   ============================================================================ */

/* Tablet and below (max-width: 992px) */
@media (max-width: 992px) {
    .login-shell {
        width: 100%;
        padding: 1.5rem 1rem;
    }
    
    .auth-form {
        max-width: 400px;
        padding: 1.75rem;
    }
    
    .auth-form h2 {
        font-size: 1.5rem;
    }

    .login-subtitle {
        font-size: 0.875rem;
        margin-bottom: 1.5rem;
    }
}

/* Mobile Landscape and Small Tablets (max-width: 768px) */
@media (max-width: 768px) {
    body {
        overflow-x: hidden;
    }
    
    body::before {
        background-attachment: scroll; /* Better performance on mobile */
        background-size: cover;
    }
    
    .login-shell {
        width: 100%;
        min-height: 100vh;
        min-height: 100dvh; /* Dynamic viewport height for mobile */
        padding: 2rem 1rem;
    }
    
    .auth-form {
        max-width: 100%;
        width: 100%;
        padding: 1.5rem;
        margin: 0;
        border-radius: var(--login-radius-lg);
    }
    
    .auth-form h2 {
        font-size: 1.375rem;
        margin-bottom: 0.35rem;
    }

    .login-subtitle {
        font-size: 0.85rem;
        margin-bottom: 1.25rem;
    }
    
    .auth-form .form-control {
        padding: 0.875rem;
        font-size: 1rem; /* Prevents iOS zoom */
    }
    
    .auth-form .form-label {
        font-size: 0.875rem;
    }
    
    .auth-form .btn-primary {
        padding: 0.875rem;
        font-size: 1rem;
    }
    
    /* Logo adjustments */
    .auth-form img {
        width: 80px !important;
        height: 64px !important;
        margin-bottom: 2rem !important;
    }
}

/* Mobile Portrait (max-width: 576px) */
@media (max-width: 576px) {
    .login-shell {
        padding: 0.75rem;
        padding-top: 1.5rem;
    }
    
    .auth-form {
        padding: 1.25rem;
        border-radius: var(--login-radius-sm);
    }
    
    .auth-form h2 {
        font-size: 1.25rem;
        margin-bottom: 0.3rem;
    }

    .login-subtitle {
        font-size: 0.8125rem;
        margin-bottom: 1rem;
    }
    
    .auth-form .form-control {
        padding: 0.75rem;
        font-size: 16px; /* Prevents iOS zoom */
    }
    
    .auth-form .form-label {
        font-size: 0.8125rem;
        margin-bottom: 0.375rem;
    }
    
    .auth-form .btn-primary {
        padding: 0.75rem;
        font-size: 0.9375rem;
        margin-top: 1rem;
    }
    
    .auth-form .form-check {
        margin: 0.625rem 0;
    }
    
    .auth-form .form-check-label {
        font-size: 0.875rem;
    }
    
    .auth-form .alert {
        padding: 0.625rem 0.875rem;
        font-size: 0.875rem;
        margin-bottom: 1rem;
    }
    
    .auth-form .invalid-feedback {
        font-size: 0.75rem;
    }
    
    /* Logo smaller on mobile */
    .auth-form img {
        width: 70px !important;
        height: 56px !important;
        margin-bottom: 1.5rem !important;
    }
    
    /* Back link */
    .login-back-link-wrap {
        margin-bottom: 0.75rem;
    }
    
    /* Sign up link */
    .text-center.mt-3 p {
        font-size: 0.875rem;
    }

    .login-back-link {
        font-size: 0.8125rem;
        white-space: normal;
    }

    .input-group .btn {
        min-width: 44px;
    }
}

/* Extra Small Mobile (max-width: 400px) */
@media (max-width: 400px) {
    .login-shell {
        padding: 0.5rem;
        padding-top: 1rem;
    }
    
    .auth-form {
        padding: 1rem;
    }
    
    .auth-form h2 {
        font-size: 1.125rem;
    }
    
    .auth-form .form-control {
        padding: 0.625rem;
    }
    
    .auth-form .btn-primary {
        padding: 0.625rem;
        font-size: 0.875rem;
    }
    
    .auth-form img {
        width: 60px !important;
        height: 48px !important;
    }
}

/* Landscape mobile devices */
@media (max-height: 600px) and (orientation: landscape) {
    .login-shell {
        height: auto;
        min-height: 100vh;
        padding: 1rem;
    }
    
    .auth-form {
        max-width: 500px;
        padding: 1.5rem;
    }
    
    .auth-form img {
        width: 70px !important;
        height: 56px !important;
        margin-bottom: 1rem !important;
    }
    
    .auth-form h2 {
        margin-bottom: 1rem;
        font-size: 1.25rem;
    }
    
    .auth-form .form-group {
        margin-bottom: 1rem;
    }
}

/* Prevent horizontal scroll */
@media (max-width: 768px) {
    html, body {
        overflow-x: hidden;
        width: 100%;
    }
    
    * {
        max-width: 100%;
    }
}

/* Safe area insets for notched devices */
@supports (padding: env(safe-area-inset-bottom)) {
    @media (max-width: 768px) {
        .login-shell {
            padding-left: max(0.75rem, env(safe-area-inset-left));
            padding-right: max(0.75rem, env(safe-area-inset-right));
            padding-bottom: max(1rem, env(safe-area-inset-bottom));
        }
        
        .auth-form {
            padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
        }
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .auth-form {
        border: 2px solid var(--primary-green);
    }
    
    .auth-form .form-control {
        border-width: 2px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    body::before {
        background-attachment: scroll;
    }
    
    .auth-form .form-control,
    .auth-form .btn-primary {
        transition: none;
    }

    .auth-form .btn-primary::after {
        display: none;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .auth-form .btn-primary::after {
        display: none;
    }
}