/* ============================================
   ارتقاء - تنسيق تسجيل الدخول
   ============================================ */

:root {
    --black: #0a0a0a;
    --black-light: #111111;
    --black-lighter: #1a1a1a;
    --black-card: #161616;
    --purple: #7c3aed;
    --purple-light: #8b5cf6;
    --purple-dark: #6d28d9;
    --purple-glow: rgba(124, 58, 237, 0.3);
    --gold: #d4af37;
    --gold-light: #f0d878;
    --gold-dark: #b8960c;
    --gold-glow: rgba(212, 175, 55, 0.3);
    --white: #ffffff;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gradient-purple: linear-gradient(135deg, var(--purple) 0%, var(--purple-dark) 100%);
    --gradient-gold: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 50%, var(--gold) 100%);
    --shadow-purple: 0 0 40px var(--purple-glow);
    --shadow-card: 0 10px 40px rgba(0, 0, 0, 0.5);
    --shadow-gold: 0 0 40px var(--gold-glow);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; }
body {
    font-family: 'Tajawal', sans-serif;
    background: var(--black);
    color: var(--white);
    line-height: 1.7;
    direction: rtl;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ============================================
   خلفية متحركة
   ============================================ */
.bg-animation {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}
.chess-piece {
    position: absolute;
    font-size: 3rem;
    opacity: 0.03;
    color: var(--purple);
    animation: float-piece 20s infinite ease-in-out;
}
.piece-1 { top: 10%; left: 10%; }
.piece-2 { top: 20%; right: 15%; font-size: 4rem; animation-delay: 2s; }
.piece-3 { top: 60%; left: 5%; animation-delay: 4s; }
.piece-4 { top: 40%; right: 10%; font-size: 5rem; animation-delay: 6s; }
.piece-5 { top: 80%; left: 20%; animation-delay: 8s; }
.piece-6 { top: 15%; left: 50%; animation-delay: 10s; }
.piece-7 { top: 70%; right: 25%; font-size: 4rem; animation-delay: 12s; }
.piece-8 { top: 30%; left: 30%; animation-delay: 14s; }

@keyframes float-piece {
    0%, 100% { transform: translateY(0); opacity: 0.03; }
    50% { transform: translateY(-30px); opacity: 0.06; }
}

/* ============================================
   زر الرجوع
   ============================================ */
.back-home {
    position: fixed;
    top: 2rem; right: 2rem;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(124, 58, 237, 0.15);
    border: 1px solid rgba(124, 58, 237, 0.3);
    padding: 0.6rem 1.2rem;
    border-radius: 50px;
    font-size: 0.9rem;
    color: var(--purple-light);
    transition: var(--transition);
    text-decoration: none;
}
.back-home:hover {
    background: var(--purple);
    color: var(--white);
    transform: translateX(-5px);
}

/* ============================================
   الحاوية الرئيسية
   ============================================ */
.login-container {
    display: flex;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

/* ============================================
   الجزء المرئي (اليسار)
   ============================================ */
.login-visual {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.1) 0%, rgba(212, 175, 55, 0.05) 100%);
    padding: 2rem;
    position: relative;
}
.visual-content { text-align: center; }

.logo-large {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
}
.logo-large .logo-icon {
    font-size: 4rem;
    color: var(--gold);
    text-shadow: 0 0 30px var(--gold-glow);
    animation: logo-pulse 3s infinite;
}
.logo-large .logo-text {
    font-size: 3rem;
    font-weight: 900;
    background: var(--gradient-gold);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
@keyframes logo-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}
.visual-text { 
    color: var(--gray-400); 
    margin-bottom: 2rem; 
    font-size: 1.1rem;
}

/* لوحة الشطرنج 3D */
.chess-board-3d {
    width: 200px; 
    height: 200px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 3px;
    transform: perspective(600px) rotateX(15deg) rotateY(-15deg);
    animation: board-float 6s ease-in-out infinite;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5), 0 0 30px var(--purple-glow);
    border-radius: 10px;
    padding: 6px;
    background: rgba(124, 58, 237, 0.1);
    margin: 0 auto;
}
@keyframes board-float {
    0%, 100% { transform: perspective(600px) rotateX(15deg) rotateY(-15deg) translateY(0); }
    50% { transform: perspective(600px) rotateX(15deg) rotateY(-15deg) translateY(-15px); }
}
.board-square { 
    border-radius: 6px; 
    transition: var(--transition); 
}
.board-square:nth-child(odd) { 
    background: var(--black-lighter); 
}
.board-square:nth-child(even) { 
    background: rgba(124, 58, 237, 0.6); 
}
.board-square:hover { 
    transform: scale(1.1); 
    box-shadow: 0 0 15px var(--purple-glow); 
}

