/**
 * Service Menu Loader Styles
 * CSS for server-side rendered service loading menu system
 */

/* Main Services Menu Container */
.service-services-menu {
    position: relative;
    min-width: 280px;
    overflow: hidden;
}

/* Mega Menu Container - Remove scrollbars */
.service-submenu-container {
    overflow: visible !important;
}

.mega-menu-services-container {
    overflow: visible !important;
}

.mega-menu-services {
    overflow: visible !important;
}

.tier-popup {
    overflow: hidden !important;
}

/* Enhanced tier popup styling using configured theme colors */
.tier-popup-enhanced {
    background: var(--service-menu-dropdown-bg) !important;
    border: var(--service-menu-border-width) solid var(--service-menu-border-color) !important;
    border-radius: var(--service-menu-border-radius) !important;
    box-shadow: 0 4px var(--service-menu-shadow-blur) rgba(0, 0, 0, var(--service-menu-shadow-opacity)) !important;
    padding: var(--service-menu-padding) !important;
    width: auto !important;
    min-width: 300px !important;
    max-width: 700px !important;
    font-family: var(--service-menu-font-family) !important;
    overflow: visible !important;
    box-sizing: border-box !important;
}

/* Force grid layout directly on the popup content - respect configured columns */
.tier-popup-enhanced .tier-grid,
.tier-popup .tier-grid {
    display: grid !important;
    /* Don't override grid-template-columns - let the inline style from configuration handle it */
    gap: var(--service-menu-column-gap, 15px) !important;
    width: 100% !important;
    align-items: start !important;
}

/* Remove CSS width overrides - let inline styles handle width */

.tier-popup-enhanced .tier-column,
.tier-popup .tier-column {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
}

/* Ensure tier popup items are properly distributed in grid */
.tier-popup-enhanced,
.tier-popup {
    overflow: visible !important;
}

.tier-popup-enhanced > .tier-grid,
.tier-popup > .tier-grid {
    display: grid !important;
    width: 100% !important;
}

.tier-popup-enhanced .tier-service-link {
    color: var(--service-menu-child-text-color) !important;
    padding: var(--service-menu-item-padding) !important;
    display: block !important;
    text-decoration: none !important;
    border-radius: 4px !important;
    transition: all var(--service-menu-animation) ease !important;
}

.tier-popup-enhanced .tier-service-link:hover {
    background-color: var(--service-menu-child-hover-bg) !important;
    color: var(--service-menu-child-hover-text) !important;
}

/* Remove hardcoded column overrides - let configuration handle columns */

/* Tier popup service items */
.tier-popup .tier-service-link {
    display: block !important;
    padding: var(--service-menu-item-padding) !important;
    color: var(--service-menu-child-text-color) !important;
    text-decoration: none !important;
    border-radius: 4px !important;
    transition: all var(--service-menu-animation) ease !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    hyphens: auto !important;
    max-width: 100% !important;
}

.tier-popup .tier-service-link:hover {
    background-color: var(--service-menu-child-hover-bg) !important;
    color: var(--service-menu-child-hover-text) !important;
}

