/* ===== إضافة التحسينات على النمط الموجود ===== */

/* عناصر التحكم بالبحث والفلترة */
.articles-controls {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 15px;
    padding: 2rem;
    margin-bottom: 3rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    border: 1px solid rgba(255,255,255,0.2);
}

.search-filter-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.search-box {
    position: relative;
    max-width: 500px;
    margin: 0 auto;
}

#articleSearch {
    width: 100%;
    padding: 15px 20px;
    border: 2px solid #e2e8f0;
    border-radius: 50px;
    font-size: 1rem;
    font-family: 'Cairo', sans-serif;
    background: white;
    transition: all 0.3s ease;
    direction: rtl;
    text-align: right;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

#articleSearch:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1), 0 4px 20px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border-radius: 15px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
    margin-top: 8px;
    z-index: 1000;
    display: none;
    max-height: 300px;
    overflow-y: auto;
}

.filter-controls {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
}

.filter-controls select {
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 25px;
    font-family: 'Cairo', sans-serif;
    font-size: 0.95rem;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 150px;
}

.filter-controls select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.clear-filters-btn {
    background: linear-gradient(45deg, #f56565, #ed4014);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Cairo', sans-serif;
    font-size: 0.9rem;
}

.clear-filters-btn:hover {
    background: linear-gradient(45deg, #e53e3e, #c53030);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(245, 101, 101, 0.3);
}

.articles-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(0,0,0,0.1);
    font-size: 0.9rem;
    color: #666;
}

#filterStatus {
    background: #667eea;
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: 600;
    display: none;
}

/* تحسينات بطاقات المقالات */
.article-card {
    background: white;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    border: 1px solid rgba(0,0,0,0.05);
}

.article-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.article-card:hover::before {
    transform: scaleX(1);
}

.article-card:hover {
    transform: translateY(-12px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0,0,0,0.15);
}

.featured-badge {
    position: absolute;
    top: 15px;
    right: 15px;
    background: linear-gradient(45deg, #ffd700, #ffed4e);
    color: #2d3748;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    z-index: 10;
    box-shadow: 0 2px 10px rgba(255, 215, 0, 0.3);
    animation: pulse 2s infinite;
}

.article-category {
    margin: 0;
    padding: 0.8rem 1rem;
    color: white;
    font-weight: 600;
    font-size: 0.85rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.article-category::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.5s ease;
}

.article-card:hover .article-category::after {
    left: 100%;
}

.article-card h3 {
    color: #2c5282;
    margin: 1.5rem 2rem 1rem 2rem;
    font-size: 1.4rem;
    line-height: 1.4;
    font-weight: 700;
    transition: color 0.3s ease;
}

.article-card:hover h3 {
    color: #1a365d;
}

.article-excerpt {
    color: #666;
    margin: 0 2rem 1.5rem 2rem;
    line-height: 1.7;
    font-size: 0.95rem;
}

.article-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0 2rem 1rem 2rem;
    padding: 1rem 0;
    border-top: 1px solid #f1f1f1;
    border-bottom: 1px solid #f1f1f1;
    font-size: 0.85rem;
    color: #777;
}

.article-author {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}

.author-icon {
    opacity: 0.7;
}

.article-stats {
    display: flex;
    gap: 1rem;
}

.article-stats span {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.article-card:hover .article-stats span {
    opacity: 1;
}

.article-tags {
    margin: 0 2rem 1.5rem 2rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag {
    background: #f8f9fa;
    color: #495057;
    padding: 0.3rem 0.8rem;
    border-radius: 15px;
    font-size: 0.75rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.tag:hover {
    background: #e9ecef;
    transform: translateY(-1px);
}

.article-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0 2rem 2rem 2rem;
    padding-top: 1rem;
}

.read-more {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    text-decoration: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.read-more::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.5s ease;
}

.read-more:hover::before {
    left: 100%;
}

.read-more:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.article-actions {
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    background: none;
    border: 2px solid #e2e8f0;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn:hover {
    transform: translateY(-2px) scale(1.1);
    border-color: #667eea;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.2);
}

.action-btn.liked {
    border-color: #f56565;
    background: #f56565;
    color: white;
}

.action-btn.bookmarked {
    border-color: #ed8936;
    background: #ed8936;
    color: white;
}

/* مؤشر التحميل */
.loading-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    backdrop-filter: blur(5px);
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-indicator p {
    font-weight: 600;
    color: #666;
    margin: 0;
}

/* تحسين زر "عرض المزيد" */
.load-more-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 18px 36px;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-family: 'Cairo', sans-serif;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.2);
}

.load-more-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.5s ease;
}

