/* UpGrad-style mega menu — EduSkills branding */

:root {
    --mega-max-width: 1250px;
    --mega-viewport-width: 78vw;
    --mega-radius: 16px;
    --mega-green: #0a8f5c;
    --mega-green-bg: #e8f7ef;
    --mega-link: #2563eb;
    --mega-trending: #7c3aed;
    --mega-shadow: 0 12px 40px rgba(15, 23, 42, 0.08), 0 4px 16px rgba(15, 23, 42, 0.04);
    --mega-sidebar-width: 220px;
}

/* Backdrop */
.mega-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 998;
    background: rgba(15, 23, 42, 0.32);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.28s ease, visibility 0.28s;
    pointer-events: none;
}

.mega-menu-backdrop.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Outer wrapper — compact floating panel */
.mega-menu {
    position: absolute;
    top: 84px;
    left: 50%;
    width: var(--mega-viewport-width);
    max-width: var(--mega-max-width);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(6px);
    transition: opacity 0.24s ease, transform 0.24s ease, visibility 0.24s;
    pointer-events: none;
}

.mega-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.mega-menu-viewport {
    padding: 8px 0 12px;
}

.mega-menu-shell {
    width: 100%;
    background: #fff;
    border-radius: var(--mega-radius);
    box-shadow: var(--mega-shadow);
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

.mega-menu-content {
    display: grid;
    grid-template-columns: var(--mega-sidebar-width) minmax(0, 1fr);
    min-height: 0;
}

/* Sidebar */
.mega-menu-sidebar {
    display: flex;
    flex-direction: column;
    background: #f4f6f8;
    padding: 18px 12px 16px;
    border-right: 1px solid #e8ecf1;
}

.mega-sidebar-title {
    margin: 0 0 10px;
    padding: 0 8px;
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
}

.mega-domain-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    overflow-y: auto;
    margin: 0;
    padding: 0;
}

.mega-domain-list::-webkit-scrollbar {
    width: 5px;
}

.mega-domain-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 8px;
}

.mega-domain-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border: 0;
    background: transparent;
    color: #334155;
    font-weight: 600;
    font-size: 15px;
    font-family: inherit;
    text-align: left;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.mega-domain-item:hover {
    background: rgba(255, 255, 255, 0.7);
    color: #0f172a;
}

.mega-domain-item.active,
.mega-domain-item[aria-selected="true"] {
    color: var(--mega-green);
    background: var(--mega-green-bg);
    font-weight: 700;
}

.mega-domain-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: #64748b;
}

.mega-domain-item.active .mega-domain-icon,
.mega-domain-item[aria-selected="true"] .mega-domain-icon {
    color: var(--mega-green);
}

.mega-domain-icon svg {
    width: 18px;
    height: 18px;
}

.mega-domain-label {
    flex: 1;
    min-width: 0;
    line-height: 1.25;
}

.mega-domain-chevron {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    opacity: 0;
    color: var(--mega-green);
    transition: opacity 0.2s ease;
}

.mega-domain-item.active .mega-domain-chevron,
.mega-domain-item[aria-selected="true"] .mega-domain-chevron {
    opacity: 1;
}

.mega-browse-all {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    padding: 6px 8px;
    font-size: 13px;
    font-weight: 600;
    color: #334155;
    text-decoration: none;
    border-radius: 8px;
    transition: color 0.2s ease;
}

.mega-browse-all:hover {
    color: var(--mega-link);
}

.mega-browse-all svg {
    width: 15px;
    height: 15px;
}

/* Main panel */
.mega-menu-main-container {
    position: relative;
    min-height: 0;
    overflow: hidden;
}

.mega-menu-panels {
    position: relative;
    min-height: auto;
    overflow: hidden;
}

.mega-menu-panels.is-switching .mega-menu-main.active {
    opacity: 0;
}

.mega-menu-main {
    display: none;
    padding: 20px 24px 22px;
    min-width: 0;
    overflow: hidden;
}

.mega-menu-main.active {
    display: block;
    animation: megaPaneIn 0.24s ease-out;
}

.mega-menu-main[hidden] {
    display: none !important;
}

.mega-pane-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid #eef2f6;
}

.mega-pane-title {
    margin: 0 0 4px;
    font-size: 22px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.mega-pane-desc {
    margin: 0;
    max-width: 480px;
    font-size: 13px;
    line-height: 1.45;
    color: #64748b;
    font-weight: 400;
}

.mega-view-all {
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--mega-link);
    text-decoration: none;
    white-space: nowrap;
    padding-top: 4px;
}

.mega-view-all:hover {
    text-decoration: underline;
}

.mega-pane-body {
    transition: opacity 0.2s ease;
    min-width: 0;
    overflow: hidden;
}

