/* Unified Search Styles */
.search-container {
    position: relative;
}

/* Search icon inside input */
.search-input-icon {
    background: transparent;
    border: 1px solid #dee2e6;
    border-right: none;
    color: #6c757d;
    font-size: 1rem;
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-input-icon i {
    font-size: 1rem;
}

/* Dark theme for header search bar - base styles (overridden by input-group below) */

.nav-search-bar .input-group .form-control {
    border-left: none;
    border-radius: 0;
}

.nav-search-bar .input-group .form-control:focus {
    border-color: var(--tyre-reviews-blue);
    box-shadow: none;
}

.nav-search-bar .input-group:focus-within .search-input-icon {
    border-color: var(--tyre-reviews-blue);
    color: var(--tyre-reviews-blue);
}

/* Hero search variant */
.universal-search-hero .search-input-icon {
    background: #fff;
    border-color: #dee2e6;
    font-size: 1.1rem;
    padding: 0.75rem 1rem;
}

/* Nav search bar - full input group styling */
.nav-search-bar .input-group {
    background: #2a2f35;
    border: 2px solid transparent;
    border-radius: 8px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.nav-search-bar .input-group:focus-within {
    border-color: var(--tyre-reviews-blue);
    box-shadow: 0 0 0 3px rgba(13, 177, 231, 0.2);
}

.nav-search-bar .input-group .search-input-icon {
    background: transparent;
    border: none;
    padding: 0 0.5rem 0 0.875rem;
    color: #9fb3c8;
}

.nav-search-bar .input-group .search-input-icon i.fa-search {
    font-size: 1.5rem !important;
}

.nav-search-bar .input-group .form-control.unified-search {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1rem;
    padding: 0;
}

.nav-search-bar .input-group .form-control.unified-search:focus {
    box-shadow: none;
    outline: none;
}

.nav-search-bar .input-group .form-control.unified-search::placeholder {
    color: #8a939e;
}

.nav-search-bar .input-group .btn-primary {
    background: var(--tyre-reviews-blue);
    border: none;
    border-radius: 0 6px 6px 0;
    font-weight: 600;
    padding: 0 1.25rem;
}

#unified-search {
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

#unified-search:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

#unified-search.size-search {
    border-left: 4px solid #28a745;
}

#unified-search.text-search {
    border-left: 4px solid #ffc107;
}

/* Search button inside input */
.search-container .btn-link {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    transition: color 0.3s ease;
}

.search-container .btn-link:hover {
    color: #0d6efd !important;
}

.search-container .btn-link:focus {
    box-shadow: none;
}

#search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1050;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    background-color: #fff;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    margin-top: 2px;
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;

    /* Smooth scrolling */
    scroll-behavior: smooth;

    /* Better scrollbar styling for webkit browsers */
    scrollbar-width: thin;
    scrollbar-color: rgba(13, 110, 253, 0.5) transparent;
}

/* Webkit scrollbar styling */
#search-suggestions::-webkit-scrollbar {
    width: 8px;
}

#search-suggestions::-webkit-scrollbar-track {
    background: transparent;
}

#search-suggestions::-webkit-scrollbar-thumb {
    background-color: rgba(13, 110, 253, 0.3);
    border-radius: 4px;
}

#search-suggestions::-webkit-scrollbar-thumb:hover {
    background-color: rgba(13, 110, 253, 0.5);
}

#search-suggestions .dropdown-item {
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: 0.65rem 1rem;
    border: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    background: none;
    text-align: left;
    color: #212529;
    text-decoration: none;
    border-radius: 0;
    transition: background-color 0.15s ease-in-out;
    gap: 0.25rem;
    min-height: fit-content;

    /* Better text handling for long names */
    word-break: break-word;
    white-space: normal;
    line-height: 1.5;
    overflow: visible;
}

#search-suggestions .dropdown-item:last-child {
    border-bottom: none;
}

#search-suggestions .dropdown-item .item-title {
    display: flex;
    align-items: flex-start;
    word-break: break-word;
    line-height: 1.5;
}

#search-suggestions .dropdown-item .item-title i {
    flex-shrink: 0;
    margin-top: 0.1rem;
}

#search-suggestions .dropdown-item .item-info {
    display: block;
    font-size: 0.875em;
    color: #6c757d;
    padding-left: 24px; /* Align with text after icon */
    line-height: 1.3;
}

#search-suggestions .dropdown-item:hover,
#search-suggestions .dropdown-item.active {
    background-color: #f8f9fa;
    color: #1e2125;
}

#search-suggestions .dropdown-item:focus {
    outline: 2px solid #0d6efd;
    outline-offset: -2px;
}

/* Legacy support - can be removed if not needed */
#search-suggestions .dropdown-item small {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.875em;
    color: #6c757d;
}

/* Visual indicator that dropdown is scrollable */
#search-suggestions::after {
    content: '';
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    height: 20px;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.95));
    pointer-events: none;
    display: none;
}

#search-suggestions.has-scroll::after {
    display: block;
}

/* Header dropdown theme */
#main-nav #search-suggestions {
    background-color: #1f2428;
    border-color: rgba(255, 255, 255, 0.12);
    color: #f8f9fa;
}

#main-nav #search-suggestions .dropdown-item {
    color: #e9ecef;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

#main-nav #search-suggestions .dropdown-item .item-info {
    color: #a6b2bf !important;
}

#main-nav #search-suggestions .dropdown-item:hover,
#main-nav #search-suggestions .dropdown-item.active {
    background-color: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

#main-nav #search-suggestions .dropdown-item:focus {
    outline: 2px solid #5aa1e3;
}

#main-nav #search-suggestions::after {
    background: linear-gradient(to bottom, rgba(31, 36, 40, 0), rgba(31, 36, 40, 0.95));
}

