@import url('fonts.css');

:root {
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --primary-glow: #3b82f6;
    --accent-glow: #8b5cf6;
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --input-bg: rgba(15, 23, 42, 0.6);
    --input-border: #334155;
    --input-focus: #60a5fa;
    --error-color: #ef4444;
}

body {
    font-family: 'Vazirmatn', sans-serif;
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(at 0% 0%, hsla(253,16%,7%,1) 0, transparent 50%), 
        radial-gradient(at 50% 0%, hsla(225,39%,30%,1) 0, transparent 50%), 
        radial-gradient(at 100% 0%, hsla(339,49%,30%,1) 0, transparent 50%);
    color: var(--text-main);
    margin: 0;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
    overflow-y: auto; /* Allow scrolling on small screens */
    padding: 1rem; /* Add padding to body to prevent card touching edges on mobile */
}

/* Mystic Particles Animation Background */
.mystic-bg {
    position: fixed; /* Fixed position to cover background even when scrolling */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.particle {
    position: absolute;
    border-radius: 50%;
    background: white;
    opacity: 0.1;
    animation: float 20s infinite linear;
}

@keyframes float {
    0% { transform: translateY(0) rotate(0deg); opacity: 0; }
    50% { opacity: 0.3; }
    100% { transform: translateY(-100vh) rotate(360deg); opacity: 0; }
}

/* Login Card */
.login-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    position: relative;
    overflow: hidden; /* Keep internal overflow hidden for effects */
    animation: cardEntry 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
    margin: auto; /* Center in flex container */
}

.login-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.03) 0%, transparent 70%);
    transform: rotate(30deg);
    pointer-events: none;
}

@keyframes cardEntry {
    from { opacity: 0; transform: translateY(30px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-icon {
    font-size: 3rem;
    color: var(--primary-glow);
    text-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
    margin-bottom: 1rem;
    animation: pulse 3s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); text-shadow: 0 0 20px rgba(59, 130, 246, 0.5); }
    50% { transform: scale(1.05); text-shadow: 0 0 30px rgba(59, 130, 246, 0.8); }
    100% { transform: scale(1); text-shadow: 0 0 20px rgba(59, 130, 246, 0.5); }
}

.login-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    background: linear-gradient(to right, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Form Elements */
.form-group {
    margin-bottom: 1.5rem;
    position: relative;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.form-control {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 8px;
    padding: 0.75rem 1rem 0.75rem 2.5rem; /* Space for icon */
    color: var(--text-main);
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.3s ease;
    box-sizing: border-box; /* Ensure padding doesn't affect width */
}

.form-control:focus {
    outline: none;
    border-color: var(--input-focus);
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
    background: rgba(15, 23, 42, 0.8);
}

.input-icon {
    position: absolute;
    left: 1rem; /* RTL: icon on left */
    top: 2.3rem;
    color: var(--text-muted);
    transition: color 0.3s;
    pointer-events: none; /* Let clicks pass through to input */
}

.form-control:focus + .input-icon {
    color: var(--input-focus);
}

/* Captcha */
.captcha-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.5rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border: 1px solid var(--input-border);
}

.captcha-image {
    border-radius: 4px;
    cursor: pointer;
    transition: opacity 0.2s;
    height: 50px;
    max-width: 100%;
}

.captcha-image:hover {
    opacity: 0.8;
}

.btn-refresh {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0.5rem;
    transition: color 0.3s, transform 0.3s;
}

.btn-refresh:hover {
    color: var(--text-main);
    transform: rotate(180deg);
}

/* Button */
.btn-login {
    width: 100%;
    padding: 0.875rem;
    background: linear-gradient(135deg, var(--primary-glow), var(--accent-glow));
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    position: relative;
    overflow: hidden;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(59, 130, 246, 0.4), 0 4px 6px -2px rgba(59, 130, 246, 0.2);
}

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

/* Links */
.links {
    margin-top: 1.5rem;
    text-align: center;
}

.links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.links a:hover {
    color: var(--primary-glow);
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    font-size: 0.9rem;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

/* Loading Overlay inside Card */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    border-radius: 16px;
}

.loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-left-color: var(--primary-glow);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Responsive Design */
@media (max-width: 480px) {
    .login-card {
        padding: 1.5rem; /* Reduce padding on mobile */
        width: 100%;
        max-width: 100%;
    }
    
    .login-icon {
        font-size: 2.5rem; /* Smaller icon */
    }
    
    .login-title {
        font-size: 1.25rem; /* Smaller title */
    }
    
    .form-group {
        margin-bottom: 1rem;
    }
    
    .btn-login {
        padding: 0.75rem;
    }

    body {
        padding: 1rem; /* Ensure some spacing from screen edges */
        align-items: flex-start; /* Align to top on mobile to avoid centering issues with keyboard */
        padding-top: 2rem;
    }
}
