/* Voice Search Styles for OpenCart 3 with SmartSearch - Universal Theme Support */

.bus-voice-search-btn {
    position: absolute !important;
    right: 50px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    cursor: pointer !important;
    z-index: 1000 !important;
    padding: 8px !important;
    border-radius: 4px !important;
    transition: all 0.3s ease !important;
    background: transparent !important;
    color: #666 !important;
    font-size: 16px !important;
    line-height: 1 !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    display: inline-block !important;
    width: 24px !important;
    height: 24px !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.bus-voice-search-btn:hover {
    color: #333 !important;
    background: rgba(0,0,0,0.05) !important;
}

.bus-voice-search-btn.recording {
    color: #dc3545 !important;
    animation: pulse 1.5s infinite !important;
}

.bus-voice-search-btn.error {
    color: #dc3545 !important;
}

@keyframes pulse {
    0% {
        opacity: 1;
        transform: translateY(-50%) scale(1);
    }
    50% {
        opacity: 0.7;
        transform: translateY(-50%) scale(1.1);
    }
    100% {
        opacity: 1;
        transform: translateY(-50%) scale(1);
    }
}

/* Ensure search container has position: relative */
#search,
#search .search,
.search {
    position: relative !important;
}

/* Voice Search Icon using SVG */
.bus-voice-search-btn i {
    display: block !important;
    width: 16px !important;
    height: 16px !important;
    background-image: url('data:image/svg+xml;charset=utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2a3 3 0 0 1 3 3v6a3 3 0 0 1-6 0V5a3 3 0 0 1 3-3z"/><path d="M19 10v1a7 7 0 0 1-14 0v-1a1 1 0 0 1 2 0v1a5 5 0 0 0 10 0v-1a1 1 0 0 1 2 0z"/><path d="M12 18.93a1 1 0 0 1-1-1V16a1 1 0 0 1 2 0v1.93a1 1 0 0 1-1 1z"/><path d="M9 20h6a1 1 0 0 1 0 2H9a1 1 0 0 1 0-2z"/></svg>') !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    background-size: 16px 16px !important;
    font-size: 0 !important;
}

/* Recording state */
.bus-voice-search-btn.recording i {
    background-image: url('data:image/svg+xml;charset=utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="red"><circle cx="12" cy="12" r="8"/></svg>') !important;
}

/* Error state */
.bus-voice-search-btn.error i {
    background-image: url('data:image/svg+xml;charset=utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2a3 3 0 0 1 3 3v6a3 3 0 0 1-6 0V5a3 3 0 0 1 3-3z"/><path d="M19 10v1a7 7 0 0 1-14 0v-1a1 1 0 0 1 2 0v1a5 5 0 0 0 10 0v-1a1 1 0 0 1 2 0z"/><path d="M12 18.93a1 1 0 0 1-1-1V16a1 1 0 0 1 2 0v1.93a1 1 0 0 1-1 1z"/><path d="M9 20h6a1 1 0 0 1 0 2H9a1 1 0 0 1 0-2z"/><path d="M3 3l18 18M21 3L3 21" stroke="currentColor" stroke-width="2"/></svg>') !important;
}

/* Use custom SVG icon if available */
.bus-voice-search-btn.has-custom-icon i {
    -webkit-mask: url('../../../theme/default/image/icons/voice-search.svg') no-repeat center !important;
    mask: url('../../../theme/default/image/icons/voice-search.svg') no-repeat center !important;
    -webkit-mask-size: 16px !important;
    mask-size: 16px !important;
    background-color: currentColor !important;
    background-image: none !important;
}

/* Theme-specific adjustments */
.bus-voice-search-btn.theme-speedy i {
    -webkit-mask: url('../../../theme/speedy/image/icons/voice-search.svg') no-repeat center !important;
    mask: url('../../../theme/speedy/image/icons/voice-search.svg') no-repeat center !important;
    -webkit-mask-size: 16px !important;
    mask-size: 16px !important;
    background-color: currentColor !important;
    background-image: none !important;
}

/* Position adjustments for different button configurations */
#search button ~ .bus-voice-search-btn,
.search button ~ .bus-voice-search-btn {
    right: 55px !important;
}

/* Special adjustment for buttons with ::after pseudo-elements */
#search button:after ~ .bus-voice-search-btn {
    right: 60px !important;
}

