/* ==========================================
   1. SCOPE & RESET (جلوگیری از تداخل)
========================================== */
.em-grid-container, .em-nearest-container {
    box-sizing: border-box;
    direction: rtl; /* راست‌چین استاندارد */
    font-family: inherit;
    margin-bottom: 50px;
    line-height: 1.6;
}
.em-grid-container *, .em-nearest-container * {
    box-sizing: inherit;
}

/* ==========================================
   2. GRID SYSTEM (گرید ۳ ستونه استاندارد)
========================================== */
.em-grid-container {
    display: grid;
    /* در موبایل 1 ستون */
    grid-template-columns: 1fr;
    gap: 30px;
}

/* در تبلت 2 ستون */
@media (min-width: 768px) {
    .em-grid-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* در دسکتاپ دقیقاً 3 ستون */
@media (min-width: 1024px) {
    .em-grid-container {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ==========================================
   3. CARDS (کارت‌های رویداد با ارتفاع برابر)
========================================== */
.em-card {
    background: #ffffff;
    border-radius: 16px;
    border: 1px solid #f1f5f9;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    display: flex;
    flex-direction: column;
    height: 100%; /* کشیدگی کامل برای ارتفاع برابر */
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.em-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.em-card-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* پر کردن فضای خالی تا دکمه‌ها پایین بمانند */
}

/* ==========================================
   4. IMAGES
========================================== */
.em-img-top, .em-img-fluid {
    width: 100%;
    height: 220px;
    object-fit: cover;
    margin: 0;
    border-bottom: 1px solid #f8fafc;
}

.em-no-img {
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    color: #64748b;
    height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: bold;
}
/* ==========================================
   5. NEAREST EVENT (طراحی جدید عکس و بلور)
========================================== */
.em-nearest-inner {
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-radius: 24px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    transition: transform 0.3s ease;
}
.em-nearest-inner:hover { transform: scale(1.01); }

@media (min-width: 992px) {
    .em-nearest-inner {
        flex-direction: row;
        align-items: stretch; /* کشیده شدن باکس عکس هم‌اندازه با باکس متن */
        min-height: 380px;
    }
    .em-nearest-image { width: 45%; }
    .em-nearest-content { width: 55%; padding: 40px 50px; }
}

/* استایل کانتینر تصویر ویژه */
.em-nearest-image {
    position: relative;
    background-color: #0f172a;
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 15px; /* ۱۵ پیکسل بالا + ۱۵ پیکسل پایین = دقیقا ۳۰ پیکسل کمتر از ارتفاع کل باکس */
}

/* لایه بک‌گراند بلور شده (ارث‌بری عکس از دایو اصلی) */
.em-nearest-image::before {
    content: "";
    position: absolute;
    top: -30px; left: -30px; right: -30px; bottom: -30px; /* سایز بزرگتر برای مخفی کردن حاشیه تاری */
    background: inherit; /* این دستور باعث میشه عکس دایو پدر رو به عنوان بکگراند بشناسه */
    filter: blur(25px) brightness(0.4); /* تاریک و بلور کردن بکگراند */
    z-index: 1;
}

/* لینک پاپ‌آپ */
.em-popup-link {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    cursor: zoom-in;
}

/* عکس پوستر (بدون برش، در مرکز) */
.em-popup-link img {
    max-width: 85% !important;
    max-height: 100% !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain;
    border-radius: 12px !important;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6) !important;
    transition: transform 0.3s;
}
.em-popup-link:hover img { transform: scale(1.03); }

/* تنظیم ارتفاع برای موبایل */
@media (max-width: 991px) {
    .em-nearest-image { height: 350px; }
    .em-nearest-content { padding: 30px 20px; }
}

.em-nearest-content { display: flex; flex-direction: column; justify-content: center; }
.em-nearest-title { margin: 0 0 20px 0; font-size: 1.6rem; font-weight: 800; color: #0f172a; }

/* ==========================================
   6. COUNTDOWN TIMER (اعمال استایل درخواستی شما)
========================================== */
.em-countdown-box {
    background: #f8fafc;
    border-radius: 16px;
    padding: 20px;
    margin: 25px 0;
    border: 1px solid #e2e8f0;
    direction: ltr !important; /* اعمال دقیق کد شما */
}
.em-cd-grid {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}
.em-cd-col {
    background: #ffffff;
    border-radius: 12px;
    padding: 12px 5px;
    flex: 1;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    border: 1px solid #f1f5f9;
    direction: rtl; /* برای اینکه جای عدد و حروف داخل باکسِ ستون‌ها به هم نریزد */
}
.em-cd-col span {
    display: block;
    font-size: 1.6rem;
    font-weight: 900;
    color: #2563eb;
    line-height: 1.2;
    margin-bottom: 4px;
}
.em-cd-col small { font-size: 0.8rem; color: #64748b; font-weight: 600; }
.em-started-msg {
    color: #dc2626;
    font-weight: bold;
    text-align: center;
    padding: 15px;
    background: #fef2f2;
    border-radius: 12px;
    border: 1px solid #fecaca;
}
/* ==========================================
   7. TYPOGRAPHY & META
========================================== */
.em-section-title {
    margin: 0 0 25px 0;
    font-size: 1.6rem;
    font-weight: 800;
    color: #1e293b;
    position: relative;
    padding-right: 15px;
}

.em-section-title::before {
    content: "";
    position: absolute;
    right: 0;
    top: 10%;
    height: 80%;
    width: 4px;
    background: #2563eb;
    border-radius: 4px;
}

.em-card-title {
    font-size: 1.15rem;
    font-weight: 800;
    margin: 0 0 15px 0;
    line-height: 1.6;
}

.em-card-title a, .em-nearest-title a {
    color: #0f172a;
    text-decoration: none;
    transition: color 0.2s;
}

.em-card-title a:hover, .em-nearest-title a:hover {
    color: #3b82f6;
}

.em-card-meta, .em-nearest-meta {
    font-size: 0.9rem;
    color: #64748b;
    margin: 0 0 10px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.em-card-meta strong, .em-nearest-meta strong {
    color: #334155;
}

/* ==========================================
   8. BUTTONS & BADGES
========================================== */
.em-btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 700;
    text-decoration: none;
    transition: all 0.3s ease;
    margin-top: auto; /* کلیدی ترین کد برای قرارگیری دکمه در انتهای کارت */
    cursor: pointer;
    box-sizing: border-box;
    border: none;
}

.em-btn-primary {
    background: #2563eb;
    color: #ffffff !important;
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2);
}
.em-btn-primary:hover { 
    background: #1d4ed8; 
    transform: translateY(-2px);
    box-shadow: 0 6px 8px -1px rgba(37, 99, 235, 0.3);
}

.em-btn-success {
    background: #10b981;
    color: #ffffff !important;
    box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.2);
    font-size: 1.05rem;
    padding: 14px 20px;
}
.em-btn-success:hover { 
    background: #059669; 
    transform: translateY(-2px);
    box-shadow: 0 6px 8px -1px rgba(16, 185, 129, 0.3);
}

.em-btn-outline {
    background: transparent;
    color: #2563eb !important;
    border: 2px solid #e2e8f0;
}
.em-btn-outline:hover { 
    border-color: #2563eb;
    background: #eff6ff;
}

.em-badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 800;
    margin-bottom: 15px;
    align-self: flex-start;
}

.em-badge-danger {
    background: #fef2f2;
    color: #ef4444;
    border: 1px solid #fecaca;
}

.em-text-center { text-align: center; align-items: center; }

/* تنظیمات آیکون‌های تاریخ و مکان */
.em-card-meta i.dashicons, 
.em-nearest-meta i.dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #2563eb; /* رنگ آبی جذاب هماهنگ با دکمه‌ها */
    margin-left: 5px; /* فاصله بین آیکون و متن در حالت راست‌چین */
    opacity: 0.85;
}

