﻿/* =========================================================
   Header + Live Search
   ========================================================= */

:root {
    --dangaah-header-text: #1f2937;
    --dangaah-header-muted: #8b93a1;
    --dangaah-header-border: #e5e7eb;
    --dangaah-header-soft: #f3f4f6;
    --dangaah-header-dark: #0f172a;
    --dangaah-header-accent: #224173;
    --dangaah-header-danger: #dc2626;
    --dangaah-search-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
}

body.site-search-open {
    overflow: hidden !important;
}

#siteHeader.dangaah-header {
    position: sticky;
    top: 0;
    z-index: 21000 !important;
    width: 100%;
    background: #fff;
    direction: rtl;
}

.dangaah-header-main {
    position: relative;
    z-index: 4;
    background: #fff;
    border-top: 1px solid rgba(15, 23, 42, 0.04);
}

.dangaah-header-container {
    width: 100%;
    max-width: 1720px;
    min-height: 90px;
    margin: 0 auto;
    padding: 14px 34px;
    display: grid;
    grid-template-columns: minmax(230px, 300px) minmax(360px, 760px) minmax(230px, 300px);
    align-items: center;
    justify-content: space-between;
    gap: 28px;
    direction: rtl;
}

.dangaah-header-logo {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    text-decoration: none;
}

.dangaah-header-logo-image {
    width: auto;
    max-width: 190px;
    height: 58px;
    object-fit: contain;
    display: block;
}

.dangaah-header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    direction: ltr;
}

.dangaah-header-icon-button {
    width: 44px;
    height: 44px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 14px;
    background: transparent;
    color: var(--dangaah-header-text);
    font-size: 1.2rem;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

    .dangaah-header-icon-button:hover,
    .dangaah-header-icon-button:focus-visible {
        color: var(--dangaah-header-accent);
        background: #eef3fb;
        transform: translateY(-1px);
        outline: 0;
    }

.dangaah-mobile-menu-button {
    display: none !important;
}

/* =========================================================
   Search shell
   ========================================================= */

.site-search-shell {
    position: relative;
    z-index: 8;
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
}

.site-search-form {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 48px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px;
    border: 1px solid #d4d7dc;
    border-radius: 8px;
    background: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, border-radius 0.2s ease;
}

.site-search-shell.is-open .site-search-form {
    border-color: rgba(34, 65, 115, 0.42);
    box-shadow: 0 0 0 4px rgba(34, 65, 115, 0.08);
}

.site-search-submit,
.site-search-clear-input {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #9aa1ad;
    cursor: pointer;
}

    .site-search-submit:hover,
    .site-search-clear-input:hover {
        color: var(--dangaah-header-accent);
        background: #f1f5f9;
    }

.site-search-input {
    width: 100%;
    min-width: 0;
    height: 100%;
    padding: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--dangaah-header-text);
    font-family: inherit;
    font-size: 0.92rem;
    line-height: 1.5;
    text-align: right;
}

    .site-search-input::placeholder {
        color: #a0a5ae;
    }

    .site-search-input::-webkit-search-cancel-button {
        display: none;
    }

.site-search-mobile-heading {
    display: none;
}

.site-search-panel {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    left: 0;
    z-index: 5;
    max-height: min(72vh, 720px);
    padding: 18px;
    overflow-x: hidden;
    overflow-y: auto;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 22px;
    background: #fff;
    box-shadow: var(--dangaah-search-shadow);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-8px) scale(0.99);
    transform-origin: top center;
    transition: opacity 0.18s ease, visibility 0.18s ease, transform 0.18s ease;
}

