/* =========================================
   1. نظام الألوان (Royal Luxury Theme) 👑
   ========================================= */
:root {
    --bg-color: #0f172a;       
    --card-bg: #1e293b;        
    --nav-bg: #1e293b;         
    
    --primary-color: #D97706;  
    --primary-gradient: linear-gradient(135deg, #F59E0B, #D97706); 
    --accent-color: #FBBF24;   
    
    --text-main: #FFFFFF;      
    --text-secondary: #94A3B8; 
    
    --success: #10B981;        
    --danger: #EF4444;         

    --border-radius: 16px;
    --border-dim: 1px solid rgba(255, 255, 255, 0.08); 
    --shadow-soft: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

/* ✅ فرض خط تجوال بقوة على كل شيء */
* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    font-family: 'Tajawal', sans-serif !important; /* هذا السطر يضمن الخط */
    -webkit-tap-highlight-color: transparent; 
}

body {
    background-color: var(--bg-color);
    background-image: radial-gradient(circle at top right, #1e293b 0%, #0f172a 60%);
    color: var(--text-main);
    direction: rtl;
    text-align: right;
    padding-bottom: 110px;
    line-height: 1.6;
    min-height: 100vh;
}

a { text-decoration: none; color: inherit; transition: 0.3s; }
ul { list-style: none; }
h1, h2, h3, h4, h5, h6, strong, b { color: var(--text-main) !important; }
p, span, label, small, td, li { color: var(--text-secondary); }

/* إخفاء العناصر القديمة */
.background-orbs, .orb, .mobile-menu-btn, .fab-btn { display: none !important; }

/* =========================================
   2. الكروت (Royal Cards)
   ========================================= */
.glass-card, .glass-card-center, .admin-card, .glass-panel, .section-card, .archive-card {
    background: var(--card-bg) !important;
    border: var(--border-dim) !important;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-soft);
    padding: 24px;
    margin-bottom: 24px;
    width: 100%;
}

/* =========================================
   3. تنسيق خاص لصفحات الدخول (Auth Pages) 🔐
   ========================================= */
.auth-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
    padding: 20px;
    width: 100%;
}

.auth-card {
    background: var(--card-bg);
    border: var(--border-dim);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-soft);
    padding: 40px;
    width: 100%;
    max-width: 450px;
    text-align: center;
}

.auth-logo { font-size: 3rem; margin-bottom: 10px; display: block; }
.auth-title { font-size: 1.5rem; color: #fff; margin-bottom: 30px; font-weight: bold; }

/* =========================================
   4. الأزرار والحقول
   ========================================= */
.btn-full, button, .action-btn {
    background: var(--primary-gradient) !important;
    color: #fff !important;
    border: none;
    padding: 14px;
    border-radius: 12px;
    font-weight: bold;
    cursor: pointer;
    font-size: 1rem;
    width: 100%;
    display: inline-flex; justify-content: center; align-items: center;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
}
.btn-full:active { transform: scale(0.98); }

input, select, textarea, .admin-input {
    width: 100%;
    padding: 14px;
    background: #0f172a !important;
    border: 1px solid rgba(255,255,255,0.1) !important;
    border-radius: 12px;
    color: #fff !important;
    font-size: 1rem;
    margin-bottom: 15px; outline: none;
}
input:focus { border-color: var(--accent-color) !important; }

table { width: 100%; border-collapse: collapse; }
th { color: var(--accent-color) !important; padding: 12px; border-bottom: 1px solid rgba(255,255,255,0.1); }
td { border-bottom: 1px solid rgba(255,255,255,0.05); padding: 12px; }
.text-green { color: var(--success) !important; } .text-red { color: var(--danger) !important; }

/* =========================================
   5. واجهة الجوال (Mobile) 📱
   ========================================= */
.navbar {
    background: rgba(30, 41, 59, 0.95) !important;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding: 15px 20px;
    display: flex; justify-content: space-between; align-items: center;
    position: sticky; top: 0; z-index: 100;
}
.navbar h2 { font-size: 1.1rem; margin: 0; color: #fff !important; }
.nav-logo { font-size: 0.9rem; color: var(--accent-color) !important; }

.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: #1e293b;
    height: 80px;
    display: flex; justify-content: space-between; align-items: center;
    z-index: 999;
    padding: 0 5px;
    padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid rgba(255,255,255,0.05);
    box-shadow: 0 -5px 30px rgba(0,0,0,0.4); 
    border-radius: 20px 20px 0 0;
}

.nav-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: #64748B !important;
    font-size: 0.65rem; width: 19%; padding-top: 8px; transition: 0.3s;
    text-align: center;
}
.nav-item span { font-size: 1.4rem; margin-bottom: 3px; color: inherit !important; display: block; }
.nav-item.active { color: var(--accent-color) !important; }
.nav-item.active span, .nav-item.active small { color: var(--accent-color) !important; text-shadow: 0 0 10px rgba(251, 191, 36, 0.3); }

