/**
 * Bitstech Store — Megamenu Styles
 * Dropdown centered within header, with hover bridge for smooth interaction.
 * 3-column layout: Categories | More | Featured Products
 */

/* Parent item keeps position:relative for hover containment */
.bt-nav-list > .menu-item-has-children.bt-has-megamenu {
    position: static;
}

/* Make header-main the positioning context */
.bt-header-main {
    position: relative;
}

/* Megamenu panel — centered within .bt-header-main */
.bt-megamenu {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 720px;
    max-width: calc(100vw - 32px);
    padding: 16px 18px;
    margin-top: 0;
    background: rgba(15, 23, 42, 0.98);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(var(--bt-primary-rgb, 117, 59, 235), 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.22s ease, visibility 0.22s;
    z-index: 1000;
    display: grid;
    grid-template-columns: 1fr 1fr 200px;
    gap: 14px;
    overflow: hidden;
}

/* Invisible hover bridge — fills the gap between nav link and megamenu */
.bt-megamenu::before {
    content: '';
    position: absolute;
    top: -20px;
    left: 0;
    right: 0;
    height: 20px;
    background: transparent;
}

/* Show on hover — JS adds .bt-mega-active class for reliable hover */
.bt-nav-list > .menu-item-has-children.bt-has-megamenu.bt-mega-active > .bt-megamenu,
.bt-nav-list > .menu-item-has-children.bt-has-megamenu:focus-within > .bt-megamenu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Keep megamenu centered on viewport regardless of nav item position */
@media (min-width: 1025px) {
    .bt-megamenu {
        left: 50%;
        transform: translateX(-50%);
    }
}

/* ═══════════════════════════════════════
   Category Columns
   ═══════════════════════════════════════ */
.bt-megamenu__col {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 320px;
    overflow-y: auto;
    padding-right: 6px;
    scrollbar-width: thin;
    scrollbar-color: rgba(var(--bt-primary-rgb, 117, 59, 235), 0.3) transparent;
}

.bt-megamenu__col::-webkit-scrollbar {
    width: 3px;
}

.bt-megamenu__col::-webkit-scrollbar-thumb {
    background: rgba(var(--bt-primary-rgb, 117, 59, 235), 0.3);
    border-radius: 3px;
}

.bt-megamenu__col-title {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--bt-primary, #753beb);
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(var(--bt-primary-rgb, 117, 59, 235), 0.15);
    position: sticky;
    top: 0;
    background: rgba(15, 23, 42, 0.98);
    z-index: 1;
}

.bt-megamenu__link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: 8px;
    text-decoration: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.78rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

.bt-megamenu__link:hover {
    background: rgba(var(--bt-primary-rgb, 117, 59, 235), 0.12);
    color: #fff;
    transform: translateX(3px);
}

.bt-megamenu__link-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: rgba(var(--bt-primary-rgb, 117, 59, 235), 0.08);
    flex-shrink: 0;
    transition: background 0.15s;
}

.bt-megamenu__link:hover .bt-megamenu__link-icon {
    background: rgba(var(--bt-primary-rgb, 117, 59, 235), 0.18);
}

