/* ------------------------------------------------------------------
   Assets/app.css - V4 (Night Mode Fixes + Animations)
   ------------------------------------------------------------------ */

:root {
    --font-family: 'Tajawal', sans-serif;
    
    /* --- Light Mode Variables --- */
    --bg-gradient: linear-gradient(135deg, #eef2f6 0%, #dbeafe 100%);
    --card-bg: rgba(255, 255, 255, 0.98);
    --text-main: #1e293b;
    --text-muted: #64748b; 
    --copyright-color: #94a3b8;
    
    --primary: #2563eb;       /* أزرق قياسي للنهار */
    --primary-hover: #1d4ed8;
    
    --passkey-bg: #0f172a;    /* خلفية داكنة لزر البصمة في النهار */
    --passkey-text: #ffffff;
    --passkey-border: transparent;
    
    --input-bg: #f8fafc;
    --input-border: #e2e8f0;
    --focus-ring: rgba(37, 99, 235, 0.25);
    
    --shadow-card: 0 20px 40px -5px rgba(0, 0, 0, 0.08);
    --radius-card: 24px;

    /* لون نص الكتابة داخل الحقول (الوضع النهاري) */
    --input-text-color: #1e293b; 
}

/* --- Dark Mode Variables --- */
[data-theme="dark"] {
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --card-bg: rgba(30, 41, 59, 0.95);
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --copyright-color: #64748b;
    
    /* (3) & (4) الأزرار في الوضع الليلي */
    --primary: #60a5fa; /* لون أزرق سماوي هادئ للإطار والنصوص */
    --primary-hover: rgba(96, 165, 250, 0.1); /* خلفية شفافة جداً عند التحويم */

    --passkey-bg: transparent;     /* خلفية شفافة لزر البصمة */
    --passkey-text: #cbd5e1;       /* نص فضي هادئ */
    --passkey-border: rgba(148, 163, 184, 0.2); /* (3) إطار هادئ جداً */
    
    --input-bg: #0f172a;
    --input-border: #334155;
    --focus-ring: rgba(96, 165, 250, 0.2);
    --shadow-card: 0 25px 50px -12px rgba(0, 0, 0, 0.5);

    /* (2) لون النص داخل الحقل أزرق هادئ */
    --input-text-color: #bfdbfe; 
}

* { box-sizing: border-box; outline: none; }

body {
    margin: 0;
    font-family: var(--font-family);
    background: var(--bg-gradient);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    direction: rtl;
    overflow-x: hidden;
}

.login-wrapper {
    width: 100%;
    max-width: 400px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: fadeIn 0.6s ease-out;
    position: relative;
    z-index: 10;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* الشعار */
.brand-section {
    text-align: center;
    margin-bottom: 25px;
}
.brand-section h1 {
    font-size: 30px;
    font-weight: 800;
    margin: 0;
    color: var(--text-main);
}
.brand-section p {
    margin: 8px 0 0;
    color: var(--text-muted);
    font-size: 15px;
}

/* البطاقة */
.login-card {
    background: var(--card-bg);
    width: 100%;
    padding: 40px 30px;
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    border: 1px solid rgba(255,255,255,0.1);
}

.welcome-text {
    margin: 0 0 25px;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-main);
    text-align: center;
}

/* جوجل */
.google-container {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-bottom: 0;
    min-height: 44px;
}
#gbtn { width: 100%; } 

/* البصمة */
.passkey-btn {
    width: 100%;
    background: var(--passkey-bg);
    color: var(--passkey-text);
    border: 1px solid var(--passkey-border); /* الإطار يأخذ قيمته من المتغيرات */
    padding: 12px;
    height: 44px; 
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 15px;
    font-family: var(--font-family);
    font-weight: 700;
    font-size: 15px;
}
.passkey-btn:hover { 
    transform: translateY(-1px); 
    filter: brightness(1.1); 
}
/* تأثير إضافي للوضع الليلي عند التحويم لزر البصمة */
[data-theme="dark"] .passkey-btn:hover {
    border-color: rgba(148, 163, 184, 0.5);
    background: rgba(255, 255, 255, 0.03);
}

/* الفواصل */
.divider {
    display: flex;
    align-items: center;
    margin: 25px 0 20px;
    color: var(--text-muted);
    font-size: 13px;
}
.divider::before, .divider::after {
    content: ''; flex: 1; height: 1px; background: var(--text-muted); opacity: 0.2;
}
.divider span { padding: 0 15px; opacity: 0.8; }

/* الحقول */
.input-wrapper { position: relative; margin-bottom: 20px; }

.custom-input {
    width: 100%;
    height: 52px;
    padding: 20px 15px 6px;
    border-radius: 12px;
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    color: var(--input-text-color); /* (2) استخدام متغير اللون المخصص */
    font-size: 15px;
    font-weight: 500;
    font-family: var(--font-family);
    transition: 0.2s;
}

/* (2) منع المتصفح من تغيير الخلفية للابيض في الوضع الليلي */
[data-theme="dark"] .custom-input:-webkit-autofill,
[data-theme="dark"] .custom-input:-webkit-autofill:hover, 
[data-theme="dark"] .custom-input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--input-text-color);
    -webkit-box-shadow: 0 0 0px 1000px #0f172a inset; /* نفس لون الخلفية الليلية */
    transition: background-color 5000s ease-in-out 0s;
}

