/* CSS Reset for Consistency Across Browsers */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Root Variables for Easy Theming */
:root {
    --primary-color: #ffffff; /* Dark Slate Grey */
    --secondary-color: #e9e9e9; /* Slate Grey */
    --accent-color: #535353; /* Blue */
    --text-color: #313131; /* Light Grey */
    --light-text-color: #181818; /* Grey */
    --background-color: #fafafa; /* Dark Blue Grey */
    --header-bg: linear-gradient(135deg, #ffccda, #ffffff); /* Blue Gradient */
    --spinner-border: #3182CE; /* Blue */
    --spinner-background: #CBD5E0; /* Light Grey */
    --shadow-color: rgba(0, 0, 0, 0.2);
    --font-family-primary: 'Inter', sans-serif;
    --font-family-secondary: 'Poppins', sans-serif;
    --sign-in-button-color: #3182CE; /* Blue for sign-in button */
    --sign-in-button-hover: #2B6CB0; /* Darker blue on hover */
}

body {
    background-color: var(--background-color);
    color: var(--text-color);
    font-family: var(--font-family-primary);
    min-height: 100vh;
    position: relative;
}

/* Pre-loader Styles */
#preloader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(26, 32, 44, 0.9); /* Semi-transparent background */
    z-index: 9999; /* Ensure it stays on top */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease, visibility 0.5s ease;
    opacity: 1;
    visibility: visible;
}

#preloader.hidden {
    opacity: 0;
    visibility: hidden;
}

.spinner {
    border: 8px solid var(--spinner-background); /* Light grey */
    border-top: 8px solid var(--spinner-border); /* Blue color for the spinner */
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1.5s linear infinite;
}

/* Spinner Animation */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Main Content Styles */
.main-content {
    padding: 80px 30px 30px 30px; /* Adjusted padding-top */
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

/* Search and Categories Wrapper Styles */
.search-and-categories-wrapper {
    width: 100%;
    max-width: 1200px; /* Same as .main-content max-width */
    margin: 0 auto;
    padding: 20px 30px; /* Adjust padding as needed */
    box-sizing: border-box;
}

/* Search Container Styles */
.search-container {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.search-container input[type="text"] {
    width: 100%;
    max-width: 800px; /* Adjust as needed */
    padding: 12px 20px;
    box-sizing: border-box;
    border: none;
    border-radius: 50px;
    background-color: var(--secondary-color);
    color: #2b2b2b;
    font-size: 1em;
    outline: none;
    transition: background-color 0.3s, box-shadow 0.3s, transform 0.3s;
}

.search-container input[type="text"]::placeholder {
    color: var(--light-text-color);
}

/* Categories List Styles */
.categories-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    margin: 0 auto;
    max-width: 100%;
}

.categories-list .category {
    margin: 5px 10px;
    padding: 8px 20px;
    border-radius: 50px;
    background-color: var(--secondary-color);
    transition: background-color 0.3s, color 0.3s, transform 0.2s;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    min-width: 120px;
    box-sizing: border-box;
    font-family: var(--font-family-secondary);
    font-weight: 500;
    color: var(--light-text-color);
}

.categories-list .category a {
    color: inherit; /* Inherit color from parent */
    text-decoration: none;
    font-size: 1em;
    text-align: center;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Hover and Active States for Categories */
.categories-list .category:hover {
    background-color: var(--accent-color);
    color: #ffffff;
    transform: translateY(-2px);
}

.categories-list .category.active {
    background-color: var(--accent-color);
    color: #ffffff;
}

/* Categories Toggle Button (Mobile) */
.categories-toggle {
    display: none;
    background-color: var(--secondary-color);
    color: var(--light-text-color);
    padding: 10px 20px;
    border: none;
    border-radius: 50px;
    font-size: 1em;
    cursor: pointer;
    margin: 0 auto 20px auto;
    font-family: var(--font-family-secondary);
    font-weight: 500;
}

/* Rotate icon when active */
.categories-toggle.active::after {
    content: ' ▲';
}

.categories-toggle::after {
    content: ' ▼';
    margin-left: 10px;
    font-size: 0.8em;
}

/* Hide categories list when toggled */
@media screen and (max-width: 768px) {
    .categories-toggle {
        display: block;
    }

    .categories-list {
        display: none;
    }

    .categories-list.expanded {
        display: flex;
    }
}

/* About Section Styles */
.about-section {
    background: var(--header-bg);
    padding: 60px 30px;
    color: #ffffff;
    border-radius: 15px;
    margin-top: 30px; /* You can adjust this if needed */
    margin-bottom: 20px; /* Reduced from 50px to 20px */
    text-align: center;
    position: relative;
    overflow: hidden;
    font-family: var(--font-family-secondary);
    box-shadow: 0 4px 8px var(--shadow-color);
    transition: transform 0.3s ease;
}

.about-section:hover {
    transform: translateY(-5px);
}

.about-section::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: radial-gradient(circle, rgba(255, 255, 255, 0.1) 10%, transparent 10%);
    background-size: 40px 40px;
    opacity: 0.3;
    pointer-events: none;
}

.about-content {
    position: relative;
    z-index: 1;
}

.about-content h1 {
    font-family: var(--font-family-secondary);
    font-size: 2.5em;
    font-weight: 700;
    color: #222222;
    margin-bottom: 20px;
    letter-spacing: 1px;
}

.about-content h1 a {
    color: var(--accent-color);
    text-decoration: underline;
}

/* Course Grid Styles */
.course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 30px;
    padding-bottom: 50px;
}

