/* ==========================================================================
   Header search + phone header — modelled on nawy.com
   Markup: header.php   Behaviour: nawy-search.js   Texts/config: functions.php

   Desktop (>= 1019px)  the magnifier in the header opens a wide search bar over the
                        header with a results dropdown under it.
   Phones  (<= 1018px)  header = hamburger | centred logo | "Get App" pill, the search bar is
                        always visible under it, and tapping it opens full-screen results.
   Logical properties (inset-inline-*, padding-inline-*) make it work in LTR and RTL.
   ========================================================================== */

/* ---------- desktop trigger ---------- */
.header-search-wrap {
    display: flex;
    align-items: center;
    height: 80px;
}

.nawy-search-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    box-shadow: none;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.nawy-search-trigger:hover,
.nawy-search-trigger:focus-visible {
    background: #f4f6f9;
}

.nawy-search-trigger svg {
    display: block;
}

/* phone-only pieces are hidden on desktop */
.nawy-search-bar-wrap,
.nawy-getapp,
.nawy-search__back {
    display: none;
}

/* ---------- the search layer ---------- */
.nawy-search {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    height: 80px; /* JS aligns top/height with the live header (also when it is sticky) */
    z-index: 100000;
    background: #fff;
    font-family: 'Poppins', 'Almarai', sans-serif;
    color: #212427;
}

.nawy-search[hidden] {
    display: none !important;
}

.nawy-search *,
.nawy-search *:before,
.nawy-search *:after {
    box-sizing: border-box;
}

.nawy-search__panel {
    position: relative;
    width: calc(100% - 40px);
    max-width: 1400px;
    height: 100%;
    margin: 0 auto;
    animation: nawy-search-in 0.16s ease-out;
}

@keyframes nawy-search-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: none; }
}

.nawy-search__row {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 100%;
}

.nawy-search__box {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    height: 50px;
    padding: 0 16px;
    background: #fff;
    border: 1px solid #e6e6e6;
    border-radius: 10px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.nawy-search__box:focus-within {
    border-color: #015c9a;
    box-shadow: 0 0 0 2px rgba(1, 92, 154, 0.15);
}

/* desktop: the magnifier sits at the start of the field */
.nawy-search__box-icon {
    order: -1;
    flex: 0 0 auto;
}

/* the tagDiv theme styles every text input (border, box, padding): reset it for this one */
.nawy-search input.nawy-search__input[type="text"] {
    flex: 1;
    width: auto;
    min-width: 0;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0 !important;
    border-radius: 0;
    outline: 0;
    background: transparent !important;
    box-shadow: none !important;
    font: 400 16px/20px 'Poppins', 'Almarai', sans-serif;
    color: #2c3138;
    text-align: start;
    -webkit-appearance: none;
    appearance: none;
}

.nawy-search input.nawy-search__input[type="text"]:focus {
    border: 0 !important;
    outline: 0;
    box-shadow: none !important;
}

.nawy-search input.nawy-search__input::placeholder {
    color: #9aa3ad;
    opacity: 1;
}

.nawy-search__close,
.nawy-search__back {
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #f4f6f9;
    color: #1e4164;
    box-shadow: none;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.nawy-search__close {
    display: flex;
}

.nawy-search__close:hover,
.nawy-search__back:hover {
    background: #e8edf3;
}

/* ---------- results ---------- */
.nawy-search__results {
    position: absolute;
    top: calc(50% + 31px);
    inset-inline-start: 0;
    inset-inline-end: 56px;
    max-height: min(440px, calc(100vh - 110px));
    overflow-y: auto;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(30, 65, 100, 0.14), 0 0 0 1px #f0f0f0;
    overscroll-behavior: contain;
}

.nawy-search__results:empty {
    display: none;
}

.nawy-search__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 58px;
    padding: 8px 16px;
    border-bottom: 1px solid #f0f0f0;
    color: #212427;
    text-decoration: none;
    box-shadow: none;
    cursor: pointer;
}

.nawy-search__item:last-child {
    border-bottom: 0;
}

.nawy-search__item.has-glyph {
    min-height: 49px;
}

.nawy-search__item.is-active,
.nawy-search__item:hover {
    background: rgba(118, 173, 225, 0.08);
    color: #212427;
}

.nawy-search__left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.nawy-search__thumb,
.nawy-search__glyph {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.nawy-search__thumb img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: cover;
}

.nawy-search__text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.nawy-search__title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
    line-height: 17.5px;
    font-weight: 500;
    color: #212427;
}