.site-search-shell.is-open .site-search-panel {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.site-search-backdrop {
    position: fixed;
    inset: 0;
    z-index: 2;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: rgba(15, 23, 42, 0.42);
    backdrop-filter: blur(1px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.18s ease, visibility 0.18s ease;
}

#siteHeader.search-is-open .site-search-backdrop {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.site-search-state,
.site-search-results-state {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.site-search-history-section,
.site-search-popular-section,
.site-search-result-section {
    display: flex;
    flex-direction: column;
    gap: 11px;
}

.site-search-section-heading,
.site-search-result-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: #111827;
}

    .site-search-section-heading strong,
    .site-search-result-title {
        font-size: 0.9rem;
        font-weight: 900;
    }

        .site-search-result-title span {
            color: #9ca3af;
            font-size: 0.7rem;
            font-weight: 500;
        }

.site-search-text-button {
    padding: 4px 6px;
    border: 0;
    background: transparent;
    color: var(--dangaah-header-danger);
    font-family: inherit;
    font-size: 0.74rem;
    cursor: pointer;
}

.site-search-history-list,
.site-search-chip-list {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.site-search-history-item {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 9px 5px 5px;
    border: 1px solid #e1e5ea;
    border-radius: 999px;
    background: #fff;
}

.site-search-history-value,
.site-search-popular-chip,
.site-search-taxonomy-chip {
    border: 0;
    background: transparent;
    color: #394150;
    font-family: inherit;
    font-size: 0.78rem;
    text-decoration: none;
    cursor: pointer;
}

.site-search-history-remove {
    width: 25px;
    height: 25px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    background: #f3f4f6;
    color: #9ca3af;
    font-size: 0.65rem;
    cursor: pointer;
}

.site-search-popular-chip,
.site-search-taxonomy-chip {
    min-height: 36px;
    padding: 7px 13px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border: 1px solid #dfe3e8;
    border-radius: 999px;
    background: #fff;
    transition: border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
}

    .site-search-popular-chip i {
        font-size: 0.64rem;
        transform: rotate(-45deg);
    }

    .site-search-popular-chip:hover,
    .site-search-taxonomy-chip:hover {
        border-color: rgba(34, 65, 115, 0.35);
        background: #f6f8fb;
        color: var(--dangaah-header-accent);
    }

.site-search-loading-state,
.site-search-message-state {
    min-height: 150px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #6b7280;
    text-align: center;
    font-size: 0.83rem;
}

    .site-search-message-state i {
        color: #aeb5c0;
        font-size: 1.45rem;
    }

    .site-search-message-state strong {
        color: #374151;
        font-size: 0.95rem;
    }

.site-search-error-state {
    color: #b91c1c;
}

.site-search-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #e5e7eb;
    border-top-color: var(--dangaah-header-accent);
    border-radius: 50%;
    animation: siteSearchSpin 0.8s linear infinite;
}

@keyframes siteSearchSpin {
    to {
        transform: rotate(360deg);
    }
}

.site-search-item-list {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.site-search-result-item {
    min-height: 66px;
    padding: 7px;
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr) 28px;
    align-items: center;
    gap: 11px;
    border-radius: 13px;
    color: #263041;
    text-decoration: none;
    transition: background 0.18s ease, transform 0.18s ease;
}

    .site-search-result-item:hover {
        color: #172033;
        background: #f5f7fa;
        transform: translateX(-2px);
    }

.site-search-result-image,
.site-search-result-image-placeholder {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #edf0f3;
    border-radius: 11px;
    background: #fff;
    overflow: hidden;
}

    .site-search-result-image img {
        width: 100%;
        height: 100%;
        object-fit: contain;
    }

.site-search-result-image-placeholder {
    color: #9ca3af;
    background: #f3f4f6;
}

.site-search-result-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

    .site-search-result-copy strong {
        display: -webkit-box;
        overflow: hidden;
        color: #242b38;
        font-size: 0.8rem;
        font-weight: 800;
        line-height: 1.7;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
    }

.site-search-result-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
    color: #9aa1ad;
    font-size: 0.68rem;
}

.site-search-result-type {
    padding: 2px 7px;
    border-radius: 999px;
    background: #eef3fb;
    color: var(--dangaah-header-accent);
}

.site-search-result-arrow {
    color: #b4bac3;
    font-size: 0.76rem;
}

.site-search-view-all {
    min-height: 46px;
    margin-top: 5px;
    padding: 10px 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-radius: 13px;
    background: #f1f4f8;
    color: var(--dangaah-header-accent);
    font-size: 0.8rem;
    font-weight: 900;
    text-decoration: none;
}

    .site-search-view-all:hover {
        color: #fff;
        background: var(--dangaah-header-accent);
    }

/* =========================================================
   Bottom navigation
   ========================================================= */

.dangaah-header-nav {
    position: relative;
    z-index: 3;
    min-height: 46px;
    background: var(--dangaah-header-dark);
}

.dangaah-header-nav-container {
    width: 100%;
    max-width: 1720px;
    min-height: 46px;
    margin: 0 auto;
    padding: 0 34px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.dangaah-desktop-menu {
    min-width: 0;
    flex: 1 1 auto;
}

.dangaah-header-nav .site-main-menu {
    justify-content: flex-start;
    margin: 0 !important;
}

    .dangaah-header-nav .site-main-menu > .nav-item > .nav-link,
    .dangaah-header-nav
    .site-main-menu > .nav-item:not(:hover) > .nav-link:focus:not(:focus-visible):not(.active),
    .dangaah-header-nav
    .site-main-menu > .nav-item:not(:hover) > .nav-link.show:not(.active) {
        min-height: 42px;
        color: #fff !important;
        background: transparent !important;
        font-size: 0.8rem;
    }

        .dangaah-header-nav
        .site-main-menu > .nav-item > .nav-link:hover,
        .dangaah-header-nav
        .site-main-menu > .nav-item:hover > .nav-link,
        .dangaah-header-nav
        .site-main-menu > .nav-item > .nav-link:focus-visible {
            color: #fff !important;
            background: rgba(255, 255, 255, 0.1) !important;
        }

.dangaah-consultation-button {
    min-width: 116px;
    min-height: 36px;
    padding: 7px 15px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    flex: 0 0 auto;
    border-radius: 10px;
    background: #fff;
    color: #1f2937;
    font-size: 0.78rem;
    font-weight: 900;
    text-decoration: none;
    transition: transform 0.18s ease, background 0.18s ease;
}

    .dangaah-consultation-button:hover {
        color: #fff;
        background: var(--dangaah-header-accent);
        transform: translateY(-1px);
    }

/* =========================================================
   Full search results page
   ========================================================= */

.search-page {
    min-height: 60vh;
    padding: 42px 0 70px;
    background: #f6f7f9;
}

.search-page-container {
    width: min(1240px, calc(100% - 32px));
    margin: 0 auto;
}

.search-page-header {
    margin-bottom: 24px;
    padding: 24px;
    border: 1px solid #e8ebef;
    border-radius: 22px;
    background: #fff;
}

    .search-page-header h1 {
        margin: 0 0 8px;
        color: #1f2937;
        font-size: 1.35rem;
        font-weight: 950;
    }

    .search-page-header p {
        margin: 0;
        color: #7b8492;
        font-size: 0.86rem;
    }

.search-page-section {
    margin-top: 22px;
    padding: 22px;
    border: 1px solid #e8ebef;
    border-radius: 22px;
    background: #fff;
}

.search-page-section-heading {
    margin-bottom: 17px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

    .search-page-section-heading h2 {
        margin: 0;
        color: #222b38;
        font-size: 1rem;
        font-weight: 950;
    }

    .search-page-section-heading span {
        color: #9ca3af;
        font-size: 0.76rem;
    }

.search-page-taxonomy-list {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
}

.search-page-taxonomy-link {
    padding: 9px 14px;
    border: 1px solid #e0e5eb;
    border-radius: 999px;
    background: #fff;
    color: #374151;
    font-size: 0.8rem;
    text-decoration: none;
}

    .search-page-taxonomy-link:hover {
        color: var(--dangaah-header-accent);
        border-color: rgba(34, 65, 115, 0.35);
        background: #f4f7fb;
    }

.search-page-product-grid,
.search-page-article-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 15px;
}

.search-page-card {
    min-width: 0;
    padding: 12px;
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 13px;
    border: 1px solid #edf0f3;
    border-radius: 17px;
    background: #fff;
    color: #273142;
    text-decoration: none;
    transition: box-shadow 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
}

    .search-page-card:hover {
        color: #1f2937;
        border-color: rgba(34, 65, 115, 0.22);
        box-shadow: 0 12px 34px rgba(15, 23, 42, 0.08);
        transform: translateY(-2px);
    }

.search-page-card-image,
.search-page-card-placeholder {
    width: 92px;
    height: 92px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 13px;
    background: #f4f5f7;
    overflow: hidden;
}

    .search-page-card-image img {
        width: 100%;
        height: 100%;
        object-fit: contain;
    }

.search-page-card-placeholder {
    color: #a5acb7;
    font-size: 1.25rem;
}

.search-page-card-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 7px;
}

    .search-page-card-copy h3 {
        margin: 0;
        display: -webkit-box;
        overflow: hidden;
        color: #273142;
        font-size: 0.86rem;
        font-weight: 900;
        line-height: 1.8;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
    }

    .search-page-card-copy p {
        margin: 0;
        display: -webkit-box;
        overflow: hidden;
        color: #838c99;
        font-size: 0.72rem;
        line-height: 1.8;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
    }

.search-page-card-meta {
    color: #9aa2ae;
    font-size: 0.69rem;
}

.search-page-price {
    color: var(--dangaah-header-accent);
    font-size: 0.78rem;
    font-weight: 900;
}

.search-page-empty {
    padding: 50px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 11px;
    border: 1px solid #e8ebef;
    border-radius: 22px;
    background: #fff;
    color: #7b8492;
    text-align: center;
}

    .search-page-empty i {
        font-size: 2rem;
        color: #b2b8c2;
    }

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 1199.98px) {
    .dangaah-header-container {
        grid-template-columns: 205px minmax(320px, 1fr) 205px;
        gap: 20px;
        padding-right: 20px;
        padding-left: 20px;
    }

    .dangaah-header-nav-container {
        padding-right: 20px;
        padding-left: 20px;
    }

    .search-page-product-grid,
    .search-page-article-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 991.98px) {
    .dangaah-header-logo {
        gap: 8px;
    }

    .dangaah-header-brand-name {
        font-size: 0.82rem;
        font-weight: 900;
    }

    #siteHeader.dangaah-header {
        z-index: 25000 !important;
    }

    .dangaah-header-container {
        min-height: auto;
        padding: 10px 14px 12px;
        grid-template-columns: minmax(100px, 1fr) auto;
        grid-template-areas: "logo actions" "search search";
        gap: 9px 12px;
    }

    .dangaah-header-logo {
        grid-area: logo;
    }

    .dangaah-header-logo-image {
        max-width: 135px;
        height: 43px;
    }

    .dangaah-header-actions {
        grid-area: actions;
    }

    .site-search-shell {
        grid-area: search;
        max-width: none;
    }

    .site-search-form {
        height: 44px;
        border: 0;
        border-radius: 999px;
        background: #f0f1f3;
        box-shadow: none !important;
    }

    .site-search-input {
        font-size: 0.8rem;
    }

    .dangaah-header-icon-button {
        width: 39px;
        height: 39px;
        border-radius: 12px;
        font-size: 1rem;
    }

    .dangaah-mobile-menu-button {
        width: 40px;
        height: 40px;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        margin: 0;
        border: 0;
        border-radius: 12px;
    }

    .dangaah-header-nav {
        display: none;
    }

    .site-search-backdrop {
        display: none !important;
    }

    /*
     * حالت تمام‌صفحه سرچ در موبایل
     */
    .site-search-shell.is-open {
        position: fixed !important;
        inset: 0 !important;
        z-index: 30050 !important;
        width: 100vw !important;
        max-width: none !important;
        height: 100vh;
        height: 100dvh;
        margin: 0 !important;
        padding: 11px 12px 0;
        display: flex;
        flex-direction: column;
        gap: 10px;
        background: #fff;
    }

        .site-search-shell.is-open
        .site-search-mobile-heading {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            min-height: 38px;
        }

    .site-search-mobile-heading strong {
        color: #1f2937;
        font-size: 0.95rem;
        font-weight: 950;
    }

    .site-search-mobile-close {
        width: 38px;
        height: 38px;
        padding: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border: 0;
        border-radius: 12px;
        background: #f1f3f5;
        color: #374151;
        cursor: pointer;
    }

    .site-search-shell.is-open
    .site-search-form {
        flex: 0 0 48px;
        height: 48px;
        border: 1px solid #e0e3e7;
        border-radius: 14px;
        background: #f4f5f7;
    }

    .site-search-shell.is-open
    .site-search-panel {
        position: static;
        inset: auto;
        width: auto;
        max-height: none;
        min-height: 0;
        flex: 1 1 auto;
        margin: 0 -12px;
        padding: 14px 14px 28px;
        overflow-y: auto;
        border: 0;
        border-top: 1px solid #edf0f3;
        border-radius: 0;
        box-shadow: none;
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: none;
    }

    .site-search-result-item {
        grid-template-columns: 56px minmax(0, 1fr) 26px;
        min-height: 72px;
    }

    .site-search-result-image,
    .site-search-result-image-placeholder {
        width: 56px;
        height: 56px;
    }

    .dangaah-header-actions {
        direction: ltr;
        flex-direction: row-reverse;
        align-items: center;
        justify-content: flex-end;
    }
}

