/* ===== إصلاح شامل لتصميم الكاردز ===== */

/* تطبيق display flex للكاردز لضمان ترتيب العناصر */
.service-card, 
.product-card, 
.project-card, 
.blog-card, 
.blog-post {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    position: relative !important;
}

/* Container للمحتوى الرئيسي */
.service-card .p-6,
.product-card .p-6,
.project-card .p-6,
.blog-card .p-6,
.blog-post .p-6 {
    display: flex !important;
    flex-direction: column !important;
    flex-grow: 1 !important;
    gap: 1rem !important;
}

/* ===== تحسين النصوص مع truncation ===== */
.card-description,
.service-card .text-brand-gray,
.product-card .text-gray-600,
.project-card .text-gray-600,
.blog-card .text-brand-gray,
.blog-post .text-gray-600 {
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    line-height: 1.5 !important;
    max-height: 3em !important; /* سطرين بالضبط */
    margin-bottom: 1rem !important;
}

/* العنوان الرئيسي للكارد */
.card-title,
.service-card h3,
.product-card h3,
.project-card h3,
.blog-card h3,
.blog-post h3 {
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    line-height: 1.3 !important;
    max-height: 2.6em !important;
    margin-bottom: 0.75rem !important;
}

/* ===== تثبيت الأزرار في الأسفل ===== */
.card-footer,
.card-actions,
.service-card .flex.justify-between,
.product-card .flex.gap-2,
.project-card .block.w-full,
.blog-card .flex.items-center.justify-between,
.blog-post .flex.items-center.justify-between {
    margin-top: auto !important;
    padding-top: 1rem !important;
}

/* تحسين أزرار الخدمات */
.service-card .flex.justify-between.items-center {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 0.75rem !important;
    flex-wrap: wrap !important;
}

.service-card .flex.justify-between.items-center a:first-child {
    color: #DC2626 !important;
    font-weight: 600 !important;
    text-decoration: none !important;
    transition: color 0.3s ease !important;
}

.service-card .flex.justify-between.items-center a:first-child:hover {
    text-decoration: underline !important;
    color: #B91C1C !important;
}

.service-card .flex.justify-between.items-center a:last-child {
    background-color: #DC2626 !important;
    color: white !important;
    padding: 0.5rem 1rem !important;
    border-radius: 0.5rem !important;
    font-weight: 600 !important;
    text-decoration: none !important;
    transition: background-color 0.3s ease !important;
    white-space: nowrap !important;
}

.service-card .flex.justify-between.items-center a:last-child:hover {
    background-color: #B91C1C !important;
}

/* تحسين أزرار المنتجات */
.product-card .flex.gap-2 {
    display: flex !important;
    gap: 0.5rem !important;
}

.product-card .flex.gap-2 a {
    flex: 1 !important;
    text-align: center !important;
    padding: 0.5rem !important;
    border-radius: 0.5rem !important;
    font-weight: 600 !important;
    transition: all 0.3s ease !important;
}

.product-card .flex.gap-2 button {
    padding: 0.5rem 1rem !important;
    border-radius: 0.5rem !important;
    transition: all 0.3s ease !important;
}

/* تحسين أزرار المشاريع */
.project-card .block.w-full {
    display: block !important;
    width: 100% !important;
    background-color: #DC2626 !important;
    color: white !important;
    padding: 0.5rem !important;
    border-radius: 0.5rem !important;
    font-weight: 600 !important;
    text-align: center !important;
    text-decoration: none !important;
    transition: background-color 0.3s ease !important;
}

.project-card .block.w-full:hover {
    background-color: #B91C1C !important;
}

/* تحسين أزرار المدونة */
.blog-card .flex.items-center.justify-between a,
.blog-post .flex.items-center.justify-between a {
    color: #DC2626 !important;
    font-weight: 600 !important;
    text-decoration: none !important;
    transition: color 0.3s ease !important;
}

.blog-card .flex.items-center.justify-between a:hover,
.blog-post .flex.items-center.justify-between a:hover {
    color: #B91C1C !important;
    text-decoration: underline !important;
}

