/**
 * UX/Design Improvements - Enhanced.css
 * تحسينات UX والتصميم دون تغيير الهوية البصرية الأساسية
 * 
 * التحسينات:
 * ✅ تحسين سهولة الاستخدام
 * ✅ تحسين الاستجابة البصرية
 * ✅ تحسين التفاعل مع الواجهة
 * ✅ تحسين سرعة التحميل
 * ✅ تحسين الوضوح والقراءة
 */

/* ============================================
   1. تحسينات التنقل والهيدر
   ============================================ */

/* شريط العنوان محسّن مع انتقالات أفضل */
.app-header {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-bottom: 1px solid var(--border-color);
}

.app-header.scrolled {
    box-shadow: var(--shadow-lg);
    padding: 8px 20px;
}

/* أزرار التنقل محسّنة */
.menu-btn, .cart-btn {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 8px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg-light);
    border: 1px solid var(--border-color);
    position: relative;
}

.menu-btn:hover, .cart-btn:hover {
    background: var(--primary-red);
    color: white;
    border-color: var(--primary-red);
    transform: scale(1.05);
}

.menu-btn:active, .cart-btn:active {
    transform: scale(0.95);
}

/* مؤشر عدد المنتجات في السلة */
.cart-count {
    position: absolute;
    top: -6px;
    left: -6px;
    background: var(--primary-red);
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
    animation: pulse 0.3s ease-out;
}

@keyframes pulse {
    0% {
        transform: scale(1.5);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ============================================
   2. تحسينات القوائم والقوائم الجانبية
   ============================================ */

/* تحسين القائمة الجانبية */
.side-menu {
    animation: slideInRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.menu-list a {
    position: relative;
    overflow: hidden;
}

.menu-list a::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    width: 4px;
    height: 100%;
    background: var(--primary-red);
    transform: scaleX(0);
    transform-origin: right;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.menu-list a:hover {
    background: rgba(211, 47, 47, 0.05);
}

.menu-list a:hover::after {
    transform: scaleX(1);
}

/* ============================================
   3. تحسينات بطاقات المنتجات
   ============================================ */

.product-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
    position: relative;
    overflow: hidden;
    border-radius: 12px;
}

.product-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, transparent 0%, rgba(0, 0, 0, 0.02) 100%);
    pointer-events: none;
}

.product-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-red);
}

/* صورة المنتج محسّنة */
.product-image {
    position: relative;
    overflow: hidden;
    background: var(--color-bg-light);
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-image img {
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-card:hover .product-image img {
    transform: scale(1.08);
}

/* شارة الخصم أو الحالة */
.product-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--primary-red);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    z-index: 2;
    animation: slideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideDown {
    from {
        transform: translateY(-10px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* تحسين اسم المنتج والسعر */
.product-info {
    padding: 12px;
}

.product-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 8px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.3s;
}

.product-card:hover .product-name {
    color: var(--primary-red);
}

.product-price {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.price-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary-red);
}

.price-unit {
    font-size: 12px;
    color: var(--text-light);
}

/* ============================================
   4. تحسينات الأزرار والتفاعلات
   ============================================ */

/* أزرار محسّنة */
.btn-primary, .btn-secondary, .btn-tertiary {
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary::before,
.btn-secondary::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
    pointer-events: none;
}

.btn-primary:hover::before,
.btn-secondary:hover::before {
    width: 300px;
    height: 300px;
}

/* أزرار القطع والإضافة */
.quantity-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-color);
    background: white;
    color: var(--text-dark);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quantity-btn:hover {
    background: var(--primary-red);
    color: white;
    border-color: var(--primary-red);
    transform: scale(1.1);
}

.quantity-btn:active {
    transform: scale(0.95);
}

/* ============================================
   5. تحسينات النماذج والمدخلات
   ============================================ */

.form-group input,
.form-group textarea,
.form-group select {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: white;
    position: relative;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--primary-red);
    box-shadow: 0 0 0 3px rgba(211, 47, 47, 0.1);
}

/* تحسين التسميات */
.form-group label {
    transition: color 0.3s;
    position: relative;
}

.form-group input:focus ~ label,
.form-group textarea:focus ~ label {
    color: var(--primary-red);
}