@media (max-width: 767.98px) {
    .search-page {
        padding: 22px 0 45px;
    }

    .search-page-container {
        width: min(100% - 20px, 1240px);
    }

    .search-page-header,
    .search-page-section {
        padding: 16px;
        border-radius: 17px;
    }

        .search-page-header h1 {
            font-size: 1.05rem;
        }

    .search-page-product-grid,
    .search-page-article-grid {
        grid-template-columns: 1fr;
    }

    .search-page-card {
        grid-template-columns: 78px minmax(0, 1fr);
    }

    .search-page-card-image,
    .search-page-card-placeholder {
        width: 78px;
        height: 78px;
    }
}

@media (max-width: 420px) {
    .dangaah-header-logo {
        gap: 6px;
    }

    .dangaah-header-brand-name {
        max-width: 95px;
        overflow: hidden;
        font-size: 0.72rem;
        text-overflow: ellipsis;
    }
    .dangaah-header-container {
        padding-right: 9px;
        padding-left: 9px;
    }

    .dangaah-header-logo-image {
        max-width: 112px;
        height: 38px;
    }

    .dangaah-header-actions {
        gap: 3px;
    }

    .dangaah-header-icon-button,
    .dangaah-mobile-menu-button {
        width: 36px;
        height: 36px;
    }
}

