/* =========================================================
   ملف التنسيق الشامل للجيل القادم - متجر فخر كارد (FAKHR CARD v9)
   يدعم خط Cairo، Glassmorphism، Skeleton Loaders، الهيدر المتجاوب، والطباعة
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700;800;900&family=Readex+Pro:wght@400;600;700&family=JetBrains+Mono:wght@500;700;800&display=swap');

:root {
    --brand-blue: #002366;
    --brand-neon: #00509e;
    --brand-cyan: #0ea5e9;
    --brand-dark: #0f172a;
    --brand-panel: #1e293b;
    --brand-sidebar: #111318;
    --brand-emerald: #10b981;
    --brand-amber: #f59e0b;
    --brand-red: #ef4444;
}

/* 1. الإعدادات العامة للخلفية والخطوط (الوضع المظلم الافتراضي) */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Cairo', 'Readex Pro', system-ui, -apple-system, sans-serif;
    background-color: var(--brand-dark);
    background-image: 
        radial-gradient(at 0% 0%, rgba(0, 80, 158, 0.18) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(14, 165, 233, 0.10) 0px, transparent 50%);
    background-attachment: fixed;
    color: #e2e8f0;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
    line-height: 1.6;
}

.font-mono, code, input[dir="ltr"] {
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace !important;
}

/* إيقاف حركات الوميض المزعجة مع الحفاظ على سلاسة الواجهة */
.animate-pulse, .animate-bounce {
    animation: none !important;
}

/* إخفاء شريط التمرير مع بقاء التمرير باللمس للأشرطة الأفقية */
.no-scrollbar::-webkit-scrollbar {
    display: none;
}
.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* =========================================================
   2. ضبط الهيدر المتجاوب لمنع تداخل الرصيد مع الشعار على الهواتف
   ========================================================= */
header > .container {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
}

header > .container > div:nth-child(2) {
    position: static !important;
    transform: none !important;
    margin: 0 auto !important;
    flex-shrink: 0 !important;
}

#header-balance-container {
    flex-shrink: 0 !important;
    max-width: 140px !important;
    padding: 4px 10px !important;
    font-size: 11px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

@media (max-width: 390px) {
    header .neon-text {
        font-size: 13px !important;
        letter-spacing: 0 !important;
    }
    #header-balance-container {
        max-width: 115px !important;
        padding: 3px 8px !important;
        font-size: 10px !important;
    }
}

/* =========================================================
   3. تنسيقات الوضع الفاتح المحسّن (Light Mode)
   ========================================================= */
body.light-mode {
    background-color: #f1f5f9;
    background-image: 
        radial-gradient(at 0% 0%, rgba(14, 165, 233, 0.08) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(0, 35, 102, 0.05) 0px, transparent 50%);
    color: #0f172a;
}

body.light-mode .bg-brand-panel {
    background-color: #ffffff !important;
    border-color: #cbd5e1 !important;
    color: #0f172a !important;
    box-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.06) !important;
}

body.light-mode .bg-brand-dark,
body.light-mode .bg-\[\#141b26\],
body.light-mode .bg-\[\#111827\],
body.light-mode .bg-\[\#111622\] {
    background-color: #f8fafc !important;
    border-color: #cbd5e1 !important;
    color: #0f172a !important;
}

body.light-mode h1,
body.light-mode h2,
body.light-mode h3,
body.light-mode h4,
body.light-mode .text-white {
    color: #0f172a;
}

body.light-mode .text-gray-200,
body.light-mode .text-gray-300,
body.light-mode .text-gray-400 {
    color: #334155 !important;
}

body.light-mode .text-blue-200 {
    color: #1e40af !important;
}

/* استثناء الهيدر والقائمة الجانبية والأزرار الملونة والنوافذ الداكنة ليبقى نصها أبيض واضحاً */
body.light-mode header h1,
body.light-mode header h2,
body.light-mode header span.text-white,
body.light-mode header .text-brand-silver,
body.light-mode #sidebar h3.text-white,
body.light-mode #sidebar .text-white,
body.light-mode .bg-brand-neon,
body.light-mode .bg-green-600,
body.light-mode .bg-emerald-600,
body.light-mode .bg-blue-600,
body.light-mode .bg-red-600,
body.light-mode .bg-amber-500,
body.light-mode .bg-amber-600,
body.light-mode .bg-purple-600,
body.light-mode .bg-cyan-600,
body.light-mode .bg-cyan-700,
body.light-mode #checkout-total-banner,
body.light-mode #checkout-total-banner *,
body.light-mode #order-received-modal *,
body.light-mode #receipt-print-modal * {
    color: #ffffff !important;
}

body.light-mode #order-received-modal .text-emerald-400,
body.light-mode #receipt-print-modal .text-emerald-400 {
    color: #34d399 !important;
}

body.light-mode #order-received-modal .text-amber-400 {
    color: #fbbf24 !important;
}

body.light-mode #order-received-modal .text-\[\#2563eb\] {
    color: #60a5fa !important;
}

body.light-mode #my-wallet-page .grid > div p,
body.light-mode #my-wallet-page .grid > div h3 {
    color: #ffffff !important;
}

body.light-mode header .text-gray-300,
body.light-mode header .text-gray-400,
body.light-mode #sidebar .text-gray-300,
body.light-mode #sidebar .text-gray-400 {
    color: #cbd5e1 !important;
}