.load-more-btn:hover::before {
    left: 100%;
}

.load-more-btn:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
}

.load-more-btn:active {
    transform: translateY(-2px) scale(1.02);
}

.load-more-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* رسائل التنبيه (Toast) */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: 15px;
    font-weight: 600;
    z-index: 10000;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
}

.toast-success {
    background: linear-gradient(135deg, #48bb78, #38a169);
    color: white;
}

.toast-error {
    background: linear-gradient(135deg, #f56565, #e53e3e);
    color: white;
}

.toast-info {
    background: linear-gradient(135deg, #4299e1, #3182ce);
    color: white;
}

/* تأثيرات القلوب الطائرة */
@keyframes floatUp {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-100px) scale(1.5);
    }
}

.floating-heart {
    pointer-events: none;
    position: fixed;
    font-size: 1.5rem;
    animation: floatUp 1s ease-out forwards;
    z-index: 1000;
}

/* تحسين الهيدر */
.header {
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.header.scrolled {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
}

/* تحسين الأنيميشن */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

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

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

/* تحسين شاشة الخطأ */
.error-message {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    backdrop-filter: blur(10px);
}

.error-content {
    text-align: center;
    background: white;
    padding: 3rem;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    max-width: 400px;
    border: 1px solid rgba(0,0,0,0.05);
}

.error-content h3 {
    color: #e53e3e;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.error-content p {
    color: #666;
    margin-bottom: 2rem;
    line-height: 1.6;
}

.retry-btn {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Cairo', sans-serif;
}

.retry-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

/* تحسينات الاستجابة للموبايل */
@media (max-width: 768px) {
    .articles-controls {
        padding: 1.5rem;
        margin-bottom: 2rem;
    }

    .search-filter-container {
        gap: 1rem;
    }

    .filter-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-controls select,
    .clear-filters-btn {
        width: 100%;
        min-width: unset;
    }

    .articles-stats {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }

    .article-card {
        margin: 0 0 1.5rem 0;
    }

    .article-meta {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }

    .article-stats {
        justify-content: space-between;
        width: 100%;
    }

    .article-footer {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }

    .article-actions {
        justify-content: center;
    }

    .toast {
        right: 10px;
        left: 10px;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .articles-controls {
        padding: 1rem;
        border-radius: 10px;
    }

    #articleSearch {
        font-size: 0.9rem;
        padding: 12px 16px;
    }

    .filter-controls select,
    .clear-filters-btn {
        padding: 10px 14px;
        font-size: 0.9rem;
    }

    .article-card h3 {
        font-size: 1.2rem;
        margin: 1rem 1.5rem 0.5rem 1.5rem;
    }

    .article-excerpt,
    .article-meta,
    .article-tags,
    .article-footer {
        margin-left: 1.5rem;
        margin-right: 1.5rem;
    }

    .load-more-btn {
        width: 100%;
        margin: 0 20px;
        box-sizing: border-box;
    }
}

/* تحسينات إضافية للأداء */
.article-card,
.articles-controls,
.load-more-btn,
.action-btn {
    will-change: transform;
    backface-visibility: hidden;
    perspective: 1000px;
}

/* تحسين التمرير */
html {
    scroll-behavior: smooth;
}

/* تحسين عام للتركيز */
*:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* تحسين النصوص */
.article-card p,
.article-meta,
.article-stats {
    text-rendering: optimizeLegibility;
    font-feature-settings: 'liga', 'kern';
}

/* تحسين للطباعة */
@media print {
    .articles-controls,
    .article-actions,
    .load-more-btn,
    .floating-heart,
    .toast,
    .loading-indicator {
        display: none !important;
    }
    
    .article-card {
        box-shadow: none;
        border: 1px solid #ddd;
        break-inside: avoid;
        page-break-inside: avoid;
    }
}

/* تأثيرات التفاعل المحسنة */
@media (hover: hover) {
    .article-card:hover {
        cursor: pointer;
    }
    
    .action-btn:hover {
        cursor: pointer;
    }
}

/* ضمان الوصولية */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .article-card:hover {
        transform: none;
    }
    
    .load-more-btn:hover {
        transform: none;
    }
}

/* تحسين الألوان للوضع المظلم */
@media (prefers-color-scheme: dark) {
    .articles-controls {
        background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    #articleSearch {
        background: #2d3748;
        color: white;
        border-color: #4a5568;
    }
    
    .filter-controls select {
        background: #2d3748;
        color: white;
        border-color: #4a5568;
    }
    
    .article-card {
        background: #2d3748;
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .article-card h3 {
        color: #e2e8f0;
    }
    
    .article-excerpt {
        color: #cbd5e0;
    }
}