/* =========================================================
   Dark mode
   ========================================================= */

body.dark-mode #siteHeader.dangaah-header,
body.dark-mode .dangaah-header-main,
body.dark-mode .site-search-panel,
body.dark-mode .site-search-shell.is-open {
    background: #111827;
}

body.dark-mode .site-search-form {
    border-color: #374151;
    background: #1f2937;
}

body.dark-mode .site-search-input,
body.dark-mode .site-search-section-heading,
body.dark-mode .site-search-result-title,
body.dark-mode .site-search-result-copy strong,
body.dark-mode .site-search-mobile-heading strong {
    color: #f3f4f6;
}

body.dark-mode .site-search-popular-chip,
body.dark-mode .site-search-taxonomy-chip,
body.dark-mode .site-search-history-item,
body.dark-mode .site-search-result-image {
    border-color: #374151;
    background: #1f2937;
    color: #e5e7eb;
}

body.dark-mode .site-search-result-item:hover,
body.dark-mode .site-search-view-all {
    background: #1f2937;
}


/* =========================================================
   Desktop navbar horizontal fix
   ========================================================= */

@media (min-width: 992px) {

    .dangaah-header-nav-container {
        width: 100%;
        max-width: 1720px;
        min-height: 46px;
        margin: 0 auto;
        padding: 0 34px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 20px;
        direction: rtl;
    }

    .dangaah-desktop-menu {
        min-width: 0;
        min-height: 46px;
        flex: 1 1 auto;
        display: flex;
        align-items: center;
    }

    .dangaah-header-nav .site-main-menu {
        width: 100%;
        min-height: 46px;
        margin: 0 !important;
        padding: 0 !important;
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 2px;
        list-style: none;
        direction: rtl;
    }

        .dangaah-header-nav .site-main-menu > .nav-item {
            flex: 0 0 auto;
            margin: 0;
        }
}