/* مؤشر الخطأ */
.form-error {
    color: var(--color-error);
    font-size: 12px;
    margin-top: 4px;
    animation: shake 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

/* ============================================
   6. تحسينات السلة والدفع
   ============================================ */

.cart-item {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 12px;
    overflow: hidden;
}

.cart-item:hover {
    box-shadow: var(--shadow-md);
    transform: translateX(-2px);
}

.cart-item-image {
    background: var(--color-bg-light);
    position: relative;
    overflow: hidden;
}

.cart-item-image img {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.cart-item:hover .cart-item-image img {
    transform: scale(1.05);
}

/* ============================================
   7. تحسينات حالات التحميل والفراغة
   ============================================ */

.empty-state {
    text-align: center;
    padding: 48px 24px;
    animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.3;
    animation: float 3s ease-in-out infinite;
}

.loading-spinner {
    display: inline-block;
    width: 32px;
    height: 32px;
    border: 3px solid rgba(211, 47, 47, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary-red);
    animation: spin 0.8s linear infinite;
}

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

/* ============================================
   8. تحسينات التنبيهات والإشعارات
   ============================================ */

.toast-notification {
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.toast-success {
    background: var(--color-success);
    color: white;
}

.toast-error {
    background: var(--color-error);
    color: white;
}

.toast-info {
    background: var(--color-info);
    color: white;
}

.toast-icon {
    flex-shrink: 0;
    font-size: 20px;
}

/* ============================================
   9. تحسينات الـ Pagination والـ Tabs
   ============================================ */

.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 24px 0;
}

.pagination button {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
}

.pagination button:hover,
.pagination button.active {
    background: var(--primary-red);
    color: white;
    border-color: var(--primary-red);
    transform: scale(1.1);
}

.tabs-nav {
    display: flex;
    gap: 12px;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 20px;
    overflow-x: auto;
}

.tab-button {
    padding: 12px 16px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

.tab-button:hover {
    color: var(--primary-red);
}

.tab-button.active {
    color: var(--primary-red);
}

.tab-button.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary-red);
    animation: expandWidth 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes expandWidth {
    from {
        width: 0;
        left: 50%;
    }
    to {
        width: 100%;
        left: 0;
    }
}

/* ============================================
   10. تحسينات الـ Accessibility والقراءة
   ============================================ */

/* تحسين التباين والقراءة */
.readable-text {
    line-height: 1.6;
    letter-spacing: 0.3px;
}

/* تحسين الـ Focus للمستخدمين الذين يستخدمون لوحة المفاتيح */
:focus-visible {
    outline: 2px solid var(--primary-red);
    outline-offset: 2px;
}

/* تحسين استجابة أنظمة الألوان الداكنة */
@media (prefers-color-scheme: dark) {
    .form-group input,
    .form-group textarea,
    .form-group select {
        background: #2a2a2a;
        color: #ffffff;
        border-color: #444;
    }
    
    .btn-secondary {
        background: #2a2a2a;
        color: var(--primary-red);
    }
}

/* تحسين استجابة حركة التقليل */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================
   11. تحسينات الـ Modals والـ Dialogs
   ============================================ */

.modal-overlay {
    animation: fadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(4px);
}

.modal-content {
    animation: zoomIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 16px;
    overflow: hidden;
}

@keyframes zoomIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-header {
    background: linear-gradient(135deg, rgba(211, 47, 47, 0.05) 0%, transparent 100%);
    border-bottom: 1px solid var(--border-color);
    padding: 20px;
}

.modal-close-btn {
    position: absolute;
    top: 12px;
    left: 12px;
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.modal-close-btn:hover {
    background: var(--primary-red);
    color: white;
    transform: rotate(90deg);
}

/* ============================================
   12. تحسينات الـ Footer والـ Bottom Navigation
   ============================================ */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    gap: 12px;
    padding: 8px;
    z-index: 99;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 12px;
    border-radius: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.nav-item:hover,
.nav-item.active {
    color: var(--primary-red);
    background: rgba(211, 47, 47, 0.05);
}

.nav-icon {
    font-size: 24px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item:hover .nav-icon,
.nav-item.active .nav-icon {
    transform: scale(1.2);
}

/* ============================================
   13. تحسينات التطبيق على الأجهزة المختلفة
   ============================================ */

@media (max-width: 480px) {
    .product-card {
        border-radius: 10px;
    }
    
    .btn-primary, .btn-secondary {
        border-radius: 10px;
        padding: 12px 20px;
    }
    
    .modal-content {
        border-radius: 16px 16px 0 0;
    }
}

@media (min-width: 768px) {
    .quantity-btn:hover {
        transform: scale(1.15);
    }
    
    .product-card:hover {
        transform: translateY(-12px);
    }
}

/* ============================================
   14. تحسينات الـ Print
   ============================================ */

@media print {
    .app-header,
    .bottom-nav,
    .menu-btn,
    .cart-btn {
        display: none !important;
    }
    
    body {
        background: white;
        padding: 0;
    }
    
    .product-card {
        page-break-inside: avoid;
    }
}

/* ============================================
   15. تحسينات الـ Scrolling والـ Performance
   ============================================ */

html {
    scroll-behavior: smooth;
}

/* تحسين الـ Scrolling على الأجهزة القديمة */
.smooth-scroll {
    -webkit-overflow-scrolling: touch;
}

/* منع الرجفان أثناء التمرير */
.list-container {
    will-change: transform;
    transform: translateZ(0);
}

/* تحسين الأداء للعناصر المتحركة */
.animated-element {
    will-change: opacity, transform;
}
