/* إعدادات عامة */
:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary-color: #f59e0b;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --border-color: #e5e7eb;
    --border-focus: #6366f1;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    direction: rtl;
    line-height: 1.6;
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* خلفية النجوم المحسنة */
.stars-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    overflow: hidden;
}

.stars {
    position: absolute;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(2px 2px at 20px 30px, rgba(255,255,255,0.9), transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255,255,255,0.7), transparent),
        radial-gradient(1px 1px at 90px 40px, rgba(255,255,255,0.8), transparent),
        radial-gradient(1px 1px at 130px 80px, rgba(255,255,255,0.6), transparent),
        radial-gradient(2px 2px at 160px 30px, rgba(255,255,255,0.9), transparent);
    background-repeat: repeat;
    background-size: 200px 100px;
    animation: sparkle 4s ease-in-out infinite;
}

@keyframes sparkle {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 0.4; }
}

/* تأثير الشهاب المحسن */
.shooting-star {
    position: absolute;
    width: 3px;
    height: 3px;
    background: radial-gradient(circle, rgba(255,255,255,1) 0%, rgba(255,255,255,0.8) 50%, transparent 100%);
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(255,255,255,0.8);
    animation: shooting 12s linear infinite;
}

.shooting-star:nth-child(2) {
    animation-delay: 3s;
    animation-duration: 8s;
    top: 20%;
    left: 10%;
}

.shooting-star:nth-child(3) {
    animation-delay: 6s;
    animation-duration: 10s;
    top: 60%;
    left: 80%;
}

.shooting-star:nth-child(4) {
    animation-delay: 9s;
    animation-duration: 7s;
    top: 80%;
    left: 20%;
}

@keyframes shooting {
    0% {
        transform: translateX(-100px) translateY(-100px) scale(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
        transform: translateX(-50px) translateY(-50px) scale(1);
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateX(100vw) translateY(100vh) scale(0);
        opacity: 0;
    }
}

.shooting-star::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 80px;
    height: 2px;
    background: linear-gradient(90deg, rgba(255,255,255,0.8), transparent);
    transform: translate(-100%, -50%);
    border-radius: 2px;
}

/* الحاوي الرئيسي */
.container {
    position: relative;
    z-index: 2;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

/* بطاقة تسجيل الدخول */
.auth-card {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 420px;
    padding: 3rem 2.5rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    animation: slideUp 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.auth-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-light), var(--primary-color));
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

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

/* رأس البطاقة */
.header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.logo-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
    color: white;
    box-shadow: var(--shadow-lg);
    animation: pulse 3s ease-in-out infinite;
    position: relative;
    overflow: hidden;
}

.logo-icon::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255,255,255,0.1), transparent);
    transform: rotate(45deg);
    animation: shimmer 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes shimmer {
    0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
    100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

.header h1 {
    color: var(--text-primary);
    font-size: 1.875rem;
    font-weight: 700;
    margin: 0;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 400;
    margin-top: 0.5rem;
}

/* رسائل النظام */
.message-container {
    margin-bottom: 1.5rem;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-lg);
    font-weight: 500;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    animation: fadeInDown 0.5s ease;
    border: 1px solid;
}

@keyframes fadeInDown {
    from { 
        opacity: 0; 
        transform: translateY(-10px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

.message-container.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
    border-color: rgba(16, 185, 129, 0.2);
}

.message-container.error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error-color);
    border-color: rgba(239, 68, 68, 0.2);
}

.message-container .icon {
    font-size: 1.125rem;
    font-weight: 600;
    flex-shrink: 0;
    margin-top: 0.125rem;
}