body.dark-mode .dangaah-header-nav {
    background: #0b0f17;
}

/* =========================================================
   Header brand name
   ========================================================= */

.dangaah-header-logo {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    white-space: nowrap;
}

.dangaah-header-brand-name {
    color: #0f172a;
    font-size: 1.05rem;
    font-weight: 900;
    line-height: 1.5;
    white-space: nowrap;
}

body.dark-mode .dangaah-header-brand-name {
    color: #f8fafc;
}


/* =========================================================
   Mega menu position under its own navbar item
   ========================================================= */

@media (min-width: 992px) {

    /*
     * هر مگامنو نسبت به آیتم والد خودش محاسبه شود،
     * نه نسبت به کل نوار ناوبری.
     */
    .dangaah-header-nav
    .site-main-menu > .site-mega-root {
        position: relative !important;
    }

        /*
     * لبه راست پنل دقیقاً با لبه راست آیتم منو
     * هم‌راستا می‌شود.
     */
        .dangaah-header-nav
        .site-main-menu > .site-mega-root > .site-mega-menu {
            top: calc(100% + 6px) !important;
            right: 0 !important;
            left: auto !important;
            z-index: 5000 !important;
            transform: translateY(14px) scale(0.985) !important;
            transform-origin: top right !important;
        }

        /*
     * حالت بازشده با Hover، Focus یا JavaScript
     */
        .dangaah-header-nav
        .site-main-menu > .site-mega-root:hover > .site-mega-menu,
        .dangaah-header-nav
        .site-main-menu > .site-mega-root:focus-within > .site-mega-menu,
        .dangaah-header-nav
        .site-main-menu > .site-mega-root.is-open > .site-mega-menu {
            transform: translateY(0) scale(1) !important;
        }

    /*
     * محل فلش بالای پنل برندها
     */
    .dangaah-header-nav
    .site-brand-mega-root > .site-brand-mega-menu::before {
        right: 38px !important;
        left: auto !important;
    }

    /*
     * محل فلش بالای پنل دسته‌بندی محصولات
     */
    .dangaah-header-nav
    .site-mega-root:not(.site-brand-mega-root) > .site-mega-menu::before {
        right: 85px !important;
        left: auto !important;
    }

    /*
     * جلوگیری از بریده شدن مگامنو توسط والدها
     */
    .dangaah-header-nav,
    .dangaah-header-nav-container,
    .dangaah-desktop-menu,
    .dangaah-header-nav .site-main-menu {
        overflow: visible !important;
    }
}


