/* =============================================
   Login Page — Premium UI with Animations
   ============================================= */

/* --- CSS Variables --- */
:root {
    --login-primary: #6366f1;
    --login-primary-light: #818cf8;
    --login-accent: #a78bfa;
    --login-glow: rgba(99, 102, 241, 0.4);
    --login-bg-1: #0f0c29;
    --login-bg-2: #302b63;
    --login-bg-3: #24243e;
    --card-bg: rgba(255, 255, 255, 0.08);
    --card-border: rgba(255, 255, 255, 0.15);
    --card-shadow: rgba(0, 0, 0, 0.3);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --input-bg: rgba(255, 255, 255, 0.06);
    --input-border: rgba(255, 255, 255, 0.12);
    --input-focus-border: var(--login-primary-light);
    --error-color: #f87171;
    --success-color: #34d399;
}

/* --- Reset & Base --- */
.login-page {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Vazirmatn FD', 'Segoe UI', Tahoma, sans-serif;
    overflow: hidden;
    position: relative;
    background: linear-gradient(-45deg, var(--login-bg-1), var(--login-bg-2), var(--login-bg-3), #1a1a2e, #16213e);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
}

/* --- Animated Gradient Background --- */
@keyframes gradientShift {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* --- Particle Container --- */
.particles-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.particle {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    opacity: 0;
    animation: floatParticle linear infinite;
}

@keyframes floatParticle {
    0% {
        opacity: 0;
        transform: translateY(100vh) scale(0);
    }
    10% {
        opacity: 0.6;
    }
    90% {
        opacity: 0.6;
    }
    100% {
        opacity: 0;
        transform: translateY(-10vh) scale(1);
    }
}

/* --- Glowing Orbs (Background Decoration) --- */
.orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.3;
    z-index: 0;
    animation: orbFloat 8s ease-in-out infinite;
}

.orb-1 {
    width: 300px;
    height: 300px;
    background: var(--login-primary);
    top: -50px;
    right: -50px;
    animation-delay: 0s;
}

.orb-2 {
    width: 250px;
    height: 250px;
    background: var(--login-accent);
    bottom: -30px;
    left: -30px;
    animation-delay: -4s;
}

.orb-3 {
    width: 200px;
    height: 200px;
    background: #06b6d4;
    top: 50%;
    left: 60%;
    animation-delay: -2s;
}

@keyframes orbFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33%      { transform: translate(30px, -30px) scale(1.05); }
    66%      { transform: translate(-20px, 20px) scale(0.95); }
}

/* --- Login Card — Glassmorphism --- */
.login-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    padding: 2.5rem 2rem 2rem;
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    box-shadow:
        0 8px 32px var(--card-shadow),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    animation: cardEntrance 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
    animation-delay: 0.2s;
    transition: transform 0.15s ease-out, box-shadow 0.3s ease;
    margin: 1rem;
}

.login-card:hover {
    box-shadow:
        0 12px 48px var(--card-shadow),
        inset 0 1px 0 rgba(255, 255, 255, 0.15),
        0 0 60px rgba(99, 102, 241, 0.08);
}

@keyframes cardEntrance {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.95);
        filter: blur(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

/* --- Lock Icon --- */
.lock-icon-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.lock-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--login-primary), var(--login-accent));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    color: white;
    animation: lockPulse 2s ease-in-out infinite, lockEntrance 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    animation-delay: 0.5s, 0.4s;
    box-shadow: 0 4px 20px var(--login-glow);
    position: relative;
}

.lock-icon::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid transparent;
    border-top-color: var(--login-primary-light);
    animation: lockRingSpin 3s linear infinite;
}

@keyframes lockPulse {
    0%, 100% { box-shadow: 0 4px 20px var(--login-glow); }
    50%      { box-shadow: 0 4px 40px var(--login-glow), 0 0 20px var(--login-glow); }
}

@keyframes lockEntrance {
    from { opacity: 0; transform: scale(0) rotate(-180deg); }
    to   { opacity: 1; transform: scale(1) rotate(0deg); }
}

@keyframes lockRingSpin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* --- Title with Typing Effect --- */
.login-title {
    text-align: center;
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
    color: var(--text-primary);
    min-height: 2rem;
}

.login-subtitle {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    opacity: 0;
    animation: fadeInUp 0.5s ease forwards;
    animation-delay: 1.8s;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.typing-cursor {
    display: inline-block;
    width: 2px;
    height: 1.2em;
    background: var(--login-primary-light);
    margin-right: 3px;
    vertical-align: text-bottom;
    animation: blink 0.7s step-end infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0; }
}