/* ============================================
   النموذج (اليمين)
   ============================================ */
.login-form-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
}
.form-container { 
    width: 100%; 
    max-width: 450px; 
}

/* ============================================
   التبويبات
   ============================================ */
.form-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    background: var(--black-card);
    border-radius: 50px;
    padding: 0.3rem;
}
.tab-btn {
    flex: 1;
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 50px;
    background: transparent;
    color: var(--gray-500);
    font-family: 'Tajawal', sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
}
.tab-btn.active {
    background: var(--gradient-purple);
    color: var(--white);
    box-shadow: var(--shadow-purple);
}
.tab-btn:hover:not(.active) { 
    color: var(--purple-light); 
}

/* ============================================
   محتوى النموذج
   ============================================ */
.form-content { 
    display: none; 
    animation: fadeIn 0.5s ease-out; 
}
.form-content.active { 
    display: block; 
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.form-content h2 {
    font-size: 1.8rem;
    font-weight: 900;
    margin-bottom: 0.5rem;
    background: var(--gradient-gold);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.form-subtitle { 
    color: var(--gray-500); 
    margin-bottom: 1.5rem; 
    font-size: 0.95rem;
}

/* ============================================
   زر Google
   ============================================ */
.google-login-wrapper {
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: center;
    min-height: 40px;
}

/* ============================================
   الفاصل
   ============================================ */
.divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    color: var(--gray-600);
    font-size: 0.85rem;
}
.divider::before, .divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, rgba(124, 58, 237, 0.3), transparent);
}

/* ============================================
   النموذج
   ============================================ */
.auth-form { 
    display: flex; 
    flex-direction: column; 
    gap: 1.2rem; 
}
.form-group { 
    display: flex; 
    flex-direction: column; 
    gap: 0.5rem; 
}
.form-group label { 
    font-size: 0.9rem; 
    font-weight: 600; 
    color: var(--gray-300); 
}

/* حقل الإدخال */
.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}
.input-wrapper > i {
    position: absolute;
    right: 1rem;
    color: var(--purple-light);
    font-size: 0.9rem;
    pointer-events: none;
}
.input-wrapper input {
    width: 100%;
    background: var(--black-card);
    border: 1px solid rgba(124, 58, 237, 0.2);
    border-radius: 12px;
    padding: 0.9rem 2.5rem;
    color: var(--white);
    font-family: 'Tajawal', sans-serif;
    font-size: 0.95rem;
    transition: var(--transition);
    outline: none;
}
.input-wrapper input::placeholder { 
    color: var(--gray-600); 
}
.input-wrapper input:focus {
    border-color: var(--purple);
    box-shadow: 0 0 20px var(--purple-glow);
}
.toggle-password {
    position: absolute;
    left: 1rem;
    background: none;
    border: none;
    color: var(--gray-500);
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition);
}
.toggle-password:hover {
    color: var(--purple-light);
}

/* ============================================
   الخيارات (تذكرني + نسيت كلمة المرور)
   ============================================ */
