/**
 * FahimAI Mega Menu - Frontend Styles
 * NerdWallet-inspired clean design
 */

/* CSS Variables */
:root {
    --fmm-bg-color: #ffffff;
    --fmm-text-color: #4b5563;
    --fmm-heading-color: #1a1a2e;
    --fmm-link-hover: #0066cc;
    --fmm-nav-bg: #ffffff;
    --fmm-nav-text: #1a1a2e;
    --fmm-border-color: #e5e7eb;
    --fmm-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    --fmm-radius: 12px;
    --fmm-transition: 0.2s ease;
}

/* Reset & Base */
.fmm-navbar {
    position: relative;
    background: var(--fmm-nav-bg);
    border-bottom: 1px solid var(--fmm-border-color);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    z-index: 99999;
}

.fmm-navbar *,
.fmm-navbar *::before,
.fmm-navbar *::after {
    box-sizing: border-box;
}

.fmm-container {
    max-width: 1320px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 72px;
}

/* Logo */
.fmm-logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    flex-shrink: 0;
}

.fmm-logo img {
    height: 40px;
    width: auto;
    display: block;
}

.fmm-logo-text {
    font-size: 22px;
    font-weight: 700;
    color: var(--fmm-heading-color);
    letter-spacing: -0.02em;
}

/* Menu Wrapper */
.fmm-menu-wrapper {
    display: flex;
    align-items: center;
    flex: 1;
    justify-content: flex-end;
    gap: 8px;
}

/* Main Menu */
.fmm-menu {
    display: flex;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 4px;
}

.fmm-menu-item {
    position: relative;
    margin: 0;
    padding: 0;
}

.fmm-menu-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    color: var(--fmm-nav-text);
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    border-radius: 8px;
    transition: all var(--fmm-transition);
    white-space: nowrap;
}

.fmm-menu-link:hover,
.fmm-menu-item.is-active .fmm-menu-link {
    background: rgba(0, 0, 0, 0.04);
    color: var(--fmm-link-hover);
}

.fmm-icon {
    font-size: 18px;
    line-height: 1;
}

.fmm-chevron {
    width: 10px;
    height: 10px;
    opacity: 0.6;
    transition: transform var(--fmm-transition);
}

.fmm-menu-item.is-active .fmm-chevron {
    transform: rotate(180deg);
}

/* Dropdown Container */
.fmm-dropdown {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding-top: 8px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.25s ease;
}

.fmm-menu-item.is-active .fmm-dropdown {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.fmm-dropdown-inner {
    background: var(--fmm-bg-color);
    border-radius: var(--fmm-radius);
    box-shadow: var(--fmm-shadow);
    border: 1px solid var(--fmm-border-color);
    min-width: 600px;
    max-width: 900px;
    overflow: hidden;
}

/* Full-width dropdowns for many columns */
.fmm-dropdown[data-columns="4"] .fmm-dropdown-inner,
.fmm-dropdown[data-columns="5"] .fmm-dropdown-inner {
    min-width: 800px;
    max-width: 1100px;
}

/* Dropdown Content */
.fmm-dropdown-content {
    padding: 24px 28px;
    display: flex;
    gap: 24px;
}

.fmm-dropdown-grid {
    display: grid;
    gap: 32px;
    flex: 1;
}

.fmm-cols-2 { grid-template-columns: repeat(2, 1fr); }
.fmm-cols-3 { grid-template-columns: repeat(3, 1fr); }
.fmm-cols-4 { grid-template-columns: repeat(4, 1fr); }
.fmm-cols-5 { grid-template-columns: repeat(5, 1fr); }

/* Category Styles */
.fmm-category {
    min-width: 0;
}

.fmm-category-title {
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--fmm-heading-color);
    text-decoration: none;
    padding-bottom: 12px;
    margin-bottom: 8px;
    border-bottom: 2px solid var(--fmm-border-color);
    transition: color var(--fmm-transition);
}

.fmm-category-title:hover {
    color: var(--fmm-link-hover);
}

/* Category Links */
.fmm-category-links {
    list-style: none;
    margin: 0;
    padding: 0;
}

.fmm-category-links li {
    margin: 0;
    padding: 0;
}

.fmm-link {
    display: block;
    padding: 8px 0;
    text-decoration: none;
    transition: all var(--fmm-transition);
}

.fmm-link:hover {
    transform: translateX(4px);
}

.fmm-link-title {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--fmm-text-color);
    transition: color var(--fmm-transition);
    line-height: 1.4;
}

.fmm-link:hover .fmm-link-title {
    color: var(--fmm-link-hover);
}

.fmm-link-desc {
    display: block;
    font-size: 12px;
    color: #9ca3af;
    margin-top: 2px;
    line-height: 1.4;
}

/* Featured Card */
.fmm-featured-card {
    flex-shrink: 0;
    width: 220px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 10px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.fmm-featured-image {
    border-radius: 8px;
    overflow: hidden;
}

.fmm-featured-image img {
    width: 100%;
    height: auto;
    display: block;
}

.fmm-featured-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.fmm-featured-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
    color: var(--fmm-link-hover);
    text-decoration: none;
    transition: gap var(--fmm-transition);
}

