/* ==========================================================================
   Shared Header Component
   Used by cart.html and checkout.html for consistent index-style navigation.
   ========================================================================== */

:root {
    --kalp-header-primary: #2d6a4f;
    --kalp-header-primary-dark: #1b4332;
    --kalp-header-accent: #4ade80;
    --kalp-header-bg: #ffffff;
    --kalp-header-text: #1f2937;
    --kalp-header-muted: #6b7280;
    --kalp-header-border: #e5e7eb;
    --kalp-header-topbar: #111827;
}

#sharedHeaderRoot {
    position: sticky;
    top: 0;
    z-index: 1500;
    background: var(--kalp-header-bg);
}

#sharedHeaderRoot .container {
    width: min(1400px, calc(100% - 2.2rem));
    margin: 0 auto;
}

#sharedHeaderRoot .header {
    background: var(--kalp-header-bg);
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.04);
}

#sharedHeaderRoot .minimal-header,
#sharedHeaderRoot .minimal-main-header {
    border-bottom: 1px solid var(--kalp-header-border);
    background: var(--kalp-header-bg);
}

#sharedHeaderRoot .minimal-header-content {
    min-height: 82px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

#sharedHeaderRoot .minimal-main-header .header-main {
    padding: 18px 0;
}

#sharedHeaderRoot .minimal-main-header .minimal-header-content {
    min-height: 70px;
}

#sharedHeaderRoot .minimal-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

#sharedHeaderRoot .minimal-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--kalp-header-border);
    background: #fff;
    color: #1f2937;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
    box-shadow: 0 6px 14px rgba(15, 23, 42, 0.06);
}

#sharedHeaderRoot .minimal-back-btn:hover {
    border-color: var(--kalp-header-primary);
    color: var(--kalp-header-primary);
    background: #f8fafc;
}

#sharedHeaderRoot .header-topbar {
    background: var(--kalp-header-topbar);
    color: #fff;
    font-size: 13px;
    padding: 8px 0;
}

#sharedHeaderRoot .topbar-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

#sharedHeaderRoot .topbar-left,
#sharedHeaderRoot .topbar-right {
    display: flex;
    align-items: center;
    gap: 18px;
}

#sharedHeaderRoot .topbar-item {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: #e5e7eb;
}

#sharedHeaderRoot .topbar-item.highlight {
    color: #ffffff;
    font-weight: 600;
}

#sharedHeaderRoot .topbar-item.highlight .delivery-amount {
    color: var(--kalp-header-accent);
    font-weight: 700;
}

#sharedHeaderRoot .container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
    /* --spacing-lg */
}

#sharedHeaderRoot .header-main {
    border-bottom: 1px solid var(--kalp-header-border);
    padding: 24px 0;
    /* Matched to styles.css (1.5rem) */
}

#sharedHeaderRoot .header-content {
    display: grid;
    grid-template-columns: auto auto 1fr auto auto;
    align-items: center;
    gap: 32px;
    /* Matched to styles.css (var(--spacing-xl)) */
}

#sharedHeaderRoot .brand-with-location {
    display: flex;
    align-items: center;
    gap: 10px;
}

#sharedHeaderRoot .brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

#sharedHeaderRoot .brand-logo-wrap {
    width: 76px;
    height: 76px;
    border-radius: 18px;
    /* Matched to styles.css */
    background: linear-gradient(135deg, #1b4332, #2d6a4f);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.2);
    overflow: hidden;
}

#sharedHeaderRoot .brand-logo {
    width: 70%;
    height: 70%;
    object-fit: contain;
}

#sharedHeaderRoot .brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1;
}

#sharedHeaderRoot .brand-name {
    font-family: 'Lora', serif;
    font-size: 2rem;
    /* Matched to styles.css */
    font-weight: 800;
    letter-spacing: 0.08em;
    /* Matched to styles.css */
    color: var(--kalp-header-primary);
}

#sharedHeaderRoot .brand-subtitle {
    margin-top: 3px;
    font-size: 0.75rem;
    /* Matched to styles.css (12px) */
    letter-spacing: 0.32em;
    font-weight: 700;
    color: var(--kalp-header-muted);
}

#sharedHeaderRoot .mobile-location-icon {
    display: none;
    width: 38px;
    height: 38px;
    border-radius: 999px;
    align-items: center;
    justify-content: center;
    background: var(--kalp-header-primary);
    color: #fff;
}