/* =========================================================
   Product mobile header
   ردیف اول صفحه محصولات در موبایل
   ========================================================= */

.dangaah-header-identity {
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    direction: rtl;
}

.dangaah-header-logo {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    white-space: nowrap;
}

.dangaah-header-brand-name {
    color: #0f172a;
    font-size: 1.05rem;
    font-weight: 900;
    line-height: 1.5;
    white-space: nowrap;
}

/*
 * Breadcrumb صفحه محصولات در دسکتاپ
 * داخل هدر نمایش داده نمی‌شود.
 */
.dangaah-product-mobile-breadcrumb {
    display: none;
}

body.dark-mode .dangaah-header-brand-name {
    color: #f8fafc;
}

@media (max-width: 991.98px) {

    .dangaah-header-identity {
        grid-area: logo;
        min-width: 0;
        gap: 8px;
    }

    .dangaah-header-brand-name {
        font-size: 0.82rem;
    }

    /*
     * ترتیب آیکون‌ها از چپ به راست:
     * منو، سبد خرید، حساب کاربری
     */
    .dangaah-header-actions {
        display: flex;
        flex-direction: row;
        direction: ltr;
        align-items: center;
        justify-content: flex-start;
        gap: 5px;
    }

        .dangaah-header-actions
        .dangaah-mobile-menu-button {
            order: 1;
        }

        .dangaah-header-actions
        #siteCartButton {
            order: 2;
        }

        .dangaah-header-actions > a.dangaah-header-icon-button {
            order: 3;
        }

    /*
     * صفحه فهرست محصولات در موبایل:
     * هدر فقط یک ردیف دارد.
     */
    body.product-index-page
    .dangaah-header-container {
        min-height: 60px;
        padding: 8px 12px;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas: "logo actions";
        gap: 8px;
    }

    body.product-index-page
    .dangaah-header-identity {
        min-width: 0;
        gap: 8px;
    }

    body.product-index-page
    .dangaah-header-logo {
        flex: 0 0 auto;
        gap: 0;
    }

    body.product-index-page
    .dangaah-header-logo-image {
        width: auto;
        max-width: 70px;
        height: 42px;
    }

    /*
     * فقط در موبایل صفحه محصولات،
     * نام شرکت مخفی شود.
     */
    body.product-index-page
    .dangaah-header-brand-name {
        display: none !important;
    }

    /*
     * Breadcrumb کنار لوگو نمایش داده شود.
     */
    body.product-index-page
    .dangaah-product-mobile-breadcrumb {
        min-width: 0;
        display: inline-flex;
        align-items: center;
        gap: 5px;
        white-space: nowrap;
        overflow: hidden;
        color: #64748b;
        font-size: 0.72rem;
        font-weight: 800;
    }

        body.product-index-page
        .dangaah-product-mobile-breadcrumb a,
        body.product-index-page
        .dangaah-product-mobile-breadcrumb span {
            min-width: 0;
            color: inherit;
            text-decoration: none;
            overflow: hidden;
            text-overflow: ellipsis;
        }

            body.product-index-page
            .dangaah-product-mobile-breadcrumb a:hover {
                color: #224173;
            }

        body.product-index-page
        .dangaah-product-mobile-breadcrumb i {
            flex: 0 0 auto;
            color: #94a3b8;
            font-size: 0.62rem;
        }

    /*
     * سرچ اصلی سایت در حالت بسته داخل هدر
     * صفحه محصولات نمایش داده نمی‌شود.
     *
     * دکمه جست‌وجوی ردیف دوم آن را باز می‌کند.
     */
    body.product-index-page
    .site-search-shell:not(.is-open) {
        display: none !important;
    }

    /*
     * پس از کلیک روی دکمه جست‌وجو،
     * پنل سرچ تمام‌صفحه دوباره نمایش داده شود.
     */
    body.product-index-page
    .site-search-shell.is-open {
        display: flex !important;
    }
}

