/**
 * Public styles for Voxel Intelligent Search
 */

/* Search container */
.vis-search-container {
    margin: 20px 0;
    position: relative;
}

/* Form styling */
.vis-search-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    max-width: 100%;
    position: relative;
}

.vis-search-form.inline {
    flex-direction: row;
}

.vis-search-form.block {
    flex-direction: column;
}

.vis-search-form input[type="text"] {
    display: block;
    padding: 10px 15px;
    padding-right: 45px;
    padding-left: 40px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.3s ease;
    position: relative;
}

.vis-search-form.inline input[type="text"] {
    margin-right: 0;
}

.vis-search-form.block input[type="text"] {
    margin-bottom: 0;
}

.vis-search-form button {
    display: inline-block;
    padding: 10px 20px;
    background-color: #3f51b5;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.vis-search-form.block button {
    width: 100%;
}

.vis-search-form button:hover {
    background-color: #303f9f;
}

/* Message styling */
.vis-search-message {
    margin-top: 15px;
    padding: 10px 15px;
    border-radius: 4px;
    display: none;
}

.vis-search-message.error {
    background-color: #fef7f7;
    border-left: 4px solid #f44336;
    color: #f44336;
}

.vis-search-message.success {
    background-color: #f0f8f0;
    border-left: 4px solid #4caf50;
    color: #4caf50;
}

/* Loading indicator */
.vis-search-loading {
    margin-top: 15px;
    padding: 10px;
    text-align: center;
    font-style: italic;
    color: #666;
}

/* Search Loader Styles */
.vis-search-loader {
    position: absolute;
    top: 100%; /* Position below the search input */
    left: 0;
    width: 100%;
    background: #fff;
    padding: 15px;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: none;
    z-index: 1000;
    margin-top: 5px; /* Add some space between input and loader */
}

.vis-search-loader.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.vis-loader-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: vis-spin 1s linear infinite;
    margin-bottom: 10px;
}

.vis-loader-text {
    color: #666;
    font-size: 14px;
    margin-top: 5px;
    text-align: center;
    margin-top: 0;
    font-size: 15px;
    color: #666;
    text-align: left;
    line-height: 1.3;
    font-weight: 400;
    display: inline-flex;
}

@keyframes vis-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Ensure the search form and input wrapper have relative positioning */
.vis-search-form,
.vis-input-wrapper {
    position: relative;
}

/* Ensure the autocomplete container appears above the loader */
.vis-autocomplete-container {
    z-index: 1001;
}

/* Autocomplete styles */
.vis-autocomplete-container {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
}

/* Media query for mobile view */
@media (max-width: 768px) {
    .vis-autocomplete-container {
        /* These properties will be overridden by the mobile CSS file */
        max-height: none;
        position: static;
        border: none;
        border-radius: 0;
        box-shadow: none;
    }
    
    /* Ensure location icon is always visible on mobile, regardless of container */
    .vis-location-Convericon,
    .vis-mobile-location-icon {
        display: block !important;
        z-index: 10;
    }
    
    /* Ensure perfect vertical alignment for all icons in mobile view */
    .vis-search-icon,
    .vis-search-form .vis-search-icon,
    .vis-location-icon,
    .vis-search-form .vis-location-icon,
    .vis-mobile-location-icon,
    .vis-input-wrapper .vis-search-icon,
    .vis-input-wrapper .vis-location-icon {
        position: absolute !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        margin: 0 !important;
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        height: auto !important;
        z-index: 10 !important;
    }
    
    /* Search icon left alignment */
    .vis-search-icon,
    .vis-search-form .vis-search-icon,
    .vis-input-wrapper .vis-search-icon {
        left: 15px !important;
    }
    
    /* Location icon right alignment */
    .vis-location-icon,
    .vis-search-form .vis-location-icon,
    .vis-mobile-location-icon,
    .vis-input-wrapper .vis-location-icon {
        right: 15px !important;
    }
}

.vis-autocomplete-list {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    max-height: 300px; /* This ensures a scrollable list in the dropdown */
}

/* For mobile, remove the max-height constraint from lists */
@media (max-width: 768px) {
    .vis-autocomplete-list {
        max-height: none;
        overflow: visible;
    }
}

.vis-autocomplete-item {
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s ease;
    display: flex;
    justify-content: flex-start;
    align-items: center;
}

.vis-autocomplete-item:last-child {
    border-bottom: none;
}

.vis-autocomplete-item:hover,
.vis-autocomplete-item.selected {
    background-color: #f5f5f5;
}

.vis-autocomplete-no-results {
    padding: 10px 15px;
    font-style: italic;
    color: #777;
}