/* النموذج */
.auth-form {
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.input-wrapper {
    position: relative;
}

.input-wrapper input {
    width: 100%;
    padding: 0.875rem 3rem 0.875rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    font-size: 1rem;
    font-family: inherit;
    transition: var(--transition);
    background: var(--bg-primary);
    color: var(--text-primary);
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    transform: translateY(-1px);
}

.input-wrapper input:valid:not(:placeholder-shown) {
    border-color: var(--success-color);
}

.input-wrapper input.error {
    border-color: var(--error-color);
    animation: shake 0.4s ease-in-out;
}

.input-wrapper input.success {
    border-color: var(--success-color);
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

.input-icon {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.125rem;
    color: var(--text-light);
    pointer-events: none;
    transition: var(--transition);
}

.input-wrapper:focus-within .input-icon {
    color: var(--primary-color);
}

.password-toggle {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    color: var(--text-light);
}

.password-toggle:hover {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
}

.toggle-icon {
    font-size: 1rem;
}

/* خيارات النموذج */
.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-secondary);
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    margin: 0;
    opacity: 0;
    position: absolute;
}

.checkmark {
    width: 1rem;
    height: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    position: relative;
    transition: var(--transition);
    background: var(--bg-primary);
    flex-shrink: 0;
}

.checkbox-label input[type="checkbox"]:checked + .checkmark {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.checkbox-label input[type="checkbox"]:checked + .checkmark::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-weight: 600;
    font-size: 0.75rem;
}

.checkbox-label input[type="checkbox"]:focus + .checkmark {
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.forgot-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    transition: var(--transition);
}

.forgot-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* زر الإرسال */
.submit-btn {
    width: 100%;
    padding: 0.875rem 1.5rem;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-md);
}

.submit-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary-color));
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.submit-btn:active:not(:disabled) {
    transform: translateY(0);
}

.submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.submit-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.submit-btn:hover::before {
    left: 100%;
}

.btn-loader {
    display: none;
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid transparent;
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.submit-btn.loading .btn-text {
    display: none;
}

.submit-btn.loading .btn-loader {
    display: block;
}

/* رابط التسجيل */
.register-link {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 2rem;
}

.register-link a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
}

.register-link a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* معلومات الأمان */
.security-info {
    display: flex;
    justify-content: center;
    gap: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.security-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-light);
}

.security-icon {
    font-size: 0.875rem;
    color: var(--success-color);
}

/* رسائل الخطأ للحقول */
.error-message {
    color: var(--error-color);
    font-size: 0.75rem;
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.error-message::before {
    content: '⚠';
    font-size: 0.875rem;
}

/* تأثيرات التركيز */
.input-wrapper.focused input {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* التصميم المتجاوب */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    .auth-card {
        padding: 2rem 1.5rem;
        margin: 0.5rem;
        border-radius: var(--radius-lg);
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .logo {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .logo-icon {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }
    
    .form-options {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .security-info {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .auth-card {
        padding: 1.5rem 1rem;
    }
    
    .header h1 {
        font-size: 1.375rem;
    }
    
    .logo-icon {
        width: 45px;
        height: 45px;
        font-size: 1.375rem;
    }
    
    .input-wrapper input {
        padding: 0.75rem 2.5rem 0.75rem 0.875rem;
        font-size: 0.875rem;
    }
    
    .submit-btn {
        padding: 0.75rem 1.25rem;
        font-size: 0.875rem;
    }
}

/* تحسينات الأداء */
.auth-card,
.input-wrapper input,
.submit-btn {
    will-change: transform;
}

/* تأثير التحميل للصفحة */
body {
    opacity: 0;
    animation: pageLoad 0.8s ease-out forwards;
}

@keyframes pageLoad {
    to {
        opacity: 1;
    }
}

/* تأثيرات إضافية للتفاعل */
.input-wrapper input:focus {
    animation: focusGlow 0.3s ease-out;
}

@keyframes focusGlow {
    0% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4);
    }
    100% {
        box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    }
}

/* تحسينات إضافية للأمان */
.auth-card::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, var(--primary-color), var(--primary-light), var(--primary-color));
    border-radius: var(--radius-xl);
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.auth-card:hover::after {
    opacity: 0.1;
}

/* تأثير الضوء المتحرك */
@keyframes movingLight {
    0% {
        background-position: -200px 0;
    }
    100% {
        background-position: 200px 0;
    }
}

.submit-btn {
    background-image: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    background-size: 200% 100%;
    animation: movingLight 3s ease-in-out infinite;
}

.submit-btn:hover {
    animation-play-state: paused;
}

