/* ============================================================
   courses.css — Courses listing page
   Place at: public/assets/qitaf/courses.css
   Full LTR + RTL direction-aware
   ============================================================ */

:root {
    --blue: #006aa3;
    --blue-dark: #004f7a;
    --blue-light: #e8f4fb;
    --blue-mid: #0080c4;
    --text: #0f1923;
    --muted: #64748b;
    --border: #e2eaf2;
    --bg: #f4f7fb;
    --white: #ffffff;
    --gold: #f59e0b;
    --radius: 14px;
    --radius-sm: 8px;
    --shadow: 0 4px 20px rgba(0, 106, 163, 0.07);
    --shadow-hover: 0 12px 40px rgba(0, 106, 163, 0.14);
}

.courses-page {
    background: var(--bg);
    min-height: 100vh;
}

/* ============================================================
   HERO
   ============================================================ */
.courses-hero {
    position: relative;
    height: 300px;
    display: flex;
    align-items: center;
    overflow: hidden;
}

.courses-hero-bg {
    position: absolute;
    inset: 0;
}

.courses-hero-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.courses-hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(0,79,122,0.88) 0%, rgba(0,106,163,0.75) 100%);
}

.courses-hero-inner {
    position: relative;
    z-index: 1;
    width: 100%;
}

.courses-hero-content {
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
}

.courses-hero-title {
    font-size: clamp(22px, 4vw, 40px);
    font-weight: 700;
    color: #fff;
    margin-bottom: 12px;
    line-height: 1.25;
}

.courses-count-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.25);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    padding: 5px 16px;
    border-radius: 30px;
    margin-bottom: 20px;
}

.courses-count-num {
    font-weight: 800;
    font-size: 16px;
}

/* Search bar */
.courses-search-form {
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
}

.courses-search-inner {
    display: flex;
    align-items: center;
    background: #fff;
    border-radius: 50px;
    padding: 6px 6px 6px 16px;
    gap: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

[dir="rtl"] .courses-search-inner {
    padding: 6px 16px 6px 6px;
}

.courses-search-icon {
    width: 18px;
    height: 18px;
    stroke: var(--muted);
    flex-shrink: 0;
}

.courses-search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 14px;
    color: var(--text);
    background: transparent;
    font-family: inherit;
    min-width: 0;
}

.courses-search-input::placeholder { color: #b0bec5; }

.courses-search-btn {
    background: var(--blue);
    color: #fff;
    border: none;
    border-radius: 40px;
    padding: 9px 22px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.courses-search-btn:hover { background: var(--blue-dark); }

/* ============================================================
   BODY LAYOUT
   ============================================================ */
.courses-body {
    padding: 36px 0 64px;
}

.courses-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 28px;
    align-items: start;
}

[dir="rtl"] .courses-layout {
    grid-template-columns: 280px 1fr;
}

@media (max-width: 991px) {
    .courses-layout { grid-template-columns: 1fr; }
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.courses-sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: sticky;
    top: 24px;
}

.sidebar-card {
    background: var(--white);
    border-radius: var(--radius);
    border: 1.5px solid var(--border);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.sidebar-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
    background: #fafcfe;
}

.sidebar-card-header svg {
    width: 18px;
    height: 18px;
    stroke: var(--blue);
    flex-shrink: 0;
}

.sidebar-card-header h3 {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

/* Filter list */
.filter-list {
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.filter-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease;
    position: relative;
    user-select: none;
}

.filter-item:hover {
    background: var(--blue-light);
}

.filter-item.active {
    background: var(--blue-light);
    color: var(--blue);
}

.filter-item.active .filter-count {
    background: var(--blue);
    color: #fff;
}

/* Hide native inputs */
.filter-item input[type="radio"],
.filter-item input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.filter-item-text {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    font-size: 13px;
    color: var(--text);
    font-weight: 500;
    gap: 8px;
}

.filter-item.active .filter-item-text {
    color: var(--blue);
    font-weight: 600;
}

.filter-count {
    font-size: 11px;
    font-weight: 700;
    background: var(--border);
    color: var(--muted);
    padding: 1px 7px;
    border-radius: 10px;
    flex-shrink: 0;
    transition: background 0.18s ease, color 0.18s ease;
}

/* Arrow toggle */
.filter-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    background: var(--border);
    flex-shrink: 0;
    transition: transform 0.25s ease, background 0.2s ease;
    cursor: pointer;
    z-index: 1;
}

.filter-arrow svg { stroke: var(--muted); transition: stroke 0.2s ease; }
.filter-arrow.open { transform: rotate(180deg); background: var(--blue-light); }
.filter-arrow.open svg { stroke: var(--blue); }

/* Subcategory list */
.subcategory-list {
    padding: 4px 8px 8px;
    border-top: 1px dashed var(--border);
    background: #fafcfe;
    display: none;
}

.filter-subitem {
    padding: 7px 8px 7px 20px;
    font-size: 12.5px;
}

[dir="rtl"] .filter-subitem {
    padding: 7px 20px 7px 8px;
}

.filter-subitem .filter-item-text {
    font-size: 12.5px;
}

/* Rating */
.filter-stars {
    display: flex;
    align-items: center;
    gap: 2px;
}

.filter-rating-text {
    font-size: 12px;
    color: var(--muted);
    margin-inline-start: 4px;
}

.filter-item.active .filter-rating-text {
    color: var(--blue);
}

/* Reset button */
.sidebar-reset-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 16px;
    background: #fff;
    border: 1.5px solid #fca5a5;
    border-radius: var(--radius);
    color: #ef4444;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    transition: background 0.2s ease, border-color 0.2s ease;
    font-family: inherit;
}

