/* ========================================
   MEGA MENU STYLES
   AI Startup Toolkit Navigation
   ======================================== */

/* Mega Menu Container - Aligned under nav button */
.mega-menu-nav-item .dropdown-menu.mega-menu {
    min-width: 650px;
    max-width: 800px;
    width: max-content;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    padding: 0.75rem !important;
    position: absolute;
    top: 100%;
    left: 0;
    right: auto;
    transform: none;
    margin-top: 0.125rem; /* Reduced from 0.5rem for easier hover */
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    overflow-x: hidden;
    display: none; /* Hidden by default */
}

/* Add invisible hover bridge between nav button and mega menu */
.mega-menu-nav-item::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 0.25rem; /* Creates a hover-sensitive area */
    background: transparent;
    pointer-events: auto;
}

/* Prevent menu from extending beyond viewport - will be adjusted by JavaScript */
.mega-menu-nav-item .dropdown-menu.mega-menu {
    max-width: min(800px, calc(100vw - 40px));
}

/* When menu would extend beyond right edge, align to right instead */
.mega-menu-nav-item .dropdown-menu.mega-menu.align-right {
    left: auto;
    right: 0;
}

/* Show mega menu when .show class is added */
.mega-menu-nav-item .dropdown-menu.mega-menu.show {
    display: block !important;
}

/* Desktop: Hide simple dropdown */
@media (min-width: 992px) {
    /* Completely hide mobile dropdowns on desktop */
    .mega-menu-nav-item .dropdown-menu.mobile-simple-dropdown {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }
}

/* Responsive: Full width on smaller screens */
@media (max-width: 1400px) {
    .mega-menu-nav-item .dropdown-menu.mega-menu {
        min-width: auto;
        max-width: calc(100vw - 40px);
        left: 50%;
        transform: translateX(-50%);
    }
}

@media (max-width: 1200px) {
    .mega-menu-nav-item .dropdown-menu.mega-menu {
        min-width: auto;
        max-width: calc(100vw - 40px);
        left: 50%;
        transform: translateX(-50%);
    }
}

