/* ═══════════════════════════════════════════════════════════
   Alfaisal Academy — Card System v7
   Compact · 4-per-row · Dark Text · Red CTA
   ═══════════════════════════════════════════════════════════ */

:root {
    --af-r: 12px;
    --af-r-sm: 8px;
    --af-shadow: 0 1px 4px rgba(0,0,0,0.05), 0 2px 10px rgba(0,0,0,0.04);
    --af-shadow-hover: 0 6px 24px rgba(0,0,0,0.1);
    --af-blue: #2E86C1;
    --af-blue-dark: #1B4F72;
    --af-blue-l: #3498DB;
    --af-blue-50: #EBF5FB;
    --af-red: #DC2626;
    --af-red-dark: #B91C1C;
    --af-green: #10B981;
    --af-green-50: #ecfdf5;
    --af-amber: #F59E0B;
    --af-amber-50: #fffbeb;
    --af-txt: #1a1a2e;
    --af-txt-2: #64748b;
    --af-txt-3: #94a3b8;
    --af-border: #e5e7eb;
    --af-font: 'Noto Kufi Arabic', 'Cairo', system-ui, sans-serif;
    --af-ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* ═══════════════════════════════════════════════════════════
   GRID CARD
   ═══════════════════════════════════════════════════════════ */
.af-card {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: var(--af-r);
    box-shadow: var(--af-shadow);
    overflow: hidden;
    transition: transform 0.3s var(--af-ease), box-shadow 0.3s var(--af-ease);
    height: 100%;
    font-family: var(--af-font);
    border: 1px solid var(--af-border);
}
.af-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--af-shadow-hover);
}

/* ── Image ── */
.af-card__img {
    position: relative;
    display: block;
    height: 150px;
    overflow: hidden;
    flex-shrink: 0;
    text-decoration: none !important;
    background: #e8edf2;
}
.af-card__img > img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s var(--af-ease);
}
.af-card:hover .af-card__img > img {
    transform: scale(1.05);
}
.af-card__overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 55%, rgba(0,0,0,0.18) 100%);
    pointer-events: none;
}

/* Teacher avatar badge */
.af-card__teacher-badge {
    position: absolute;
    bottom: 10px;
    left: 10px;
    z-index: 5;
}
[dir="rtl"] .af-card__teacher-badge {
    left: auto;
    right: 10px;
}
.af-card__teacher-badge img {
    width: 38px !important;
    height: 38px !important;
    border-radius: 50% !important;
    object-fit: cover;
    border: 2.5px solid #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
    background: #fff;
}

