/* ==========================================================================
   Login Page Styles
   ========================================================================== */

html,
body {
    height: 100%;
    margin: 0;
    overflow-x: hidden;
}

/* Override base template flex-column to center content */
body {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 100vh !important;
    min-height: 100dvh !important; /* Dynamic viewport height for iOS Safari */
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    position: relative;
}

/* Make the flex-grow-1 wrapper also center its content */
body > .flex-grow-1 {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    flex-grow: 0 !important; /* Don't grow, just center */
}

/* Dark theme background */
body.bg-dark,
[data-bs-theme="dark"] body {
    background: linear-gradient(135deg, #0d0d0d 0%, #1a1a1a 50%, #2d2d2d 100%);
}

/* ==========================================================================
   Popcorn Background Animation (Snowflake-style)
   ========================================================================== */

.popcorn-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

/* Each popcorn particle */
.popcorn {
    position: absolute;
    top: -50px;
    user-select: none;
    pointer-events: none;
    animation: fall linear infinite, sway ease-in-out infinite;
    will-change: transform;
}

@keyframes fall {
    0% {
        transform: translateY(-100px);
    }
    100% {
        transform: translateY(calc(100vh + 100px));
    }
}

@keyframes sway {
    0%, 100% {
        margin-left: 0;
    }
    25% {
        margin-left: 25px;
    }
    75% {
        margin-left: -25px;
    }
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .popcorn {
        animation: none !important;
        display: none;
    }

    .popcorn-bg::before {
        content: '🍿';
        position: absolute;
        top: 20%;
        left: 15%;
        font-size: 24px;
        opacity: 0.08;
        filter: blur(2px);
    }

    .popcorn-bg::after {
        content: '🍿';
        position: absolute;
        bottom: 25%;
        right: 20%;
        font-size: 28px;
        opacity: 0.06;
        filter: blur(3px);
    }
}

/* ==========================================================================
   Login Form Layout
   ========================================================================== */

.login-container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 400px;
    padding: 1rem;
    margin: 0 auto;
}

/* Logo with circle background */
.login-logo-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.login-logo-circle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: linear-gradient(145deg, #e8e8e8, #f5f5f5);
    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.15),
        0 2px 8px rgba(0, 0, 0, 0.1),
        inset 0 -2px 4px rgba(0, 0, 0, 0.05);
}

[data-bs-theme="dark"] .login-logo-circle {
    background: linear-gradient(145deg, #3a3a3a, #4a4a4a);
    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.4),
        0 2px 8px rgba(0, 0, 0, 0.3),
        inset 0 -2px 4px rgba(0, 0, 0, 0.2);
}

/* Logo container with shadow border effect */
.login-logo-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 170px;
    height: 170px;
}

/* Shadow border behind the SVG using pseudo-element */
.login-logo-container::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 160px;
    height: 160px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.08);
    filter: blur(4px);
    z-index: 0;
}

[data-bs-theme="dark"] .login-logo-container::before {
    background: rgba(0, 0, 0, 0.25);
    filter: blur(5px);
}

.login-logo {
    position: relative;
    z-index: 1;
    display: block;
    width: 170px;
    height: 170px;
    /* No border-radius needed for transparent SVG */
    /* No box-shadow on the img itself - shadow is on the container::before */
}

@media (max-width: 576px) {
    .login-logo-circle {
        width: 140px;
        height: 140px;
    }

    .login-logo-container {
        width: 120px;
        height: 120px;
    }

    .login-logo-container::before {
        width: 112px;
        height: 112px;
    }

    .login-logo {
        width: 120px;
        height: 120px;
    }

    .login-logo-wrapper {
        margin-bottom: 1rem;
    }
}

.login-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

[data-bs-theme="dark"] .login-card {
    background: rgba(40, 40, 40, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.login-card h1 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: #1a1a2e;
}

[data-bs-theme="dark"] .login-card h1 {
    color: #ffffff;
}

/* Form inputs */
.login-card .form-floating {
    margin-bottom: 0;
}

.login-card .form-floating:focus-within {
    z-index: 2;
}

.login-card input[type="email"] {
    border-bottom-right-radius: 0;
    border-bottom-left-radius: 0;
    border-bottom: none;
}

.login-card input[type="password"] {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

.login-card .form-control {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

[data-bs-theme="dark"] .login-card .form-control {
    background: rgba(60, 60, 60, 0.9);
    border-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

[data-bs-theme="dark"] .login-card .form-control::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

[data-bs-theme="dark"] .login-card .form-floating label {
    color: rgba(255, 255, 255, 0.7);
}

/* Checkbox */
.login-card .form-check {
    margin: 1rem 0;
    text-align: left;
}

.login-card .form-check-label {
    color: #1a1a2e;
}

[data-bs-theme="dark"] .login-card .form-check-label {
    color: rgba(255, 255, 255, 0.8);
}

/* Submit button */
.login-card .btn-primary {
    background: linear-gradient(135deg, #FBBC09 0%, #e0a800 100%);
    border: none;
    color: #1a1a2e;
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.login-card .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(251, 188, 9, 0.4);
}

.login-card .btn-primary:active {
    transform: translateY(0);
}

/* Error alerts */
.login-card .alert {
    border-radius: 8px;
    margin-bottom: 1rem;
}

/* Links */
.login-card a {
    color: #FBBC09;
    text-decoration: none;
}

.login-card a:hover {
    text-decoration: underline;
}

/* TOTP form */
.login-card #totpForm p {
    color: #1a1a2e;
    margin-bottom: 1rem;
}

[data-bs-theme="dark"] .login-card #totpForm p {
    color: rgba(255, 255, 255, 0.8);
}

/* ==========================================================================
   Legacy class overrides (for backward compatibility)
   ========================================================================== */

.form-signin {
    max-width: none;
    padding: 0;
    margin: 0;
    width: 100%;
}