.course-card {
    background-color: var(--secondary-color);
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 6px 12px var(--shadow-color);
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.5s ease, transform 0.5s ease, box-shadow 0.3s;
    text-decoration: none; /* Remove underline from links */
    color: inherit; /* Inherit text color */
}

.course-card.hidden {
    opacity: 0;
    transform: translateY(20px);
}

.course-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 24px var(--shadow-color);
}

.course-image img {
    width: 100%;
    height: 180px; /* Increased height for better image display */
    object-fit: cover;
    border-radius: 10px;
    display: block;
    margin-bottom: 20px; /* Increased margin for spacing */
    transition: transform 0.3s ease;
}

.course-image img:hover {
    transform: scale(1.05);
}

.course-info {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.course-title {
    color: #222222;
    font-family: var(--font-family-secondary);
    font-size: 1.4em;
    font-weight: 600;
    margin-bottom: 10px;
    transition: color 0.3s ease;
}

.course-title:hover {
    color: var(--accent-color);
}

.course-instructor {
    font-size: 1em;
    color: var(--light-text-color);
    margin-bottom: 8px;
}

/* Removed course-rating styles as 'rating' does not exist */

.course-price {
    font-size: 1.2em;
    font-weight: 700;
    color: #222222;
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid #4A5568; /* Updated border color to match secondary color */
}

/* Infinite Scroll Loading Indicator */
#loading {
    text-align: center;
    padding: 20px;
    display: none;
    font-size: 1.2em;
    color: #E2E8F0; /* Updated to match text color */
}

.udemy-link {
    color: var(--accent-color); /* Matches your theme's accent color */
    font-weight: bold;
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 5px; /* Optional: Rounded edges */
    transition: background-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}

.udemy-link:hover {
    background-color: var(--accent-color);
    color: #fff; /* White text on hover */
    box-shadow: 0 0 8px var(--accent-color);
}

/* Accessibility: Screen Reader Only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

#backToTop {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background-color: var(--accent-color); /* Updated to match the theme */
    color: white;
    border: none;
    border-radius: 50%;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    font-size: 24px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1000;
    transition: opacity 0.3s ease, transform 0.3s ease;
    opacity: 0;
    transform: translateY(50px);
    visibility: hidden;
}

#backToTop:hover {
    background-color: #2B6CB0; /* Slightly darker shade */
}

#backToTop.show {
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
}

.course-meta i {
    color: #222222 !important; /* White text for the publish date */
    opacity: 0.8;
}

.course-price span {
    color: #222222 !important; /* White text for Read More */
}