.vis-suggestion-title {
    flex: 1;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

.vis-suggestion-distance {
    margin-left: 8px;
    font-size: 0.8em;
    color: #4caf50;
    white-space: nowrap;
}

/* Input wrapper for search form */
.vis-input-wrapper {
    position: relative;
    width: 100%;
}

.vis-search-form.inline .vis-input-wrapper {
    flex: 1;
}

.vis-search-form.block .vis-input-wrapper {
    margin-bottom: 10px;
    width: 100%;
}

.input-with-icon {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
}

.input-with-icon input[type="text"] {
    width: 100%;
    padding-right: 40px; /* Space for icon */
}

/* Location icon */
.vis-location-icon {
    cursor: pointer;
    transition: all 0.3s ease;
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    padding: 5px;
    font-size: 16px;
    color: #888; /* Default inactive color */
}

/* Search icon */
.vis-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    color: #777;
    pointer-events: none;
    z-index: 1;
}

/* Standard search form */
.vis-search-form .vis-search-icon {
    left: 15px;
}

/* Location icon states */
.vis-location-icon.requesting {
    color: #FFA000 !important; /* Orange for requesting state - use !important to override inline styles */
    animation: vis-pulse 1.5s infinite;
}

.vis-location-icon.active {
    color: #4CAF50 !important; /* Green for active state - use !important to override inline styles */
}

.vis-location-icon.error {
    color: #F44336 !important; /* Red for error state - use !important to override inline styles */
}

/* Add toggle indication to active location icon */
.vis-location-icon.active:hover {
    color: #3a9b3f !important; /* Slightly darker green on hover */
    transform: translateY(-50%) scale(1.1); /* Slightly enlarge on hover */
}

/* Add hover effect for inactive state */
.vis-location-icon:not(.active):not(.requesting):not(.error):hover {
    color: #555 !important; /* Darker gray on hover */
    transform: translateY(-50%) scale(1.1); /* Slightly enlarge on hover */
}

/* Pulse animation for requesting state */
@keyframes vis-pulse {
    0% { opacity: 1; }
    50% { opacity: 0.4; }
    100% { opacity: 1; }
}

@media (max-width: 768px) {
    .vis-search-form.inline {
        flex-direction: column;
    }
    
    .vis-search-form.inline input[type="text"] {
        margin-right: 0;
        width: 100%;
    }
    
    .vis-search-form.inline button {
        width: 100%;
    }
    
    .vis-search-form.block .vis-location-icon {
        top: calc(50% - 5px);
    }
}

/* Debug scoring indicators */
.vis-debug-scores {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 5px;
    font-size: 11px;
    color: #666;
    border-top: 1px solid #f0f0f0;
    padding-top: 5px;
}

.vis-debug-scores .vis-score {
    padding: 1px 4px;
    background: #f0f0f0;
    border-radius: 3px;
}

.vis-suggestion-with-debug {
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* Add more space to items with debug scores */
.vis-autocomplete-item:has(.vis-suggestion-with-debug) {
    padding-bottom: 5px;
}

/* Show distance unit only for active location */
.vis-location-icon.active ~ .vis-autocomplete-container .vis-suggestion-distance {
    display: inline-block;
}

/* Thumbnail styling */
.vis-item-thumbnail {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 4px;
    overflow: hidden;
    margin-right: 12px;
    background-color: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.vis-item-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.vis-item-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;
    min-width: 0;
}

.vis-item-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 2px;
}