.form-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.remember-me {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--gray-500);
}
.remember-me input { 
    display: none; 
}
.checkmark {
    width: 18px; 
    height: 18px;
    border: 2px solid rgba(124, 58, 237, 0.3);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.remember-me input:checked + .checkmark {
    background: var(--purple);
    border-color: var(--purple);
}
.remember-me input:checked + .checkmark::after {
    content: '✓';
    color: var(--white);
    font-size: 0.7rem;
    font-weight: bold;
}
.forgot-password {
    font-size: 0.85rem;
    color: var(--purple-light);
    text-decoration: none;
    transition: var(--transition);
}
.forgot-password:hover { 
    color: var(--gold); 
}

/* ============================================
   قوة كلمة المرور
   ============================================ */
.password-strength { 
    margin-top: 0.5rem; 
}
.strength-bar {
    width: 100%;
    height: 4px;
    background: var(--black-lighter);
    border-radius: 2px;
    overflow: hidden;
}
.strength-fill {
    height: 100%;
    width: 0;
    background: var(--gradient-purple);
    transition: var(--transition);
}
.strength-text {
    font-size: 0.75rem;
    color: var(--gray-600);
    margin-top: 0.3rem;
    display: block;
}

/* ============================================
   الأزرار
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 2rem;
    border-radius: 12px;
    font-family: 'Tajawal', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    outline: none;
}
.btn-primary {
    background: var(--gradient-purple);
    color: var(--white);
    box-shadow: var(--shadow-purple);
}
.btn-primary:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 10px 40px var(--purple-glow);
}
.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}
.btn-full { 
    width: 100%; 
}

/* ============================================
   الإشعارات (Toast)
   ============================================ */
.notification-container {
    position: fixed;
    top: 90px;
    left: 2rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* ============================================
   حركات إضافية
   ============================================ */
@keyframes slideInLeft {
    from { 
        opacity: 0; 
        transform: translateX(-50px); 
    }
    to { 
        opacity: 1; 
        transform: translateX(0); 
    }
}

@keyframes slideInRight {
    from { 
        opacity: 0; 
        transform: translateX(50px); 
    }
    to { 
        opacity: 1; 
        transform: translateX(0); 
    }
}

@keyframes pulse-glow {
    0%, 100% { 
        box-shadow: 0 0 20px var(--purple-glow); 
    }
    50% { 
        box-shadow: 0 0 40px var(--purple-glow), 0 0 60px var(--gold-glow); 
    }
}

/* ============================================
   التصميم المتجاوب
   ============================================ */
@media (max-width: 1024px) {
    .login-container { 
        flex-direction: column; 
    }
    .login-visual { 
        min-height: 250px; 
        padding: 2rem; 
    }
    .logo-large .logo-icon { 
        font-size: 3rem; 
    }
    .logo-large .logo-text { 
        font-size: 2rem; 
    }
    .chess-board-3d {
        width: 150px;
        height: 150px;
    }
}

@media (max-width: 768px) {
    .back-home { 
        top: 1rem; 
        right: 1rem; 
        padding: 0.5rem 1rem; 
        font-size: 0.8rem; 
    }
    .login-form-wrapper { 
        padding: 2rem 1.5rem; 
    }
    .form-tabs { 
        flex-direction: column; 
        border-radius: 20px; 
    }
    .tab-btn { 
        border-radius: 15px; 
    }
    .notification-container { 
        left: 1rem; 
        right: 1rem; 
        top: 80px; 
    }
    .form-content h2 {
        font-size: 1.5rem;
    }
    .visual-text {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .login-visual {
        display: none;
    }
    .login-form-wrapper {
        padding: 1.5rem 1rem;
        min-height: 100vh;
    }
    .google-login-wrapper {
        transform: scale(0.9);
    }
}

/* ============================================
   🔐 OTP Modal
   ============================================ */
.otp-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 10, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 11000;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    direction: rtl;
    overflow-y: auto;
}
.otp-overlay.active { display: flex; }

.otp-modal {
    position: relative;
    background: linear-gradient(180deg, var(--black-card) 0%, var(--black-light) 100%);
    border: 1px solid rgba(124, 58, 237, 0.3);
    border-radius: 20px;
    padding: 2.2rem 2rem 1.6rem;
    max-width: 460px;
    width: 100%;
    box-shadow: 0 20px 80px rgba(0,0,0,0.7), 0 0 60px rgba(124,58,237,0.18);
    animation: otpIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-height: 95vh;
    overflow-y: auto;
}
@keyframes otpIn {
    from { opacity: 0; transform: scale(0.9) translateY(20px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.otp-close {
    position: absolute;
    top: 1rem; left: 1rem;
    width: 36px; height: 36px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 50%;
    color: var(--gray-400);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}
.otp-close:hover {
    background: rgba(239,68,68,0.15);
    color: var(--danger);
    border-color: rgba(239,68,68,0.3);
}

.otp-icon-wrap {
    width: 72px; height: 72px;
    margin: 0 auto 1.2rem;
    background: linear-gradient(135deg, var(--purple), var(--purple-dark));
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.8rem;
    color: var(--gold);
    box-shadow: 0 0 40px rgba(124,58,237,0.4);
}

.otp-title {
    text-align: center;
    font-size: 1.45rem;
    font-weight: 800;
    color: var(--white);
    margin: 0 0 0.5rem;
}
.otp-subtitle {
    text-align: center;
    color: var(--gray-400);
    font-size: 0.9rem;
    margin: 0 0 1.5rem;
    line-height: 1.6;
}
.otp-subtitle strong {
    color: var(--gold);
    font-weight: 700;
    direction: ltr;
    display: inline-block;
}

/* خانات الأرقام */
.otp-inputs {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.5rem;
    direction: ltr;
    margin: 0 0 1rem;
}
.otp-digit {
    width: 100%;
    aspect-ratio: 1;
    text-align: center;
    font-size: 1.4rem;
    font-weight: 800;
    background: rgba(0,0,0,0.4);
    border: 2px solid rgba(124, 58, 237, 0.25);
    border-radius: 12px;
    color: var(--white);
    font-family: 'Courier New', monospace;
    caret-color: var(--gold);
    transition: all 0.15s;
}
.otp-digit:focus {
    outline: none;
    border-color: var(--gold);
    background: rgba(124, 58, 237, 0.08);
    box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.15);
    transform: scale(1.05);
}
.otp-digit.filled {
    border-color: rgba(124, 58, 237, 0.6);
    background: rgba(124, 58, 237, 0.08);
}
.otp-digit.error {
    border-color: var(--danger);
    animation: otpShake 0.4s;
}
@keyframes otpShake {
    0%, 100% { transform: translateX(0); }
    25%      { transform: translateX(-6px); }
    75%      { transform: translateX(6px); }
}
.otp-digit.success {
    border-color: var(--success);
    background: rgba(34,197,94,0.08);
}

/* رسالة الحالة */
.otp-status {
    min-height: 22px;
    text-align: center;
    font-size: 0.85rem;
    margin-bottom: 1rem;
    transition: all 0.2s;
}
.otp-status.error   { color: var(--danger); }
.otp-status.success { color: var(--success); }
.otp-status.info    { color: var(--gray-400); }

/* عدّاد + إعادة إرسال */
.otp-timer-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1rem;
    padding: 0.7rem 0.9rem;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(124,58,237,0.12);
    border-radius: 10px;
}
.otp-timer {
    display: flex; align-items: center; gap: 0.5rem;
    color: var(--gray-300);
    font-size: 0.85rem;
    font-family: 'Courier New', monospace;
    font-weight: 700;
}
.otp-timer i { color: var(--gold); }
.otp-timer.warning { color: var(--gold); }
.otp-timer.danger  { color: var(--danger); }

.otp-resend {
    background: none;
    border: none;
    color: var(--purple-light);
    font-family: 'Tajawal', sans-serif;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    display: flex; align-items: center; gap: 0.4rem;
    padding: 0.3rem 0.6rem;
    border-radius: 8px;
    transition: all 0.2s;
}
.otp-resend:hover:not(:disabled) {
    background: rgba(124,58,237,0.1);
    color: var(--gold);
}
.otp-resend:disabled {
    color: var(--gray-600);
    cursor: not-allowed;
}

/* تذكّر الجهاز */
.otp-trust {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0 0 1rem;
    padding: 0.6rem 0.8rem;
    background: rgba(212,175,55,0.05);
    border: 1px solid rgba(212,175,55,0.15);
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--gray-300);
    transition: all 0.2s;
}
.otp-trust:hover {
    background: rgba(212,175,55,0.08);
    border-color: rgba(212,175,55,0.3);
}
.otp-trust input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px; height: 18px;
    border: 2px solid rgba(212,175,55,0.4);
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
}
.otp-trust input[type="checkbox"]:checked {
    background: var(--gold);
    border-color: var(--gold);
}
.otp-trust input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center; justify-content: center;
    color: var(--black);
    font-size: 0.85rem;
    font-weight: 900;
}

/* تغيير الإيميل */
.otp-change-email {
    background: none;
    border: none;
    color: var(--gray-400);
    font-family: 'Tajawal', sans-serif;
    font-size: 0.82rem;
    cursor: pointer;
    width: 100%;
    text-align: center;
    padding: 0.8rem;
    margin-top: 0.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    transition: color 0.2s;
}
.otp-change-email:hover { color: var(--purple-light); }

@media (max-width: 500px) {
    .otp-modal { padding: 1.8rem 1.2rem 1.2rem; }
    .otp-inputs { gap: 0.35rem; }
    .otp-digit { font-size: 1.2rem; }
    .otp-title { font-size: 1.25rem; }
}