@media (max-width: 420px) {

    body.product-index-page
    .dangaah-header-container {
        padding-right: 8px;
        padding-left: 8px;
        gap: 5px;
    }

    body.product-index-page
    .dangaah-header-logo-image {
        max-width: 58px;
        height: 38px;
    }

    body.product-index-page
    .dangaah-product-mobile-breadcrumb {
        gap: 4px;
        font-size: 0.66rem;
    }
}

body.dark-mode.product-index-page
.dangaah-product-mobile-breadcrumb {
    color: #cbd5e1;
}

/* =========================================================
   FINAL FIX
   Product index mobile first row
   ========================================================= */

@media (max-width: 991.98px) {

    /*
     * خود هدر در بالای صفحه باقی بماند.
     */
    body.product-index-page #siteHeader.dangaah-header {
        position: sticky !important;
        top: 0 !important;
        z-index: 25000 !important;
        width: 100% !important;
        height: auto !important;
        min-height: 58px !important;
        margin: 0 !important;
        padding: 0 !important;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        background: #ffffff !important;
    }

    body.product-index-page
    #siteHeader
    .dangaah-header-main {
        width: 100% !important;
        height: 58px !important;
        min-height: 58px !important;
        margin: 0 !important;
        padding: 0 !important;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        background: #ffffff !important;
        border-bottom: 1px solid #eef1f4;
    }

    /*
     * ساختار ردیف اول با Flex ساخته شود تا
     * Search مخفی، Grid هدر را به‌هم نریزد.
     */
    body.product-index-page
    #siteHeader
    .dangaah-header-container {
        width: 100% !important;
        max-width: none !important;
        height: 58px !important;
        min-height: 58px !important;
        margin: 0 !important;
        padding: 6px 10px !important;
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        justify-content: space-between !important;
        direction: rtl !important;
        gap: 8px !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    /*
     * سمت راست:
     * لوگو و Breadcrumb
     */
    body.product-index-page
    #siteHeader
    .dangaah-header-identity {
        min-width: 0 !important;
        max-width: calc(100% - 128px) !important;
        margin: 0 !important;
        padding: 0 !important;
        display: flex !important;
        flex: 1 1 auto !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        justify-content: flex-start !important;
        direction: rtl !important;
        gap: 7px !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    body.product-index-page
    #siteHeader
    .dangaah-header-logo {
        width: auto !important;
        min-width: 48px !important;
        margin: 0 !important;
        padding: 0 !important;
        display: inline-flex !important;
        flex: 0 0 auto !important;
        align-items: center !important;
        justify-content: center !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    body.product-index-page
    #siteHeader
    .dangaah-header-logo-image {
        width: auto !important;
        max-width: 58px !important;
        height: 42px !important;
        max-height: 42px !important;
        display: block !important;
        object-fit: contain !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    /*
     * نام شرکت فقط در موبایل صفحه محصولات
     * مخفی می‌شود.
     */
    body.product-index-page
    #siteHeader
    .dangaah-header-brand-name {
        display: none !important;
    }

    /*
     * Breadcrumb کنار لوگو
     */
    body.product-index-page
    #siteHeader
    .dangaah-product-mobile-breadcrumb {
        min-width: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        display: inline-flex !important;
        flex: 0 1 auto !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 5px !important;
        direction: rtl !important;
        color: #64748b !important;
        font-size: 0.69rem !important;
        font-weight: 800 !important;
        line-height: 1.4 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

        body.product-index-page
        #siteHeader
        .dangaah-product-mobile-breadcrumb a,
        body.product-index-page
        #siteHeader
        .dangaah-product-mobile-breadcrumb span {
            min-width: 0 !important;
            display: inline-block !important;
            color: inherit !important;
            text-decoration: none !important;
            white-space: nowrap !important;
            overflow: hidden !important;
            text-overflow: ellipsis !important;
        }

        body.product-index-page
        #siteHeader
        .dangaah-product-mobile-breadcrumb i {
            flex: 0 0 auto !important;
            color: #94a3b8 !important;
            font-size: 0.6rem !important;
        }

    /*
     * سمت چپ:
     * منو، سبد خرید، کاربر
     */
    body.product-index-page
    #siteHeader
    .dangaah-header-actions {
        width: auto !important;
        min-width: 120px !important;
        margin: 0 0 0 auto !important;
        padding: 0 !important;
        display: flex !important;
        flex: 0 0 auto !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        justify-content: flex-start !important;
        direction: ltr !important;
        gap: 3px !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

        body.product-index-page
        #siteHeader
        .dangaah-header-actions > * {
            visibility: visible !important;
            opacity: 1 !important;
        }

    /*
     * ترتیب دیداری از چپ به راست:
     * منو، سبد خرید، کاربر
     */
    body.product-index-page
    #siteHeader
    .dangaah-mobile-menu-button {
        order: 1 !important;
    }

    body.product-index-page
    #siteHeader
    #siteCartButton {
        order: 2 !important;
    }

    body.product-index-page
    #siteHeader
    .dangaah-header-actions > a.dangaah-header-icon-button {
        order: 3 !important;
    }

    body.product-index-page
    #siteHeader
    .dangaah-header-icon-button,
    body.product-index-page
    #siteHeader
    .dangaah-mobile-menu-button {
        width: 38px !important;
        min-width: 38px !important;
        height: 38px !important;
        min-height: 38px !important;
        margin: 0 !important;
        padding: 0 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        border-radius: 11px !important;
    }

    /*
     * سرچ اصلی در حالت بسته در ردیف اول
     * فضا اشغال نکند.
     */
    body.product-index-page
    #siteHeader
    .site-search-shell:not(.is-open) {
        width: 0 !important;
        min-width: 0 !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        display: none !important;
        flex: 0 0 0 !important;
        overflow: hidden !important;
    }

    /*
     * هنگام باز شدن، سرچ تمام‌صفحه نمایش داده شود.
     */
    body.product-index-page
    #siteHeader
    .site-search-shell.is-open {
        position: fixed !important;
        inset: 0 !important;
        z-index: 30050 !important;
        width: 100vw !important;
        max-width: none !important;
        height: 100vh !important;
        height: 100dvh !important;
        display: flex !important;
    }

    /*
     * منوی دسکتاپ در موبایل مخفی باشد.
     */
    body.product-index-page
    #siteHeader
    .dangaah-header-nav {
        display: none !important;
    }
}

@media (max-width: 360px) {

    body.product-index-page
    #siteHeader
    .dangaah-header-container {
        padding-right: 6px !important;
        padding-left: 6px !important;
        gap: 4px !important;
    }

    body.product-index-page
    #siteHeader
    .dangaah-header-actions {
        min-width: 108px !important;
        gap: 1px !important;
    }

    body.product-index-page
    #siteHeader
    .dangaah-header-icon-button,
    body.product-index-page
    #siteHeader
    .dangaah-mobile-menu-button {
        width: 35px !important;
        min-width: 35px !important;
        height: 35px !important;
        min-height: 35px !important;
    }

    body.product-index-page
    #siteHeader
    .dangaah-header-logo-image {
        max-width: 50px !important;
        height: 38px !important;
    }

    body.product-index-page
    #siteHeader
    .dangaah-product-mobile-breadcrumb {
        gap: 3px !important;
        font-size: 0.63rem !important;
    }
}

body.search-results-page .search-page h1,
body.search-results-page .search-page h2,
body.search-results-page .search-page h3 {
    font-size: 1rem !important; /* برابر با 16px */
}

/* دسکتاپ */
body.search-results-page .search-page p {
    font-size: 13px !important;
}

/* موبایل و تبلت */
@media (max-width: 991px) {
    body.search-results-page .search-page p {
        font-size: 11px !important;
    }
}