/* Search in navbar dropdown */
#main-nav .nav-search-dropdown .search-container {
    max-width: none;
    margin: 0;
}

/* Force search input to use full width */
#unified-search {
    width: 100% !important;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    /* Fix search box centering on mobile */
    .navbar .search-container {
        margin-left: 0;
        margin-right: 0;
    }

    #search-suggestions {
        font-size: 0.9rem;
        max-height: 300px;
        /* Ensure it doesn't overflow viewport on mobile */
        max-width: 100vw;
        left: -15px;
        right: -15px;
    }

    #main-nav #search-suggestions {
        left: 0;
        right: 0;
        max-width: none;
    }

    .search-container .btn-link {
        font-size: 0.8rem;
    }

    /* Reduce padding on mobile for more visible items */
    #search-suggestions .dropdown-item {
        padding: 0.5rem 0.75rem;
        gap: 0.15rem;
    }

    #search-suggestions .dropdown-item .item-info {
        font-size: 0.8em;
        padding-left: 20px;
    }

    #search-suggestions .dropdown-item .item-title i {
        width: 14px;
        margin-right: 6px;
    }
}

/* Ensure dropdown stays within viewport bounds */
@media (max-width: 576px) {
    #search-suggestions {
        max-height: 250px;
        border-radius: 0.25rem;
    }
}

/* Search type indicators */
.search-helper-text {
    position: absolute;
    top: -1.5rem;
    left: 0;
    font-size: 0.75rem;
    color: #6c757d;
    background: rgba(255, 255, 255, 0.9);
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#unified-search:focus + .search-helper-text,
#unified-search.size-search + .search-helper-text,
#unified-search.text-search + .search-helper-text {
    opacity: 1;
}

/* Focus trap for accessibility */
.search-container:focus-within {
    position: relative;
    z-index: 1;
}

/* Custom tooltip styling */
.tooltip {
    z-index: 1070 !important;
}

.tooltip .tooltip-inner {
    max-width: 300px;
    background-color: #2c3e50;
    color: white;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.875rem;
    line-height: 1.4;
}

/* Tooltip arrow colors for different placements */
.tooltip.bs-tooltip-top .tooltip-arrow::before {
    border-top-color: #2c3e50 !important;
}

.tooltip.bs-tooltip-bottom .tooltip-arrow::before {
    border-bottom-color: #2c3e50 !important;
}

.tooltip.bs-tooltip-right .tooltip-arrow::before {
    border-right-color: #2c3e50 !important;
}

.tooltip.bs-tooltip-left .tooltip-arrow::before {
    border-left-color: #2c3e50 !important;
}

/* Keyboard shortcut hint */
.search-keyboard-hint {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    color: #adb5bd;
    background: #f8f9fa;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    border: 1px solid #dee2e6;
}

#unified-search:focus + .search-keyboard-hint {
    display: none;
}

/* Error state for invalid sizes */
#unified-search.is-invalid {
    border-color: #dc3545;
}

#unified-search.is-invalid:focus {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

/* Success state for valid sizes */
#unified-search.is-valid {
    border-color: #28a745;
}

#unified-search.is-valid:focus {
    border-color: #28a745;
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
}

/* Search Results Tab Enhancements */
/* Tabs with results get highlighted styling */
.nav-tabs .nav-link.has-results {
    font-weight: 600;
    color: #0d6efd;
    position: relative;
}

.nav-tabs .nav-link.has-results:not(.active) {
    background-color: rgba(13, 110, 253, 0.05);
    border-bottom: 3px solid transparent;
}

.nav-tabs .nav-link.has-results:hover {
    background-color: rgba(13, 110, 253, 0.1);
}

/* Active tab with results gets even more emphasis */
.nav-tabs .nav-link.has-results.active {
    color: #0d6efd;
    background-color: #fff;
    border-color: #dee2e6 #dee2e6 #fff;
    border-bottom: 3px solid #0d6efd;
}

/* Empty tabs are muted */
.nav-tabs .nav-link:not(.has-results) {
    color: #6c757d;
    opacity: 0.6;
}

.nav-tabs .nav-link:not(.has-results):hover {
    opacity: 0.8;
}

/* Badge styling for tabs with results */
.nav-tabs .nav-link .badge.bg-primary {
    background-color: #0d6efd !important;
    font-weight: 700;
    padding: 0.35em 0.6em;
    font-size: 0.85em;
    box-shadow: 0 2px 4px rgba(13, 110, 253, 0.3);
}

/* Badge styling for empty tabs */
.nav-tabs .nav-link .badge.bg-secondary {
    background-color: #adb5bd !important;
    opacity: 0.6;
}

/* Pulse animation for tabs with results (subtle) */
@keyframes tabPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(13, 110, 253, 0.4);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(13, 110, 253, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(13, 110, 253, 0);
    }
}

/* Apply subtle pulse to non-active tabs with results on page load */
.nav-tabs .nav-link.has-results:not(.active) .badge.bg-primary {
    animation: tabPulse 2s ease-out 1;
}

/* Icon styling for better visibility */
.nav-tabs .nav-link.has-results i {
    color: #0d6efd;
    margin-right: 0.35rem;
}

.nav-tabs .nav-link:not(.has-results) i {
    color: #adb5bd;
}

/* Results indicator - small dot for visual emphasis */
.nav-tabs .nav-link.has-results::before {
    content: '';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background-color: #0d6efd;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.2);
    display: none; /* Hidden by default, can be enabled */
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .nav-tabs .nav-link {
        font-size: 0.85rem;
        padding: 0.5rem 0.75rem;
    }

    .nav-tabs .nav-link .badge {
        font-size: 0.75em;
        padding: 0.25em 0.5em;
    }
}
