/* =================================================================== */
/*           auth_style.css - Stable Mobile Version (Fix Jitter)       */
/* =================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700&display=swap');

:root {
    --primary-glow: #00c6ff;
    --secondary-glow: #3a7bd5;
    --container-bg: rgba(30, 41, 59, 0.6);
    --input-bg: rgba(15, 23, 42, 0.7);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: rgba(100, 116, 139, 0.5);
}

*, *::before, *::after {
    box-sizing: border-box;
}

/* 1. تثبيت الصفحة تماماً ومنع أي حركة خارجية */
html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden; /* يمنع السكرول والهز نهائياً */
}

body {
    font-family: 'Cairo', sans-serif;
    background-color: #0f172a;
    display: flex;
    justify-content: center;
    align-items: center;
    direction: rtl;
    position: relative;
}

/* 2. إصلاح الخلفية: استخدام fixed وعزلها عن اللي اوت */
body::before {
    content: '';
    position: fixed; /* تثبيت كامل بالنسبة للشاشة */
    top: 50%;
    left: 50%;
    /* توسيط العنصر يدوياً بالأبعاد لمنع تضارب الأنيميشن */
    width: 600px;
    height: 600px;
    margin-top: -300px; /* نصف الطول */
    margin-left: -300px; /* نصف العرض */
    
    border-radius: 50%;
    background-image: conic-gradient(
        var(--primary-glow) 20deg,
        var(--secondary-glow) 120deg,
        transparent 250deg
    );
    filter: blur(120px);
    animation: rotateBackground 15s linear infinite;
    z-index: -1; /* وضعها خلف كل شيء */
    
    /* تحسين الأداء على الموبايل لمنع التقطيع */
    will-change: transform;
    pointer-events: none; /* عشان التاتش ميلمسهاش بالغلط */
}

/* تصغير الخلفية للموبايل */
@media (max-width: 600px) {
    body::before {
        width: 300px;
        height: 300px;
        margin-top: -150px;
        margin-left: -150px;
        filter: blur(80px);
    }
}

@keyframes rotateBackground {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* 3. الكارت: إضافة translateZ لتشغيل كارت الشاشة وتثبيت العنصر */
.auth-container {
    background: var(--container-bg);
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
    width: 90%; /* استخدام نسبة مئوية لضمان عدم الخروج */
    max-width: 420px;
    text-align: center;
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 10;
    
    /* هذا السطر يمنع الهزة بجعل المتصفح يعالجه كطبقة منفصلة */
    transform: translateZ(0); 
}

/* باقي التنسيقات كما هي (انيميشن وحقول) */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.auth-header, .form-group, .btn-submit, .auth-footer {
    animation: fadeInUp 0.8s ease-out forwards;
    opacity: 0;
}
.auth-header { animation-delay: 0.2s; }
.form-group:nth-of-type(1) { animation-delay: 0.4s; }
.form-group:nth-of-type(2) { animation-delay: 0.5s; }
.form-group:nth-of-type(3) { animation-delay: 0.6s; }
.btn-submit { animation-delay: 0.7s; }
.auth-footer { animation-delay: 0.8s; }

.auth-header h2 { font-size: 2rem; margin-bottom: 10px;}
.auth-header p { color: var(--text-secondary); margin-bottom: 40px; }
.auth-header .icon { font-size: 48px; color: var(--primary-glow); margin-bottom: 20px;}

.form-group { position: relative; margin-bottom: 30px; }

/* حجم الخط 16px يمنع الآيفون من عمل زووم عند الكتابة */
.form-control {
    width: 100%; padding: 14px; background-color: var(--input-bg);
    border: 1px solid var(--border-color); border-radius: 10px;
    color: var(--text-primary); font-size: 16px; /* مهم جداً للموبايل */
    transition: all 0.3s ease;
}

.form-label {
    position: absolute; right: 15px; top: 14px; color: var(--text-secondary);
    pointer-events: none; transition: all 0.3s ease;
}

.form-control:focus, .form-control:not(:placeholder-shown) {
    outline: none; border-color: var(--primary-glow); background-color: var(--container-bg);
}

.form-control:focus + .form-label, .form-control:not(:placeholder-shown) + .form-label {
    top: -10px; right: 10px; font-size: 0.8rem;
    color: var(--primary-glow); background-color: var(--container-bg); padding: 0 5px;
}

.btn-submit {
    position: relative; width: 100%; padding: 16px; border: none; border-radius: 12px; color: #fff; font-size: 1.1rem; font-weight: 700; cursor: pointer; background-image: linear-gradient(to left, var(--primary-glow) 0%, var(--secondary-glow) 100%); background-size: 200% auto; transition: all 0.4s ease; box-shadow: 0 4px 15px rgba(0, 114, 255, 0.3);
}
.btn-submit .btn-text { transition: opacity 0.3s ease; }
.btn-submit.btn-loading .btn-text { opacity: 0; }
.btn-submit::after {
    content: ''; position: absolute; width: 24px; height: 24px; top: 50%; left: 50%; transform: translate(-50%, -50%);
    border: 3px solid rgba(255, 255, 255, 0.5); border-top-color: #fff; border-radius: 50%; opacity: 0; transition: opacity 0.3s ease; animation: spin 1s linear infinite;
}
.btn-submit.btn-loading::after { opacity: 1; }
@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }

.auth-footer { margin-top: 30px; font-size: 0.9rem; }
.auth-footer a { color: var(--primary-glow); text-decoration: none; font-weight: 600; }

.alert { padding: 12px; margin-bottom: 20px; border-radius: 8px; color: #fff; font-size: 0.95rem; background-color: rgba(255, 255, 255, 0.05); border: 1px solid; }
.alert-danger { border-color: #e74c3c; color: #f8b4b4; }
.alert-success { border-color: #2ecc71; color: #a7f3d0; }

/* تحسينات الموبايل */
@media (max-width: 480px) {
    .auth-container { padding: 30px 20px; }
    .auth-header h2 { font-size: 1.8rem; }
}

/* LTR/RTL Support */
html[dir="rtl"] .form-control[type="password"], html[dir="rtl"] .form-control[type="text"][name="password"] { padding-left: 45px; padding-right: 14px; }
html[dir="ltr"] .form-control[type="password"], html[dir="ltr"] .form-control[type="text"][name="password"] { padding-left: 14px; padding-right: 45px; }

.toggle-password { position: absolute; top: 15px; color: var(--text-secondary); cursor: pointer; transition: color 0.3s ease; }
.toggle-password:hover { color: var(--primary-glow); }
html[dir="rtl"] .toggle-password { left: 15px; }
html[dir="ltr"] .toggle-password { right: 15px; }

.language-switcher-auth { position: absolute; top: 20px; z-index: 20; }
html[dir="rtl"] .language-switcher-auth { right: 20px; }
html[dir="ltr"] .language-switcher-auth { left: 20px; }
.language-switcher-auth a { color: #94a3b8; font-weight: bold; text-decoration: none; transition: color 0.3s; }
.language-switcher-auth a:hover { color: #00c6ff; }

/* LTR fixes */
html[dir="ltr"] .form-label { right: auto; left: 15px; }
html[dir="ltr"] .form-control:focus + .form-label, html[dir="ltr"] .form-control:not(:placeholder-shown) + .form-label { right: auto; left: 10px; }