/*
|--------------------------------------------------------------------------
| Frontend Header
|--------------------------------------------------------------------------
| Tách từ resources/views/frontend/partials/header.blade.php.
| Không thay đổi bố cục, breakpoint hay hành vi hiển thị hiện tại.
*/

.frontend-header,
.frontend-header *,
.frontend-header *::before,
.frontend-header *::after {
    box-sizing: border-box;
}

.frontend-header {
    position: relative;
    z-index: 50;
}

.frontend-header.is-sticky {
    position: sticky;
    top: 0;
}

.frontend-header [hidden],
.frontend-header [x-cloak] {
    display: none !important;
}

.frontend-header__container {
    width: 100%;
    max-width: 1300px;
    margin-right: auto;
    margin-left: auto;
}

/* Topbar */

.frontend-header__topbar {
    background: #0f172a;
    color: #ffffff;
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.frontend-header__topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.5rem 1rem;
}

.frontend-header__topbar-contact {
    display: flex;
    min-width: 0;
    flex-wrap: wrap;
    align-items: center;
    column-gap: 1.25rem;
    row-gap: 0.25rem;
}

.frontend-header__topbar-text {
    display: none;
    color: #e5e7eb;
}

.frontend-header__topbar-link {
    white-space: nowrap;
    color: inherit;
    text-decoration: none;
    transition: color 150ms ease;
}

.frontend-header__topbar-link:hover {
    color: #93c5fd;
}

