/**
 * Copyright © 2024 Custom. All rights reserved.
 */

.voice-search-wrapper {
    display: inline-block;
    vertical-align: middle;
    margin-left: 5px;
    position: relative;
}

.voice-search-btn {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border: 1px solid #e0e0e0;
    padding: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: #495057;
    min-width: 40px;
    height: 40px;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    position: relative;
    overflow: hidden;
}

.voice-search-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(0, 123, 255, 0.1);
    transform: translate(-50%, -50%);
    transition: width 0.3s ease, height 0.3s ease;
}

.voice-search-btn:hover:not(.disabled)::before {
    width: 100%;
    height: 100%;
}

.voice-search-btn:hover:not(.disabled) {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    color: #007bff;
    border-color: #007bff;
    box-shadow: 0 4px 8px rgba(0, 123, 255, 0.15);
    transform: translateY(-1px);
}

.voice-search-btn:active:not(.disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.2);
}

.voice-search-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f5f5f5;
}

.voice-search-btn.recording {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: #ffffff;
    border-color: #dc3545;
    box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7), 0 4px 12px rgba(220, 53, 69, 0.3);
    animation: recordingPulse 2s ease-in-out infinite;
}

.voice-search-btn.recording::before {
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.2);
    animation: recordingRipple 2s ease-in-out infinite;
}

.voice-search-btn.recording .voice-icon {
    animation: recordingIcon 1s ease-in-out infinite;
    transform-origin: center;
}

.voice-search-btn.recording .voice-icon svg {
    animation: recordingIcon 1s ease-in-out infinite;
}

.voice-search-btn .voice-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
    transition: transform 0.3s ease;
}

.voice-search-btn:hover:not(.disabled) .voice-icon {
    transform: scale(1.1);
}

.voice-search-btn .voice-icon svg {
    width: 20px;
    height: 20px;
    transition: all 0.3s ease;
}

.voice-status {
    display: none!important;
    font-size: 11px;
    margin-left: 8px;
    color: #6c757d;
    font-weight: 500;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    animation: statusFadeIn 0.3s ease;
}

.voice-status.show {
    display: inline-block;
}

.voice-search-status {
    position: absolute;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: #ffffff;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    z-index: 1000;
    margin-top: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    min-width: 180px;
    text-align: center;
    letter-spacing: 0.2px;
    line-height: 1.5;
    animation: statusSlideDown 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.voice-search-status::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid #2c3e50;
}

.voice-search-status small {
    display: block;
    font-size: 10px;
    opacity: 0.9;
    margin-top: 4px;
    font-weight: 400;
}


/* Recording animations */

@keyframes recordingPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7), 0 4px 12px rgba(220, 53, 69, 0.3);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(220, 53, 69, 0), 0 4px 16px rgba(220, 53, 69, 0.4);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7), 0 4px 12px rgba(220, 53, 69, 0.3);
    }
}

@keyframes recordingRipple {
    0% {
        opacity: 0.3;
        transform: translate(-50%, -50%) scale(0.8);
    }
    50% {
        opacity: 0.1;
        transform: translate(-50%, -50%) scale(1.2);
    }
    100% {
        opacity: 0.3;
        transform: translate(-50%, -50%) scale(0.8);
    }
}

@keyframes recordingIcon {
    0%,
    100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.15);
    }
}

@keyframes statusFadeIn {
    from {
        opacity: 0;
        transform: translateX(-5px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes statusSlideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* Mobile responsive - Only size adjustments, animations remain the same */

@media (max-width: 768px) {
    .voice-search-btn {
        min-width: 36px;
        height: 36px;
        padding: 6px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }
    .voice-search-btn:hover:not(.disabled) {
        box-shadow: 0 3px 6px rgba(0, 123, 255, 0.2);
    }
    .voice-search-btn .voice-icon svg {
        width: 18px;
        height: 18px;
    }
    .voice-status {
        font-size: 10px;
        margin-left: 6px;
    }
    .voice-search-status {
        font-size: 11px;
        padding: 8px 12px;
        min-width: 160px;
        margin-top: 6px;
    }
    /* Ensure all animations work the same on mobile */
    .voice-search-btn.recording {
        animation: recordingPulse 2s ease-in-out infinite;
    }
    .voice-search-btn.recording::before {
        animation: recordingRipple 2s ease-in-out infinite;
    }
    .voice-search-btn.recording .voice-icon {
        animation: recordingIcon 1s ease-in-out infinite;
    }
    .voice-search-btn.recording .voice-icon svg {
        animation: recordingIcon 1s ease-in-out infinite;
    }
}


/* Integration with search form */

.field.search .control {
    position: relative;
    display: flex;
    align-items: center;
}

.field.search .control .voice-search-wrapper {
    position: absolute;
    right: 45px;
    z-index: 10;
}

.field.search .control input[type="text"] {
    padding-right: 90px;
}


/* Mobile search form specific styling */

.block-search-mobile .field.search .control {
    position: relative;
    display: flex;
    align-items: center;
}

.block-search-mobile .field.search .control .voice-search-wrapper {
    position: absolute;
    right: 45px;
    z-index: 10;
}

.block-search-mobile .field.search .control input[type="text"] {
    padding-right: 90px;
}


/* Adjust for forms with category select */

.field.search .control select+input[type="text"] {
    padding-right: 90px;
}
