/**
 * Events Slider Styles
 *
 * Responsive slider for displaying upcoming events
 * Optimized for RTL (Arabic) websites
 * Designed to fit within any container width
 *
 * @package Events_Management_System
 * @version 1.0.0
 */

/* Ensure slider respects parent container width */
.events-slider-container * {
    box-sizing: border-box;
}

.events-slider-container {
    position: relative;
    width: 100% !important;
    max-width: none !important;
    margin: 0 auto;
    direction: rtl;
    box-sizing: border-box;
    overflow: hidden; /* منع أي تجاوز للحدود */
    transform: translateZ(0); /* Create stacking context */
}

.events-slider-wrapper {
    position: relative;
    width: 100%;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    box-sizing: border-box;
}

.events-slider {
    display: flex;
    width: 100%;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
    box-sizing: border-box;
    transform: translateZ(0); /* Force GPU acceleration */
    backface-visibility: hidden; /* Prevent flickering */
    perspective: 1000px;
}

.events-slide {
    min-width: 100%;
    width: 100%;
    flex-shrink: 0;
    height: 300px; 
    box-sizing: border-box;
    background-color: #F8F9FA;
    transform: translateZ(0); /* GPU acceleration */
    will-change: transform;
}

.event-card {
    display: block;
    text-decoration: none;
    color: inherit;
    overflow: hidden;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
    height: 100%;
    width: 100%;
    box-sizing: border-box;
    will-change: transform;
}

.event-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
    text-decoration: none;
    color: inherit;
}

.event-image {
    position: relative;
    width: 100%;
    height: 200px;
    overflow: hidden;
    box-sizing: border-box;
    background-color: #f0f0f0; /* Placeholder background */
}

.event-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    max-width: 100%;
    display: block;
    will-change: transform;
    opacity: 1;
}

.event-card:hover .event-image img {
    transform: scale(1.05);
}

.event-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, rgba(0,0,0,0.7), rgba(0,0,0,0.3));
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.event-card:hover .event-overlay {
    opacity: 1;
}

.event-view-text {
    color: white;
    font-weight: 600;
    font-size: 16px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.event-content {
    padding: 20px;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-sizing: border-box;
}

.event-title {
    font-size: var(--font-lg);
    font-weight: 700;
    margin: 0 0 6px 0; /* تقليل المسافة من 12px إلى 6px */
    line-height: 1.3;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: 46px; /* ارتفاع محدد لسطرين */
    word-wrap: break-word;
}

.event-meta {
    flex-shrink: 0;
}

.event-date,
.event-location {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 4px; /* تقليل المسافة من 6px إلى 4px */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.event-date svg,
.event-location svg {
    flex-shrink: 0;
    opacity: 0.7;
    min-width: 16px;
}

.event-date span,
.event-location span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.event-date:last-child,
.event-location:last-child {
    margin-bottom: 0;
}

/* Dots indicator */
.events-slider-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 10px;
    margin-bottom:10px;
    width: 100%;
    box-sizing: border-box;
}

.events-slider-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--gray-pale);
    cursor: pointer;
    transition: all 0.3s ease;
}

.events-slider-dot.active {
    background: var(--accent);
    transform: scale(1.2);
}

.events-slider-dot:hover {
    background: var(--gray-medium);
    transform: scale(1.1);
}

/* No events message */
.events-no-content {
    text-align: center;
    padding: 60px 20px;
    background: #f8f9fa;
    border-radius: var(--border-radius-md);
    border: 2px dashed #dee2e6;
}

.no-events-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.7;
}

.events-no-content h3 {
    color: #6c757d;
    margin: 0 0 8px 0;
    font-size: 20px;
}

.events-no-content p {
    color: #adb5bd;
    margin: 0;
    font-size: 14px;
}

/* Responsive design */
@media (max-width: 768px) {
    .events-slide {
        height: 280px; /* ارتفاع أقل للشاشات الصغيرة */
        width: 100%;
    }

    .event-image {
        height: 140px;
        width: 100%;
    }

    .event-content {
        padding: 15px;
        height: 100px;
        width: 100%;
    }

    .event-title {
        font-size: 16px;
        max-height: 40px; /* ارتفاع أقل للعنوان */
        line-height: 1.25;
    }

    .events-slider-dots {
        margin-top: 15px;
        width: 100%;
    }

    .events-slider-dot {
        width: 10px;
        height: 10px;
    }
}

@media (max-width: 480px) {
    .events-slide {
        height: 260px; /* ارتفاع أقل للهواتف */
        width: 100%;
    }

    .event-image {
        height: 120px;
        width: 100%;
    }

    .event-content {
        padding: 12px;
        height: 90px;
        width: 100%;
    }

    .event-title {
        font-size: 15px;
        max-height: 36px;
        line-height: 1.2;
        margin-bottom: 4px; /* تقليل المسافة من 8px إلى 4px */
    }

    .event-date,
    .event-location {
        font-size: 13px;
        margin-bottom: 2px; /* تقليل المسافة من 4px إلى 2px */
    }

    .event-date svg,
    .event-location svg {
        width: 14px;
        height: 14px;
    }

    .events-slider-dots {
        width: 100%;
    }
}

/* Optimize for slow connections */
@media (prefers-reduced-motion: reduce) {
    .events-slider,
    .event-image img,
    .event-card {
        transition-duration: 0.01ms !important;
    }
}

/* Special styles for narrow containers (like 1/3 width columns) */
@media (max-width: 600px), (max-width: 1200px) and (min-width: 769px) {
    .events-slider-container {
        font-size: 14px; /* خط أصغر للمساحات الضيقة */
    }

    .event-title {
        font-size: 16px;
        line-height: 1.2;
    }

    .event-date,
    .event-location {
        font-size: 12px;
    }

    .event-content {
        padding: 15px;
    }
}

/* Very narrow containers */
@container (max-width: 400px) {
    .event-title {
        font-size: 14px;
        max-height: 32px;
    }

    .event-content {
        padding: 12px;
    }

    .event-date,
    .event-location {
        font-size: 11px;
    }
}