#sharedHeaderRoot .location-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid var(--kalp-header-border);
    background: #f8fafc;
    min-width: 190px;
    cursor: pointer;
}

#sharedHeaderRoot .location-icon {
    color: var(--kalp-header-primary);
    font-size: 18px;
}

#sharedHeaderRoot .location-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

#sharedHeaderRoot .location-label {
    font-size: 11px;
    color: #64748b;
}

#sharedHeaderRoot .location-value {
    font-size: 14px;
    color: #111827;
    font-weight: 700;
    white-space: nowrap;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
}

#sharedHeaderRoot .location-arrow {
    font-size: 12px;
    color: #64748b;
}

#sharedHeaderRoot .search-container {
    width: 100%;
}

#sharedHeaderRoot .search-box {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f8fafc;
    border: 1px solid var(--kalp-header-border);
    border-radius: 999px;
    padding: 11px 14px;
}

#sharedHeaderRoot .search-icon {
    color: #64748b;
    font-size: 14px;
}

#sharedHeaderRoot .search-input {
    width: 100%;
    border: none;
    outline: none;
    background: transparent;
    color: var(--kalp-header-text);
    font-size: 14px;
}

#sharedHeaderRoot .search-clear {
    display: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    color: #475569;
    background: #e2e8f0;
}

#sharedHeaderRoot .header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    /* Matched to styles.css (8px) */
}

#sharedHeaderRoot .shared-header--default .header-actions.desktop-only {
    gap: 0.35rem;
    min-width: 0;
}

#sharedHeaderRoot .shared-nav-search-wrap {
    position: relative;
    width: clamp(220px, 20vw, 300px);
    min-width: 220px;
    flex: 0 0 auto;
}

#sharedHeaderRoot .kalp-nav-search {
    position: relative;
    display: inline-flex;
    align-items: center;
    width: 100%;
    min-width: 0;
    height: 38px;
    border-radius: 999px;
    border: 1px solid #d7e3db;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbf9 100%);
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
    transition: border-color 0.22s ease, box-shadow 0.22s ease, transform 0.22s ease;
}

#sharedHeaderRoot .kalp-nav-search:focus-within {
    border-color: #2d6a4f;
    box-shadow: 0 0 0 3px rgba(45, 106, 79, 0.17), 0 10px 24px rgba(15, 23, 42, 0.12);
}

#sharedHeaderRoot .kalp-nav-search-input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: none;
    background: transparent;
    color: #1f2937;
    font-size: 14px;
    line-height: 1;
    padding-left: 14px;
    padding-right: 84px;
    appearance: none;
    -webkit-appearance: none;
}

#sharedHeaderRoot .kalp-nav-search-input::placeholder {
    color: #93a1b2;
}

#sharedHeaderRoot .kalp-nav-search-input::-webkit-search-decoration,
#sharedHeaderRoot .kalp-nav-search-input::-webkit-search-cancel-button,
#sharedHeaderRoot .kalp-nav-search-input::-webkit-search-results-button,
#sharedHeaderRoot .kalp-nav-search-input::-webkit-search-results-decoration {
    -webkit-appearance: none;
    appearance: none;
    display: none;
}

#sharedHeaderRoot .kalp-nav-search-clear {
    position: absolute;
    right: 44px;
    top: 50%;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 999px;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #607282;
    background: #e8eef0;
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

#sharedHeaderRoot .kalp-nav-search-clear:hover {
    background: #d9e4e9;
    color: #1f2937;
}

#sharedHeaderRoot .kalp-nav-search-submit {
    position: absolute;
    right: 0;
    top: 0;
    width: 38px;
    height: 100%;
    border: none;
    border-radius: 0 999px 999px 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #2d6a4f 0%, #1b4332 100%);
    color: #ffffff;
    cursor: pointer;
    transition: filter 0.2s ease, transform 0.2s ease;
}

#sharedHeaderRoot .kalp-nav-search-submit svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

#sharedHeaderRoot .kalp-nav-search-submit:hover {
    filter: brightness(1.03);
}

#sharedHeaderRoot .kalp-nav-search-submit:active {
    transform: scale(0.98);
}