.vis-item-title {
    font-weight: 500;
    color: #222;
    font-size: 15px;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.vis-item-distance-badge {
    display: flex;
    align-items: center;
    background-color: #e5e7eb;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    color: #6b7280;
    white-space: nowrap;
    font-weight: 500;
    margin-left: 8px;
    max-height: 24px;
}

.vis-item-distance-badge i {
    font-size: 10px;
    margin-right: 4px;
}

.vis-item-distance {
    font-size: 12px;
    color: #6b7280;
    margin-left: 8px;
    display: flex;
    align-items: center;
    white-space: nowrap;
}

.vis-item-distance i {
    font-size: 12px;
    margin-right: 4px;
    opacity: 0.8;
}

.vis-location-icon.active ~ .vis-autocomplete-container .vis-item-distance {
    display: flex;
}

.vis-item-type {
    display: inline-block;
    font-size: 11px;
    padding: 1px 6px;
    background: #f0f0f0;
    color: #666;
    border-radius: 3px;
    margin-right: 5px;
    text-transform: uppercase;
}

.vis-item-additional-data {
    font-size: 12px;
    color: #666;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
    line-height: 1.4;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.vis-autocomplete-item:hover .vis-item-additional-data {
    opacity: 1;
}

.vis-item-debug,
.vis-item-chunk-text {
    font-size: 11px;
    color: #777;
    margin-top: 4px;
    font-style: italic;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.vis-autocomplete-item:has(.vis-item-additional-data) {
    padding-top: 8px;
    padding-bottom: 8px;
}

/* Removing location notification styles */
@keyframes vis-fade-in {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Search History Styles */
.vis-search-history {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-top: 5px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    max-height: 350px;
    overflow-y: auto;
    padding: 10px 0;
    display: none;
}

/* Header for recent and trending sections */
.vis-trending-header,
.vis-recent-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 15px;
    font-weight: bold;
    color: #555;
    font-size: 14px;
    margin-bottom: 5px;
}

/* Clear history button */
.vis-clear-history {
    background: none;
    border: none;
    color: #3f51b5;
    font-size: 12px;
    cursor: pointer;
    padding: 3px 8px;
    border-radius: 3px;
    transition: background-color 0.2s;
}

.vis-clear-history:hover {
    background-color: rgba(63, 81, 181, 0.1);
}

/* Lists for trending and recent searches */
.vis-trending-list,
.vis-recent-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* List items */
.vis-trending-list li,
.vis-recent-list li {
    padding: 16px 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: background-color 0.2s;
}

.vis-trending-list li:hover,
.vis-recent-list li:hover {
    background-color: #f5f5f5;
}

/* Icons in trending and recent items */
.vis-trending-list li i,
.vis-recent-list li i,
.vis-trending-list li .vis-trending-icon {
    margin-right: 10px;
    color: #6b7280;
    font-size: 14px;
    width: 16px;
    text-align: center;
    flex-shrink: 0;
}

.vis-trending-icon svg {
    width: 14px;
    height: 14px;
    stroke: #6b7280;
    fill: none;
}

/* Trending icons (fire) */
.vis-trending-list li .vis-trending-icon svg {
    stroke: #f59e0b; /* Orange color for trending items */
}

/* Pinned icons (thumbtack) */
.vis-trending-list li[data-term] .vis-trending-icon svg {
    stroke: #3f51b5; /* Blue color for pinned items */
}

/* History icons (clock) */
.vis-recent-list li i.fa-history {
    color: #666;
}

/* Recent search item text */
.vis-history-item {
    flex: 1;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #333;
}

/* Delete history item button */
.vis-delete-history-item {
    margin-left: auto;
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, color 0.2s;
    padding: 5px;
    font-size: 16px;
}

.vis-recent-list li:hover .vis-delete-history-item {
    opacity: 1;
}

/* Empty search history state */
.vis-history-list:empty::after {
    content: 'No recent searches';
    display: block;
    padding: 15px;
    text-align: center;
    font-style: italic;
    color: #888;
}

/* Location Display Widget Styles */
.vis-location-display {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    border-radius: 4px;
    position: relative;
    transition: all 0.3s ease;
}

.vis-location-icon-wrapper {
    margin-right: 8px;
    display: flex;
    align-items: center;
    font-size: 16px; /* Set base font size for the icon */
    line-height: 1;
}

/* Ensure SVG icons from Elementor display properly */
.vis-location-icon-wrapper i,
.vis-location-icon-wrapper svg,
.vis-location-icon-wrapper .elementor-icon,
.vis-location-display-icon {
    width: 1em;
    height: 1em;
    position: relative;
    display: inline-block;
    font-size: inherit;
    color: #888; /* Default color */
    vertical-align: middle;
    fill: currentColor; /* For SVG icons */
    transition: all 0.3s ease;
}

/* Ensure specific icon styling */
.elementor-icon.vis-location-display-icon,
i.vis-location-display-icon,
.elementor-icon i {
    font-size: inherit;
    color: inherit;
}

.vis-location-text {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
}

.vis-location-city {
    margin-left: 3px;
    font-weight: 500;
    color: #4CAF50;
    transition: color 0.3s ease;
}

.vis-location-fallback {
    color: #888;
    font-style: italic;
}

/* Location status classes - updated to target all possible icon formats */
.vis-location-display.has-location .vis-location-icon-wrapper i,
.vis-location-display.has-location .vis-location-icon-wrapper svg,
.vis-location-display.has-location .vis-location-icon-wrapper .elementor-icon,
.vis-location-display.has-location .vis-location-icon-wrapper .elementor-icon i,
.vis-location-display.has-location i.vis-location-display-icon,
.vis-location-display.has-location svg.vis-location-display-icon {
    color: #4CAF50 !important;
    fill: currentColor !important; /* For SVG icons */
}

.vis-location-display.location-requesting .vis-location-icon-wrapper i,
.vis-location-display.location-requesting .vis-location-icon-wrapper svg,
.vis-location-display.location-requesting .vis-location-icon-wrapper .elementor-icon,
.vis-location-display.location-requesting .vis-location-icon-wrapper .elementor-icon i,
.vis-location-display.location-requesting i.vis-location-display-icon,
.vis-location-display.location-requesting svg.vis-location-display-icon {
    color: #FFA000 !important;
    fill: currentColor !important; /* For SVG icons */
    animation: vis-pulse 1.5s infinite;
}

.vis-location-display.location-error .vis-location-icon-wrapper i,
.vis-location-display.location-error .vis-location-icon-wrapper svg,
.vis-location-display.location-error .vis-location-icon-wrapper .elementor-icon,
.vis-location-display.location-error .vis-location-icon-wrapper .elementor-icon i,
.vis-location-display.location-error i.vis-location-display-icon,
.vis-location-display.location-error svg.vis-location-display-icon {
    color: #F44336 !important;
    fill: currentColor !important; /* For SVG icons */
}

.vis-location-display.location-requesting .vis-location-fallback {
    color: #FFA000;
    animation: vis-text-pulse 1.5s infinite;
}

.vis-location-display.location-error .vis-location-fallback {
    color: #F44336;
}

/* Removing location notification styles */
@keyframes vis-fade-in {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Special styling for denied permission state */
.vis-detect-location-btn.permission-denied {
    background-color: #fff0f0;
    border-color: #ffcccc;
    color: #e53935;
}

.vis-detect-location-btn.permission-denied:hover {
    background-color: #ffe0e0;
    border-color: #ffb8b8;
}

/* Add hover effect for location display widget */
.vis-location-display {
    transition: all 0.2s ease;
}

/* Trending searches section styles */
.vis-autocomplete-section-heading {
    padding: 8px 15px;
    font-size: 12px;
    font-weight: 500;
    color: #777;
    background-color: #f9f9f9;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #eee;
}

.vis-trending-item {
    cursor: pointer;
}

.vis-trending-item .vis-item-title {
    font-weight: normal;
    display: flex;
    align-items: center;
}

.vis-trending-icon {
    margin-right: 8px;
    display: inline-block;
    width: 14px;
    height: 14px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23ff6b00'%3E%3Cpath d='M12 23a7.5 7.5 0 0 1-5.138-12.963C8.204 8.774 8.507 5.5 8.5 4.75c0 0 2.909 1.178 4.209 5.279l-2.52.86 2.996 3.602c-1.407.832-2.185 2.265-2.185 3.909 0 1.125.41 2.197 1.154 3.035.744.837 1.756 1.365 2.846 1.485V23z'/%3E%3Cpath d='M14.254 21.472c-.761-.857-1.126-1.995-1.01-3.144.117-1.15.728-2.2 1.698-2.918l.589-.437-1.563-1.874 1.136-.387c.635-.215 1.17-.674 1.523-1.301a4.45 4.45 0 0 0 .458-3.52L18.944 5.6a11.28 11.28 0 0 1-2.336 7.343c-.407.523-.633 1.188-.633 1.878 0 1.014.384 1.937 1.073 2.599.69.662 1.579.988 2.55.988-.324 1.032-.92 1.898-1.698 2.498-.778.6-1.698.917-2.646.917v-.371z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
}

.vis-autocomplete-separator {
    height: 1px;
    background-color: #eee;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* VVS Autocomplete History Styling */
.vis-search-history .vis-trending-list,
.vis-search-history .vis-recent-list {
    list-style-type: none; /* Remove bullets */
    padding-left: 0;       /* Remove default padding */
    margin-top: 0;         /* Reset top margin */
    margin-bottom: 0;      /* Reset bottom margin */
}

/* Adjust margins for new headers if necessary */
.vis-search-history .vis-trending-header,
.vis-search-history .vis-recent-header {
    margin-bottom: 5px; /* Add a small gap below headers before lists */
    /* If there was a top margin causing issues, reset it: margin-top: 0; */
}

/* Ensure the main history container itself doesn't have odd default margins if it's a new top-level element being shown/hidden */
.vis-search-history {
    margin-top: 0;
    margin-bottom: 0;
}

/* Loader row for horizontal layout */
.vis-loader-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    min-height: 40px;
}

.vis-loader-spinner {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0;
    margin-right: 14px;
    vertical-align: middle;
}

.vis-dropdown-loader {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 12px;
}