/* ===== Мега-меню шапки (inc/mega-menu.php) ===== */

.twc-mega-item {
    position: relative;
}

/* Стрелка у пункта меню */
.twc-mega-item > a .nav-link-text::after {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-left: 7px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: translateY(-3px) rotate(45deg);
    transition: transform .2s ease;
    opacity: .6;
}

.twc-mega-item.is-open > a .nav-link-text::after {
    transform: translateY(0) rotate(225deg);
}

.twc-mega {
    --twc-blue: var(--wd-primary-color, rgb(46, 107, 198));
    --twc-blue-soft: rgba(46, 107, 198, .08);
    --twc-ink: var(--wd-title-color, #242424);
    --twc-muted: #6b7280;
    --twc-line: rgba(16, 16, 16, .08);

    position: absolute;
    top: 100%;
    left: 0;
    z-index: 400;
    width: 1200px;
    padding-top: 10px; /* «мостик», чтобы меню не закрывалось по пути мыши */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity .2s ease, transform .2s ease, visibility 0s linear .2s;
    text-align: left;
    text-transform: none;
    letter-spacing: normal;
    font-family: var(--wd-text-font);
    font-weight: 400;
}

.twc-mega-item.is-open > .twc-mega {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
    transition: opacity .2s ease, transform .2s ease, visibility 0s;
}

.twc-mega__inner {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr) 250px;
    grid-template-rows: minmax(0, 1fr);
    height: min(520px, calc(100vh - 160px));
    background: #fff;
    border: 1px solid var(--twc-line);
    border-radius: 18px;
    box-shadow: 0 24px 60px -12px rgba(16, 24, 40, .22), 0 4px 12px rgba(16, 24, 40, .06);
    overflow: hidden;
}

/* --- Вкладки серий --- */
.twc-mega__tabs {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 14px 10px;
    background: #f7f8fa;
    border-right: 1px solid var(--twc-line);
    overflow-y: auto;
}

.twc-mega .twc-mega__tab {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    min-height: 0;
    margin: 0;
    padding: 10px 12px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    box-shadow: none;
    color: var(--twc-ink);
    font-family: var(--wd-title-font);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    text-align: left;
    text-transform: none;
    letter-spacing: 0;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
}

.twc-mega .twc-mega__tab:hover {
    background: rgba(16, 16, 16, .04);
}

.twc-mega .twc-mega__tab.is-active {
    background: #fff;
    color: var(--twc-blue);
    box-shadow: 0 1px 3px rgba(16, 24, 40, .08);
}

.twc-mega__count {
    flex-shrink: 0;
    min-width: 26px;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(16, 16, 16, .06);
    color: var(--twc-muted);
    font-size: 11px;
    font-weight: 600;
    text-align: center;
}

.twc-mega__tab.is-active .twc-mega__count {
    background: var(--twc-blue-soft);
    color: var(--twc-blue);
}

.twc-mega.is-searching .twc-mega__tab.is-active {
    background: transparent;
    color: var(--twc-ink);
    box-shadow: none;
}

/* --- Центр: поиск + модели --- */
.twc-mega__main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.twc-mega *,
.twc-mega *::before,
.twc-mega *::after {
    box-sizing: border-box;
}

.twc-mega__head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 20px;
    padding: 16px 22px;
    border-bottom: 1px solid var(--twc-line);
}

.twc-mega .twc-mega__search {
    position: relative;
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
    margin: 0;
}

.twc-mega__search svg {
    position: absolute;
    top: 50%;
    left: 14px;
    transform: translateY(-50%);
    color: var(--twc-muted);
    pointer-events: none;
}

.twc-mega .twc-mega__search input {
    box-sizing: border-box;
    width: 100%;
    height: 42px;
    margin: 0;
    padding: 0 14px 0 42px;
    border: 1px solid var(--twc-line);
    border-radius: 12px;
    background: #f7f8fa;
    box-shadow: none;
    color: var(--twc-ink);
    font-size: 14px;
    transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease;
}

.twc-mega .twc-mega__search input:focus {
    border-color: var(--twc-blue);
    background: #fff;
    box-shadow: 0 0 0 3px var(--twc-blue-soft);
    outline: none;
}

