/* Assuming these are defined in your :root or a common CSS file */
:root {
    --primary-navy: #072ac8;
    --primary-yellow: #ffc600;
    --primary-blue: #1e96fc;
    --background: #f7f7f7;
    --text-dark: #343a40;
    --text-medium: #495057;
    --text-light: #6c757d;
}

/* General body and reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Ubuntu", sans-serif; /* Ensure Ubuntu is linked in HTML head */
}
html {
    scroll-behavior: smooth;
}
body {
    font-family: "Ubuntu", sans-serif;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    background-color: var(--background);
    color: var(--text-dark);
}

/* --- Courses Hero Section --- */
.courses-hero-section {
    color: var(--primary-navy);
    padding: 60px 20px;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
    overflow: hidden;
}

.courses-hero-content {
    max-width: 800px;
    margin: 0 auto;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInSlideUpContent 1s ease-out forwards;
    animation-delay: 0.2s;
}

.courses-header {
    font-size: 3.8em;
    font-weight: 700;
    margin-bottom: 20px;
    letter-spacing: -1px;
    line-height: 1.1;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInSlideUpHeader 0.8s ease-out forwards;
    animation-delay: 0.4s;
}

.courses-tagline {
    font-size: 1.3em;
    line-height: 1.6;
    margin-bottom: 40px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    opacity: 0.9;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInSlideUpTagline 0.8s ease-out forwards;
    animation-delay: 0.6s;
}

/* --- Search Bar Styling --- */
.search-bar-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    background-color: transparent;
    border-radius: 50px;
    border: 3px solid var(--primary-yellow);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    padding: 8px;
    transition: box-shadow 0.3s ease-in-out;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInSlideUpSearch 0.8s ease-out forwards;
    animation-delay: 0.8s;
}

.search-bar-container:focus-within {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.25), 0 0 0 4px rgba(255, 198, 0, 0.5);
}

.course-search-input {
    flex-grow: 1;
    border: none;
    outline: none;
    padding: 12px 20px;
    font-size: 1.1em;
    color: var(--text-dark);
    background-color: transparent;
    border-radius: 50px;
}

.course-search-input::placeholder {
    color: var(--text-light);
    opacity: 0.7;
}

.search-button {
    background-color: var(--primary-yellow);
    color: var(--background);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 1.3em;
    transition: background-color 0.3s ease-in-out, transform 0.2s ease-in-out;
}

.search-button:hover {
    background-color: var(--primary-blue);
    transform: scale(1.05);
}

/* --- Keyframe Animations --- */
@keyframes fadeInSlideUpContent {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInSlideUpHeader {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInSlideUpTagline {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInSlideUpSearch {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInScaleUp {
    from { opacity: 0; transform: scale(0.95) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* --- Courses Listing Section --- */
.courses-listing-section {
    max-width: 1200px;
    margin: 20px auto;
    padding: 0 25px;
}

/* Category Bar Styling (General) */
.category-bar-container { /* New wrapper for category list */
    margin-bottom: 50px;
    padding: 10px 0; /* Adjust padding as needed */
    border-radius: 12px;
}

.category-list { /* This will be the scrollable flex container on mobile */
    display: flex;
    flex-wrap: wrap; /* Allows wrapping on desktop */
    justify-content: center;
    gap: 15px;
    padding: 15px 10px; /* Internal padding for desktop */
}

.category-button {
    background-color: transparent;
    border: 2px solid var(--primary-blue);
    color: var(--primary-blue);
    padding: 10px 20px;
    border-radius: 30px;
    font-size: 1em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease-in-out;
    white-space: nowrap; /* Prevent text wrap */
    width: auto; /* Allow buttons to take natural width */
}
.category-button:hover:not(.active) {
    background-color: var(--primary-blue);
    color: #ffffff;
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}
.category-button.active {
    background-color: var(--primary-yellow);
    color: var(--background);
    border-color: var(--primary-yellow);
    font-weight: 700;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    transform: translateY(-2px);
}


/* --- Courses Grid (Desktop) / Custom Carousel (Mobile) --- */
.courses-display-container { /* Wrapper for the courses grid/carousel */
    width: 100%;
    overflow: hidden; /* Hide overflow from scroll snap */
}

.courses-grid { /* This is the main container for cards */
    /* Desktop (default) styles: GRID */
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); /* Your desired 3-column grid */
    gap: 30px; /* Gap between grid items */
    padding-bottom: 0; /* No pagination space on desktop */
}

/* Individual Course Card Item */
.course-card-item {
    max-width: 350px;
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 400px; /* Fixed height for consistency */
    transition: transform 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
    animation: fadeInScaleUp 0.6s ease-out forwards;
    border: 3px solid var(--primary-blue);
}

.course-card-item:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
}

.course-item-image {
    width: 100%;
    height: 180px;
    object-fit: fill;
    border-bottom: 1px solid #e9ecef;
}

.course-item-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow-y: auto;
    padding-right: 15px;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-blue) transparent;
}
.course-item-content::-webkit-scrollbar { width: 8px; }
.course-item-content::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 4px; }
.course-item-content::-webkit-scrollbar-thumb { background: var(--primary-blue); border-radius: 4px; }
.course-item-content::-webkit-scrollbar-thumb:hover { background: var(--primary-navy); }

.course-item-title {
    font-size: 1.4em;
    color: var(--primary-navy);
    margin-bottom: 10px;
    font-weight: 700;
    line-height: 1.3;
    flex-shrink: 0;
}

.course-item-description {
    font-size: 1em;
    color: var(--text-medium);
    line-height: 1.6;
    flex-grow: 1;
    margin-bottom: 10px;
}

.no-courses-found {
    text-align: center;
    font-size: 1.2em;
    color: var(--text-light);
    padding: 50px;
}

/* --- Responsive Adjustments --- */

/* Desktop/Tablet (min-width: 768px) */
@media (min-width: 768px) {

    /* Category Bar on Desktop (remains as a flex-wrapped layout) */
    .category-list {
        flex-wrap: wrap;
        justify-content: center;
        overflow-x: hidden; /* Hide scrollbar on desktop */
        scroll-snap-type: none; /* Disable scroll snap on desktop */
    }
    .category-button {
        flex-shrink: 0; /* Prevent shrinking */
    }

    /* Courses Grid on Desktop (already default) */
    .courses-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        gap: 30px;
    }
    .course-card-item {
        width: auto; /* Allow grid to determine width */
        margin-right: 0; /* Remove mobile margin */
    }
}