.bt-megamenu__link-icon svg {
    width: 14px;
    height: 14px;
    stroke: var(--bt-accent, #00e0f0);
}

.bt-megamenu__link-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.bt-megamenu__link-name {
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.76rem;
    line-height: 1.3;
}

.bt-megamenu__link-desc {
    font-size: 0.62rem;
    color: rgba(255, 255, 255, 0.35);
    margin-top: 1px;
}

/* ═══════════════════════════════════════
   Featured Products Column
   ═══════════════════════════════════════ */
.bt-megamenu__featured {
    background: rgba(var(--bt-primary-rgb, 117, 59, 235), 0.04);
    border-radius: 10px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid rgba(var(--bt-primary-rgb, 117, 59, 235), 0.08);
}

.bt-megamenu__featured-title {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--bt-accent, #00e0f0);
    margin-bottom: 2px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(var(--bt-primary-rgb, 117, 59, 235), 0.1);
}

.bt-megamenu__featured-card {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 6px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    text-decoration: none;
    transition: all 0.15s ease;
    align-items: center;
    text-align: center;
}

.bt-megamenu__featured-card:hover {
    background: rgba(var(--bt-primary-rgb, 117, 59, 235), 0.1);
    border-color: rgba(var(--bt-primary-rgb, 117, 59, 235), 0.2);
    transform: translateY(-1px);
}

.bt-megamenu__featured-img {
    width: 100%;
    height: 48px;
    border-radius: 5px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.04);
    flex-shrink: 0;
    margin-bottom: 4px;
}

.bt-megamenu__featured-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 2px;
}

.bt-megamenu__featured-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
    width: 100%;
}

.bt-megamenu__featured-name {
    font-size: 0.6rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.3;
    max-width: 100%;
}

.bt-megamenu__featured-price {
    font-size: 0.58rem;
    font-weight: 700;
    color: var(--bt-accent, #00e0f0);
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Hide WooCommerce price HTML extras in megamenu */
.bt-megamenu__featured-price del {
    display: none;
}

.bt-megamenu__featured-price .woocommerce-Price-amount {
    font-size: inherit;
}

.bt-megamenu__viewall {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: auto;
    padding: 5px 10px;
    border-radius: 5px;
    background: linear-gradient(135deg, var(--bt-primary, #753beb), rgba(var(--bt-primary-rgb, 117, 59, 235), 0.8));
    color: #fff;
    font-size: 0.58rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.15s ease;
}

.bt-megamenu__viewall:hover {
    filter: brightness(1.15);
    transform: translateY(-1px);
}

/* ═══════════════════════════════════════
   Light Mode
   ═══════════════════════════════════════ */
html[data-theme="light"] .bt-megamenu {
    background: rgba(255, 255, 255, 0.99);
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.12),
        0 0 0 1px rgba(0, 0, 0, 0.04);
}

html[data-theme="light"] .bt-megamenu__col-title {
    background: rgba(255, 255, 255, 0.99);
    color: var(--bt-primary, #753beb);
    border-bottom-color: rgba(0, 0, 0, 0.06);
}

html[data-theme="light"] .bt-megamenu__link {
    color: #4b5563;
}

html[data-theme="light"] .bt-megamenu__link:hover {
    background: rgba(var(--bt-primary-rgb, 117, 59, 235), 0.06);
    color: #1a1f35;
}

html[data-theme="light"] .bt-megamenu__link-name {
    color: #1f2937;
}

html[data-theme="light"] .bt-megamenu__link-desc {
    color: #9ca3af;
}

html[data-theme="light"] .bt-megamenu__link-icon {
    background: rgba(var(--bt-primary-rgb, 117, 59, 235), 0.06);
}

html[data-theme="light"] .bt-megamenu__featured {
    background: #f8f9fb;
    border-color: rgba(0, 0, 0, 0.05);
}

html[data-theme="light"] .bt-megamenu__featured-card {
    background: #fff;
    border-color: #e5e7eb;
}

html[data-theme="light"] .bt-megamenu__featured-card:hover {
    border-color: rgba(var(--bt-primary-rgb, 117, 59, 235), 0.2);
    background: rgba(var(--bt-primary-rgb, 117, 59, 235), 0.02);
}

html[data-theme="light"] .bt-megamenu__featured-name {
    color: #1f2937;
}

html[data-theme="light"] .bt-megamenu__featured-price {
    color: var(--bt-primary, #753beb);
}

/* ═══════════════════════════════════════
   Responsive — hide on tablet/mobile
   ═══════════════════════════════════════ */
@media (max-width: 1024px) {
    .bt-megamenu {
        display: none !important;
    }
}
