/* === General Reset and Global Styles === */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.4;
    background-color: #f4f6f9;
    /* Light grey background like reference */
}

.msc-course-container {
    max-width: 1400px;
    /* Container width for 6 columns */
    margin: 20px auto;
    padding: 0 40px;
    /* Side margins */
}

/* --- FILTER BAR --- */
.msc-filter-row {
    background-color: #fff;
    padding: 10px 15px;
    margin-bottom: 25px;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid #ddd;
    /* White bar with border */
}

.msc-filter-form {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    flex-grow: 1;
}

.msc-form-group {
    flex-grow: 0;
    min-width: 100px;
}

.msc-select {
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #fff;
    font-size: 0.85rem;
    color: #555;
    cursor: pointer;
    height: 34px;
    width: 100%;
}

.msc-select[type="text"] {
    cursor: text;
}

.msc-select[type="text"]::placeholder {
    color: #999;
}

.msc-select:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    background-color: #eee;
}

.msc-clear-btn {
    padding: 6px 15px;
    background: #2c3e50;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    height: 34px;
}

.msc-clear-btn:hover {
    background-color: #1a252f;
}

.msc-download-btn {
    padding: 6px 15px;
    background-color: #7b4f99;
    color: #fff;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.85rem;
    white-space: nowrap;
    margin-left: 10px;
}

.msc-download-btn:hover {
    background-color: #5d3b74;
}

/* === Course Cards Grid === */
.msc-course-grid {
    display: grid;
    /* Fixed 6 columns per row */
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
    /* Spacing between cards */
}

/* --- COURSE CARD STYLING --- */
.msc-course-grid:not(.list-view) .msc-course-card {
    background: #fff;
    border: 1px solid #1a237e;
    /* Dark blue border per reference */
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s;
    height: 100%;
}

.msc-course-grid:not(.list-view) .msc-course-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.msc-course-grid:not(.list-view) .card-image {
    height: 140px;
    /* Reduced height */
    background-size: cover;
    background-position: center;
    background-color: #eee;
    position: relative;
    border-bottom: 1px solid #eee;
}

.status-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    color: #d32f2f;
    padding: 5px 10px;
    border-radius: 3px;
    font-weight: bold;
    font-size: 0.8rem;
    white-space: nowrap;
}

.plus-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: #0087a3;
    color: #fff;
    padding: 4px 8px;
    font-size: 0.7rem;
    font-weight: bold;
    border-radius: 2px;
}