#sharedHeaderRoot .shared-nav-search-suggestions {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 100%;
    min-width: 0;
    background: #ffffff;
    border: 1px solid #dbe6df;
    border-radius: 12px;
    box-shadow: 0 14px 32px rgba(15, 23, 42, 0.16);
    max-height: 320px;
    overflow-y: auto;
    z-index: 1200;
}

#sharedHeaderRoot .shared-nav-search-suggestions[hidden] {
    display: none !important;
}

#sharedHeaderRoot .shared-search-suggestion {
    width: 100%;
    border: 0;
    border-bottom: 1px solid #edf2ef;
    background: #ffffff;
    color: #1f2937;
    text-align: left;
    padding: 10px 12px;
    display: grid;
    grid-template-columns: 16px 1fr;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    line-height: 1.3;
    cursor: pointer;
}

#sharedHeaderRoot .shared-search-suggestion:last-child {
    border-bottom: 0;
}

#sharedHeaderRoot .shared-search-suggestion:hover,
#sharedHeaderRoot .shared-search-suggestion.active {
    background: #f5f9f6;
}

#sharedHeaderRoot .shared-search-suggestion strong {
    color: #14532d;
    font-weight: 700;
}

#sharedHeaderRoot .shared-search-suggestion__icon {
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
}

#sharedHeaderRoot .shared-search-suggestion__icon svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

#sharedHeaderRoot .shared-search-suggestion__label {
    min-width: 0;
}

#sharedHeaderRoot .shared-search-empty {
    padding: 10px 12px;
    font-size: 13px;
    color: #64748b;
}

#sharedHeaderRoot .kalp-nav-search-clear:focus-visible,
#sharedHeaderRoot .kalp-nav-search-input:focus-visible {
    outline: none;
}

#sharedHeaderRoot .header-btn {
    position: relative;
    display: flex;
    flex-direction: row;
    /* Row for text only */
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    /* Matched to styles.css */
    padding: 0.5rem 1rem;
    /* Matched to styles.css (8px 16px) */
    border-radius: 10px;
    color: #374151;
    border: none;
    background: transparent;
    cursor: pointer;
    height: 44px;
    /* Consistent height */
    transition: background-color 0.2s ease, color 0.2s ease;
}

#sharedHeaderRoot .header-btn:hover {
    background: #f1f5f9;
    color: var(--kalp-header-primary);
}

#sharedHeaderRoot .header-btn span:not(.badge) {
    font-size: 0.95rem;
    /* Increased size */
    font-weight: 600;
    /* Bolder */
    color: #1f2937;
    /* Darker text */
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

#sharedHeaderRoot .header-btn:hover span:not(.badge) {
    color: var(--kalp-header-primary);
}

#sharedHeaderRoot .badge {
    position: absolute;
    top: 1px;
    right: 1px;
    min-width: 18px;
    height: 18px;
    border-radius: 999px;
    background: var(--kalp-header-primary);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

#sharedHeaderRoot .mobile-menu-toggle {
    display: none;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--kalp-header-border);
    background: #f8fafc;
    color: #334155;
    align-items: center;
    justify-content: center;
}

#sharedHeaderRoot .shared-nav-search-toggle {
    display: none;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--kalp-header-border);
    background: #f8fafc;
    color: #334155;
    align-items: center;
    justify-content: center;
}

#sharedHeaderRoot .shared-nav-search-toggle svg {
    width: 17px;
    height: 17px;
    fill: currentColor;
}

#sharedHeaderRoot .shared-nav-search-toggle:focus-visible,
#sharedHeaderRoot .mobile-menu-toggle:focus-visible {
    outline: 2px solid rgba(45, 106, 79, 0.32);
    outline-offset: 2px;
}

#sharedHeaderRoot .mobile-search {
    display: none;
    border-bottom: 1px solid var(--kalp-header-border);
    background: #fff;
    padding: 9px 0 12px;
}

#sharedHeaderRoot .mobile-search .search-box {
    display: flex;
}

#sharedHeaderRoot .shared-header--default .mobile-search[hidden] {
    display: none !important;
}

#sharedHeaderRoot .shared-header--default .mobile-search {
    display: none;
}

#sharedHeaderRoot .shared-header--default .mobile-search.active {
    display: block;
    animation: sharedSearchDropIn 0.2s ease;
}

#sharedHeaderRoot .shared-nav-no-results {
    margin: 12px auto 0;
    max-width: 420px;
    border-radius: 14px;
    border: 1px solid #dce7df;
    background: #f8fbf9;
    padding: 14px 16px;
    text-align: center;
    color: #4f5f56;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
}