/* --- Form Groups --- */
.login-form-group {
    margin-bottom: 1.25rem;
    position: relative;
    animation: fieldEntrance 0.5s ease both;
}

.login-form-group:nth-child(1) { animation-delay: 0.8s; }
.login-form-group:nth-child(2) { animation-delay: 1.0s; }

@keyframes fieldEntrance {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

.login-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    transition: color 0.3s ease;
}

.login-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.login-input-icon {
    position: absolute;
    right: 14px;
    color: var(--text-secondary);
    font-size: 1rem;
    transition: color 0.3s ease, transform 0.3s ease;
    z-index: 2;
    pointer-events: none;
}

.login-input {
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 0.75rem;
    background: var(--input-bg);
    border: 1.5px solid var(--input-border);
    border-radius: 12px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.login-input::placeholder {
    color: rgba(148, 163, 184, 0.5);
}

.login-input:focus {
    border-color: var(--input-focus-border);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15), 0 0 20px rgba(99, 102, 241, 0.1);
}

.login-input:focus ~ .login-input-icon {
    color: var(--login-primary-light);
    transform: scale(1.15);
}

.login-form-group:focus-within .login-label {
    color: var(--login-primary-light);
}

/* Focus underline animation */
.input-focus-line {
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--login-primary), var(--login-accent));
    border-radius: 2px;
    transition: all 0.3s ease;
    z-index: 1;
}

.login-input:focus ~ .input-focus-line {
    left: 5%;
    width: 90%;
}

/* --- Password Toggle --- */
.password-toggle {
    position: absolute;
    left: 14px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
    padding: 4px;
    border-radius: 6px;
    transition: all 0.3s ease;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
}

.password-toggle:hover {
    color: var(--login-primary-light);
    background: rgba(99, 102, 241, 0.1);
}

/* --- Submit Button --- */
.login-btn {
    width: 100%;
    padding: 0.85rem;
    margin-top: 0.5rem;
    background: linear-gradient(135deg, var(--login-primary), var(--login-accent));
    border: none;
    border-radius: 12px;
    color: white;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    animation: btnEntrance 0.5s ease forwards;
    animation-delay: 1.2s;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

@keyframes btnEntrance {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4);
    background: linear-gradient(135deg, var(--login-primary-light), var(--login-accent));
}

.login-btn:active {
    transform: translateY(0) scale(0.98);
}

/* Ripple effect */
.ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.35);
    transform: scale(0);
    animation: rippleAnim 0.6s ease-out;
    pointer-events: none;
}

@keyframes rippleAnim {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* Button loading spinner */
.login-btn.loading {
    pointer-events: none;
    color: transparent;
}

.login-btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 22px;
    height: 22px;
    margin: -11px 0 0 -11px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- Error Alert --- */
.login-error {
    background: rgba(248, 113, 113, 0.12);
    border: 1px solid rgba(248, 113, 113, 0.3);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    color: var(--error-color);
    font-size: 0.85rem;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: errorSlideIn 0.4s ease;
}

@keyframes errorSlideIn {
    from { opacity: 0; transform: translateY(-10px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.login-error i {
    font-size: 1.1rem;
}

/* Shake animation on error */
.login-card.shake {
    animation: shakeCard 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes shakeCard {
    10%, 90% { transform: translateX(-1px); }
    20%, 80% { transform: translateX(2px); }
    30%, 50%, 70% { transform: translateX(-4px); }
    40%, 60% { transform: translateX(4px); }
}

/* --- Footer / Brand --- */
.login-footer {
    text-align: center;
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    opacity: 0;
    animation: fadeInUp 0.5s ease forwards;
    animation-delay: 1.5s;
}

.login-footer-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.login-footer-brand {
    font-weight: 600;
    color: var(--login-primary-light);
}

/* --- Responsive --- */
@media (max-width: 480px) {
    .login-card {
        padding: 2rem 1.5rem 1.5rem;
        border-radius: 20px;
        margin: 0.75rem;
    }

    .lock-icon {
        width: 56px;
        height: 56px;
        font-size: 1.4rem;
    }

    .login-title {
        font-size: 1.2rem;
    }

    .orb {
        opacity: 0.15;
    }
}

/* --- Input validation states --- */
.login-input.valid {
    border-color: var(--success-color);
}

.login-input.valid ~ .login-input-icon {
    color: var(--success-color);
}

.login-input.invalid {
    border-color: var(--error-color);
}

.login-input.invalid ~ .login-input-icon {
    color: var(--error-color);
}
