/**
 * Common Search Bar Styles
 * @package     Listing Directory
 * @copyright   Copyright (C) 2025 Vision Technology Consulting. All rights reserved.
 */

/* Remove top padding from main body when search bar is present */
.t4-main-body {
    padding-top: 0 !important;
}

.com-listingdirectory.listings-view,
.com-listingdirectory.listing-detail-view {
    padding-top: 0 !important;
    margin-top: 0 !important;
}

/* Target parent containers */
body .t4-main-body,
body .t4-content {
    padding-top: 0 !important;
}

@media (min-width: 768px) {
    .t4-main-body {
        padding-top: 0 !important;
    }
}

/* Search Section at Top - Full Width */
.search-section-wrapper {
    display: flex;
    max-width: 100%;
    padding: var(--spacing-x, 12px) var(--spacing-sm, 16px);
    flex-direction: column;
    align-items: center;
    gap: 10px;
    align-self: stretch;
}

.search-section-container {
    width: 100%;
    max-width: 100%;
}

.main-content-wrapper {
    display: flex;
    width: 100%;
    max-width: 100%;
    padding: var(--spacing-sm, 16px) 0 var(--spacing-2xl, 68px) 0;
    justify-content: space-between;
    align-items: flex-start;
}

/* Match Bootstrap/T4 container widths at different breakpoints */
@media (min-width: 576px) {
    .search-section-container {
        max-width: 540px;
    }
}

@media (min-width: 768px) {
    .search-section-container {
        max-width: 720px;
    }
}

@media (min-width: 992px) {
    .search-section-container {
        max-width: 960px;
    }
}

@media (min-width: 1200px) {
    .search-section-container {
        max-width: 1140px;
    }
}

@media (min-width: 1400px) {
    .search-section-container {
        max-width: 1320px;
    }
}