@media (max-width: 992px) {
    .mega-menu-nav-item .dropdown-menu.mega-menu {
        min-width: auto;
        max-width: calc(100vw - 20px);
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) !important;
        padding: 1.25rem !important;
        max-height: 80vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Mobile: Hide mega menus and use simple dropdowns instead */
@media (max-width: 991px) {
    /* Hide mega menu dropdowns on mobile - force hide even with .show class */
    .mega-menu-nav-item .dropdown-menu.mega-menu {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
        height: 0 !important;
        overflow: hidden !important;
    }

    /* Also hide when show class is added on mobile */
    .mega-menu-nav-item .dropdown-menu.mega-menu.show {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
        height: 0 !important;
        overflow: hidden !important;
    }

    /* Show the simple mobile navigation instead */
    .mega-menu-nav-item .dropdown-menu.mobile-simple-dropdown {
        position: static !important;
        float: none;
        width: 100%;
        margin-top: 0;
        margin-left: 0;
        margin-right: 0;
        background-color: #f8f9fa;
        border: 0;
        border-radius: 0.5rem;
        box-shadow: none;
        padding: 0.5rem 0;
    }

    /* Force show mobile dropdown when it has .show class */
    .mega-menu-nav-item .dropdown-menu.mobile-simple-dropdown.show {
        display: block !important;
        animation: slideDown 0.2s ease-out;
    }

    /* Hide when doesn't have show class */
    .mega-menu-nav-item .dropdown-menu.mobile-simple-dropdown:not(.show) {
        display: none !important;
    }

    /* Make dropdown toggle look clickable on mobile */
    .mega-menu-nav-item .nav-link.dropdown-toggle {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        padding: 0.75rem 1rem;
        border-radius: 0.375rem;
        transition: background-color 0.15s ease;
    }

    .mega-menu-nav-item .nav-link.dropdown-toggle:hover,
    .mega-menu-nav-item .nav-link.dropdown-toggle[aria-expanded="true"] {
        background-color: #f8f9fa;
    }

    /* Show dropdown arrow on mobile */
    .mega-menu-nav-item .nav-link.dropdown-toggle::after {
        display: inline-block !important;
        margin-left: auto;
        transition: transform 0.2s ease;
    }

    /* Rotate arrow when expanded */
    .mega-menu-nav-item .nav-link.dropdown-toggle[aria-expanded="true"]::after {
        transform: rotate(180deg);
    }

    /* Slide down animation for mobile dropdowns */
    @keyframes slideDown {
        from {
            opacity: 0;
            transform: translateY(-10px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}

    /* Style mobile dropdown items */
    .mega-menu-nav-item .dropdown-menu.mobile-simple-dropdown .dropdown-item {
        padding: 0.5rem 1.5rem;
        color: #1f2937;
    }

    .mega-menu-nav-item .dropdown-menu.mobile-simple-dropdown .dropdown-item:hover {
        background-color: #f3f4f6;
    }

    .mega-menu-nav-item .dropdown-menu.mobile-simple-dropdown .dropdown-divider {
        margin: 0.5rem 0;
    }

    .mega-menu-nav-item .dropdown-menu.mobile-simple-dropdown .dropdown-header {
        padding: 0.5rem 1.5rem;
        font-size: 0.875rem;
        color: #6b7280;
    }
}

/* Stage Card Styling */
.mega-menu-stage-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0;
    transition: all 0.2s ease;
    height: 100%;
    overflow: hidden;
}

.mega-menu-stage-card:hover {
    border-color: #d1d5db;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

/* Stage Header */
.mega-menu-stage-card .stage-header {
    padding: 0.5rem 0.75rem;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

/* Stage title - works for both <a> and <div> */
.mega-menu-stage-card .stage-title {
    text-decoration: none;
    color: #111827;
    font-size: 0.875rem;
    font-weight: 600;
    display: block;
    transition: color 0.2s ease;
}

/* Hover effect only for links */
.mega-menu-stage-card a.stage-title:hover {
    color: #4f46e5;
}

/* Non-clickable headers (divs) - no hover effect */
.mega-menu-stage-card div.stage-title {
    cursor: default;
}

.mega-menu-stage-card .stage-title i {
    font-size: 1rem;
}

/* Stage-specific header colors */
.mega-menu-stage-card .stage-header[style*="#9333EA"] {
    border-left-color: #9333EA !important;
}

.mega-menu-stage-card .stage-header[style*="#059669"] {
    border-left-color: #059669 !important;
}

.mega-menu-stage-card .stage-header[style*="#1D4ED8"] {
    border-left-color: #1D4ED8 !important;
}

.mega-menu-stage-card .stage-header[style*="#EA580C"] {
    border-left-color: #EA580C !important;
}

.mega-menu-stage-card .stage-header[style*="#0891B2"] {
    border-left-color: #0891B2 !important;
}

.mega-menu-stage-card .stage-header[style*="#047857"] {
    border-left-color: #047857 !important;
}

/* Stage Tools Section */
.mega-menu-stage-card .stage-tools {
    padding: 0.25rem 0;
}

.mega-menu-stage-card .tool-link {
    display: block;
    padding: 0.4rem 0.75rem;
    text-decoration: none;
    color: #4b5563;
    font-size: 0.813rem;
    line-height: 1.4;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
}

.mega-menu-stage-card .tool-link:hover {
    background: #f3f4f6;
    color: #111827;
    border-left-color: #4f46e5;
    padding-left: 1rem;
}

.mega-menu-stage-card .tool-link i {
    width: 18px;
    font-size: 0.875rem;
    text-align: center;
    display: inline-block;
}

/* View All Link */
.mega-menu-stage-card .view-all-link {
    display: block;
    padding: 0.5rem 1rem;
    text-decoration: none;
    color: #4f46e5;
    font-size: 0.813rem;
    font-weight: 600;
    margin-top: 0.25rem;
    border-top: 1px solid #e5e7eb;
    transition: all 0.2s ease;
}

.mega-menu-stage-card .view-all-link:hover {
    color: #4338ca;
    background: #eef2ff;
    padding-left: 1.25rem;
}

.mega-menu-stage-card .view-all-link i {
    font-size: 0.75rem;
    transition: transform 0.2s ease;
}

.mega-menu-stage-card .view-all-link:hover i {
    transform: translateX(4px);
}

/* Mega Menu Header */
.mega-menu .mega-menu-title {
    color: #111827;
    font-weight: 700;
    font-size: 1.125rem;
}

.mega-menu .row:first-child p.text-muted {
    color: #6b7280;
    font-size: 0.875rem;
}

/* Close button for mobile/tablet */
.mega-menu-close {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 10;
    padding: 0.5rem;
}

/* Dashboard button positioning */
.mega-menu-dashboard-btn {
    float: right;
    margin-left: 0.5rem;
}

@media (max-width: 768px) {
    .mega-menu-dashboard-btn {
        float: none;
        display: block;
        width: 100%;
        margin-top: 2rem;
        margin-left: 0;
    }

    .mega-menu-close {
        right: 0.5rem;
        top: 0.5rem;
    }

    .mega-menu-title {
        margin-top: 0.5rem;
    }
}

/* Footer Section */
.mega-menu .row:last-child hr {
    border-color: #e5e7eb;
}

.mega-menu .row:last-child .btn {
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
}

/* Dropdown positioning fix */
.mega-menu-nav-item.dropdown:hover .mega-menu {
    display: block;
}

/* Ensure proper z-index */
.mega-menu-nav-item .dropdown-menu.mega-menu {
    z-index: 1050;
}

/* Grid spacing consistency */
.mega-menu .row.g-3 {
    row-gap: 0.75rem;
    column-gap: 0.75rem;
}

/* Animation for dropdown appearance */
.mega-menu-nav-item .dropdown-menu.mega-menu {
    animation: fadeInDown 0.2s ease;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Icon color consistency */
.mega-menu-stage-card .stage-title i[style*="#9333EA"] {
    color: #9333EA !important;
}

.mega-menu-stage-card .stage-title i[style*="#059669"] {
    color: #059669 !important;
}

.mega-menu-stage-card .stage-title i[style*="#1D4ED8"] {
    color: #1D4ED8 !important;
}

.mega-menu-stage-card .stage-title i[style*="#EA580C"] {
    color: #EA580C !important;
}

.mega-menu-stage-card .stage-title i[style*="#0891B2"] {
    color: #0891B2 !important;
}

.mega-menu-stage-card .stage-title i[style*="#047857"] {
    color: #047857 !important;
}

/* Mobile adjustments */
@media (max-width: 576px) {
    .mega-menu-nav-item .dropdown-menu.mega-menu {
        padding: 0.75rem !important;
    }

    .mega-menu .row:first-child h5 {
        font-size: 0.938rem;
    }

    .mega-menu .row:first-child .btn-sm {
        font-size: 0.75rem;
        padding: 0.375rem 0.75rem;
    }

    .mega-menu .row:first-child p.text-muted {
        font-size: 0.75rem;
    }

    .mega-menu-stage-card .stage-title {
        font-size: 0.875rem;
    }

    .mega-menu-stage-card .tool-link {
        font-size: 0.813rem;
        padding: 0.4rem 0.75rem;
    }

    .mega-menu-stage-card .view-all-link {
        font-size: 0.75rem;
        padding: 0.4rem 0.75rem;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Increase touch target sizes on touch devices */
    .mega-menu-stage-card .tool-link {
        padding: 0.75rem 1rem;
        min-height: 44px;
    }

    .mega-menu-stage-card .stage-title {
        padding: 0.875rem 1rem;
        min-height: 44px;
    }

    .mega-menu-stage-card .view-all-link {
        padding: 0.75rem 1rem;
        min-height: 44px;
    }

    /* Remove hover effects on touch devices */
    .mega-menu-stage-card:hover {
        transform: none;
    }

    .mega-menu-stage-card .tool-link:hover {
        padding-left: 1rem;
    }

    .mega-menu-stage-card .view-all-link:hover {
        padding-left: 1rem;
    }
}

/* Accessibility improvements */
.mega-menu-stage-card .tool-link:focus,
.mega-menu-stage-card .stage-title:focus,
.mega-menu-stage-card .view-all-link:focus {
    outline: 2px solid #4f46e5;
    outline-offset: 2px;
}

/* Smooth scrolling for all mega menus */
.mega-menu-nav-item .dropdown-menu.mega-menu,
.resources-mega-menu .resources-mega-menu-dropdown,
.profile-mega-menu .profile-mega-menu-dropdown {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Custom scrollbar styling for mega menus */
.mega-menu-nav-item .dropdown-menu.mega-menu::-webkit-scrollbar,
.resources-mega-menu .resources-mega-menu-dropdown::-webkit-scrollbar,
.profile-mega-menu .profile-mega-menu-dropdown::-webkit-scrollbar {
    width: 8px;
}

.mega-menu-nav-item .dropdown-menu.mega-menu::-webkit-scrollbar-track,
.resources-mega-menu .resources-mega-menu-dropdown::-webkit-scrollbar-track,
.profile-mega-menu .profile-mega-menu-dropdown::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.mega-menu-nav-item .dropdown-menu.mega-menu::-webkit-scrollbar-thumb,
.resources-mega-menu .resources-mega-menu-dropdown::-webkit-scrollbar-thumb,
.profile-mega-menu .profile-mega-menu-dropdown::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

.mega-menu-nav-item .dropdown-menu.mega-menu::-webkit-scrollbar-thumb:hover,
.resources-mega-menu .resources-mega-menu-dropdown::-webkit-scrollbar-thumb:hover,
.profile-mega-menu .profile-mega-menu-dropdown::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Print styles */
@media print {
    .mega-menu-nav-item .dropdown-menu.mega-menu {
        display: none !important;
    }
}

/* ========================================
   RESOURCES MEGA MENU SPECIFIC STYLES
   ======================================== */

/* Smaller width for Resources mega menu (3 columns instead of 6) */
.resources-mega-menu .resources-mega-menu-dropdown {
    min-width: 650px;
    max-width: 750px;
    width: max-content;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    overflow-x: hidden;
    right: 0 !important;
    left: auto !important;
    transform: none !important;
}

/* Prevent Resources menu from extending beyond left edge */
.resources-mega-menu .resources-mega-menu-dropdown {
    max-width: min(750px, calc(100vw - 40px));
}

@media (max-width: 1400px) {
    .resources-mega-menu .resources-mega-menu-dropdown {
        min-width: 600px;
        max-width: calc(100vw - 40px);
        right: 20px;
    }
}

@media (max-width: 1200px) {
    .resources-mega-menu .resources-mega-menu-dropdown {
        min-width: auto;
        max-width: calc(100vw - 40px);
        right: 20px;
    }
}

@media (max-width: 992px) {
    .resources-mega-menu .resources-mega-menu-dropdown {
        min-width: auto;
        max-width: calc(100vw - 20px);
        right: 10px !important;
        left: 10px !important;
    }
}

@media (max-width: 768px) {
    .resources-mega-menu .resources-mega-menu-dropdown {
        min-width: 100vw;
        max-width: 100vw;
        right: 0 !important;
        left: 0 !important;
        border-radius: 0;
        margin-top: 0;
    }
}

/* Resources specific section colors */
.resources-mega-menu-dropdown .stage-header[style*="#3B82F6"] {
    border-left-color: #3B82F6 !important;
}

.resources-mega-menu-dropdown .stage-header[style*="#8B5CF6"] {
    border-left-color: #8B5CF6 !important;
}

.resources-mega-menu-dropdown .stage-header[style*="#F59E0B"] {
    border-left-color: #F59E0B !important;
}

.resources-mega-menu-dropdown .stage-title i[style*="#3B82F6"] {
    color: #3B82F6 !important;
}

.resources-mega-menu-dropdown .stage-title i[style*="#8B5CF6"] {
    color: #8B5CF6 !important;
}

.resources-mega-menu-dropdown .stage-title i[style*="#F59E0B"] {
    color: #F59E0B !important;
}

/* Badge styling for featured resources */
.resources-mega-menu-dropdown .badge {
    font-weight: 500;
    font-size: 0.813rem;
    padding: 0.5rem 0.75rem;
}

/* Compact footer for resources */
.resources-mega-menu-dropdown .row:last-child {
    margin-bottom: 0;
}

.resources-mega-menu-dropdown .btn-outline-primary {
    font-size: 0.875rem;
}

/* ========================================
   PROFILE MEGA MENU SPECIFIC STYLES
   ======================================== */

/* Profile mega menu width (4 columns) */
.profile-mega-menu .profile-mega-menu-dropdown {
    min-width: 700px;
    max-width: 800px;
    width: max-content;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    overflow-x: hidden;
}

/* Align to right since it's the last menu item */
.profile-mega-menu .profile-mega-menu-dropdown {
    right: 0 !important;
    left: auto !important;
    transform: none !important;
}

/* Prevent Profile menu from extending beyond left edge */
.profile-mega-menu .profile-mega-menu-dropdown {
    max-width: min(800px, calc(100vw - 40px));
}

@media (max-width: 1400px) {
    .profile-mega-menu .profile-mega-menu-dropdown {
        min-width: 600px;
        max-width: calc(100vw - 40px);
        right: 20px;
    }
}

@media (max-width: 1200px) {
    .profile-mega-menu .profile-mega-menu-dropdown {
        min-width: auto;
        max-width: calc(100vw - 40px);
        right: 20px;
    }
}

@media (max-width: 992px) {
    .profile-mega-menu .profile-mega-menu-dropdown {
        min-width: auto;
        max-width: calc(100vw - 20px);
        right: 10px !important;
        left: 10px !important;
    }
}

@media (max-width: 768px) {
    .profile-mega-menu .profile-mega-menu-dropdown {
        min-width: 100vw;
        max-width: 100vw;
        right: 0 !important;
        left: 0 !important;
        border-radius: 0;
        margin-top: 0;
    }
}

/* Profile specific section colors */
.profile-mega-menu-dropdown .stage-header[style*="#6366F1"] {
    border-left-color: #6366F1 !important;
}

.profile-mega-menu-dropdown .stage-header[style*="#F59E0B"] {
    border-left-color: #F59E0B !important;
}

.profile-mega-menu-dropdown .stage-header[style*="#10B981"] {
    border-left-color: #10B981 !important;
}

.profile-mega-menu-dropdown .stage-header[style*="#EC4899"] {
    border-left-color: #EC4899 !important;
}

.profile-mega-menu-dropdown .stage-header[style*="#64748B"] {
    border-left-color: #64748B !important;
}

.profile-mega-menu-dropdown .stage-title i[style*="#6366F1"] {
    color: #6366F1 !important;
}

.profile-mega-menu-dropdown .stage-title i[style*="#F59E0B"] {
    color: #F59E0B !important;
}

.profile-mega-menu-dropdown .stage-title i[style*="#10B981"] {
    color: #10B981 !important;
}

.profile-mega-menu-dropdown .stage-title i[style*="#EC4899"] {
    color: #EC4899 !important;
}

.profile-mega-menu-dropdown .stage-title i[style*="#64748B"] {
    color: #64748B !important;
}

/* Horizontal settings links styling */
.profile-mega-menu-dropdown .stage-tools.d-flex {
    padding: 0.75rem 0.875rem;
}

.profile-mega-menu-dropdown .stage-tools.d-flex .tool-link {
    padding: 0.5rem 0.875rem;
    border-left: none;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
}

.profile-mega-menu-dropdown .stage-tools.d-flex .tool-link:hover {
    background: #f3f4f6;
    border-left: none;
    padding-left: 0.875rem;
}

/* Badge in messages link */
.profile-mega-menu-dropdown .badge {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    vertical-align: middle;
}

/* Footer buttons styling */
.profile-mega-menu-dropdown .btn-sm {
    font-size: 0.813rem;
    padding: 0.5rem 1rem;
}

/* Logout button styling */
.profile-mega-menu-dropdown .btn-outline-danger {
    border-color: #dc2626;
    color: #dc2626;
}

.profile-mega-menu-dropdown .btn-outline-danger:hover {
    background-color: #dc2626;
    color: white;
}

/* Responsive: Stack on mobile */
@media (max-width: 576px) {
    .profile-mega-menu-dropdown .col-md-3 {
        width: 100%;
        margin-bottom: 0.5rem;
    }
}

/* ========================================
   GOALS MEGA MENU SPECIFIC STYLES
   ======================================== */

/* Goals mega menu width (3 columns) */
.goals-mega-menu .goals-mega-menu-dropdown {
    min-width: 650px;
    max-width: 750px;
    width: max-content;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    overflow-x: hidden;
}

/* Prevent Goals menu from extending beyond viewport */
.goals-mega-menu .goals-mega-menu-dropdown {
    max-width: min(750px, calc(100vw - 40px));
}

@media (max-width: 1400px) {
    .goals-mega-menu .goals-mega-menu-dropdown {
        min-width: auto;
        max-width: calc(100vw - 40px);
    }
}

@media (max-width: 1200px) {
    .goals-mega-menu .goals-mega-menu-dropdown {
        min-width: auto;
        max-width: calc(100vw - 40px);
    }
}

@media (max-width: 992px) {
    .goals-mega-menu .goals-mega-menu-dropdown {
        min-width: auto;
        max-width: calc(100vw - 20px);
    }
}

@media (max-width: 768px) {
    .goals-mega-menu .goals-mega-menu-dropdown {
        min-width: 100vw;
        max-width: 100vw;
        left: 0 !important;
        right: 0 !important;
        border-radius: 0;
        margin-top: 0;
    }
}

/* Goals specific section colors */
.goals-mega-menu-dropdown .stage-header[style*="#4361ee"] {
    border-left-color: #4361ee !important;
}

.goals-mega-menu-dropdown .stage-header[style*="#38b000"] {
    border-left-color: #38b000 !important;
}

.goals-mega-menu-dropdown .stage-header[style*="#6366F1"] {
    border-left-color: #6366F1 !important;
}

.goals-mega-menu-dropdown .stage-title i[style*="#4361ee"] {
    color: #4361ee !important;
}

.goals-mega-menu-dropdown .stage-title i[style*="#38b000"] {
    color: #38b000 !important;
}

.goals-mega-menu-dropdown .stage-title i[style*="#6366F1"] {
    color: #6366F1 !important;
}

/* Responsive: Stack on mobile */
@media (max-width: 576px) {
    .goals-mega-menu-dropdown .col-md-4 {
        width: 100%;
        margin-bottom: 0.5rem;
    }
}

/* ========================================
   DASHBOARD MEGA MENU SPECIFIC STYLES
   ======================================== */

/* Dashboard mega menu width (4 columns) */
.dashboard-mega-menu .dashboard-mega-menu-dropdown {
    min-width: 750px;
    max-width: 850px;
    width: max-content;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    overflow-x: hidden;
}

/* Prevent Dashboard menu from extending beyond viewport */
.dashboard-mega-menu .dashboard-mega-menu-dropdown {
    max-width: min(850px, calc(100vw - 40px));
}

@media (max-width: 1400px) {
    .dashboard-mega-menu .dashboard-mega-menu-dropdown {
        min-width: auto;
        max-width: calc(100vw - 40px);
    }
}

@media (max-width: 1200px) {
    .dashboard-mega-menu .dashboard-mega-menu-dropdown {
        min-width: auto;
        max-width: calc(100vw - 40px);
    }
}

@media (max-width: 992px) {
    .dashboard-mega-menu .dashboard-mega-menu-dropdown {
        min-width: auto;
        max-width: calc(100vw - 20px);
    }
}

@media (max-width: 768px) {
    .dashboard-mega-menu .dashboard-mega-menu-dropdown {
        position: fixed !important;
        min-width: 100vw;
        max-width: 100vw;
        width: 100vw;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        border-radius: 0;
        margin-top: 0;
        margin-left: 0;
        margin-right: 0;
        transform: none !important;
        z-index: 1050;
    }
}

/* Dashboard specific section colors */
.dashboard-mega-menu-dropdown .stage-header[style*="#4361EE"] {
    border-left-color: #4361EE !important;
}

.dashboard-mega-menu-dropdown .stage-header[style*="#9333EA"] {
    border-left-color: #9333EA !important;
}

.dashboard-mega-menu-dropdown .stage-header[style*="#0891B2"] {
    border-left-color: #0891B2 !important;
}

.dashboard-mega-menu-dropdown .stage-header[style*="#F59E0B"] {
    border-left-color: #F59E0B !important;
}

.dashboard-mega-menu-dropdown .stage-title i[style*="#4361EE"] {
    color: #4361EE !important;
}

.dashboard-mega-menu-dropdown .stage-title i[style*="#9333EA"] {
    color: #9333EA !important;
}

.dashboard-mega-menu-dropdown .stage-title i[style*="#0891B2"] {
    color: #0891B2 !important;
}

.dashboard-mega-menu-dropdown .stage-title i[style*="#F59E0B"] {
    color: #F59E0B !important;
}

/* Responsive: Stack on mobile */
@media (max-width: 768px) {
    .dashboard-mega-menu-dropdown .col-md-6 {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .dashboard-mega-menu-dropdown .col-md-4 {
        width: 100%;
        margin-bottom: 0.5rem;
    }
}

/* ========================================
   AI COACH MEGA MENU SPECIFIC STYLES
   ======================================== */

/* AI Coach mega menu width (2 columns) */
.ai-coach-mega-menu .ai-coach-mega-menu-dropdown {
    min-width: 650px;
    max-width: 750px;
    width: max-content;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    overflow-x: hidden;
}

/* Align AI Coach menu to right (towards end of nav) */
.ai-coach-mega-menu .ai-coach-mega-menu-dropdown {
    right: 0 !important;
    left: auto !important;
    transform: none !important;
}

/* Prevent AI Coach menu from extending beyond viewport */
.ai-coach-mega-menu .ai-coach-mega-menu-dropdown {
    max-width: min(750px, calc(100vw - 40px));
}

@media (max-width: 1400px) {
    .ai-coach-mega-menu .ai-coach-mega-menu-dropdown {
        min-width: auto;
        max-width: calc(100vw - 40px);
    }
}

@media (max-width: 1200px) {
    .ai-coach-mega-menu .ai-coach-mega-menu-dropdown {
        min-width: auto;
        max-width: calc(100vw - 40px);
    }
}

@media (max-width: 992px) {
    .ai-coach-mega-menu .ai-coach-mega-menu-dropdown {
        min-width: auto;
        max-width: calc(100vw - 20px);
    }
}

@media (max-width: 768px) {
    .ai-coach-mega-menu .ai-coach-mega-menu-dropdown {
        position: fixed !important;
        min-width: 100vw;
        max-width: 100vw;
        width: 100vw;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        border-radius: 0;
        margin-top: 0;
        margin-left: 0;
        margin-right: 0;
        transform: none !important;
        z-index: 1050;
    }

    .ai-coach-mega-menu-dropdown .col-md-6 {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .ai-coach-mega-menu-dropdown .col-md-12 {
        width: 100%;
        margin-bottom: 0.5rem;
    }
}

/* AI Coach specific section colors */
.ai-coach-mega-menu-dropdown .stage-header[style*="#8B5CF6"] {
    border-left-color: #8B5CF6 !important;
}

.ai-coach-mega-menu-dropdown .stage-header[style*="#3B82F6"] {
    border-left-color: #3B82F6 !important;
}

.ai-coach-mega-menu-dropdown .stage-title i[style*="#8B5CF6"] {
    color: #8B5CF6 !important;
}

.ai-coach-mega-menu-dropdown .stage-title i[style*="#3B82F6"] {
    color: #3B82F6 !important;
}

/* Responsive: Stack on mobile */
@media (max-width: 576px) {
    .ai-coach-mega-menu-dropdown .col-md-6 {
        width: 100%;
        margin-bottom: 0.5rem;
    }
}

/* ========================================
   ADDITIONAL MOBILE OPTIMIZATIONS
   ======================================== */

/* Ensure all column types stack properly on mobile */
@media (max-width: 768px) {
    .mega-menu .col-md-3,
    .mega-menu .col-md-4,
    .mega-menu .col-md-6,
    .mega-menu .col-md-12 {
        width: 100% !important;
        margin-bottom: 0.75rem;
    }

    .mega-menu .col-md-3:last-child,
    .mega-menu .col-md-4:last-child,
    .mega-menu .col-md-6:last-child,
    .mega-menu .col-md-12:last-child {
        margin-bottom: 0;
    }
}

/* Tablet optimizations */
@media (min-width: 769px) and (max-width: 991px) {
    /* 2-column layout on tablet for 3+ column menus */
    .mega-menu .col-md-4,
    .mega-menu .col-md-3 {
        width: 50% !important;
    }

    /* Keep 2-column layouts as-is on tablet */
    .mega-menu .col-md-6 {
        width: 50% !important;
    }
}

/* Mobile touch optimizations */
@media (max-width: 768px) {
    /* Larger touch targets on mobile */
    .mega-menu-stage-card .tool-link {
        padding: 0.625rem 1rem;
        min-height: 44px;
        font-size: 0.875rem;
    }

    .mega-menu-stage-card .stage-title {
        padding: 0.75rem 1rem;
        min-height: 44px;
    }

    /* Better spacing on mobile */
    .mega-menu-stage-card {
        margin-bottom: 0.75rem;
    }

    /* Adjust header spacing */
    .mega-menu .row.mb-2,
    .mega-menu .row.mb-3 {
        margin-bottom: 1rem !important;
    }
}

/* Prevent body scroll when mega menu is open on mobile */
@media (max-width: 768px) {
    body.mega-menu-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
    }
}