.nawy-search__subtitle {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
    line-height: 13.75px;
    font-weight: 400;
    color: #646464;
}

.nawy-search__tag {
    flex: 0 0 auto;
    padding: 2.5px 8px;
    border-radius: 4px;
    background: #f0f0f0;
    font-size: 12px;
    line-height: 15px;
    font-weight: 500;
    color: #212427;
}

.nawy-search__tag--offer {
    padding: 4px 16px;
    border-radius: 20px;
    background: #ff9108;
    font-size: 14px;
    line-height: 17.5px;
    font-weight: 500;
    color: #fff;
}

.nawy-search__message {
    padding: 24px 16px;
    font-size: 14px;
    line-height: 20px;
    text-align: center;
    color: #646464;
}

/* ==========================================================================
   Phones and tablets: same header as nawy.com
   ========================================================================== */
@media (max-width: 1018px) {
    html.nawy-search-lock,
    html.nawy-search-lock body {
        overflow: hidden;
    }

    /* header bar: 60px, white */
    /* !important: the tagDiv multi-purpose plugin sets a 54px header with a later stylesheet */
    .td-header-wrap .td-header-menu-wrap-full,
    .td-header-wrap .td-header-menu-wrap,
    .td-header-wrap .td-header-main-menu,
    .td-container.td-header-row.td-header-main-menu {
        height: 60px !important;
        padding: 0 !important;
        background: #fff !important;
    }

    #td-header-menu {
        position: relative;
        height: 60px !important;
    }

    /* hamburger — nawy.com's icon, at the start of the bar */
    #td-top-mobile-toggle {
        position: absolute;
        top: 0;
        inset-inline-start: 0;
        z-index: 3;
        display: flex;
        float: none;
        width: 60px;
        height: 60px;
    }

    #td-top-mobile-toggle a {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 100%;
        padding: 0;
    }

    .nawy-burger {
        display: block;
    }

    /* logo centred, 79 x 20 like nawy.com. The theme keeps several logo variants and hides the unused
       ones with display:none, so only the container is laid out here (never force display on the links). */
    .td-header-wrap .td-main-menu-logo {
        position: absolute !important;
        top: 0;
        left: 50%;
        z-index: 2;
        display: flex !important;
        align-items: center;
        justify-content: center;
        float: none !important;
        width: 79px;
        height: 60px;
        margin: 0 !important;
        transform: translateX(-50%);
    }

    .td-header-wrap .td-main-menu-logo a {
        width: 79px;
        height: auto;
        line-height: 0 !important;
    }

    .td-header-wrap .td-main-menu-logo img {
        position: static !important;
        display: block;
        width: 79px !important;
        height: 20px !important;
        max-width: none !important;
        max-height: none !important;
        margin: 0 !important;
        padding: 0 !important;
        object-fit: cover;
    }

    /* "Get App" pill at the end of the bar */
    .nawy-getapp {
        position: absolute;
        top: 15px;
        inset-inline-end: 16px;
        z-index: 3;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        height: 30px;
        padding: 5px 8px;
        border-radius: 10px;
        background: linear-gradient(75deg, #015c9a -2.06%, #308ccc 98.98%);
        font: 500 14px/20px 'Poppins', 'Almarai', sans-serif;
        color: #fff;
        text-decoration: none;
        white-space: nowrap;
        box-shadow: none;
    }

    .nawy-getapp:hover,
    .nawy-getapp:focus {
        color: #fff;
        opacity: 0.92;
    }

    /* search bar, always visible under the header */
    .nawy-search-bar-wrap {
        display: block;
        height: 60px;
        padding: 8px 16px;
        background: #fff;
    }

    .nawy-search-bar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        width: 100%;
        height: 44px;
        margin: 0;
        padding: 0 14px;
        border: 1px solid #e6e6e6;
        border-radius: 12px;
        background: #fff;
        box-shadow: none;
        font: 400 16px/20px 'Poppins', 'Almarai', sans-serif;
        color: #9aa3ad;
        text-align: start;
        cursor: text;
    }

    .nawy-search-bar__text {
        flex: 1;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .nawy-search-bar svg {
        flex: 0 0 auto;
    }

    /* full-screen search under the header */
    .nawy-search {
        top: 60px !important;
        bottom: 0;
        height: auto !important;
    }

    .nawy-search__panel {
        display: flex;
        flex-direction: column;
        width: 100%;
        max-width: none;
        margin: 0;
        animation: none;
    }

    .nawy-search__row {
        flex: 0 0 auto;
        gap: 8px;
        height: 60px;
        padding: 8px 16px;
    }

    .nawy-search__back {
        display: flex;
    }

    .nawy-search__close {
        display: none;
    }

    .nawy-search__box {
        height: 44px;
        padding: 0 14px;
        border-color: #015c9a;
        border-radius: 12px;
        box-shadow: 0 0 0 2px rgba(1, 92, 154, 0.15);
    }

    .nawy-search__box-icon {
        order: 0;
    }

    .nawy-search input.nawy-search__input::placeholder {
        font-size: 15px;
    }

    .nawy-search__results {
        position: static;
        flex: 1;
        max-height: none;
        padding: 0 16px;
        border-radius: 0;
        box-shadow: none;
        -webkit-overflow-scrolling: touch;
    }
}