/* Progress bar */
.af-card__prog {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 3px;
    background: rgba(255,255,255,0.2);
    z-index: 5;
}
.af-card__prog-fill {
    height: 100%;
    background: linear-gradient(90deg, #10B981, #34D399);
    border-radius: 0 3px 3px 0;
}
[dir="rtl"] .af-card__prog-fill { border-radius: 3px 0 0 3px; }

/* ── Body ── */
.af-card__body {
    display: flex;
    flex-direction: column;
    padding: 12px 14px 14px;
    gap: 0;
    flex: 1;
}

/* Title */
.af-card__title {
    font-size: 13.5px;
    font-weight: 700;
    line-height: 1.6;
    color: #111 !important;
    margin: 0 0 4px;
    text-decoration: none !important;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.2s;
}
.af-card__title:hover { color: var(--af-blue) !important; }

/* Description */
.af-card__desc {
    font-size: 11.5px;
    line-height: 1.55;
    color: #4b5563;
    margin: 0 0 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Duration row */
.af-card__dur {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11.5px;
    color: #6b7280;
    margin-bottom: 6px;
}
.af-card__dur svg {
    color: #6b7280;
    flex-shrink: 0;
    opacity: 0.85;
}

/* ── Price Block ── */
.af-card__price-block {
    margin-top: auto;
    padding-top: 6px;
}
.af-card__price-val {
    display: block;
    font-size: 15px;
    font-weight: 800;
    color: #111;
    line-height: 1.3;
}
.af-card__price-val--free {
    color: var(--af-green);
    font-size: 15px;
}
.af-card__price-old {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #9ca3af;
    text-decoration: line-through;
    line-height: 1.2;
    margin-bottom: 2px;
}
.af-card__sar-icon--old {
    opacity: 0.35 !important;
    width: 10px !important;
    height: 10px !important;
}
.af-card__sar {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    margin-inline-start: 2px;
}
.af-card__sar-icon {
    display: inline-block !important;
    width: 12px !important;
    height: 12px !important;
    max-width: 12px !important;
    max-height: 12px !important;
    object-fit: contain !important;
    vertical-align: baseline !important;
    margin-inline-start: 2px !important;
    opacity: 0.65;
    position: relative;
    top: -1px;
}

/* ── RED CTA Button ── */
.af-card__cta {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    padding: 8px 14px !important;
    background: var(--af-red) !important;
    color: #fff !important;
    font-size: 12.5px !important;
    font-weight: 700 !important;
    border-radius: var(--af-r-sm) !important;
    text-decoration: none !important;
    transition: background 0.25s ease, transform 0.2s ease;
    margin-top: 8px;
    border: none !important;
    cursor: pointer;
    height: auto !important;
    line-height: 1.4 !important;
    box-shadow: none !important;
    letter-spacing: 0.01em;
}
.af-card__cta:hover,
.af-card__cta:focus,
.af-card__cta:active {
    background: var(--af-red-dark) !important;
    color: #fff !important;
    text-decoration: none !important;
    box-shadow: 0 4px 12px rgba(220,38,38,0.3) !important;
    transform: translateY(-1px);
}

/* ═══════════════════════════════════════════════════════════
   LEGACY COMPAT
   ═══════════════════════════════════════════════════════════ */
.af-card__content { display: flex; flex-direction: column; padding: 16px 18px 18px; flex: 1; }
.af-card__image-wrap { position: relative; display: block; height: 190px; overflow: hidden; flex-shrink: 0; text-decoration: none; }
.af-card__image-wrap img { width: 100%; height: 100%; object-fit: cover; }
.af-card__bottom { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 10px; border-top: 1px solid #f0f0f0; gap: 6px; }
.af-card__title-link { text-decoration: none; color: inherit; }
.af-card__title-link h3 { font-size: 14.5px; font-weight: 700; line-height: 1.7; color: var(--af-txt); margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.af-card__btn { display: flex !important; align-items: center !important; justify-content: center !important; width: 100% !important; padding: 10px 16px !important; background: var(--af-red) !important; color: #fff !important; font-size: 13.5px !important; font-weight: 700 !important; border-radius: var(--af-r-sm) !important; text-decoration: none !important; transition: background 0.25s ease; margin-top: 10px; border: none !important; height: auto !important; }
.af-card__btn:hover { background: var(--af-red-dark) !important; color: #fff !important; }
.af-card__price-now { font-size: 17px; font-weight: 800; color: var(--af-txt); }
.af-card__price-old { font-size: 11px; color: var(--af-txt-3); text-decoration: line-through; }
.af-card__price-free { font-size: 15px; font-weight: 800; color: var(--af-green); }
.af-card__price-points { font-size: 13px; font-weight: 700; color: var(--af-amber); }
.af-card__price-current { font-size: 17px; font-weight: 800; color: var(--af-txt); }
.af-card__price { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; min-width: 0; }
.af-card__now { font-size: 17px; font-weight: 800; color: var(--af-txt); }
.af-card__old { font-size: 11px; color: var(--af-txt-3); text-decoration: line-through; }
.af-card__free { font-size: 15px; font-weight: 800; color: var(--af-green); }
.af-card__pts { font-size: 13px; font-weight: 700; color: var(--af-amber); }
.af-card__foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 10px; border-top: 1px solid #f0f0f0; gap: 6px; }
.af-card__footer { display: flex; align-items: center; justify-content: space-between; padding: 10px 18px 14px; border-top: 1px solid #f0f0f0; margin-top: auto; gap: 6px; }
.af-card__figure { margin: 0; padding: 0; display: flex; flex-direction: column; flex: 1; }

/* Legacy price-main — for old templates still using handlePrice */
.af-card__price-main {
    display: flex !important;
    align-items: center !important;
    font-size: 17px !important;
    font-weight: 800 !important;
    color: var(--af-txt) !important;
    line-height: 1.4 !important;
    gap: 4px;
}
.af-card__price-main img,
.af-card__price-main .riyal-icon,
.af-card__price-main .riyal-icon svg {
    width: 14px !important;
    height: 14px !important;
    max-width: 14px !important;
    max-height: 14px !important;
    vertical-align: middle;
}

/* Force all SAR icons inside any card price area to stay small */
.af-card__price-block img,
.af-card__price-val img,
.af-card img[alt="SAR"] {
    width: 12px !important;
    height: 12px !important;
    max-width: 12px !important;
    max-height: 12px !important;
    display: inline-block !important;
    vertical-align: baseline !important;
}
.af-card__installment {
    display: block;
    font-size: 11px;
    color: var(--af-blue);
    font-weight: 600;
    margin-top: 2px;
}

/* Legacy teacher/instructor */
.af-card__teacher { display: flex; align-items: center; gap: 6px; min-width: 0; }
.af-card__teacher img { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.af-card__teacher span { font-size: 11px; font-weight: 600; color: var(--af-txt-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.af-card__instructor-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.af-card__instructor { display: flex; align-items: center; gap: 6px; min-width: 0; }
.af-card__instructor-avatar { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.af-card__instructor-name { font-size: 11px; font-weight: 600; color: var(--af-txt-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.af-card__students-count { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--af-txt-3); flex-shrink: 0; }
.af-card__students-count svg { width: 12px; height: 12px; }

/* Legacy positioned elements */
.af-card__category { position: absolute; top: 10px; left: 10px; padding: 4px 10px; background: rgba(255,255,255,0.92); backdrop-filter: blur(8px); border-radius: 6px; font-size: 10.5px; font-weight: 700; color: var(--af-blue); z-index: 4; }
[dir="rtl"] .af-card__category { left: auto; right: 10px; }
.af-card__duration-tag { position: absolute; bottom: 10px; left: 10px; display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; background: rgba(0,0,0,0.55); border-radius: 6px; font-size: 10.5px; font-weight: 600; color: #fff; z-index: 4; }
[dir="rtl"] .af-card__duration-tag { left: auto; right: 10px; }
.af-card__image-overlay { position: absolute; inset: 0; background: linear-gradient(180deg, transparent 55%, rgba(0,0,0,0.18) 100%); pointer-events: none; }
.af-card__progress { position: absolute; bottom: 0; left: 0; right: 0; height: 3px; background: rgba(255,255,255,0.15); z-index: 5; }
.af-card__progress-bar { height: 100%; background: linear-gradient(90deg, #10B981, #34D399); border-radius: 0 3px 3px 0; }
[dir="rtl"] .af-card__progress-bar { border-radius: 3px 0 0 3px; }
.af-card__badges { position: absolute; top: 10px; right: 10px; display: flex; flex-direction: column; gap: 4px; z-index: 5; }
[dir="rtl"] .af-card__badges { right: auto; left: 10px; }
.af-badge { display: inline-flex; align-items: center; gap: 3px; padding: 3px 8px; border-radius: 6px; font-size: 10px; font-weight: 700; color: #fff; white-space: nowrap; }
.af-badge--discount { background: #EF4444; }
.af-badge--featured { background: #F59E0B; }
.af-badge--info { background: var(--af-blue-l); }
.af-badge--secondary { background: rgba(0,0,0,0.5); }
.af-card__bell { position: absolute; top: 10px; left: 10px; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,0.9); border-radius: 50%; color: var(--af-txt-2); text-decoration: none; box-shadow: 0 1px 6px rgba(0,0,0,0.08); z-index: 5; transition: all 0.25s ease; }
[dir="rtl"] .af-card__bell { left: auto; right: 10px; }
.af-card__bell:hover { background: #fff; color: var(--af-blue); transform: scale(1.1); }
.af-card__bell--sm { position: relative; top: auto; left: auto; right: auto; width: 24px; height: 24px; flex-shrink: 0; }
.af-card__category-float { position: absolute; bottom: 10px; left: 10px; z-index: 4; }
[dir="rtl"] .af-card__category-float { left: auto; right: 10px; }
.af-card__category-link { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; background: rgba(255,255,255,0.9); border-radius: 6px; font-size: 10.5px; font-weight: 700; color: var(--af-blue); text-decoration: none; box-shadow: 0 1px 6px rgba(0,0,0,0.08); transition: all 0.25s ease; }
.af-card__category-link:hover { background: #fff; }

/* Category in body */
.af-card__cat { font-size: 11px; font-weight: 600; color: var(--af-txt-3); display: block; margin-bottom: 2px; }

/* Rating */
.af-card__rating { display: flex; align-items: center; gap: 3px; margin-bottom: 4px; }
.af-card__stars { display: inline-flex; align-items: center; gap: 1px; }
.af-card__stars svg.star-on { color: var(--af-amber); }
.af-card__stars svg.star-off { color: #d1d5db; }
.af-card__rate-val { font-size: 12px; font-weight: 700; color: var(--af-txt); margin-inline-start: 3px; }
.af-card__rate-count { font-size: 11px; color: var(--af-txt-3); }
.af-card__dur-sep { color: var(--af-txt-3); margin: 0 1px; }

/* Stars legacy compat */
.af-card__stars .stars-card { display: flex; align-items: center; gap: 1px; margin: 0; }
.af-card__stars .stars-card svg, .af-card__stars .stars-card i { width: 14px; height: 14px; }
.af-card__stars .stars-card i.active { color: var(--af-amber); fill: var(--af-amber); }
.af-card__stars .badge { font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 5px; background: var(--af-amber-50); color: var(--af-amber); border: none; }
.af-card__rating .stars-card { display: flex; align-items: center; gap: 1px; margin: 0; }
.af-card__rating .stars-card svg, .af-card__rating .stars-card i { width: 14px; height: 14px; }

/* Meta helpers */
.af-card__meta { display: flex; align-items: center; gap: 8px; }
.af-card__rate-num { font-size: 12px; font-weight: 700; color: var(--af-txt); margin-inline-start: 3px; }
.af-card__dot { width: 3px; height: 3px; border-radius: 50%; background: var(--af-txt-3); flex-shrink: 0; }
.af-card__students { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--af-txt-3); }
.af-card__students svg { opacity: 0.7; }
.af-card__meta-item { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--af-txt-2); }
.af-card__meta-item svg { width: 13px; height: 13px; color: var(--af-txt-3); flex-shrink: 0; }
.af-card__meta-dot, .af-card__meta-divider { width: 3px; height: 3px; border-radius: 50%; background: var(--af-txt-3); flex-shrink: 0; }
.af-card__info-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: auto; }


/* ═══════════════════════════════════════════════════════════
   LIST CARD
   ═══════════════════════════════════════════════════════════ */
.af-list-card {
    display: flex;
    flex-direction: row;
    background: #fff;
    border-radius: var(--af-r);
    box-shadow: var(--af-shadow);
    border: 1px solid var(--af-border);
    overflow: hidden;
    transition: transform 0.3s var(--af-ease), box-shadow 0.3s var(--af-ease);
    height: 100%;
    font-family: var(--af-font);
    position: relative;
}
.af-list-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--af-shadow-hover);
}
.af-list-card__image-wrap { position: relative; width: 240px; min-width: 200px; flex-shrink: 0; overflow: hidden; }
.af-list-card__image-link { display: block; width: 100%; height: 100%; }
.af-list-card__image { width: 100%; height: 100%; object-fit: cover; transition: transform 0.45s var(--af-ease); }
.af-list-card:hover .af-list-card__image { transform: scale(1.04); }
.af-list-card__body { flex: 1; display: flex; flex-direction: column; padding: 14px 16px; gap: 6px; min-width: 0; }
.af-list-card__category { font-size: 12px; color: var(--af-txt-3); }
.af-list-card__category a { color: var(--af-blue); text-decoration: none; font-weight: 600; }
.af-list-card__bottom { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 10px; border-top: 1px solid #f0f0f0; gap: 10px; }


/* ═══════════════════════════════════════════════════════════
   HOME SECTIONS — FULL WIDTH
   ═══════════════════════════════════════════════════════════ */
.home-sections { margin-top: 50px; }
.home-sections.container,
section.home-sections.container,
div.home-sections.container {
    max-width: 100% !important;
    width: 100% !important;
    padding-left: 48px;
    padding-right: 48px;
}
.home-sections .d-flex.justify-content-between {
    align-items: flex-end;
    margin-bottom: 4px;
}
.home-sections .section-title {
    font-size: 24px;
    font-weight: 800;
    color: var(--af-blue-dark);
    position: relative;
    padding-bottom: 10px;
    margin-bottom: 0;
}
.home-sections .section-title::after {
    content: '';
    position: absolute;
    bottom: 0; right: 0;
    width: 40px; height: 3px;
    background: var(--af-blue);
    border-radius: 3px;
}
[dir="ltr"] .home-sections .section-title::after { right: auto; left: 0; }
.home-sections .section-hint {
    font-size: 13px;
    color: var(--af-txt-3);
    margin-top: 4px;
    line-height: 1.5;
}
.home-sections .btn-border-white {
    border: 2px solid var(--af-blue);
    color: var(--af-blue);
    background: transparent;
    font-weight: 700;
    font-size: 12px;
    border-radius: var(--af-r-sm);
    padding: 7px 18px;
    transition: all 0.25s ease;
    text-decoration: none;
    white-space: nowrap;
}
.home-sections .btn-border-white:hover {
    background: var(--af-blue);
    color: #fff;
}


/* ═══════════════════════════════════════════════════════════
   SWIPER ALIGNMENT
   ═══════════════════════════════════════════════════════════ */
.home-sections-swiper .swiper-slide {
    height: auto;
    display: flex;
}
.home-sections-swiper .swiper-slide > .af-card,
.home-sections-swiper .swiper-slide > .af-list-card {
    flex: 1;
}


/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 1200px) {
    .af-card__img { height: 140px; }
    .af-card__body { padding: 12px 14px 14px; }
}

@media (max-width: 991px) {
    .af-card__img { height: 135px; }
    .home-sections.container,
    section.home-sections.container,
    div.home-sections.container {
        padding-left: 24px;
        padding-right: 24px;
    }
    .af-card__body, .af-card__content { padding: 10px 12px 12px; }
    .af-card__title, .af-card__title-link h3 { font-size: 12.5px; }
    .af-card__desc { font-size: 10.5px; -webkit-line-clamp: 2; }
    .af-card__cta, .af-card__btn { padding: 7px 12px !important; font-size: 12px !important; }
    .af-card__price-val { font-size: 14px; }
    .af-list-card__image-wrap { width: 200px; min-width: 180px; }
    .home-sections .section-title { font-size: 20px; }
    .home-sections { margin-top: 40px; }
}

@media (max-width: 767px) {
    .af-card__img { height: 130px; }
    .home-sections.container,
    section.home-sections.container,
    div.home-sections.container {
        padding-left: 16px;
        padding-right: 16px;
    }
    .af-list-card { flex-direction: column; }
    .af-list-card__image-wrap { width: 100%; min-width: 100%; height: 180px; }
    .af-list-card__body { padding: 12px 14px; }
    .af-card__footer, .af-card__foot { flex-wrap: wrap; }
    .home-sections .section-title { font-size: 18px; }
    .home-sections .btn-border-white { padding: 5px 14px; font-size: 11px; }
    .af-card__teacher-badge img { width: 32px !important; height: 32px !important; }
}

@media (max-width: 480px) {
    .af-card__img { height: 120px; }
    .af-card__body, .af-card__content { padding: 8px 10px 10px; }
    .af-card__title, .af-card__title-link h3 { font-size: 12px; }
    .af-card__desc { -webkit-line-clamp: 2; font-size: 10px; }
    .af-card__cta, .af-card__btn { padding: 7px 10px !important; font-size: 11px !important; }
    .af-card__price-val, .af-card__now, .af-card__price-now { font-size: 14px; }
    .af-card__cat, .af-card__category { font-size: 10px; }
    .af-card__teacher-badge img { width: 28px !important; height: 28px !important; }
}


/* ═══════════════════════════════════════════════════════════
   ANIMATION
   ═══════════════════════════════════════════════════════════ */
@keyframes af-card-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
.af-card, .af-list-card {
    animation: af-card-in 0.35s ease both;
}
.swiper-slide:nth-child(2) .af-card,
.swiper-slide:nth-child(2) .af-list-card { animation-delay: 0.05s; }
.swiper-slide:nth-child(3) .af-card,
.swiper-slide:nth-child(3) .af-list-card { animation-delay: 0.1s; }
.swiper-slide:nth-child(4) .af-card,
.swiper-slide:nth-child(4) .af-list-card { animation-delay: 0.15s; }


/* ═══════════════════════════════════════════════════════════
   PRINT
   ═══════════════════════════════════════════════════════════ */
@media print {
    .af-card__overlay, .af-card__cta, .af-card__btn,
    .af-card__badges, .af-card__teacher-badge { display: none; }
    .af-card, .af-list-card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
}