.mega-menu-main-container.is-loading .mega-menu-panels {
    opacity: 0;
    pointer-events: none;
}

.mega-columns {
    display: grid;
    grid-template-columns: repeat(var(--mega-cols, 2), minmax(0, 1fr));
    gap: 16px 28px;
    min-width: 0;
    overflow: hidden;
}

.mega-column {
    min-width: 0;
    overflow: hidden;
}

/* Single section: split course rows into 2 columns to reduce empty space */
.mega-columns[style*="--mega-cols: 1"] .mega-column:only-child .mega-course-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 16px;
    row-gap: 0;
}

.mega-column-title {
    margin: 0 0 8px;
    padding-bottom: 8px;
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
    border-bottom: 1px solid #eef2f6;
}

.mega-course-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    max-height: 280px;
    overflow-x: hidden;
    overflow-y: auto;
    padding-right: 0;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.mega-course-list::-webkit-scrollbar {
    width: 4px;
    height: 0;
}

.mega-course-list::-webkit-scrollbar:horizontal {
    display: none;
    height: 0;
}

.mega-course-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 8px;
}

.mega-course-link {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 54px;
    max-width: 100%;
    padding: 10px 8px;
    margin: 0;
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s ease;
    box-sizing: border-box;
    overflow: hidden;
}

.mega-course-link:hover,
.mega-course-link:focus-visible {
    background: #f4f7fa;
    outline: none;
}

.mega-course-logo {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    border: 1px solid #e8ecf1;
    background: #fff;
}