.twc-mega .twc-mega__all {
    flex-shrink: 0;
    color: var(--twc-blue);
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

.twc-mega .twc-mega__all:hover {
    color: var(--twc-ink);
}

.twc-mega__panes {
    flex: 1;
    padding: 18px 22px 22px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.twc-mega__pane {
    display: none;
}

.twc-mega__pane.is-active {
    display: block;
    animation: twc-mega-in .2s ease;
}

.twc-mega__pane-title {
    display: none;
    margin: 0 0 10px;
    color: var(--twc-muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
}

/* Во время поиска показываем результаты из всех серий */
.twc-mega.is-searching .twc-mega__pane {
    display: none;
    animation: none;
}

.twc-mega.is-searching .twc-mega__pane.has-results {
    display: block;
    margin-bottom: 18px;
}

.twc-mega.is-searching .twc-mega__pane-title {
    display: block;
}

.twc-mega .twc-mega__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.twc-mega .twc-mega__grid li {
    margin: 0;
    padding: 0;
}

.twc-mega .twc-mega__grid li::before {
    display: none;
}

.twc-mega .twc-mega__grid a {
    position: relative;
    display: block;
    padding: 9px 28px 9px 12px;
    border: 1px solid transparent;
    border-radius: 10px;
    color: var(--twc-ink);
    font-size: 14px;
    line-height: 1.35;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

.twc-mega .twc-mega__grid a::after {
    content: "→";
    position: absolute;
    top: 50%;
    right: 10px;
    opacity: 0;
    transform: translate(-4px, -50%);
    transition: opacity .15s ease, transform .15s ease;
}

.twc-mega .twc-mega__grid a:hover,
.twc-mega .twc-mega__grid a:focus-visible {
    border-color: rgba(46, 107, 198, .25);
    background: var(--twc-blue-soft);
    color: var(--twc-blue);
    outline: none;
}

.twc-mega .twc-mega__grid a:hover::after,
.twc-mega .twc-mega__grid a:focus-visible::after {
    opacity: 1;
    transform: translate(0, -50%);
}

.twc-mega__empty {
    padding: 30px 10px;
    color: var(--twc-muted);
    font-size: 15px;
    text-align: center;
}

.twc-mega__empty a {
    color: var(--twc-blue);
    font-weight: 600;
    text-decoration: underline;
}

/* --- Правая карточка: своя под каждый бренд --- */
.twc-mega__promo {
    --p1: #2e6bc6;
    --p2: #1b3f80;
    --accent: #9cc0ff;

    position: relative;
    display: flex;
    flex-direction: column;
    padding: 22px 22px 22px;
    background:
        radial-gradient(circle at 80% 8%, rgba(255, 255, 255, .22), transparent 45%),
        linear-gradient(165deg, var(--p1) 0%, var(--p2) 100%);
    color: rgba(255, 255, 255, .8);
    overflow: hidden;
}

.twc-mega__promo::before {
    content: "";
    position: absolute;
    right: -60px;
    bottom: -60px;
    width: 200px;
    height: 200px;
    border: 30px solid rgba(255, 255, 255, .06);
    border-radius: 50%;
}

.twc-promo--iphone  { --p1: #3a3a3c; --p2: #111113; --accent: #d1d1d6; }
.twc-promo--samsung { --p1: #1f4bd8; --p2: #0b1f6b; --accent: #9db8ff; }
.twc-promo--xiaomi  { --p1: #ff7a1a; --p2: #c2410c; --accent: #ffe1c7; }
.twc-promo--tablet  { --p1: #7c3aed; --p2: #3b1a85; --accent: #d6c4ff; }
.twc-promo--other   { --p1: #0f9488; --p2: #0b4f4a; --accent: #b8f0e8; }

.twc-promo__img {
    position: relative;
    display: grid;
    place-items: center;
    height: 150px;
    margin-bottom: 16px;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 18px 36px -18px rgba(0, 0, 0, .55);
    overflow: hidden;
}

.twc-promo__img img {
    width: 100%;
    height: 100%;
    padding: 10px;
    box-sizing: border-box;
    object-fit: contain;
    transition: opacity .12s ease, transform .3s ease;
}

.twc-promo__img img.is-swap {
    opacity: 0;
    transform: scale(.94);
}

.twc-mega__promo:hover .twc-promo__img img {
    transform: scale(1.04);
}

.twc-promo__brand {
    color: var(--accent);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.twc-promo__name {
    color: #fff;
    font-family: var(--wd-title-font);
    font-size: 22px;
    font-weight: 700;
    line-height: 1.15;
}

.twc-promo__from {
    margin-top: 2px;
    color: var(--accent);
    font-size: 14px;
    font-weight: 600;
}

.twc-promo__from[hidden] {
    display: none;
}

.twc-mega .twc-promo__list {
    margin: 14px 0 16px;
    padding: 0;
    list-style: none;
}

.twc-mega .twc-promo__list li {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin: 0;
    padding: 7px 0;
    border-top: 1px solid rgba(255, 255, 255, .12);
    font-size: 13px;
}

.twc-mega .twc-promo__list li::before {
    display: none;
}

.twc-promo__list b {
    color: #fff;
    white-space: nowrap;
}

.twc-promo__list .is-free {
    padding: 1px 8px;
    border-radius: 999px;
    background: #22c55e;
    color: #fff;
}

.twc-mega .twc-mega__promo .twc-mega__btn {
    position: relative;
    display: block;
    width: 100%;
    min-height: 0;
    margin: auto 0 0;
    padding: 13px 16px;
    border: 0;
    border-radius: 12px;
    background: #fff;
    color: var(--p2);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    text-transform: none;
    letter-spacing: 0;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease;
}

.twc-mega .twc-mega__promo .twc-mega__btn:hover {
    background: #fff;
    color: var(--p2);
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(0, 0, 0, .25);
}

@keyframes twc-mega-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: none; }
}

/* Узкие экраны десктопа — убираем карточку */
@media (max-width: 1200px) {
    .twc-mega__inner {
        grid-template-columns: 200px minmax(0, 1fr);
    }

    .twc-mega__promo {
        display: none;
    }
}

/* Мобильные/планшеты используют своё меню темы */
@media (max-width: 1024px) {
    .twc-mega {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .twc-mega,
    .twc-mega__pane.is-active {
        transition: none;
        animation: none;
    }
}

.twc-mega [hidden] {
    display: none !important;
}

/* ===== Главное меню — всегда в одну строку ===== */
.wd-nav-main > li > a {
    white-space: nowrap;
}

.wd-nav-main {
    flex-wrap: nowrap !important;
}

/* Ноутбуки: плотнее, чтобы всё влезло в одну строку */
@media (min-width: 1025px) and (max-width: 1399px) {
    .wd-nav-main > li {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    .wd-nav-main > li > a {
        padding-left: 9px !important;
        padding-right: 9px !important;
    }
}

@media (min-width: 1025px) and (max-width: 1199px) {
    .wd-nav-main > li > a {
        padding-left: 6px !important;
        padding-right: 6px !important;
        font-size: 14px;
    }

    .twc-cta-long {
        display: none;
    }

    .whb-general-header .whb-space-element {
        width: 12px !important;
    }
}

/* ===== Мобильное меню: категории ===== */
.twc-mcats {
    margin: 0 !important;
    padding: 8px 0 !important;
    list-style: none !important;
}

.twc-mcat {
    border-bottom: 1px solid rgba(16, 24, 40, .07);
}

.twc-mcat__row {
    display: flex;
    align-items: stretch;
}

.twc-mcat .twc-mcat__link {
    display: flex;
    flex: 1;
    flex-direction: column;
    padding: 14px 20px !important;
    color: #14181f !important;
    line-height: 1.25;
}

.twc-mcat__link b {
    font-size: 16px;
    font-weight: 700;
}

.twc-mcat__link span {
    color: #6b7280;
    font-size: 12px;
    font-weight: 500;
}

.twc-mcat .twc-mcat__toggle {
    position: relative;
    width: 56px;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    border-left: 1px solid rgba(16, 24, 40, .07);
    background: transparent;
    box-shadow: none;
    cursor: pointer;
}

.twc-mcat__toggle::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--wd-primary-color, #2e6bc6);
    border-bottom: 2px solid var(--wd-primary-color, #2e6bc6);
    transform: translate(-50%, -70%) rotate(45deg);
    transition: transform .2s ease;
}

.twc-mcat.is-open .twc-mcat__toggle::after {
    transform: translate(-50%, -30%) rotate(225deg);
}

.twc-mcat__sub {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 !important;
    padding: 0 20px 16px !important;
    list-style: none !important;
}

.twc-mcat__sub[hidden] {
    display: none;
}

.twc-mcat__sub li {
    margin: 0 !important;
    border: 0 !important;
}

.twc-mcat__sub a {
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    padding: 7px 12px !important;
    border-radius: 999px;
    background: rgba(46, 107, 198, .08);
    color: var(--wd-primary-color, #2e6bc6) !important;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
}

.twc-mcat__sub a span {
    color: #6b7280;
    font-size: 11px;
}

.twc-mpages a {
    font-weight: 600;
}

.twc-mega .twc-promo__list li[hidden] {
    display: none;
}