/* ===== تحسين التخطيط للمعلومات الإضافية ===== */
.card-meta,
.product-card .flex.justify-between.items-center.mb-4,
.project-card .flex.justify-between.items-center.mb-4,
.project-card .grid.grid-cols-2.gap-4.mb-4 {
    margin-bottom: 0.75rem !important;
}

/* تحسين العناصر الفرعية */
.card-badges,
.product-card .flex.gap-2.mb-4,
.project-card .flex.justify-between.items-center.mb-4 span {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 0.5rem !important;
    margin-bottom: 0.75rem !important;
}

/* ===== تحسين الاستجابة للجوال ===== */
@media (max-width: 768px) {
    .service-card .flex.justify-between.items-center {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.5rem !important;
    }
    
    .service-card .flex.justify-between.items-center a:first-child {
        text-align: center !important;
        padding: 0.5rem !important;
        border: 1px solid #DC2626 !important;
        border-radius: 0.5rem !important;
        background-color: transparent !important;
    }
    
    .product-card .flex.gap-2 {
        flex-direction: column !important;
    }
    
    .card-description,
    .service-card .text-brand-gray,
    .product-card .text-gray-600,
    .project-card .text-gray-600,
    .blog-card .text-brand-gray,
    .blog-post .text-gray-600 {
        -webkit-line-clamp: 3 !important;
        max-height: 4.5em !important;
    }
}

/* ===== تحسين تأثيرات الـ hover ===== */
.service-card:hover,
.product-card:hover,
.project-card:hover,
.blog-card:hover,
.blog-post:hover {
    transform: translateY(-4px) !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1) !important;
    transition: all 0.3s ease !important;
}

/* ===== ضمان تطبيق التخطيط ===== */
.service-card img,
.product-card img,
.project-card img,
.blog-card img,
.blog-post img {
    width: 100% !important;
    height: 12rem !important; /* 48 = h-48 */
    object-fit: cover !important;
}

/* تأكيد أن الكاردز تأخذ الارتفاع الكامل */
.grid > .service-card,
.grid > .product-card,
.grid > .project-card,
.grid > .blog-card,
.grid > .blog-post {
    height: auto !important;
    min-height: 400px !important;
}

/* خاص للفئات الثانوية */
.card-category,
.service-card .text-sm.text-gray-500,
.product-card .text-sm.text-gray-500,
.project-card .text-sm.text-gray-500 {
    font-size: 0.875rem !important;
    color: #6B7280 !important;
    margin-bottom: 0.5rem !important;
}

/* ===== إصلاح مشاكل محددة ===== */

/* إصلاح مشكلة overflow في العناوين الطويلة */
.card-title {
    word-wrap: break-word !important;
    hyphens: auto !important;
}

/* إصلاح مشكلة المسافات */
.service-card .p-6 > *:not(:last-child),
.product-card .p-6 > *:not(:last-child),
.project-card .p-6 > *:not(:last-child),
.blog-card .p-6 > *:not(:last-child),
.blog-post .p-6 > *:not(:last-child) {
    margin-bottom: 0.75rem !important;
}

/* التأكد من أن آخر عنصر (الأزرار) دائماً في الأسفل */
.service-card .p-6 > *:last-child,
.product-card .p-6 > *:last-child,
.project-card .p-6 > *:last-child,
.blog-card .p-6 > *:last-child,
.blog-post .p-6 > *:last-child {
    margin-top: auto !important;
    margin-bottom: 0 !important;
}

/* ===== خاص بالصفحة الرئيسية ===== */
.grid.grid-cols-1.md\\:grid-cols-2.lg\\:grid-cols-3 {
    align-items: stretch !important;
}

/* للكاردز التي تحتوي على معلومات إضافية */
.project-card .grid.grid-cols-2 div {
    padding: 0.25rem 0 !important;
}

.project-card .grid.grid-cols-2 .text-gray-500 {
    font-size: 0.75rem !important;
    margin-bottom: 0.25rem !important;
}

.project-card .grid.grid-cols-2 .font-semibold {
    font-weight: 600 !important;
    color: #374151 !important;
}
