/* assets/css/site-header.css */
/* Mobile-First Responsive Header */

/* ===== BASE HEADER ===== */
.ud-header {
    background-color: var(--ud-surface, #ffffff);
    border-bottom: 1px solid var(--ud-border-subtle, #e3e4ff);
    font-family: var(--ud-font-main, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.ud-header__inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 24px;
    min-height: 60px;
    display: flex;
    align-items: center;
    position: relative;
    z-index: 60;
    gap: 16px;
}

/* LEFT: logo */
.ud-header__left {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.ud-header__logo img {
    display: block;
    height: 50px;
    width: auto;
}

/* CENTER: location */
.ud-header__location {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    min-width: 0;
    flex: 0 1 auto;
}

.ud-location__selector {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    min-width: 0;
}

/* ===== ICON COLOR SYSTEM ===== */
.ud-header,
.ud-header * {
    --ud-icon-color: var(--ud-primary);
}

/* These icon containers use theme color */
.ud-contact__icon,
.ud-nav-item__icon,
.ud-location-popup__search-icon,
.ud-location-popup__gps-icon,
.ud-gps-modal__pin-icon {
    color: var(--ud-icon-color);
}

/* Inline SVG support */
.ud-contact__icon svg,
.ud-nav-item__icon svg,
.ud-location-popup__gps-icon svg,
.ud-gps-modal__pin-icon svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
    stroke: currentColor;
}

/* External <img> icons recolor */
.ud-contact__icon img,
.ud-nav-item__icon img,
.ud-location-popup__search-icon,
.ud-location-popup__gps-icon img,
.ud-gps-modal__pin-icon img {
    display: block;
    filter: var(--ud-primary);
}

/* -------- LOCATION ICON -------- */
.ud-location__icon {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

.ud-location__icon .ud-loc-icon {
    width: 15px;
    height: 15px;
    display: block;
}

.ud-location__icon .ud-loc-icon__pin {
    fill: var(--ud-primary);
}

.ud-location__icon .ud-loc-icon__bg {
    fill: var(--ud-surface-soft);
    stroke: var(--ud-primary-soft);
    stroke-width: .41px;
    stroke-miterlimit: 1.66;
}

.ud-location__title {
    max-width: 190px;
    font-weight: 700;
    font-size: 14px;
    color: var(--ud-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ud-location__caret {
    font-size: 11px;
    color: var(--ud-primary);
    flex-shrink: 0;
}

.ud-location__subtitle {
    font-size: 11px;
    color: var(--ud-text-muted, #777a8c);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Spacer */
.ud-header__spacer {
    flex: 1 1 auto;
}

/* RIGHT: actions */
.ud-header__right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

/* Call section */
.ud-header__contact {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-right: 4px;
}

.ud-contact__icon img {
    width: 28px;
    height: 28px;
}

.ud-contact__text {
    display: flex;
    flex-direction: column;
    font-size: 11px;
}

.ud-contact__label {
    color: var(--ud-text-main, #000000);
}

.ud-contact__number {
    font-weight: 700;
    font-size: 13px;
    color: var(--ud-text-main, #000000);
    text-decoration: none;
}

/* Nav items */
.ud-header__nav-item {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
    border: none;
    background: transparent;
    font-size: 12px;
    cursor: pointer;
    color: var(--ud-primary);
    border-radius: var(--ud-radius-sm, 6px);
    transition: background 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.ud-header__nav-item:hover {
    background: var(--ud-surface-soft, #fff3fd);
}

.ud-nav-item__icon {
    position: relative;
}

.ud-nav-item__icon img {
    width: 20px;
    height: 20px;
}

.ud-nav-item__label {
    font-size: 11px;
    color: var(--ud-text-muted, #777a8c);
    white-space: nowrap;
}

.ud-nav-item__label--strong {
    font-weight: 700;
    color: var(--ud-primary);
}

/* Profile avatar */
.ud-profile__avatar img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: block;
    filter: none !important;
}

/* Divider */
.ud-header__divider {
    width: 1px;
    height: 24px;
    background-color: var(--ud-border-subtle, #e3e4ff);
}

/* ===== CART BADGE ===== */
.ud-nav-item__icon--cart {
    position: relative;
}

.ud-cart-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    background: #dc3545;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    line-height: 1;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.ud-cart-badge:empty,
.ud-cart-badge.hidden {
    display: none;
}

a.ud-header__nav-item--cart {
    text-decoration: none;
    color: inherit;
}

/* ===== LOCATION POPUP ===== */
.ud-location-popup {
    position: absolute;
    left: 0;
    top: 100%;
    width: 420px;
    background-color: var(--ud-surface);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    border-radius: 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s;
    z-index: 70;
}

.ud-location-popup--open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.ud-location-popup__inner {
    padding: 18px 18px 20px;
}

/* top search row */
.ud-location-popup__search-row {
    display: flex;
    align-items: stretch;
    border: 1px solid #e0e0e0;
}

.ud-location-popup__country {
    display: inline-flex;
    align-items: center;
    padding: 0 10px;
    border: none;
    background: #f9f9f9;
    cursor: pointer;
    gap: 6px;
}

.ud-country-flag img {
    width: 22px;
    height: 14px;
    object-fit: cover;
    display: block;
    filter: none !important;
}

.ud-country-code {
    font-size: 13px;
}

.ud-country-caret {
    font-size: 10px;
}

/* search box */
.ud-location-popup__search {
    flex: 1;
    position: relative;
}

.ud-location-popup__search input {
    width: 100%;
    border: none;
    padding: 10px 12px 10px 30px;
    font-size: 13px;
    outline: none;
}

.ud-location-popup__search-icon {
    position: absolute;
    left: 9px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    opacity: 0.9;
}

/* Suggest list */
.ud-location-popup__suggest-list {
    list-style: none;
    padding: 0;
    margin: 10px 0 0;
    max-height: 260px;
    overflow-y: auto;
    border: 1px solid #f0f0f0;
    border-top: none;
}

.ud-location-popup__suggest-list.hidden {
    display: none;
}

.ud-location-suggest {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 10px;
    cursor: pointer;
}

.ud-location-suggest:hover {
    background-color: #f7f7ff;
}

.ud-location-suggest__icon img {
    width: 16px;
    height: 16px;
    margin-top: 3px;
}

.ud-location-suggest__body {
    flex: 1;
    min-width: 0;
}

.ud-location-suggest__line1 {
    font-size: 14px;
    font-weight: 600;
    color: #222;
}

.ud-location-suggest__line2 {
    font-size: 12px;
    color: #666;
    margin-top: 2px;
}

/* GPS row */
.ud-location-popup__gps-row {
    margin-top: 16px;
    border: none;
    background: transparent;
    padding: 0;
    display: inline-flex;
    align-items: center;
    font-size: 13px;
    color: var(--ud-primary);
    cursor: pointer;
    gap: 8px;
}

.ud-location-popup__gps-icon img {
    width: 18px;
    height: 18px;
}

/* card */
.ud-location-popup__card {
    margin-top: 18px;
    padding: 40px 16px;
    background-color: #fafafa;
    text-align: center;
}

.ud-location-popup__pin-circle {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ud-location-popup__pin-circle img {
    width: 56px;
    height: 56px;
}

.ud-location-popup__card h3 {
    margin: 0 0 8px;
    font-size: 18px;
    font-weight: 700;
}

.ud-location-popup__card p {
    margin: 0;
    font-size: 13px;
    color: #555;
}

/* BACKDROP */
.ud-location-backdrop {
    position: fixed;
    inset: 0;
    background: transparent;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.16s ease, visibility 0.16s;
    z-index: 50;
}

.ud-location-backdrop--open {
    opacity: 1;
    visibility: visible;
}

/* ===== GPS MODAL ===== */
.ud-gps-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 200;
}

.ud-gps-modal-backdrop.is-visible {
    opacity: 1;
    visibility: visible;
}

.ud-gps-modal {
    width: 800px;
    max-width: 95vw;
    background: #fff;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Map wrapper */
.ud-gps-modal__map-wrap {
    position: relative;
    height: 420px;
    background: #f2f2f2;
}

.ud-gps-modal__map {
    position: absolute;
    inset: 0;
}

/* Round back & close buttons */
.ud-gps-modal__back,
.ud-gps-modal__close {
    position: absolute;
    top: 12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--ud-surface);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}

.ud-gps-modal__back {
    left: 12px;
}

.ud-gps-modal__close {
    right: 12px;
}

/* Center pin + bubble */
.ud-gps-modal__pin-wrapper {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -40px);
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
}

.ud-gps-modal__bubble {
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 11px;
    text-align: center;
    margin-bottom: 6px;
}

.ud-gps-modal__bubble-main {
    font-weight: 600;
}

/* Bottom panel */
.ud-gps-modal__bottom {
    padding: 18px 20px 20px;
    border-top: 1px solid #eee;
}

.ud-gps-modal__info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.ud-gps-modal__pin-icon img {
    width: 18px;
    height: 18px;
}

.ud-gps-modal__label {
    font-size: 12px;
    color: #777;
}

.ud-gps-modal__title {
    font-size: 16px;
    font-weight: 600;
    margin-top: 2px;
}

.ud-gps-modal__address {
    font-size: 12px;
    color: #555;
    margin-top: 2px;
}

.ud-gps-modal__btn {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--ud-primary);
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    padding: 12px 16px;
    border-radius: 3px;
    cursor: pointer;
}

/* ===== RESPONSIVE: TABLET (900px) ===== */
@media (max-width: 900px) {
    .ud-header__inner {
        padding: 12px 16px;
        gap: 12px;
    }

    .ud-header__right {
        gap: 12px;
    }

    .ud-header__contact {
        display: none;
    }

    .ud-gps-modal {
        width: 95vw;
    }

    .ud-location__title {
        max-width: 140px;
    }
}

/* ===== RESPONSIVE: MOBILE (640px) ===== */
@media (max-width: 640px) {
    .ud-header__inner {
        padding: 10px 12px;
        min-height: 56px;
        gap: 8px;
    }

    .ud-header__logo img {
        height: 38px;
    }

    .ud-location__subtitle {
        display: none;
    }

    .ud-location__title {
        max-width: 100px;
        font-size: 13px;
    }

    .ud-header__right {
        gap: 4px;
    }

    .ud-header__nav-item {
        padding: 4px 6px;
    }

    .ud-header__nav-item .ud-nav-item__label {
        display: none;
    }

    .ud-header__divider {
        display: none;
    }

    .ud-profile__avatar img {
        width: 28px;
        height: 28px;
    }

    .ud-nav-item__icon img {
        width: 22px;
        height: 22px;
    }

    .ud-location-popup {
        width: calc(100vw - 24px);
        left: 12px;
        right: 12px;
        border-radius: var(--ud-radius-md, 10px);
    }

    .ud-gps-modal__map-wrap {
        height: 300px;
    }
}

/* ===== RESPONSIVE: SMALL MOBILE (400px) ===== */
@media (max-width: 400px) {
    .ud-header__inner {
        padding: 8px 10px;
    }

    .ud-header__logo img {
        height: 32px;
    }

    .ud-location__icon {
        display: none;
    }

    .ud-location__title {
        max-width: 80px;
        font-size: 12px;
    }

    .ud-location__caret {
        font-size: 10px;
    }

    .ud-header__nav-item {
        padding: 4px;
    }

    .ud-nav-item__icon img {
        width: 20px;
        height: 20px;
    }

    .ud-profile__avatar img {
        width: 26px;
        height: 26px;
    }

    .ud-cart-badge {
        min-width: 16px;
        height: 16px;
        font-size: 9px;
        top: -4px;
        right: -4px;
    }

    .ud-location-popup {
        width: calc(100vw - 16px);
        left: 8px;
        right: 8px;
    }

    .ud-location-popup__inner {
        padding: 14px;
    }

    .ud-location-popup__card {
        padding: 30px 12px;
    }

    .ud-location-popup__pin-circle {
        width: 70px;
        height: 70px;
    }

    .ud-location-popup__pin-circle img {
        width: 40px;
        height: 40px;
    }
}

/* ===== MOBILE BOTTOM NAV (Optional future enhancement) ===== */
@media (max-width: 640px) {
    /* Prepare for mobile bottom nav if needed */
    .ud-header {
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    }
}
