/* Контейнер поиска */
.search-block--with-voice {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

/* Поле ввода с учетом кнопки */
.search-block--with-voice .search-block__input {
    padding-right: 60px !important;
    width: 100%;
    box-sizing: border-box;
}

/* Базовая кнопка голосового поиска */
.voice-search-btn {
    position: absolute;
    right: 8px;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    cursor: pointer;
    color: #495057;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    width: 44px;
    height: 44px;
    box-sizing: border-box;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    z-index: 10;
}

/* Ховер эффекты */
.voice-search-btn:hover {
    background: #e9ecef;
    border-color: #dee2e6;
    color: #212529;
}

.voice-search-btn:active {
    transform: scale(0.95);
    background: #dee2e6;
}

/* Состояние записи */
.voice-search-btn.listening {
    background: #dc3545;
    border-color: #dc3545;
    color: white;
}

/* Иконка */
.voice-search-btn__icon {
    display: block;
    width: 24px;
    height: 24px;
    pointer-events: none;
}

/* Анимация пульсации */
.voice-search-btn__pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    border-radius: 8px;
    background: transparent;
    opacity: 0;
}

.voice-search-btn.listening .voice-search-btn__pulse {
    animation: voicePulse 2s infinite;
}

@keyframes voicePulse {
    0% {
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7);
        opacity: 1;
    }
    70% {
        box-shadow: 0 0 0 15px rgba(220, 53, 69, 0);
        opacity: 0.7;
    }
    100% {
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0);
        opacity: 0;
    }
}

/* === АДАПТИВНОСТЬ ДЛЯ РАЗНЫХ УСТРОЙСТВ === */

/* ПК и ноутбуки */
@media (min-width: 1025px) {
    .voice-search-btn {
        right: 10px;
        width: 40px;
        height: 40px;
    }
    
    .voice-search-btn__icon {
        width: 20px;
        height: 20px;
    }
}

/* Планшеты и маленькие ноутбуки */
@media (max-width: 1024px) and (min-width: 768px) {
    .voice-search-btn {
        right: 8px;
        width: 44px;
        height: 44px;
    }
    
    .search-block--with-voice .search-block__input {
        padding-right: 55px !important;
    }
}

/* Мобильные телефоны */
@media (max-width: 767px) {
    .voice-search-btn {
        right: 6px;
        width: 46px;
        height: 46px;
        border-radius: 10px;
        border-width: 2px;
    }
    
    .voice-search-btn__icon {
        width: 22px;
        height: 22px;
    }
    
    .search-block--with-voice .search-block__input {
        padding-right: 58px !important;
        font-size: 16px; /* Предотвращает zoom в iOS */
    }
    
    @keyframes voicePulse {
        0% {
            box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7);
            opacity: 1;
        }
        70% {
            box-shadow: 0 0 0 20px rgba(220, 53, 69, 0);
            opacity: 0.7;
        }
        100% {
            box-shadow: 0 0 0 0 rgba(220, 53, 69, 0);
            opacity: 0;
        }
    }
}

/* Большие экраны (ТВ, мониторы) */
@media (min-width: 1440px) {
    .voice-search-btn {
        width: 48px;
        height: 48px;
        right: 12px;
    }
    
    .voice-search-btn__icon {
        width: 26px;
        height: 26px;
    }
    
    .search-block--with-voice .search-block__input {
        padding-right: 65px !important;
    }
}

/* Android TV и Smart TV */
@media (min-width: 1920px) {
    .voice-search-btn {
        width: 52px;
        height: 52px;
        right: 15px;
        border-radius: 10px;
    }
    
    .voice-search-btn__icon {
        width: 28px;
        height: 28px;
    }
    
    .search-block--with-voice .search-block__input {
        padding-right: 70px !important;
        font-size: 18px;
    }
}

/* Поддержка темной темы */
@media (prefers-color-scheme: dark) {
    .voice-search-btn {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .voice-search-btn:hover {
        background: #4a5568;
        border-color: #718096;
        color: white;
    }
}

/* Улучшение доступности для фокуса */
.voice-search-btn:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

.voice-search-btn:focus:not(:focus-visible) {
    outline: none;
}

/* Поддержка старых браузеров */
.voice-search-btn {
    min-width: 44px; /* Минимальный размер для тач-устройств */
}

/* Голосовой поиск */
.voice-search-btn {
    transition: all 0.3s ease !important;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2) !important;
}

.voice-search-btn:hover {
    background: #5a6268 !important;
    transform: translateY(-50%) scale(1.1) !important;
}

.voice-search-btn.listening {
    background: #dc3545 !important;
    animation: voice-pulse 1.5s infinite !important;
}

@keyframes voice-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(220, 53, 69, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0);
    }
}

/* Мобильные устройства */
@media (max-width: 768px) {
    .search-block__input {
        padding-right: 45px !important;
    }
    
    .voice-search-btn {
        right: 8px !important;
        width: 36px !important;
        height: 36px !important;
        font-size: 18px !important;
    }
}

/* Большие экраны */
@media (min-width: 1200px) {
    .voice-search-btn {
        width: 34px !important;
        height: 34px !important;
    }
}

.voice-search-btn.listening {
    background: #dc3545 !important;
    animation: pulse 1.5s infinite !important;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(220, 53, 69, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0);
    }
}

/* Для мобильных */
@media (max-width: 768px) {
    .voice-search-btn {
        width: 36px !important;
        height: 36px !important;
        right: 8px !important;
    }
    
    .voice-search-btn svg {
        width: 18px !important;
        height: 18px !important;
    }
}