.mega-course-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mega-course-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.mega-course-meta {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 400;
    color: #64748b;
    line-height: 1.25;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mega-meta-dot {
    color: #94a3b8;
}

.mega-trending-badge {
    display: inline-flex;
    flex-shrink: 0;
    padding: 0 5px;
    border-radius: 3px;
    background: #f3e8ff;
    color: var(--mega-trending);
    font-size: 10px;
    font-weight: 600;
    line-height: 1.35;
    letter-spacing: 0.01em;
}

.mega-course-title {
    font-size: 14px;
    font-weight: 600;
    color: #0f172a;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mega-course-link:hover .mega-course-title,
.mega-course-link:focus-visible .mega-course-title {
    color: var(--mega-link);
}

/* Skeleton */
.mega-skeleton {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: 1fr;
    padding: 20px 24px;
    background: #fff;
    z-index: 2;
    gap: 0;
}

.mega-skeleton[hidden] {
    display: none !important;
}

.mega-skeleton:not([hidden]) {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mega-skeleton-line,
.mega-skeleton-avatar {
    background: linear-gradient(90deg, #f1f5f9 25%, #e8ecf1 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: megaShimmer 1.2s ease-in-out infinite;
    border-radius: 8px;
}

.mega-skeleton-title {
    height: 22px;
    width: 40%;
}

.mega-skeleton-desc {
    height: 16px;
    width: 65%;
}

.mega-skeleton-course {
    display: flex;
    gap: 10px;
    align-items: center;
    min-height: 54px;
}

.mega-skeleton-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
}

.mega-skeleton-meta {
    height: 12px;
    width: 120px;
    margin-bottom: 8px;
}

.mega-skeleton-course-title {
    height: 16px;
    width: 75%;
}

@keyframes megaPaneIn {
    from {
        opacity: 0;
        transform: translateX(8px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes megaShimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* All Courses trigger enhancements */
.btn-all-courses {
    gap: 6px;
}

.btn-all-courses-icon {
    width: 18px;
    height: 18px;
}

.btn-all-courses-chevron {
    width: 14px;
    height: 14px;
    margin-left: 2px;
    transition: transform 0.25s ease;
}

.btn-all-courses.active .btn-all-courses-chevron {
    transform: rotate(180deg);
}

/* Desktop: All Courses sits beside logo (spacing in style.css) */
.nav-center--desktop {
    flex: 0 0 auto;
    justify-content: flex-start;
}

.search-container {
    flex: 1;
    min-width: 0;
    max-width: 480px;
    margin-left: 12px;
}

.search-input {
    border-radius: 999px !important;
    height: 44px !important;
    padding-left: 46px !important;
}

.search-input:focus-visible {
    border-color: var(--royal, #004a7e) !important;
    box-shadow: 0 0 0 4px rgba(0, 74, 126, 0.1) !important;
}

.search-dropdown {
    border-radius: 16px;
}

.search-item strong {
    color: #0f172a;
    font-weight: 700;
}

.search-item-meta {
    font-size: 0.78rem;
    color: #64748b;
}

/* Mobile course browser (KnowledgeHut-style) */
.mega-mobile-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1195;
    background: rgba(15, 23, 42, 0.4);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mega-mobile-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.mega-mobile-drawer {
    position: fixed;
    inset: 0;
    z-index: 1200;
    background: #fff;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.34s cubic-bezier(0.16, 1, 0.3, 1);
    visibility: hidden;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.mega-mobile-drawer.active {
    transform: translateX(0);
    visibility: visible;
}

.mega-mobile-drawer[hidden] {
    display: none !important;
}

.mega-mobile-drawer:not([hidden]).active {
    display: flex;
}

.mega-mobile-screen {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.mega-mobile-screen.is-active {
    display: flex;
}

.mega-mobile-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid #e8ecf1;
    flex-shrink: 0;
}

.mega-mobile-logo img {
    height: 34px;
    width: auto;
    object-fit: contain;
    display: block;
}

.mega-mobile-close {
    border: 0;
    background: #f1f5f9;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    color: #64748b;
    flex-shrink: 0;
}

.mega-mobile-screen-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0;
}

.mega-mobile-screen-title {
    margin: 0;
    padding: 16px 20px 8px;
    font-size: 1.1rem;
    font-weight: 800;
    color: #0f172a;
}

.mega-mobile-domain-list {
    display: flex;
    flex-direction: column;
}

.mega-mobile-domain-row {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    min-height: 54px;
    padding: 12px 20px;
    border: 0;
    border-bottom: 1px solid #eef2f6;
    background: #fff;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    transition: background 0.15s ease;
}

.mega-mobile-domain-row:hover,
.mega-mobile-domain-row:focus-visible {
    background: #f8fafc;
    outline: none;
}

.mega-mobile-domain-row__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    flex-shrink: 0;
    color: #64748b;
}

.mega-mobile-domain-row__icon .mega-domain-icon svg {
    width: 22px;
    height: 22px;
}

.mega-mobile-domain-row__label {
    flex: 1;
    font-size: 0.92rem;
    font-weight: 600;
    color: #475569;
}

.mega-mobile-domain-row__chevron {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: #94a3b8;
}

.mega-mobile-browse-all {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 12px 16px calc(16px + env(safe-area-inset-bottom, 0));
    padding: 14px 20px;
    border: 1px solid #d1d9e0;
    border-radius: 10px;
    background: #fff;
    color: #0f172a;
    font-weight: 700;
    font-size: 0.9rem;
    text-decoration: none;
    flex-shrink: 0;
}

.mega-mobile-browse-all svg {
    width: 16px;
    height: 16px;
}

.mega-mobile-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 12px 16px 8px;
    padding: 8px 14px;
    border: 1px solid #d1d9e0;
    border-radius: 999px;
    background: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
    font-family: inherit;
}

.mega-mobile-back svg {
    width: 16px;
    height: 16px;
}

.mega-mobile-screen-body--category {
    padding-bottom: 24px;
}

.mega-mobile-panels {
    padding: 0 16px 16px;
}

.mega-mobile-panel {
    display: none;
}

.mega-mobile-panel.is-visible {
    display: block;
}

.mega-mobile-panel-intro {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e8ecf1;
}

.mega-mobile-panel-title {
    margin: 0 0 8px;
    font-size: 1.2rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.25;
}

.mega-mobile-panel-desc {
    margin: 0 0 10px;
    font-size: 0.88rem;
    line-height: 1.5;
    color: #64748b;
}

.mega-mobile-view-all {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--mega-link);
    text-decoration: none;
}

.mega-mobile-column-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: #64748b;
    margin: 18px 0 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.mega-mobile-column-title:first-of-type {
    margin-top: 0;
}

.mega-mobile-course-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    border-top: 1px solid #eef2f6;
}

.mega-mobile-course-list .mega-course-link {
    min-height: 58px;
    padding: 12px 4px;
    border-bottom: 1px solid #eef2f6;
}

.mega-mobile-course-list .mega-course-link:last-child {
    border-bottom: none;
}

body.mega-menu-open,
body.mega-mobile-open {
    overflow: hidden;
}

/* Tablet */
@media (max-width: 1199px) {
    .mega-menu {
        width: 92vw;
    }

    .mega-columns[style*="--mega-cols: 1"] .mega-column:only-child .mega-course-list {
        grid-template-columns: 1fr;
    }
}

/* Hide desktop mega on mobile; show drawer */
@media (max-width: 1024px) {
    .mega-menu,
    .mega-menu-backdrop {
        display: none !important;
    }
}


@media (prefers-reduced-motion: reduce) {
    .mega-menu,
    .mega-menu-backdrop,
    .mega-mobile-drawer,
    .mega-course-link,
    .btn-all-courses-chevron {
        transition: none;
    }

    .mega-menu-main.active,
    .mega-skeleton-line,
    .mega-skeleton-avatar {
        animation: none;
    }
}
