/**
 * Mega Menu Navigation Styles
 * Desktop-only dropdown menus with visual cards
 * Theme-compatible with dark/light mode support
 */

/* =============================================
   BASE MEGA MENU STYLES
   ============================================= */

.mega-menu-nav {
    position: relative;
    z-index: 2000;
}

.mega-menu-list {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.mega-menu-item {
    position: relative;
}

/* Trigger Button */
.mega-menu-trigger {
    background: transparent;
    border: none;
    color: var(--text-color);
    font-size: 1rem;
    font-weight: 500;
    padding: 0.625rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.mega-menu-trigger:hover {
    background: var(--input-bg);
    color: var(--primary-color, #007bff);
}

.mega-menu-trigger[aria-expanded="true"] {
    background: var(--input-bg);
    color: var(--primary-color, #007bff);
}

.mega-menu-trigger[aria-expanded="true"] i.fa-chevron-down {
    transform: rotate(180deg);
}

.mega-menu-trigger i.fa-chevron-down {
    transition: transform 0.2s ease;
    font-size: 0.75rem;
}

/* =============================================
   DROPDOWN PANEL
   ============================================= */

.mega-menu-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    min-width: 600px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2001;
    overflow: hidden;
}

.mega-menu-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.mega-menu-container {
    padding: 1.5rem;
}

/* =============================================
   SECTIONS
   ============================================= */

.mega-menu-section {
    margin-bottom: 1.5rem;
}

.mega-menu-section:last-child {
    margin-bottom: 0;
}

.mega-menu-section-title {
    font-size: 0.875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-color);
    opacity: 0.7;
    margin-bottom: 1rem;
}

/* =============================================
   CARD GRID
   ============================================= */

.mega-menu-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

/* =============================================
   MENU CARDS
   ============================================= */

.mega-menu-card {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
    background: var(--input-bg);
    border: 2px solid transparent;
    border-radius: 12px;
    text-decoration: none;
    color: var(--text-color);
    transition: all 0.2s ease;
    position: relative;
}

.mega-menu-card:hover {
    background: var(--card-bg);
    border-color: var(--primary-color, #007bff);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.15);
    text-decoration: none;
    color: var(--text-color);
}

/* Card Icon */
.mega-menu-card-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: white;
    transition: transform 0.2s ease;
}

.mega-menu-card:hover .mega-menu-card-icon {
    transform: scale(1.1);
}

/* Icon Colors */
.planning-icon { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.results-icon { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); }
.sip-icon { background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); }
.expense-icon { background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%); }
.tax-icon { background: linear-gradient(135deg, #fa709a 0%, #fee140 100%); }
.backtest-icon { background: linear-gradient(135deg, #30cfd0 0%, #330867 100%); }
.picks-icon { background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%); }
.insights-icon { background: linear-gradient(135deg, #ffd89b 0%, #19547b 100%); }
.library-icon { background: linear-gradient(135deg, #89f7fe 0%, #66a6ff 100%); }
.strategy-icon { background: linear-gradient(135deg, #fddb92 0%, #d1fdff 100%); }

/* Card Content */
.mega-menu-card-content {
    flex: 1;
    min-width: 0;
}

.mega-menu-card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.25rem;
    line-height: 1.3;
}

.mega-menu-card-desc {
    font-size: 0.875rem;
    color: var(--text-color);
    opacity: 0.7;
    margin: 0;
    line-height: 1.4;
}

/* Card Badges */
.mega-menu-card-badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.mega-menu-card-badge.badge-new {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

/* =============================================
   CTA SECTION
   ============================================= */

.mega-menu-cta {
    border-top: 1px solid var(--border-color);
    padding-top: 1.5rem;
}

.mega-menu-promo-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
}

.mega-menu-promo-icon {
    font-size: 2rem;
    margin-bottom: 0.75rem;
    opacity: 0.9;
}

.mega-menu-promo-title {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: white;
}

.mega-menu-promo-desc {
    font-size: 0.875rem;
    opacity: 0.9;
    margin-bottom: 1rem;
    color: white;
}

.mega-menu-promo-card .btn {
    background: white;
    color: #667eea;
    font-weight: 600;
    border: none;
    padding: 0.5rem 1.5rem;
    border-radius: 50px;
    transition: all 0.2s ease;
}

.mega-menu-promo-card .btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* =============================================
   BACKDROP
   ============================================= */

.mega-menu-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 1999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mega-menu-backdrop.active {
    opacity: 1;
}

/* =============================================
   RESPONSIVE ADJUSTMENTS
   ============================================= */

/* Wider dropdowns for Tools menu (has 2 sections) */
#menu-tools {
    min-width: 700px;
}

/* Last menu item dropdown - wider, more substantial appearance */
.mega-menu-item:last-child .mega-menu-dropdown {
    min-width: 500px;  /* Make it more substantial */
    max-width: calc(100vw - 2rem);  /* Prevent viewport overflow */
}

/* Resources menu specific styling - make cards full width */
#menu-resources .mega-menu-grid {
    grid-template-columns: 1fr;  /* Stack cards vertically for better readability */
    gap: 1rem;
}

/* =============================================
   TABLET ADJUSTMENTS (768px - 991px)
   ============================================= */

@media (max-width: 991px) {
    .mega-menu-dropdown {
        min-width: 500px;
    }

    #menu-tools,
    #menu-resources {
        min-width: 600px;
    }

    .mega-menu-grid {
        grid-template-columns: 1fr;
    }
}

/* =============================================
   MOBILE HIDE (< 768px)
   ============================================= */

@media (max-width: 767px) {
    .mega-menu-nav {
        display: none !important;
    }
}

/* =============================================
   ACCESSIBILITY
   ============================================= */

/* Focus styles for keyboard navigation */
.mega-menu-trigger:focus-visible {
    outline: 2px solid var(--primary-color, #007bff);
    outline-offset: 2px;
}

.mega-menu-card:focus-visible {
    outline: 2px solid var(--primary-color, #007bff);
    outline-offset: 2px;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .mega-menu-dropdown,
    .mega-menu-trigger i,
    .mega-menu-card,
    .mega-menu-card-icon,
    .mega-menu-backdrop {
        transition: none !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .mega-menu-card {
        border: 2px solid var(--text-color);
    }

    .mega-menu-card:hover {
        border-color: var(--primary-color, #007bff);
        border-width: 3px;
    }
}