.custom-input:focus {
    background: var(--input-bg); /* الحفاظ على الخلفية الأصلية */
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--focus-ring);
}
/* في الوضع الليلي تحديداً عند التركيز لا نريد خلفية فاتحة */
[data-theme="dark"] .custom-input:focus {
    background: #0f172a;
}

.floating-label {
    position: absolute; right: 15px; top: 50%; transform: translateY(-50%);
    font-size: 14px; color: var(--text-muted); pointer-events: none; transition: 0.2s;
}
.custom-input:focus ~ .floating-label,
.custom-input:not(:placeholder-shown) ~ .floating-label {
    top: 12px; font-size: 11px; color: var(--primary); font-weight: 700;
}
.ltr { direction: ltr; text-align: right; }
.custom-input:focus.ltr, .custom-input:not(:placeholder-shown).ltr { text-align: left; }

/* زر الإرسال */
.submit-btn {
    width: 100%; padding: 14px; 
    background: var(--primary); 
    color: #fff;
    border: none; /* افتراضي للوضع النهاري */
    border-radius: 12px; font-size: 16px; font-weight: 700;
    font-family: var(--font-family); cursor: pointer; display: flex;
    justify-content: center; align-items: center; gap: 8px; transition: 0.3s;
}

/* (4) تخصيص زر الإرسال للوضع الليلي (إطار فقط) */
[data-theme="dark"] .submit-btn {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
}

.submit-btn:hover { 
    background: var(--primary-hover); 
}
/* تعديل الهوفر في الوضع الليلي ليكون متوافق مع الإطار */
[data-theme="dark"] .submit-btn:hover {
    background: rgba(96, 165, 250, 0.1);
}

/* (1) حركة السهم عند التحويم */
.submit-btn svg {
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.submit-btn:hover svg {
    transform: translateX(-4px); /* يتحرك لليسار مع اتجاه السهم */
}

/* الروابط السفلية */
.footer-links { margin-top: 15px; text-align: center; }
.link-btn {
    background: none; border: none; color: var(--text-muted); font-size: 14px;
    cursor: pointer; font-family: var(--font-family);
}
.link-btn:hover { color: var(--primary); text-decoration: underline; }

/* رسائل الحالة */
.status { font-size: 12px; text-align: center; margin-top: 8px; font-weight: 500; min-height: 10px; }
.status.ok { color: #10b981; }
.status.err { color: #ef4444; }

/* الفوتر */
.footer-copyright {
    margin-top: 20px;
    text-align: center;
    font-size: 14px; 
    color: var(--copyright-color); 
    font-family: var(--font-family);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
}
.footer-copyright .numbers-wrapper {
    direction: ltr; 
    display: inline-flex;
    gap: 5px;
}
.footer-copyright a {
    color: inherit;
    text-decoration: none;
    font-weight: normal;
    transition: color 0.2s;
    font-family: sans-serif;
}
.footer-copyright a:hover { color: var(--text-main); }
.footer-copyright .sep { margin: 0 2px; }

/* زر الثيم */
.theme-corner-btn {
    position: fixed; 
    top: 30px; left: 30px; 
    background: transparent; border: none; cursor: pointer; color: var(--text-muted);
    z-index: 9999; padding: 0; display: flex; align-items: center; justify-content: center;
}
.theme-corner-btn:hover { color: var(--primary); }
.sun, .moon { position: absolute; transition: 0.5s; }
.sun { opacity: 0; transform: scale(0.5); }
.moon { opacity: 1; transform: scale(1); }
[data-theme="dark"] .sun { opacity: 1; transform: scale(1); color: #fbbf24; }
[data-theme="dark"] .moon { opacity: 0; transform: scale(0.5); }

/* ✅ Secondary back link */
.back-home-link{
    display: inline-block;
    margin-top: 10px;
    font-size: 13px;
    color: var(--text-muted);
    text-decoration: none;
    font-family: var(--font-family);
}
.back-home-link:hover{
    color: var(--primary);
    text-decoration: underline;
}