#sharedHeaderRoot .shared-nav-no-results__title {
    font-weight: 700;
    color: #213129;
    margin-bottom: 2px;
}

#sharedHeaderRoot .shared-nav-no-results p {
    margin: 0;
    font-size: 13px;
}

@keyframes sharedSearchDropIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#sharedHeaderRoot .mobile-menu {
    position: fixed;
    inset: 0;
    z-index: 1800;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

#sharedHeaderRoot .mobile-menu.active {
    visibility: visible;
    opacity: 1;
}

#sharedHeaderRoot .mobile-menu-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
}

#sharedHeaderRoot .mobile-menu-panel {
    position: absolute;
    right: 0;
    top: 0;
    width: min(320px, 88vw);
    height: 100%;
    background: #fff;
    box-shadow: -10px 0 30px rgba(15, 23, 42, 0.2);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

#sharedHeaderRoot .mobile-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#sharedHeaderRoot .mobile-menu-header h3 {
    font-size: 18px;
}

#sharedHeaderRoot .mobile-menu-header button {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    border: 1px solid var(--kalp-header-border);
}

#sharedHeaderRoot .mobile-menu-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

#sharedHeaderRoot .mobile-menu-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border-radius: 10px;
    text-decoration: none;
    color: #1f2937;
    font-weight: 600;
}

#sharedHeaderRoot .mobile-menu-nav a:hover {
    background: #f8fafc;
}

@media (max-width: 1024px) {
    #sharedHeaderRoot .header-content {
        grid-template-columns: auto auto 1fr auto;
    }

    #sharedHeaderRoot .shared-nav-search-wrap {
        width: 220px;
        min-width: 180px;
    }

    #sharedHeaderRoot .header-actions.desktop-only {
        display: none;
    }

    #sharedHeaderRoot .shared-nav-search-toggle {
        display: inline-flex;
    }

    #sharedHeaderRoot .mobile-menu-toggle {
        display: inline-flex;
    }
}

@media (max-width: 768px) {
    #sharedHeaderRoot .header-topbar {
        display: none;
    }

    #sharedHeaderRoot .container {
        width: min(100%, calc(100% - 1.2rem));
    }

    #sharedHeaderRoot .header-content {
        grid-template-columns: auto 1fr auto;
        gap: 10px;
    }

    #sharedHeaderRoot .brand-logo-wrap {
        width: 52px;
        height: 52px;
        border-radius: 14px;
    }

    #sharedHeaderRoot .brand-name {
        font-size: 24px;
    }

    #sharedHeaderRoot .brand-subtitle {
        font-size: 9px;
        letter-spacing: 0.26em;
    }

    #sharedHeaderRoot .location-selector {
        display: none;
    }

    #sharedHeaderRoot .mobile-location-icon {
        display: inline-flex;
    }

    #sharedHeaderRoot .search-container {
        display: none;
    }

    #sharedHeaderRoot .mobile-search {
        display: block;
    }

    #sharedHeaderRoot .shared-nav-search-toggle {
        display: none !important;
    }

    #sharedHeaderRoot .shared-header--default .mobile-search,
    #sharedHeaderRoot .shared-header--default .mobile-search[hidden] {
        display: block !important;
    }

    #sharedHeaderRoot .shared-header--default .mobile-search.active {
        display: block;
    }

    #sharedHeaderRoot .kalp-nav-search-mobile {
        width: 100%;
        min-width: 0;
    }

    #sharedHeaderRoot .shared-nav-search-wrap {
        width: 100%;
        min-width: 0;
    }

    #sharedHeaderRoot .mobile-search .shared-nav-search-suggestions {
        position: static;
        margin-top: 8px;
        width: 100%;
        max-height: 50vh;
    }

    #sharedHeaderRoot .kalp-nav-search-input {
        font-size: 16px;
    }

    #sharedHeaderRoot .minimal-header-content {
        min-height: 62px;
        gap: 10px;
    }

    #sharedHeaderRoot .minimal-main-header .header-main {
        padding: 12px 0;
    }

    #sharedHeaderRoot .minimal-back-btn {
        padding: 9px 12px;
        border-radius: 10px;
        font-size: 13px;
    }

    #sharedHeaderRoot .minimal-back-btn span {
        display: none;
    }
}