/* Mobile Specific (max-width: 767px) - Activate Custom Carousels */
@media (max-width: 767px) {
          .course-item-content {
        overflow-y: auto; /* Ensure it's still scrollable */
        padding-right: 20px; /* Adjust padding for content, not scrollbar */
        scrollbar-width: none;  /* Firefox */
        -ms-overflow-style: none; /* IE and Edge */
    }
    .course-item-content::-webkit-scrollbar { /* Chrome, Safari, Opera */
        display: none;
    }
    
    /* --- Category Bar as Custom Swiper on Mobile --- */
    .category-list {
        flex-wrap: nowrap; /* Force single row for carousel */
        justify-content: flex-start; /* Align items to start for scroll snap */
        overflow-x: auto; /* Enable horizontal scrolling */
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
        scroll-snap-type: x mandatory; /* Enable scroll snapping */
        padding: 15px 15px; /* Padding for carousel edges */
        /* Hide scrollbar visually */
        scrollbar-width: none; /* Firefox */
        -ms-overflow-style:initial; /* IE and Edge */
    }
    .category-list::-webkit-scrollbar { /* Chrome, Safari, Opera */
        display: none;
    }
    .category-button {
        box-shadow: none;
        flex-shrink: 0; /* Prevent buttons from shrinking */
        margin-right: 15px; /* Space between buttons */
        scroll-snap-align: start; /* Snap to start of each button */
    }
    .category-button.active{
        box-shadow: none;
    }
    /* Add padding to the last button to allow snapping to it */
 
    /* --- Courses Grid as Custom Swiper on Mobile --- */
    .courses-grid {
        display: flex; /* Force flex for carousel */
        flex-wrap: nowrap; /* Force single row */
        overflow-x: auto; /* Enable horizontal scrolling */
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
        scroll-snap-type: x mandatory; /* Enable scroll snapping */
        padding: 0 15px; /* Padding for carousel edges */
        gap: 20px; /* Gap between cards */
        /* Hide scrollbar visually */
        scrollbar-width: none; /* Firefox */
        -ms-overflow-style: none; /* IE and Edge */
    }
   
    .course-card-item {
        box-shadow: none;
        max-height: 350px;
        flex-shrink: 0;
        width: 300px;
        scroll-snap-align: none;
        height: auto;
    }
   
}

/* Responsive adjustments for other sections (e.g., hero section on mobile) */
@media (max-width: 992px) {
    .courses-header { font-size: 3em; }
    .courses-tagline { font-size: 1.2em; }
}
@media (max-width: 767px) {
    .courses-hero-section {
        padding: 60px 15px;
        min-height: 350px;
        border-bottom-left-radius: 15px;
        border-bottom-right-radius: 15px;
    }
    .courses-header { font-size: 2.5em; margin-bottom: 15px; }
    .courses-tagline { font-size: 1em; margin-bottom: 30px; }
    .search-bar-container { flex-direction: row; padding: 6px; }
    .course-search-input { padding: 10px 15px; font-size: 1em; }
    .search-button { width: 45px; height: 45px; font-size: 1.1em; }
}
@media (max-width: 480px) {
    .courses-header { font-size: 2em; }
    .courses-tagline { font-size: 0.9em; }
}