.search-box-wrapper {
    position: relative;
    border-radius: var(--border-radius-round, 999px);
    border: 1px solid var(--border-tertiary, #D1D5DB);
    background: #FFF;
    box-shadow: 0 4px 20px 0 #FAFAFA;
    display: flex;
    height: 52px;
    padding: var(--spacing-2xs, 6px) var(--spacing-2xs, 6px) var(--spacing-2xs, 6px) var(--spacing-sm, 16px);
    align-items: center;
    gap: var(--spacing-x, 12px);
    align-self: stretch;
    z-index: 1000; /* Ensure search box is above content */
}

.search-box-wrapper .search-input {
    display: block; /* Input should be block or inline-block */
    width: 100%;    /* Take full width of flex item */
    height: 36px;
    padding: 0;     /* Remove default padding if alignment is handled by parent gap */
    flex: 1 1 auto; /* Grow and shrink */
    font-family: var(--font-family-inter, "Inter");
    font-size: 14px;
    color: #1E2939;
    background: transparent;
    border: none;
    outline: none;
    min-width: 0;   /* prevent overflow */
}

.search-box-wrapper .search-input::placeholder {
    color: var(--text-body-tertiary, #9CA3AF);
    border-radius: var(--radius-none, 0);
    display: flex;
    align-items: center;
    gap: var(--spacing-xs, 8px);
    flex: 1 0 0;
}

.search-box-wrapper .search-input:focus {
    border: none;
    box-shadow: none;
    outline: none;
}

.search-box-wrapper .btn-search {
    position: relative; /* Changed from absolute */
    right: auto;
    top: auto;
    transform: none;
    display: flex;
    height: 36px;
    min-width: 100px;
    padding: 10px var(--sizing-component-lg, 20px) 10px var(--sizing-component-md, 16px);
    justify-content: center;
    align-items: center;
    gap: var(--spacing-xs, 8px);
    border-radius: var(--border-radius-round, 999px);
    background: var(--surface-primary-on-light, #BD0F16);
    border: none;
    color: #FFFFFF;
    font-family: var(--font-family-inter, "Inter");
    font-size: 14px;
    font-weight: 600;
    line-height: 20px;
    cursor: pointer;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
    white-space: nowrap;
    box-shadow: 0 2px 6px 0 rgba(45, 35, 61, 0.15);
    --t4-btn-padding-x: 0 !important;
    --t4-btn-padding-y: 0 !important;
}

.search-box-wrapper .btn-search:hover {
    background: #A60E14;
    box-shadow: 0 4px 8px 0 rgba(45, 35, 61, 0.2);
}

.search-box-wrapper .btn-search:active {
    background: #8F0C11;
    box-shadow: 0 1px 3px 0 rgba(45, 35, 61, 0.15);
}

.search-box-wrapper .btn-search:focus {
    outline: none;
    box-shadow: none;
}

.search-box-wrapper .btn-search svg {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}

.btn-search .search-icon {
    width: 16px;
    height: 16px;
    display: block;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .search-section-wrapper {
        padding: 15px;
        margin-bottom: 20px;
    }

    .search-box-wrapper {
        max-width: 100%;
    }

    .search-box-wrapper .search-input {
        height: 44px;
        font-size: 13px;
    }

    .search-box-wrapper .btn-search {
        height: 36px;
        padding: 8px 16px;
        font-size: 13px;
    }

    .search-box-wrapper .btn-search svg {
        width: 16px;
        height: 16px;
    }
}

@media (max-width: 480px) {
    .search-box-wrapper .btn-search {
        padding: 8px 12px;
    }

    .search-box-wrapper .btn-search span {
        display: none;
    }

    .search-box-wrapper .btn-search svg {
        width: 18px;
        height: 18px;
    }
}

/* Autocomplete Dropdown - LinkedIn Style */
.search-autocomplete-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #FFFFFF;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 4px 8px rgba(0, 0, 0, 0.08);
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 9999;
    display: none;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    min-width: 100%;
    width: auto;
}

.search-autocomplete-dropdown.show {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.search-autocomplete-dropdown::-webkit-scrollbar {
    width: 6px;
}

.search-autocomplete-dropdown::-webkit-scrollbar-track {
    background: transparent;
}

.search-autocomplete-dropdown::-webkit-scrollbar-thumb {
    background: #D1D5DB;
    border-radius: 3px;
}

.search-autocomplete-dropdown::-webkit-scrollbar-thumb:hover {
    background: #9CA3AF;
}

.autocomplete-item {
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid #F3F4F6;
    transition: background-color 0.15s ease;
    text-decoration: none;
    color: inherit;
    position: relative;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item:focus {
    background-color: #F3F4F6;
    text-decoration: none;
    outline: none;
}

.autocomplete-item-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6B7280;
    background: #F9FAFB;
    border-radius: 6px;
    padding: 4px;
    overflow: hidden;
    position: relative;
}

.autocomplete-item:hover .autocomplete-item-icon {
    background: #E5E7EB;
    color: #4847EB;
}

/* Product image styles */
.autocomplete-item-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
    display: block;
}

.autocomplete-item-icon-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.autocomplete-item-icon-fallback svg {
    width: 16px;
    height: 16px;
}

.autocomplete-item-content {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.autocomplete-item-text {
    font-family: var(--font-family-inter, "Inter");
    font-size: 14px;
    font-weight: 500;
    line-height: 20px;
    color: #1E2939;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.autocomplete-item-text .autocomplete-highlight {
    background-color: transparent;
    color: inherit;
    font-weight: 700;
}

.autocomplete-item-category {
    font-family: var(--font-family-inter, "Inter");
    font-size: 12px;
    font-weight: 500;
    line-height: 16px;
    color: #6B7280;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.autocomplete-item[data-type="product"] .autocomplete-item-category {
    color: #4847EB;
}

.autocomplete-item[data-type="category"] .autocomplete-item-text {
    color: #059669;
}

.autocomplete-item[data-type="company"] .autocomplete-item-text {
    color: #DC2626;
}

/* Section headers and dividers */
.autocomplete-section-header {
    padding: 8px 16px 6px 16px;
    font-family: var(--font-family-inter, "Inter");
    font-size: 11px;
    font-weight: 700;
    line-height: 16px;
    color: #6B7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #F9FAFB;
    border-bottom: 1px solid #F3F4F6;
}

.autocomplete-divider {
    height: 1px;
    background: #E5E7EB;
    margin: 4px 0;
}

.autocomplete-item-meta {
    flex-shrink: 0;
    font-family: var(--font-family-inter, "Inter");
    font-size: 12px;
    font-weight: 400;
    line-height: 16px;
    color: #9CA3AF;
}

.autocomplete-no-results {
    padding: 20px 16px;
    text-align: center;
    color: #6B7280;
    font-family: var(--font-family-inter, "Inter");
    font-size: 14px;
    font-weight: 400;
    line-height: 20px;
}

.autocomplete-loading {
    padding: 20px 16px;
    text-align: center;
    color: #6B7280;
    font-family: var(--font-family-inter, "Inter");
    font-size: 14px;
    font-weight: 400;
    line-height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.autocomplete-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #E5E7EB;
    border-top-color: #4847EB;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive adjustments for autocomplete */
@media (max-width: 768px) {
    .search-autocomplete-dropdown {
        max-height: 300px;
    }

    .autocomplete-item {
        padding: 10px 14px;
    }

    .autocomplete-item-text {
        font-size: 13px;
    }

    .autocomplete-item-category,
    .autocomplete-item-meta {
        font-size: 11px;
    }
}


/* Breadcrumbs Styles */
.listing-breadcrumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px; /* Space between breadcrumb and search box */
    font-family: var(--font-family-inter, "Inter", sans-serif);
    font-size: 14px;
    color: var(--body-primary);
    flex-wrap: wrap;
    width: 100%;
}

.listing-breadcrumb-item:first-child {
    font-weight: bold;
}
.listing-breadcrumb-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--body-primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.listing-breadcrumb-item:hover {
    color: #111827; /* Gray-900 */
    text-decoration: none;
}

.listing-breadcrumb-item.active {
    pointer-events: none;
}

.listing-breadcrumb-separator {
    display: flex;
    align-items: center;
    color: #9CA3AF; /* Gray-400 */
}

.listing-breadcrumb-separator svg {
    width: 8px;
    height: 12px;
}