.fmm-featured-link:hover {
    gap: 10px;
}

.fmm-featured-link svg {
    flex-shrink: 0;
}

/* CTA Button */
.fmm-cta {
    margin-left: 16px;
}

.fmm-cta-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    background: var(--fmm-link-hover);
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 8px;
    transition: all var(--fmm-transition);
    white-space: nowrap;
}

.fmm-cta-button:hover {
    background: #0052a3;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 102, 204, 0.3);
}

/* Mobile Toggle */
.fmm-mobile-toggle {
    display: none;
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    border-radius: 8px;
}

.fmm-mobile-toggle:hover {
    background: rgba(0, 0, 0, 0.04);
}

.fmm-hamburger {
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 24px;
}

.fmm-hamburger span {
    display: block;
    height: 2px;
    background: var(--fmm-nav-text);
    border-radius: 2px;
    transition: all var(--fmm-transition);
}

.fmm-mobile-toggle[aria-expanded="true"] .fmm-hamburger span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.fmm-mobile-toggle[aria-expanded="true"] .fmm-hamburger span:nth-child(2) {
    opacity: 0;
}

.fmm-mobile-toggle[aria-expanded="true"] .fmm-hamburger span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* ============================================
   RESPONSIVE STYLES
   ============================================ */

@media (max-width: 1200px) {
    .fmm-dropdown-inner {
        min-width: 500px;
        max-width: 700px;
    }
    
    .fmm-dropdown[data-columns="4"] .fmm-dropdown-inner,
    .fmm-dropdown[data-columns="5"] .fmm-dropdown-inner {
        min-width: 600px;
        max-width: 800px;
    }
    
    .fmm-cols-4 { grid-template-columns: repeat(3, 1fr); }
    .fmm-cols-5 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 980px) {
    .fmm-mobile-toggle {
        display: flex;
    }
    
    .fmm-menu-wrapper {
        position: fixed;
        top: 72px;
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--fmm-bg-color);
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        padding: 16px;
        overflow-y: auto;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        gap: 16px;
    }
    
    .fmm-menu-wrapper.is-open {
        transform: translateX(0);
    }
    
    .fmm-menu {
        flex-direction: column;
        width: 100%;
        gap: 0;
    }
    
    .fmm-menu-item {
        width: 100%;
        border-bottom: 1px solid var(--fmm-border-color);
    }
    
    .fmm-menu-link {
        width: 100%;
        padding: 16px 0;
        justify-content: space-between;
        border-radius: 0;
    }
    
    .fmm-menu-link:hover {
        background: transparent;
    }
    
    .fmm-dropdown {
        position: static;
        transform: none;
        padding-top: 0;
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        display: none;
    }
    
    .fmm-menu-item.is-active .fmm-dropdown {
        display: block;
    }
    
    .fmm-dropdown-inner {
        min-width: 100%;
        max-width: 100%;
        box-shadow: none;
        border: none;
        border-radius: 0;
    }
    
    .fmm-dropdown-content {
        padding: 0 0 16px;
        flex-direction: column;
    }
    
    .fmm-dropdown-grid {
        grid-template-columns: 1fr !important;
        gap: 24px;
    }
    
    .fmm-featured-card {
        width: 100%;
    }
    
    .fmm-cta {
        margin-left: 0;
        margin-top: 16px;
    }
    
    .fmm-cta-button {
        width: 100%;
        text-align: center;
    }
}

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

.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.fmm-menu-link:focus,
.fmm-link:focus,
.fmm-category-title:focus,
.fmm-cta-button:focus {
    outline: 2px solid var(--fmm-link-hover);
    outline-offset: 2px;
}

/* ============================================
   DIVI COMPATIBILITY OVERRIDES
   ============================================ */

.et_pb_section .fmm-navbar,
#main-header .fmm-navbar,
.et-l .fmm-navbar {
    all: unset;
    display: block;
    position: relative;
    background: var(--fmm-nav-bg);
    border-bottom: 1px solid var(--fmm-border-color);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    z-index: 99999;
}

.et_pb_section .fmm-menu,
.et-l .fmm-menu {
    all: unset;
    display: flex;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 4px;
}

.et_pb_section .fmm-menu-item,
.et-l .fmm-menu-item {
    all: unset;
    position: relative;
    margin: 0;
    padding: 0;
}

.et_pb_section .fmm-menu-link,
.et-l .fmm-menu-link {
    all: unset;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    color: var(--fmm-nav-text);
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--fmm-transition);
    white-space: nowrap;
}

.et_pb_section .fmm-category-links,
.et-l .fmm-category-links {
    all: unset;
    display: block;
    list-style: none;
    margin: 0;
    padding: 0;
}

.et_pb_section .fmm-category-links li,
.et-l .fmm-category-links li {
    all: unset;
    display: block;
    margin: 0;
    padding: 0;
}
