/* خطوط عربية واضحة للموبايل */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700;900&display=swap');

* {
    font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    direction: rtl;
    text-align: right;
}

/* تحسينات للموبايل */
html {
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: 100%;
    touch-action: manipulation;
}

/* تحسين حجم النصوص للموبايل */
@media (max-width: 640px) {
    html {
        font-size: 15px;
    }
    
    body {
        font-size: 0.95rem;
    }
    
    h1 {
        font-size: 1.75rem !important;
        line-height: 1.3 !important;
    }
    
    h2 {
        font-size: 1.5rem !important;
        line-height: 1.3 !important;
    }
    
    h3 {
        font-size: 1.25rem !important;
        line-height: 1.4 !important;
    }
    
    h4 {
        font-size: 1.1rem !important;
        line-height: 1.4 !important;
    }
}

/* تحسين التباعد للموبايل */
@media (max-width: 640px) {
    .container {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    .section-padding {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }
}

/* تأثيرات الحركة */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

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

.card-hover {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-hover:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.card-hover:active {
    transform: scale(0.98);
}

/* تحسين الأزرار للموبايل */
button, .btn {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    min-height: 44px; /* الحد الأدنى للمس المريح */
}

/* تحسين الـ inputs للموبايل */
input, select, textarea {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    font-size: 16px !important; /* منع الـ zoom التلقائي في iOS */
    min-height: 44px;
}

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
    background-position: left 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-left: 2.5rem;
}

/* تحسين Modal للموبايل */
.modal-content {
    max-height: 90vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 640px) {
    .modal-content {
        max-height: 100vh;
        border-radius: 1.5rem 1.5rem 0 0;
        margin-top: auto;
    }
}

/* Scrollbar مخصص للموبايل */
.modal-content::-webkit-scrollbar {
    width: 6px;
}

.modal-content::-webkit-scrollbar-track {
    background: transparent;
}

.modal-content::-webkit-scrollbar-thumb {
    background: rgba(156, 163, 175, 0.4);
    border-radius: 10px;
}

/* تحسين الصور للموبايل */
img {
    display: block;
    max-width: 100%;
    height: auto;
    -webkit-user-drag: none;
    user-select: none;
}

/* منع تحديد النص عند اللمس السريع */
.no-select {
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
}

/* تحسين Grid للموبايل */
@media (max-width: 640px) {
    .grid-mobile-1 {
        grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
    }
    
    .grid-mobile-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

/* تحسين الـ Gradient Buttons */
.gradient-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    font-weight: 700;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.gradient-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gradient-btn:hover::before {
    opacity: 1;
}

.gradient-btn span {
    position: relative;
    z-index: 1;
}

/* تحسين الـ Badge */
.badge-featured {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    box-shadow: 0 4px 6px -1px rgba(251, 191, 36, 0.3);
}

/* تحسين النصوص متعددة الأسطر */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* تحسين الظلال للوضع الداكن */
.dark .shadow-lg {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
}

/* Smooth Scrolling */
html {
    scroll-behavior: smooth;
}

/* تحسين الـ Focus للوصولية */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Pulse Animation للعناصر المهمة */
.pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: .8;
    }
}

/* تحسين الـ Safe Area للأجهزة الحديثة */
@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }
    
    .modal-content {
        padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
    }
}

/* تحسين الـ Typography */
p {
    line-height: 1.7;
}

strong, b {
    font-weight: 700;
}

/* تحسين الـ Links */
a {
    color: inherit;
    text-decoration: none;
    transition: all 0.2s ease;
}

a:active {
    opacity: 0.7;
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s ease-in-out infinite;
}

.dark .skeleton {
    background: linear-gradient(90deg, #374151 25%, #4b5563 50%, #374151 75%);
    background-size: 200% 100%;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* تحسين الـ Toast Notifications */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 1rem;
    left: 1rem;
    background: white;
    border-radius: 1rem;
    padding: 1rem 1.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 9999;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

/* تحسين الـ Sticky Header */
.sticky-header {
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.9);
}

.dark .sticky-header {
    background: rgba(31, 41, 55, 0.9);
}

/* تحسين الـ Bottom Navigation للموبايل */
@media (max-width: 640px) {
    .bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        border-top: 1px solid #e5e7eb;
        padding: 0.75rem 1rem;
        padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
        z-index: 40;
        box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.05);
    }
    
    .dark .bottom-nav {
        background: #1f2937;
        border-top-color: #374151;
    }
}

/* تحسين الـ Floating Action Button */
.fab {
    position: fixed;
    bottom: 5rem;
    left: 1rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    z-index: 30;
    transition: all 0.3s ease;
}

.fab:active {
    transform: scale(0.9);
}

/* تحسين الـ Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* تحسين الـ Divider */
.divider {
    height: 1px;
    background: linear-gradient(to right, transparent, #e5e7eb, transparent);
    margin: 2rem 0;
}

.dark .divider {
    background: linear-gradient(to right, transparent, #374151, transparent);
}