.frontend-header__topbar-email {
    display: none;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.frontend-header__topbar-address {
    display: none;
    max-width: 28rem;
    overflow: hidden;
    color: #d1d5db;
    text-align: right;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Header main */

.frontend-header__main {
    border-bottom: 1px solid #e5e7eb;
    background: #ffffff;
    box-shadow:
        0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.frontend-header__main-inner {
    display: flex;
    min-height: 92px;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
}

.frontend-header__logo {
    order: 1;
    display: flex;
    min-width: 0;
    flex-shrink: 0;
    align-items: center;
    color: inherit;
    text-decoration: none;
}

.frontend-header__logo-image {
    width: auto;
    max-width: 160px;
    height: 3rem;
    object-fit: contain;
}

.frontend-header__logo-text {
    max-width: 190px;
    overflow: hidden;
    color: #2563eb;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.75rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* AJAX search */

.frontend-header__search {
    position: relative;
    order: 3;
    width: 100%;
}

.frontend-header__search-form {
    display: grid;
    width: 100%;
    grid-template-columns: minmax(0, 1fr) 48px;
    overflow: hidden;
    border: 1px solid #38bdf8;
    border-radius: 0.5rem;
    background: #ffffff;
    transition:
        border-color 150ms ease,
        box-shadow 150ms ease;
}

.frontend-header__search-form:focus-within {
    border-color: #0ea5e9;
    box-shadow: 0 0 0 2px #e0f2fe;
}

.frontend-header__sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    border: 0;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

.frontend-header__search-input {
    width: 100%;
    min-width: 0;
    height: 2.75rem;
    padding: 0 1rem;
    border: 0;
    outline: 0;
    background: transparent;
    color: #374151;
    font: inherit;
    font-size: 0.875rem;
    line-height: 1.25rem;
    box-shadow: none;
}

.frontend-header__search-input::placeholder {
    color: #9ca3af;
}

.frontend-header__search-input:focus {
    border: 0;
    outline: 0;
    box-shadow: none;
}

.frontend-header__search-input::-webkit-search-cancel-button {
    cursor: pointer;
}

.frontend-header__search-button {
    display: flex;
    height: 2.75rem;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    background: #0ea5e9;
    color: #ffffff;
    cursor: pointer;
    transition: background-color 150ms ease;
}

.frontend-header__search-button:hover {
    background: #0284c7;
}

.frontend-header__search-button:focus {
    outline: 0;
}

.frontend-header__search-icon {
    width: 1.25rem;
    height: 1.25rem;
}

.frontend-header__search-results {
    position: absolute;
    z-index: 200;
    top: calc(100% + 8px);
    right: 0;
    left: 0;
    max-height: 430px;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    background: #ffffff;
    box-shadow:
        0 25px 50px -12px rgb(0 0 0 / 0.25);
}

.frontend-header__search-message {
    padding: 1.25rem 1rem;
    color: #6b7280;
    font-size: 0.875rem;
    line-height: 1.25rem;
    text-align: center;
}

.frontend-header__search-message.is-error {
    color: #dc2626;
}

.frontend-header__search-result {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1rem;
    color: inherit;
    text-decoration: none;
    transition: background-color 150ms ease;
}

.frontend-header__search-result + .frontend-header__search-result {
    border-top: 1px solid #f3f4f6;
}

.frontend-header__search-result:hover,
.frontend-header__search-result:focus {
    outline: 0;
    background: #f0f9ff;
}

.frontend-header__search-product-info {
    min-width: 0;
    flex: 1 1 0%;
}

.frontend-header__search-product-name {
    display: block;
    color: #1f2937;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.25rem;
}

.frontend-header__search-product-sku {
    display: block;
    margin-top: 0.25rem;
    color: #9ca3af;
    font-size: 0.75rem;
    line-height: 1rem;
}

.frontend-header__search-product-price {
    flex-shrink: 0;
    color: #dc2626;
    font-size: 0.875rem;
    font-weight: 700;
    line-height: 1.25rem;
    white-space: nowrap;
}

/* Header actions */

.frontend-header__actions {
    order: 2;
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
}

.frontend-header__contact-button {
    display: none;
    min-height: 48px;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.25rem;
    border-radius: 0.75rem;
    background: #2563eb;
    color: #ffffff;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.25rem;
    text-decoration: none;
    transition: background-color 150ms ease;
}

.frontend-header__contact-button:hover {
    background: #1d4ed8;
}

.frontend-header__mobile-toggle {
    display: inline-flex;
    width: 2.75rem;
    height: 2.75rem;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    background: transparent;
    color: #374151;
    cursor: pointer;
    transition: background-color 150ms ease;
}

.frontend-header__mobile-toggle:hover {
    background: #f3f4f6;
}

.frontend-header__mobile-toggle-icon {
    width: 1.5rem;
    height: 1.5rem;
}

/* Desktop mega menu */

.frontend-header__desktop-menu {
    display: none;
    background: #0284c7;
}

.frontend-header__desktop-nav {
    position: relative;
    width: 100%;
    max-width: 1300px;
    margin-right: auto;
    margin-left: auto;
}

.frontend-header__desktop-list {
    display: flex;
    min-height: 60px;
    align-items: stretch;
}

.frontend-header__desktop-item {
    position: static;
    display: flex;
    min-width: 0;
    flex: 1 1 0%;
}

.frontend-header__desktop-link {
    display: flex;
    width: 100%;
    min-height: 60px;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.5rem 0.75rem;
    color: #ffffff;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.25rem;
    text-align: center;
    text-decoration: none;
    transition: background-color 150ms ease;
}

.frontend-header__desktop-link:hover,
.frontend-header__desktop-link.is-active {
    background: #0369a1;
}

.frontend-header__desktop-link.is-promotion {
    background: #dc2626;
}

.frontend-header__desktop-link.is-promotion:hover {
    background: #b91c1c;
}

.frontend-header__desktop-arrow {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    transition: transform 200ms ease;
}

.frontend-header__desktop-item:hover
    .frontend-header__desktop-arrow,
.frontend-header__desktop-item:focus-within
    .frontend-header__desktop-arrow {
    transform: rotate(180deg);
}

.frontend-header__mega-menu {
    position: absolute;
    z-index: 100;
    top: 100%;
    right: 0;
    left: 0;
    visibility: hidden;
    transform: translateY(0.5rem);
    opacity: 0;
    transition:
        visibility 150ms ease,
        transform 150ms ease,
        opacity 150ms ease;
}

.frontend-header__desktop-item:hover
    .frontend-header__mega-menu,
.frontend-header__desktop-item:focus-within
    .frontend-header__mega-menu {
    visibility: visible;
    transform: translateY(0);
    opacity: 1;
}

.frontend-header__mega-inner {
    width: 100%;
    min-height: 250px;
    padding: 1.75rem;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    box-shadow:
        0 25px 50px -12px rgb(0 0 0 / 0.25);
}

.frontend-header__mega-grid {
    display: grid;
    justify-content: start;
    grid-template-columns:
        repeat(auto-fill, minmax(180px, 220px));
    column-gap: 2.5rem;
    row-gap: 2rem;
}

.frontend-header__mega-column {
    min-width: 0;
}

.frontend-header__level-two-link {
    display: block;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e5e7eb;
    color: #1f2937;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.5rem;
    text-decoration: none;
    transition: color 150ms ease;
}

.frontend-header__level-two-link:hover {
    color: #0284c7;
}

.frontend-header__level-two-link.is-active {
    color: #0369a1;
}

.frontend-header__level-three-list {
    margin-top: 0.5rem;
}

.frontend-header__level-three-link {
    display: block;
    padding: 0.5rem 0.25rem;
    border-radius: 0.5rem;
    color: #4b5563;
    font-size: 0.875rem;
    line-height: 1.25rem;
    text-decoration: none;
    transition:
        color 150ms ease,
        transform 150ms ease;
}

.frontend-header__level-three-link:hover {
    transform: translateX(0.25rem);
    color: #0284c7;
}

.frontend-header__level-three-link.is-active {
    color: #0369a1;
    font-weight: 600;
}

.frontend-header__empty-desktop {
    display: flex;
    width: 100%;
    min-height: 60px;
    align-items: center;
    justify-content: center;
    padding: 0 1rem;
    color: #ffffff;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.25rem;
    text-align: center;
}

.frontend-header__empty-desktop-link {
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    background: rgb(255 255 255 / 0.15);
    color: #ffffff;
    text-decoration: none;
    transition: background-color 150ms ease;
}

.frontend-header__empty-desktop-link:hover {
    background: rgb(255 255 255 / 0.25);
}

/* Mobile menu */

.frontend-header__mobile-menu {
    border-top: 1px solid #0ea5e9;
    background: #0284c7;
}

.frontend-header__mobile-nav {
    width: 100%;
    max-width: 1300px;
    max-height: calc(100vh - 130px);
    margin-right: auto;
    margin-left: auto;
    overflow-y: auto;
    padding: 0.75rem;
}

.frontend-header__mobile-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.frontend-header__mobile-item {
    overflow: hidden;
    border: 1px solid rgb(255 255 255 / 0.10);
    border-radius: 0.75rem;
}

.frontend-header__mobile-row {
    display: flex;
    align-items: stretch;
}

.frontend-header__mobile-level-one-link {
    display: flex;
    min-width: 0;
    min-height: 48px;
    flex: 1 1 0%;
    align-items: center;
    padding: 0.75rem 1rem;
    color: #ffffff;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.25rem;
    text-decoration: none;
    transition: background-color 150ms ease;
}

.frontend-header__mobile-level-one-link:hover {
    background: rgb(255 255 255 / 0.10);
}

.frontend-header__mobile-level-one-link.is-active {
    background: rgb(255 255 255 / 0.20);
}

.frontend-header__mobile-level-one-toggle {
    display: flex;
    width: 3rem;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-left: 1px solid rgb(255 255 255 / 0.10);
    background: transparent;
    color: #ffffff;
    cursor: pointer;
    transition: background-color 150ms ease;
}

.frontend-header__mobile-level-one-toggle:hover {
    background: rgb(255 255 255 / 0.10);
}

.frontend-header__mobile-arrow {
    width: 1.25rem;
    height: 1.25rem;
    transition: transform 200ms ease;
}

.frontend-header__mobile-arrow--small {
    width: 1rem;
    height: 1rem;
}

.frontend-header__mobile-arrow.is-open {
    transform: rotate(180deg);
}

.frontend-header__mobile-level-two-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.5rem;
    border-top: 1px solid rgb(255 255 255 / 0.10);
    background: rgb(3 105 161 / 0.60);
}

.frontend-header__mobile-level-two-item {
    overflow: hidden;
    border: 1px solid rgb(255 255 255 / 0.10);
    border-radius: 0.5rem;
    background: rgb(255 255 255 / 0.05);
}

.frontend-header__mobile-level-two-link {
    display: flex;
    min-width: 0;
    min-height: 44px;
    flex: 1 1 0%;
    align-items: center;
    padding: 0.625rem 1rem;
    color: #ffffff;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.25rem;
    text-decoration: none;
    transition: background-color 150ms ease;
}

.frontend-header__mobile-level-two-link:hover {
    background: rgb(255 255 255 / 0.10);
}

.frontend-header__mobile-level-two-link.is-active {
    background: rgb(255 255 255 / 0.20);
}

.frontend-header__mobile-level-prefix {
    margin-right: 0.5rem;
    color: rgb(255 255 255 / 0.50);
}

.frontend-header__mobile-level-two-toggle {
    display: flex;
    width: 2.75rem;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-left: 1px solid rgb(255 255 255 / 0.10);
    background: transparent;
    color: #ffffff;
    cursor: pointer;
    transition: background-color 150ms ease;
}

.frontend-header__mobile-level-two-toggle:hover {
    background: rgb(255 255 255 / 0.10);
}

.frontend-header__mobile-level-three-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.5rem;
    border-top: 1px solid rgb(255 255 255 / 0.10);
    background: rgb(7 89 133 / 0.50);
}

.frontend-header__mobile-level-three-link {
    display: block;
    padding: 0.625rem 1rem;
    border-radius: 0.5rem;
    color: rgb(255 255 255 / 0.90);
    font-size: 0.875rem;
    line-height: 1.25rem;
    text-decoration: none;
    transition: background-color 150ms ease;
}

.frontend-header__mobile-level-three-link:hover {
    background: rgb(255 255 255 / 0.10);
}

.frontend-header__mobile-level-three-link.is-active {
    background: rgb(255 255 255 / 0.20);
    color: #ffffff;
    font-weight: 600;
}

.frontend-header__mobile-level-three-prefix {
    margin-right: 0.5rem;
    color: rgb(255 255 255 / 0.40);
}

.frontend-header__empty-mobile {
    padding: 1rem;
    border: 1px solid rgb(255 255 255 / 0.20);
    border-radius: 0.75rem;
    background: rgb(255 255 255 / 0.10);
    color: #ffffff;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.25rem;
    text-align: center;
}

.frontend-header__empty-mobile-link {
    display: block;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    background: #ffffff;
    color: #0369a1;
    text-decoration: none;
}

.frontend-header__mobile-contact {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgb(255 255 255 / 0.20);
}

.frontend-header__mobile-contact-link {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.25rem;
    border-radius: 0.75rem;
    background: #ffffff;
    color: #0369a1;
    font-weight: 600;
    text-decoration: none;
    transition: background-color 150ms ease;
}

.frontend-header__mobile-contact-link:hover {
    background: #f3f4f6;
}

/* Responsive */

@media (min-width: 640px) {
    .frontend-header__topbar-inner,
    .frontend-header__main-inner {
        padding-right: 1.5rem;
        padding-left: 1.5rem;
    }

    .frontend-header__topbar-email {
        display: inline;
    }

    .frontend-header__logo-image {
        max-width: 190px;
        height: 3.5rem;
    }

    .frontend-header__mobile-nav {
        padding-right: 1.5rem;
        padding-left: 1.5rem;
    }
}

@media (min-width: 768px) {
    .frontend-header__topbar-address {
        display: block;
    }

    .frontend-header__contact-button {
        display: inline-flex;
    }
}

@media (min-width: 1024px) {
    .frontend-header__topbar-text {
        display: inline;
    }

    /*
     * Chia header thành 3 cột cân bằng:
     * Logo | Tìm kiếm ở giữa | Liên hệ
     */
    .frontend-header__main-inner {
        display: grid;
        grid-template-columns:
            minmax(160px, 220px)
            minmax(320px, 650px)
            minmax(160px, 220px);
        align-items: center;
        justify-content: center;
        gap: 1.5rem;
        padding-top: 1rem;
        padding-bottom: 1rem;
    }

    .frontend-header__logo {
        order: initial;
        justify-self: start;
    }

    .frontend-header__logo-image {
        max-width: 220px;
        height: 4rem;
    }

    .frontend-header__logo-text {
        font-size: 1.5rem;
        line-height: 2rem;
    }

    /*
     * Form tìm kiếm luôn nằm giữa header.
     */
    .frontend-header__search {
        order: initial;
        width: 100%;
        max-width: 650px;
        min-width: 0;
        justify-self: center;
        flex: none;
    }

    .frontend-header__search-input,
    .frontend-header__search-button {
        height: 2.5rem;
    }

    /*
     * Khu vực nút liên hệ canh về bên trái.
     */
    .frontend-header__actions {
        order: initial;
        width: 100%;
        margin-left: 0;
        justify-self: start;
        justify-content: flex-start;
    }

    /*
     * Nút liên hệ dài hơn và nội dung canh trái.
     */
    .frontend-header__contact-button {
        width: 100%;
        min-width: 200px;
        max-width: 220px;
        min-height: 48px;
        justify-content: center;
        padding-right: 1.5rem;
        padding-left: 1.5rem;
        text-align: center;
    }

    .frontend-header__mobile-toggle {
        display: none;
    }

    .frontend-header__desktop-menu {
        display: block;
    }
}