body.light-mode #profile-display-modal .bg-gray-800\/50 {
    background-color: #f1f5f9 !important;
    border-color: #cbd5e1 !important;
}

body.light-mode #custom-dialog-modal > div,
body.light-mode #unread-popup-modal > div,
body.light-mode #notifications-modal > div,
body.light-mode #auth-modal > div {
    background-color: #1e293b !important;
    color: #ffffff !important;
}

body.light-mode #custom-dialog-modal h3,
body.light-mode #unread-popup-modal h3,
body.light-mode #notifications-modal h3,
body.light-mode #auth-modal h3 {
    color: #ffffff !important;
}

body.light-mode #custom-dialog-modal p,
body.light-mode #unread-popup-modal #unread-popup-body,
body.light-mode #notifications-modal p {
    color: #e2e8f0 !important;
}

/* =========================================================
   4. تأثيرات النيون الأزرق الملكي والـ Glassmorphism
   ========================================================= */
.neon-border {
    border: 1px solid rgba(14, 165, 233, 0.35);
    box-shadow: 0 4px 20px -2px rgba(0, 80, 158, 0.35), inset 0 1px 0 0 rgba(255, 255, 255, 0.08);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.neon-border:hover {
    border-color: rgba(14, 165, 233, 0.75);
    box-shadow: 0 8px 25px -4px rgba(14, 165, 233, 0.45), inset 0 1px 0 0 rgba(255, 255, 255, 0.15);
}

.neon-text {
    text-shadow: 0 0 10px rgba(14, 165, 233, 0.65);
}

.glass-card {
    background: rgba(30, 41, 59, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.glass-input {
    background: rgba(15, 23, 42, 0.72);
    border: 1px solid #334155;
    backdrop-filter: blur(6px);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.glass-input:focus {
    border-color: #0ea5e9;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.22);
    outline: none;
}

/* =========================================================
   5. نظام التنقل السريع بين الصفحات (SPA) وحركة الظهور
   ========================================================= */
.page {
    display: none;
}

.page.active {
    display: block;
    animation: fadeInSlide 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeInSlide {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =========================================================
   6. تأثيرات التحميل الهيكلي الهادئة (Skeleton Loaders)
   ========================================================= */
.skeleton-box {
    position: relative;
    overflow: hidden;
    background-color: #1e293b;
    border-radius: 1rem;
    border: 1px solid rgba(14, 165, 233, 0.18);
}

body.light-mode .skeleton-box {
    background-color: #e2e8f0;
}

/* =========================================================
   7. الشريط الإعلاني المتحرك الحديث (بديل Marquee السلس)
   ========================================================= */
.salam-ticker-wrap {
    width: 100%;
    overflow: hidden;
    white-space: nowrap;
    position: relative;
}

.salam-ticker-move {
    display: inline-block;
    white-space: nowrap;
    padding-left: 100%;
    animation: salamTickerRTL 22s linear infinite;
}

.salam-ticker-wrap:hover .salam-ticker-move {
    animation-play-state: paused;
}

@keyframes salamTickerRTL {
    0% {
        transform: translate3d(-100%, 0, 0);
    }
    100% {
        transform: translate3d(100%, 0, 0);
    }
}

/* =========================================================
   8. شاشة التحميل السريعة (Preloader) وإشعارات التوست (#toast)
   ========================================================= */
#app-preloader.fade-out {
    opacity: 0;
    pointer-events: none;
}

#toast {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    padding: 12px 24px;
    border-radius: 14px;
    transition: all 0.35s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    z-index: 250000;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.55);
    font-weight: 800;
    font-size: 13px;
    white-space: nowrap;
    max-width: 92vw;
    overflow: hidden;
    text-overflow: ellipsis;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

#toast.show {
    bottom: 85px;
}

#toast.error {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

/* =========================================================
   9. القائمة الجانبية (#sidebar) وخلفية التعتيم (#overlay)
   ========================================================= */
#sidebar {
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#sidebar.open {
    transform: translateX(0);
}

#overlay {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease-in-out;
}

#overlay.show {
    opacity: 1;
    pointer-events: auto;
}

/* =========================================================
   10. الجداول، أشرطة التمرير، وترتيب النوافذ المنبثقة
   ========================================================= */
.admin-table-container {
    overflow-x: auto;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #0f172a;
}

::-webkit-scrollbar-thumb {
    background: #00509e;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #0ea5e9;
}

#custom-dialog-modal {
    z-index: 220000 !important;
}

#image-modal {
    z-index: 230000 !important;
}

#receipt-print-modal {
    z-index: 225000 !important;
}

/* =========================================================
   11. تنسيق طباعة الفواتير الرسمية (Print Media Query)
   ========================================================= */
@media print {
    body * {
        visibility: hidden;
    }
    #receipt-printable-area,
    #receipt-printable-area * {
        visibility: visible;
    }
    #receipt-printable-area {
        position: fixed;
        left: 0;
        top: 0;
        width: 100%;
        background: #ffffff !important;
        color: #000000 !important;
        padding: 24px !important;
        box-shadow: none !important;
        border: 2px solid #002366 !important;
        border-radius: 16px !important;
    }
    #receipt-printable-area span,
    #receipt-printable-area h3,
    #receipt-printable-area p,
    #receipt-printable-area code {
        color: #0f172a !important;
    }
    .no-print {
        display: none !important;
    }
}