/* Responsive tier popup columns */
@media (max-width: 768px) {
    .tier-popup .tier-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Search Functionality */
.menu-item-search {
    padding: 15px;
    border-bottom: 2px solid #333;
    background: #f8f9fa;
}

.service-search-wrapper {
    position: relative;
}

.service-search {
    width: 100%;
    padding: 10px 15px;
    border: 2px solid #333;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    color: #222;
    background: #ffffff;
    outline: none;
    transition: all 0.3s ease;
}

.service-search:focus {
    border-color: #007cba;
    box-shadow: 0 0 0 3px rgba(0, 124, 186, 0.2);
}

.service-search::placeholder {
    color: #666;
    font-weight: 400;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.search-loading,
.search-error {
    padding: 10px 15px;
    text-align: center;
    color: #666;
    font-style: italic;
}

.search-error {
    color: #d63638;
}

/* Service Load Triggers */
.service-load-trigger {
    position: relative;
}

.service-load-trigger > a {
    position: relative;
    padding-right: 25px;
}

.services-mega-menu .mobile-accordion-menu {
    display: none !important;
}

.services-mega-menu.fl-active .mobile-accordion-menu {
    display: block !important;
}

.service-load-trigger > a:after {
    content: '▶';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    transition: transform 0.3s ease;
}

.service-load-trigger:hover > a:after,
.menu-loaded > a:after {
    transform: translateY(-50%) rotate(90deg);
}

/* Service Submenu Container */
.service-submenu-container {
    position: absolute;
    left: 0;
    top: 100%;
    min-width: 600px;
    max-width: 90vw;
    background: #ffffff;
    border: 2px solid #333;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    z-index: 999;
    display: none;
}

/* Adjust positioning based on menu location */
.navbar-nav .service-submenu-container {
    left: 0;
    top: 100%;
}

/* Prevent off-screen issues */
.service-submenu-container {
    transform: translateX(0);
}

/* If container would go off right edge, align to right */
.services-mega-menu:last-child .service-submenu-container,
.services-mega-menu.align-right .service-submenu-container {
    left: auto;
    right: 0;
}

.service-load-trigger:hover .service-submenu-container,
.menu-loaded .service-submenu-container {
    display: block;
}

/* Loading States */
.loading-placeholder,
.loading-error {
    padding: 20px;
    text-align: center;
    color: #333;
    font-style: italic;
    font-weight: 600;
    font-size: 16px;
}

.loading-error {
    color: #d63638;
    font-weight: 700;
}

/* Mega Menu Services Layout */
.mega-menu-services {
    display: flex;
    padding: 15px;
    gap: 20px;
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
}

.services-column {
    flex: 1;
    min-width: 180px;
}

.service-item {
    margin-bottom: 8px;
}

.service-link {
    display: block;
    padding: 8px 12px;
    color: #222;
    text-decoration: none;
    border-radius: 4px;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.4;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.service-link:hover {
    background-color: #007cba;
    color: #ffffff;
    text-decoration: none;
    transform: translateX(2px);
    border-color: #005a87;
    box-shadow: 0 2px 4px rgba(0, 124, 186, 0.2);
}

/* Column Responsive Adjustments */
.mega-menu-services[data-columns="1"] {
    max-width: 250px;
}

.mega-menu-services[data-columns="2"] {
    max-width: 400px;
}

.mega-menu-services[data-columns="3"] {
    max-width: 600px;
}

.mega-menu-services[data-columns="4"] {
    max-width: 800px;
}

.mega-menu-services[data-columns="5"] {
    max-width: 1000px;
}

/* View All Services Link */
.view-all-services {
    border-top: 1px solid #eee;
    background: #f9f9f9;
}

.view-all-services a {
    display: block;
    padding: 12px 15px;
    font-weight: 600;
    color: #007cba;
    text-align: center;
}

.view-all-services a:hover {
    background-color: #e6f3ff;
    text-decoration: none;
}

/* No Services Found */
.no-services a {
    color: #666;
    font-style: italic;
    cursor: default;
}

.no-services a:hover {
    background: none;
    color: #666;
}

/* Animation for loaded content */
.mega-menu-services {
    opacity: 0;
    animation: fadeInUp 0.3s ease forwards;
}

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

/* Mobile Responsive */
@media (max-width: 768px) {
    .service-submenu-container {
        position: fixed;
        left: 0;
        right: 0;
        top: 60px;
        min-width: auto;
        max-height: calc(100vh - 80px);
        border-radius: 0;
    }
    
    .mega-menu-services {
        flex-direction: column;
        max-height: none;
    }
    
    .services-column {
        min-width: auto;
    }
    
    .mega-menu-services[data-columns="3"],
    .mega-menu-services[data-columns="4"],
    .mega-menu-services[data-columns="5"] {
        max-width: none;
    }
}

/* Loading Animation */
.loading-placeholder {
    position: relative;
}

.loading-placeholder:after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007cba;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Cache indicator for development */
.menu-loaded > a:before {
    content: '●';
    color: #46b450;
    font-size: 8px;
    position: absolute;
    left: -15px;
    top: 50%;
    transform: translateY(-50%);
}

/*
 * UNIVERSAL THEME COMPATIBILITY FOR SERVICE MENU ITEMS
 * This CSS ensures service menu items look like regular menu items with children
 * across ALL WordPress themes by detecting and copying existing theme styles
 */

/* Method 1: Standard WordPress classes - works with most themes */
.wpps-mega-menu.menu-item-has-children > a::after,
.wpps-mega-menu.has-dropdown > a::after {
    content: '' !important;
    display: inline-block !important;
    width: 0 !important;
    height: 0 !important;
    margin-left: 8px !important;
    vertical-align: middle !important;
    border-top: 4px solid currentColor !important;
    border-right: 4px solid transparent !important;
    border-left: 4px solid transparent !important;
    opacity: 1 !important;
}

/* Method 2: Copy styles from existing menu items with children */
/* This will be dynamically generated by JavaScript to match the current theme */

/* Method 3: Fallback for themes that use different approaches */
.wpps-mega-menu > a[data-wpps-enable-service-menu]::after {
    content: '▼' !important;
    font-size: 0.7em !important;
    margin-left: 6px !important;
    opacity: 0.7 !important;
}

/* Method 4: Popular theme compatibility */
/* Astra Theme */
.ast-menu-toggle .wpps-mega-menu > a::after,
.astra-menu .wpps-mega-menu > a::after {
    content: '' !important;
    border: solid currentColor !important;
    border-width: 0 2px 2px 0 !important;
    display: inline-block !important;
    padding: 2px !important;
    transform: rotate(45deg) !important;
    margin-left: 8px !important;
}

/* GeneratePress Theme */
.main-navigation .wpps-mega-menu > a::after {
    content: '' !important;
    border-top: 4px solid currentColor !important;
    border-right: 4px solid transparent !important;
    border-left: 4px solid transparent !important;
    margin-left: 8px !important;
    display: inline-block !important;
}

/* OceanWP Theme */
.oceanwp-menu .wpps-mega-menu > a::after {
    content: '\f107' !important;
    font-family: 'Font Awesome 5 Free' !important;
    font-weight: 900 !important;
    margin-left: 8px !important;
}

/* Divi Theme */
.et_pb_menu .wpps-mega-menu > a::after {
    content: '3' !important;
    font-family: 'ETmodules' !important;
    margin-left: 8px !important;
}

/* Avada Theme */
.fusion-menu .wpps-mega-menu > a::after {
    content: '' !important;
    border-top: 4px solid currentColor !important;
    border-right: 4px solid transparent !important;
    border-left: 4px solid transparent !important;
    margin-left: 8px !important;
    display: inline-block !important;
}

/* Ensure service menu items inherit positioning */
.wpps-mega-menu.menu-item-has-children,
.wpps-mega-menu.has-dropdown {
    position: relative !important;
}