/* الزر العائم */
.fab-container { position: relative; top: -30px; display: flex; justify-content: center; }
.fab-btn-main {
    background: #FBBF24 !important;
    width: 60px; height: 60px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 0 0 6px var(--bg-color), 0 8px 20px rgba(217, 119, 6, 0.4);
    
    color: #0000A2 !important; 
    
    font-size: 2rem; 
    transition: 0.2s;
}
.fab-btn-main:active { transform: scale(0.9); }

/* القائمة الجانبية */
.mobile-sidebar {
    position: fixed; top: 0; right: -100%; width: 80%; height: 100vh;
    background: #1e293b; z-index: 2000;
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -10px 0 50px rgba(0,0,0,0.7);
    display: flex; flex-direction: column;
    border-left: 1px solid rgba(255,255,255,0.1);
}
.mobile-sidebar.open { right: 0; }
.sidebar-header { padding: 30px 20px; border-bottom: 1px solid rgba(255,255,255,0.05); }
.sidebar-scroll { flex: 1; overflow-y: auto; padding: 10px; }
.drawer-link {
    display: flex; align-items: center; padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    color: #cbd5e1 !important; font-size: 0.95rem; border-radius: 10px;
}
.drawer-link span { width: 35px; color: var(--accent-color) !important; font-size: 1.2rem; text-align: center; }
.sakan-code-card {
    margin: 20px 10px; padding: 15px;
    background: rgba(245, 158, 11, 0.05);
    border: 1px dashed var(--primary-color);
    border-radius: 12px; text-align: center;
}
.sakan-code-val { font-family: monospace; font-size: 1.3rem; color: var(--accent-color) !important; font-weight: bold; margin-top: 5px; display: block; }
.overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.8); z-index: 1999; display: none; backdrop-filter: blur(4px); }
.overlay.show { display: block; }

/* =========================================
   6. واجهة اللابتوب (Desktop) 💻 - تم الإصلاح
   ========================================= */
@media (min-width: 1024px) {
    body { padding-bottom: 0; display: block; }
    
    .bottom-nav, .navbar, .fab-container, .mobile-sidebar, .overlay { display: none !important; }
    
    /* القائمة الجانبية ثابتة */
    .sidebar {
        /* العرض كان 280 وتم إخفاؤه في الجوال عبر كلاس desktop-sidebar في layout.php */
        display: block; width: 280px; background: #1e293b;
        height: 100vh; position: fixed; right: 0; top: 0;
        border-left: 1px solid rgba(255,255,255,0.05); padding: 40px 30px;
        z-index: 1000;
        overflow-y: auto;
    }
    .sidebar h3 { color: var(--accent-color) !important; margin-bottom: 40px; }
    .sidebar a {
        display: flex; align-items: center; padding: 15px;
        margin-bottom: 10px; color: #94a3b8 !important; border-radius: 12px;
    }
    .sidebar a:hover, .sidebar a.active {
        background: rgba(251, 191, 36, 0.1); color: var(--accent-color) !important;
    }

    /* المحتوى الرئيسي يتمدد */
    .main-content, .admin-main {
        margin-right: 280px; /* يترك مساحة للقائمة */
        width: auto; /* يتمدد ليأخذ الباقي */
        max-width: 100%; /* إلغاء أي حد أقصى */
        padding: 40px;
        min-height: 100vh;
    }
    
    /* توزيع الكروت في الشبكة */
    .stats-grid, .admin-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); /* تعبئة تلقائية ذكية */
        gap: 25px;
    }
    
    /* إصلاح صفحة الدخول على اللابتوب */
    .auth-wrapper {
        width: 100%;
        margin-right: 0; 
    }
}

/* ألوان التنبيهات */
.alert-danger { background: linear-gradient(45deg, #EF4444, #B91C1C) !important; }
.alert-warning { background: linear-gradient(45deg, #F59E0B, #D97706) !important; }
.alert-success { background: linear-gradient(45deg, #10B981, #059669) !important; }
.alert-info { background: linear-gradient(45deg, #3B82F6, #2563EB) !important; }

/* =========================================
   إصلاح الهامش العلوي للجوال 📱
   ========================================= */
@media (max-width: 768px) {
    .main-content {
        /* الهامش القياسي كان 80px، سنزيده قليلاً للجوال */
        margin-top: 20px !important; 
        padding-top: 10px !important;
    }
}





/* منع ارتداد الصفحة في المتصفح ليعمل الكود الخاص بنا */
body {
    overscroll-behavior-y: contain;
}

/* أنيميشن دوران الأيقونة عند التحديث */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.loading-spin {
    animation: spin 1s linear infinite;
}