/* the back chevron and the burger point the other way in RTL */
html[dir="rtl"] .nawy-search__back svg,
html[dir="rtl"] .nawy-burger {
    transform: scaleX(-1);
}

@media (prefers-reduced-motion: reduce) {
    .nawy-search__panel {
        animation: none;
    }
}

/* blog post rows */
.nawy-search__tag--post {
    background: rgba(1, 92, 154, 0.1);
    color: #015c9a;
}

/* ==========================================================================
   Phone / tablet slide-in menu: nawy.com's design (white drawer, logo + close button on top,
   grey rounded item cards, hotline card at the end). No icons.
   Markup: header.php (#td-mobile-nav)   Menu items: Appearance > Menus (header-menu)
   ========================================================================== */
@media (max-width: 1018px) {
    .td-menu-background {
        background: #fff !important;
        background-image: none !important;
    }

    #td-mobile-nav {
        background: #fff !important;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        font-family: 'Poppins', 'Almarai', sans-serif;
    }

    #td-mobile-nav .td-mobile-container {
        padding: 0 0 32px;
    }

    /* top: logo at the start, close button at the end */
    #td-mobile-nav .td-menu-socials-wrap {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 20px 20px 0;
    }

    #td-mobile-nav .nawy-mnav-logo {
        display: block;
        line-height: 0;
    }

    #td-mobile-nav .nawy-mnav-logo img {
        display: block;
        width: 101px;
        height: 26px;
    }

    #td-mobile-nav .td-mobile-close {
        position: static;
    }

    #td-mobile-nav .td-mobile-close a {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background: #f3f3f3;
    }

    #td-mobile-nav .td-mobile-close .td-icon-close-mobile {
        position: static;
        width: 40px;
        height: 40px;
        line-height: 40px;
        font-size: 16px;
        color: #1e4164;
        text-align: center;
    }

    /* the item cards */
    #td-mobile-nav .td-mobile-content {
        padding: 40px 20px 0 !important; /* later theme/plugin rules add 74px here */
    }

    #td-mobile-nav .td-mobile-main-menu > li {
        position: relative;
        margin: 0 0 8px;
        background: #f8f8f8;
        border: 1px solid #e8e8e8;
        border-radius: 8px;
    }

    #td-mobile-nav .td-mobile-main-menu > li > a {
        display: block;
        height: 58px;
        padding: 0;
        padding-inline-start: 16px;
        padding-inline-end: 48px; /* room for the expand arrow at the end */
        font: 400 14px/58px 'Poppins', 'Almarai', sans-serif !important;
        color: #212427;
        text-align: start;
        text-transform: none;
    }

    #td-mobile-nav .td-mobile-main-menu > li.current-menu-item > a,
    #td-mobile-nav .td-mobile-main-menu > li.current_page_item > a {
        font-weight: 500;
        color: #1e4164;
    }

    /* expand arrow for items that have a sub menu */
    #td-mobile-nav .td-mobile-content .td-icon-menu-right {
        top: 0;
        right: 4px;
        inset-inline-start: auto;
        inset-inline-end: 4px;
        padding: 0 12px;
        font-size: 12px;
        line-height: 58px;
        color: #1e4164;
    }

    html[dir="rtl"] #td-mobile-nav .td-mobile-content .td-icon-menu-right {
        right: auto;
        left: 4px;
        transform: rotate(90deg); /* closed: points left (towards the start of the line in RTL) */
        -webkit-transform: rotate(90deg);
    }

    /* open: points down, in both directions */
    #td-mobile-nav .td-mobile-content .td-sub-menu-open > a .td-icon-menu-right,
    html[dir="rtl"] #td-mobile-nav .td-mobile-content .td-sub-menu-open > a .td-icon-menu-right {
        transform: rotate(0deg);
        -webkit-transform: rotate(0deg);
    }

    /* sub menu: links inside the same card, separated by a thin line */
    #td-mobile-nav .td-mobile-content .sub-menu {
        margin: 0;
        padding: 0;
        background: #fff;
        border-radius: 0 0 8px 8px;
    }

    #td-mobile-nav .td-mobile-content .sub-menu a {
        padding: 0 !important;
        padding-inline-start: 28px !important;
        padding-inline-end: 16px !important;
        border-top: 1px solid #e8e8e8;
        font: 400 14px/46px 'Poppins', 'Almarai', sans-serif;
        color: #212427;
        text-align: start;
        text-transform: none;
    }

    /* the "New" tag on Nawy Now, like nawy.com's "New" on Verify Agent */
    #td-mobile-nav .td-mobile-content .move-now a:before {
        display: block;
        top: 50%;
        right: 16px;
        transform: translateY(-50%);
        background: #ff5e00;
    }

    html[dir="rtl"] #td-mobile-nav .td-mobile-content .move-now a:before {
        right: auto;
        left: 16px;
    }

    /* The language switcher item that WPML adds to the menu: a normal card like the others.
       (A global rule floats every .wpml-ls-item for the footer switcher, which shrank this one into a
       small box beside the hotline card.) */
    #td-mobile-nav .td-mobile-main-menu > li.wpml-ls-item,
    #td-mobile-nav .td-mobile-main-menu > li.menu-item-language,
    #td-mobile-nav .td-mobile-main-menu > li.wpml-ls-menu-item {
        float: none !important;
        display: block;
        clear: both;
        width: auto;
        margin: 0 0 8px;
    }

    #td-mobile-nav .td-mobile-main-menu > li.wpml-ls-item > a,
    #td-mobile-nav .td-mobile-main-menu > li.menu-item-language > a,
    #td-mobile-nav .td-mobile-main-menu > li.wpml-ls-menu-item > a {
        display: block;
        width: auto;
        height: 58px;
        padding: 0;
        padding-inline-start: 16px;
        padding-inline-end: 48px;
        font: 400 14px/58px 'Poppins', 'Almarai', sans-serif !important;
        color: #212427;
        text-align: start;
        text-transform: none;
    }

    #td-mobile-nav .td-mobile-main-menu > li.wpml-ls-item .wpml-ls-flag,
    #td-mobile-nav .td-mobile-main-menu > li.menu-item-language .wpml-ls-flag,
    #td-mobile-nav .td-mobile-main-menu > li.wpml-ls-menu-item .wpml-ls-flag {
        display: none;
    }

    /* hotline card, last item */
    #td-mobile-nav .nawy-hotline {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        min-height: 99px;
        margin: 16px 0 0;
        background: #f8f8f8;
        border: 1px solid #e8e8e8;
        border-radius: 8px;
        text-align: center;
        text-decoration: none;
    }

    #td-mobile-nav .nawy-hotline__label {
        font: 400 14px/18px 'Poppins', 'Almarai', sans-serif;
        color: #666;
    }

    #td-mobile-nav .nawy-hotline__number {
        font: 700 40px/50px 'Poppins', sans-serif;
        color: #1e4164;
    }
}