.sidebar-reset-btn:hover {
    background: #fff5f5;
    color: #dc2626;
}

.sidebar-reset-btn svg { stroke: currentColor; flex-shrink: 0; }

/* ============================================================
   COURSES MAIN
   ============================================================ */
.courses-main {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Results bar */
.courses-results-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--white);
    border-radius: var(--radius);
    padding: 12px 18px;
    border: 1.5px solid var(--border);
    box-shadow: var(--shadow);
    gap: 16px;
    flex-wrap: wrap;
}

.results-count {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.results-in {
    color: var(--blue);
    margin-inline-start: 4px;
}

.results-view-toggle {
    display: flex;
    gap: 4px;
}

.view-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid var(--border);
    color: var(--muted);
    text-decoration: none;
    transition: all 0.2s ease;
}

.view-btn:hover, .view-btn.active {
    background: var(--blue);
    border-color: var(--blue);
    color: #fff;
}

.view-btn svg { stroke: currentColor; }

/* Courses grid */
.courses-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

@media (max-width: 1200px) {
    .courses-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 575px) {
    .courses-grid { grid-template-columns: 1fr; }
}

.course-grid-item {
    animation: cardFadeIn 0.35s ease both;
}

.course-grid-item:nth-child(1) { animation-delay: 0.05s; }
.course-grid-item:nth-child(2) { animation-delay: 0.10s; }
.course-grid-item:nth-child(3) { animation-delay: 0.15s; }
.course-grid-item:nth-child(4) { animation-delay: 0.20s; }
.course-grid-item:nth-child(5) { animation-delay: 0.25s; }
.course-grid-item:nth-child(6) { animation-delay: 0.30s; }

@keyframes cardFadeIn {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Course list */
.courses-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Empty state */
.courses-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 64px 24px;
    color: var(--muted);
    background: var(--white);
    border-radius: var(--radius);
    border: 1.5px dashed var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.courses-empty svg { stroke: var(--border); }
.courses-empty p { font-size: 15px; font-weight: 600; margin: 0; }

/* Pagination */
.courses-pagination {
    padding-top: 8px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 991px) {
    .courses-sidebar {
        position: static;
    }

    .courses-hero { height: 240px; }

    .courses-results-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}

@media (max-width: 575px) {
    .courses-hero { height: 200px; }
    .courses-hero-title { font-size: 20px; }
    .courses-search-inner { border-radius: 14px; }
}

/* ============================================================
   LTR SPECIFIC FIXES
   ============================================================ */
[dir="ltr"] .courses-hero-content { text-align: center; }
[dir="ltr"] .filter-subitem { padding-left: 20px; padding-right: 8px; }
[dir="ltr"] .results-in { margin-left: 4px; margin-right: 0; }
/* ── Tab active state fix ── */
.csd-tab-link {
    /* Remove Bootstrap's default active bg that conflicts */
    background: transparent !important;
}

.csd-tab-link.active {
    color: var(--blue) !important;
    border-bottom-color: var(--blue) !important;
    background: transparent !important;
}

.csd-tab-link:not(.active) {
    color: var(--muted) !important;
    border-bottom-color: transparent !important;
}