/* استایل چکیده برای رویداد بعدی */
.em-nearest-excerpt {
    font-size: 0.95rem;
    color: #475569;
    margin: 10px 0 15px 0;
    line-height: 1.8;
    text-align: justify;
}

/* ==========================================
   10. NO EVENTS MESSAGE (پیام خالی بودن رویدادها)
========================================== */
.em-no-events-message {
    background: #f8fafc;
    border: 2px dashed #cbd5e1; /* حاشیه نقطه‌چین زیبا */
    border-radius: 16px;
    padding: 40px 20px;
    text-align: center;
    color: #64748b;
    margin: 30px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    direction: rtl;
}

.em-no-events-message i.dashicons {
    font-size: 48px;
    width: 48px;
    height: 48px;
    color: #94a3b8; /* رنگ خنثی و هماهنگ */
}

.em-no-events-message p {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}
/* ==========================================
   11. ONGOING EVENTS (رویداد در جریان - تم قرمز)
========================================== */
.em-ongoing-list {
    display: flex;
    flex-direction: column;
    gap: 30px; /* فاصله بین چند رویداد در جریان */
    margin-bottom: 50px;
}

.em-countdown-title {
    text-align: center;
    font-weight: 900;
    color: #ef4444; /* رنگ قرمز */
    font-size: 1.15rem;
    margin-bottom: 15px;
}

/* تغییر رنگ پس‌زمینه و حاشیه‌ها به طیف قرمز */
.em-timer-red {
    background: #fef2f2 !important;
    border-color: #fecaca !important;
}

.em-timer-red .em-cd-col {
    border-color: #fee2e2 !important;
}

.em-timer-red .em-cd-col span {
    color: #ef4444 !important; /* اعداد شمارنده به رنگ قرمز */
}

/* استایل عمومی برای آیکون‌های برگردانده شده (اگر قبلاً اضافه نکردید) */
.em-card-meta i.dashicons, 
.em-nearest-meta i.dashicons {
    font-size: 18px; width: 18px; height: 18px;
    display: inline-flex; align-items: center; justify-content: center;
    color: #2563eb; margin-left: 5px; opacity: 0.85;
}