.card-content {
    padding: 12px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.card-title {
    font-size: 0.95rem;
    /* Smaller title */
    font-weight: 700;
    color: #333;
    margin: 0 0 10px 0;
    line-height: 1.3;
    min-height: 2.6em;
    /* Ensure 2 lines check */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-meta {
    flex-grow: 1;
    margin-bottom: 10px;
}

.card-meta p {
    margin: 4px 0;
    font-size: 0.75rem;
    /* Compact text */
    color: #666;
    display: flex;
    align-items: center;
}

.card-meta span::before {
    margin-right: 6px;
    font-size: 0.85rem;
    color: #e67e22;
    /* Orange icons like reference */
}

/* Icons */
.card-meta span.icon-calendar::before {
    content: "📅";
}

.card-meta span.icon-flag::before {
    content: "🏳️";
}

.card-meta span.icon-location::before {
    content: "🎓";
}

.card-meta span.icon-city::before {
    content: "📍";
}

.card-meta .location-detail {
    margin-top: -3px;
    padding-left: 18px;
    font-size: 0.7rem;
    color: #888;
}

.msc-register-btn {
    display: block;
    width: 100%;
    margin-top: auto;
    /* Push to bottom */
    background-color: #1a237e;
    /* Dark blue */
    color: #fff;
    text-align: center;
    padding: 8px 0;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: 3px;
}

.msc-register-btn:hover {
    background-color: #0d1658;
}

.msc-no-courses-found {
    grid-column: 1/-1;
    text-align: center;
    padding: 50px;
    background: #f8f8f8;
    border-radius: 6px;
    border: 1px dashed #ccc;
    font-size: 1.2rem;
    color: #555;
}

/* --- Mobile Responsiveness --- */
@media (max-width: 992px) {
    .msc-filter-row {
        flex-direction: column;
        align-items: stretch;
        padding: 15px;
    }

    .msc-filter-form {
        gap: 10px;
        margin-bottom: 15px;
        justify-content: space-between;
    }

    .msc-form-group {
        flex: 1 1 45%;
        min-width: 140px;
    }

    .msc-clear-btn,
    .msc-download-btn {
        width: 100%;
        margin-top: 5px;
    }
}

/* =========================================
   NEW SLIDING TOGGLE & LIST VIEW STYLES
   ========================================= */

/* --- Header Row --- */
.msc-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.msc-title {
    font-size: 1.75rem;
    color: #2c3e50;
    margin: 0;
    font-weight: 700;
}

/* --- Sliding Toggle Container --- */
.msc-view-toggle-wrapper {
    display: flex;
    align-items: center;
}

.msc-toggle-switch {
    display: flex;
    position: relative;
    background-color: #e6e6e6;
    /* Initial Grey */
    border-radius: 50px;
    padding: 4px;
    border: 1px solid #dcdcdc;
    overflow: hidden;
    cursor: pointer;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
    user-select: none;
}

/* The Sliding Blue Pill */
.msc-toggle-slider {
    position: absolute;
    top: 4px;
    left: 4px;
    bottom: 4px;
    width: calc(50% - 4px);
    /* Roughly half width */
    background-color: #2596be;
    /* Updated color */
    border-radius: 50px;
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    z-index: 1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    pointer-events: none;
    /* Let clicks pass to container/buttons */
}

/* Move slider to the right when List is active */
.msc-toggle-switch.list-view-active .msc-toggle-slider {
    transform: translateX(100%);
}

/* The Option Text/Buttons */
.msc-toggle-option {
    position: relative;
    z-index: 2;
    /* Sit ABOVE the slider */
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px 25px;
    font-size: 0.95rem;
    font-family: inherit;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    transition: color 0.3s;
    outline: none;
    white-space: nowrap;
    text-align: center;
    min-width: 100px;
}

.msc-toggle-option.active {
    color: #0d4e6b;
    /* Darker blue text when active */
}

.msc-toggle-option:hover:not(.active) {
    color: #333;
}


/* --- List View Logic --- */

.msc-course-grid.list-view {
    grid-template-columns: 100%;
}

.msc-course-grid.list-view .msc-course-card {
    flex-direction: row;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 15px;
}

.msc-course-grid.list-view .card-image {
    width: 250px;
    min-height: 160px;
    background-size: cover;
    border-right: 1px solid #eee;
}

.msc-course-grid.list-view .card-content {
    padding: 15px 20px;
    display: grid;
    grid-template-columns: 1fr auto;
    /* Title + Button */
    grid-template-rows: auto auto;
    grid-template-areas:
        "title button"
        "meta meta";
    gap: 10px 20px;
    align-items: center;
    flex-grow: 1;
}

.msc-course-grid.list-view .card-title {
    grid-area: title;
    width: 100%;
    margin-bottom: 0;
    font-size: 1.3rem;
    min-height: auto;
    color: #2c3e50;
    line-height: 1.2;
}

.msc-course-grid.list-view .card-meta {
    grid-area: meta;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, auto);
    /* Compact columns */
    justify-content: start;
    gap: 8px 30px;
    margin-bottom: 0;
    padding-top: 5px;
}

.msc-course-grid.list-view .msc-register-btn {
    grid-area: button;
    width: auto;
    min-width: 150px;
    margin: 0;
    padding: 10px 20px;
    height: fit-content;
    white-space: nowrap;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .msc-course-grid {
        grid-template-columns: repeat(2, 1fr);
        /* 2 columns on mobile */
    }

    .msc-course-grid.list-view .msc-course-card {
        flex-direction: column;
        height: auto;
    }

    .msc-course-grid.list-view .card-image {
        width: 100%;
        height: 180px;
        border-right: none;
        border-bottom: 1px solid #d1d1d1;
    }

    .msc-course-grid.list-view .card-content {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .msc-course-grid.list-view .card-meta {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .msc-course-grid.list-view .msc-register-btn {
        width: 100%;
        margin-left: 0;
    }

    .msc-header-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .msc-view-toggle-wrapper {
        margin-left: auto;
    }
}