/* SmartSearch specific styles */
.smartsearch .bus-voice-search-btn {
    right: 50px !important;
}

.smartsearch-dropdown ~ .bus-voice-search-btn {
    right: 55px !important;
}

/* Input group adjustments */
.input-group .bus-voice-search-btn {
    right: 60px !important;
    z-index: 1001 !important;
}

.input-group-btn ~ .bus-voice-search-btn {
    right: 65px !important;
}

/* Mobile responsive */
@media (max-width: 767px) {
    .bus-voice-search-btn {
        right: 45px !important;
        width: 20px !important;
        height: 20px !important;
        padding: 6px !important;
    }
    
    .bus-voice-search-btn i {
        background-size: 14px 14px !important;
        -webkit-mask-size: 14px !important;
        mask-size: 14px !important;
    }
}

@media (max-width: 480px) {
    .bus-voice-search-btn {
        right: 40px !important;
        width: 18px !important;
        height: 18px !important;
        padding: 5px !important;
    }
    
    .bus-voice-search-btn i {
        background-size: 12px 12px !important;
        -webkit-mask-size: 12px !important;
        mask-size: 12px !important;
    }
}

/* Large screens */
@media (min-width: 1200px) {
    .bus-voice-search-btn {
        width: 26px !important;
        height: 26px !important;
        padding: 10px !important;
    }
    
    .bus-voice-search-btn i {
        background-size: 18px 18px !important;
        -webkit-mask-size: 18px !important;
        mask-size: 18px !important;
    }
}

/* Dark theme support */
.dark-theme .bus-voice-search-btn {
    color: #ccc !important;
}

.dark-theme .bus-voice-search-btn:hover {
    color: #fff !important;
    background: rgba(255,255,255,0.1) !important;
}

/* Accessibility */
.bus-voice-search-btn:focus {
    outline: 2px solid #007bff !important;
    outline-offset: 2px !important;
}

/* Loading animation */
.bus-voice-search-btn {
    animation: fadeIn 0.5s ease forwards !important;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-50%) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translateY(-50%) scale(1);
    }
}

/* Tooltip on hover */
.bus-voice-search-btn[title]:hover::after {
    content: attr(title) !important;
    position: absolute !important;
    bottom: -35px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    background: rgba(0,0,0,0.9) !important;
    color: white !important;
    padding: 6px 10px !important;
    border-radius: 4px !important;
    font-size: 12px !important;
    white-space: nowrap !important;
    z-index: 2000 !important;
    animation: tooltipFadeIn 0.3s ease !important;
    pointer-events: none !important;
}

@keyframes tooltipFadeIn {
    from { 
        opacity: 0; 
        transform: translateX(-50%) translateY(-5px); 
    }
    to { 
        opacity: 1; 
        transform: translateX(-50%) translateY(0); 
    }
}

/* Hide tooltip on click */
.bus-voice-search-btn:active::after {
    display: none !important;
}

/* Debug mode - make button more visible */
.debug .bus-voice-search-btn {
    background: rgba(255,0,0,0.2) !important;
    border: 1px solid red !important;
}

/* Reset conflicting styles */
.bus-voice-search-btn * {
    pointer-events: none !important;
}

.bus-voice-search-btn i {
    font-style: normal !important;
    font-variant: normal !important;
    text-rendering: auto !important;
    line-height: 1 !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Final fallback styles */
.bus-voice-search-btn {
    margin: 0 !important;
    text-decoration: none !important;
    text-align: center !important;
    vertical-align: middle !important;
    white-space: nowrap !important;
    font-weight: normal !important;
    font-family: inherit !important;
}