/* ---------------------------------- */
/* ГОЛОСОВЫЕ СООБЩЕНИЯ, АУДИОПЛЕЕРЫ  */
/* ---------------------------------- */

/* Линейное голосовое сообщение */
.voice-message {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-xl);
    padding: 8px 16px;
    max-width: 320px;
    min-width: 240px;
    cursor: default;
    user-select: none;
}

.voice-play-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition-fast), background var(--transition-fast);
    flex-shrink: 0;
}

.voice-play-btn:hover {
    transform: scale(1.05);
    background: var(--primary-dark);
}

.voice-play-btn:active {
    transform: scale(0.95);
}

.voice-progress-container {
    flex: 1;
    height: 36px;
    position: relative;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 18px;
    overflow: hidden;
    cursor: pointer;
}

.voice-progress-bar {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.1s linear;
    border-radius: 18px;
}

.voice-wave {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
            90deg,
            transparent,
            transparent 6px,
            rgba(255, 255, 255, 0.2) 6px,
            rgba(255, 255, 255, 0.2) 12px
    );
    pointer-events: none;
}

.voice-time {
    font-size: 12px;
    color: var(--text-secondary);
    font-family: monospace;
    white-space: nowrap;
}

.voice-filename {
    font-size: 11px;
    color: var(--text-secondary);
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.voice-download-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.voice-download-btn:hover {
    background: var(--bg-hover);
    color: var(--text);
}

/* Круглый аудиоплеер */
.voice-circle-wrapper {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 100px;
    height: 100px;
    background: transparent;
    border-radius: 50%;
    overflow: visible;
}

.voice-circle {
    position: relative;
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border-radius: 50%;
    overflow: hidden;
}

.voice-progress-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
}

.voice-progress-bg {
    stroke: rgba(255, 255, 255, 0.15);
}

.voice-progress-fill {
    stroke: var(--primary);
    filter: drop-shadow(0 0 6px var(--primary)) drop-shadow(0 0 2px var(--primary));
    transition: stroke-dashoffset 0.05s linear;
}

.voice-play-circle {
    position: relative;
    z-index: var(--z-base);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    border: none;
    color: white;
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition), background var(--transition), box-shadow var(--transition);
    box-shadow: 0 0 8px var(--primary-glow);
}

.voice-play-circle:hover {
    transform: scale(1.05);
    background: var(--primary-dark);
    box-shadow: 0 0 12px var(--primary-glow);
}

.voice-play-circle:active {
    transform: scale(0.95);
}

.voice-play-circle:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Анимация пульсации для круга */
.voice-circle-pulse .voice-progress-fill {
    animation: neonPulse 1.5s ease-in-out infinite;
}

.voice-circle-pulse .voice-play-circle {
    animation: buttonPulse 1.5s ease-in-out infinite;
}

@keyframes neonPulse {
    0% {
        filter: drop-shadow(0 0 2px var(--primary)) drop-shadow(0 0 1px var(--primary));
        stroke: var(--primary);
    }
    50% {
        filter: drop-shadow(0 0 14px var(--primary)) drop-shadow(0 0 6px var(--primary));
        stroke: #fff;
    }
    100% {
        filter: drop-shadow(0 0 2px var(--primary)) drop-shadow(0 0 1px var(--primary));
        stroke: var(--primary);
    }
}

@keyframes buttonPulse {
    0% {
        box-shadow: 0 0 0 0 var(--primary-glow);
        background: var(--primary);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(76, 154, 255, 0);
        background: var(--primary-dark);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(76, 154, 255, 0);
        background: var(--primary);
    }
}

/* Тултип с длительностью при наведении */
.voice-circle[data-duration]:hover::after {
    content: attr(data-duration);
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    color: white;
    font-size: 11px;
    padding: 4px 8px;
    border-radius: var(--radius-full);
    white-space: nowrap;
    z-index: var(--z-tooltip);
    pointer-events: none;
    font-family: monospace;
    box-shadow: var(--shadow-sm);
}

/* Спиннер загрузки */
.voice-loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: voiceSpin 0.8s linear infinite;
    z-index: 3;
}

/* Контейнер для голосового сообщения в сообщении (без фона) */
.message:has(.voice-circle-wrapper):not(:has(.reply-indicator-compact)) .message-bubble {
    background: transparent !important;
    padding: 0 !important;
    box-shadow: none !important;
}

.message:has(.voice-circle-wrapper):not(:has(.reply-indicator-compact)) {
    padding: 0 !important;
    margin: 4px 0 !important;
}

/* Компактная версия для ответов */
.voice-reply-wrapper {
    width: 50px !important;
    height: 50px !important;
}

.voice-reply-wrapper .voice-circle {
    width: 50px;
    height: 50px;
}

.voice-reply-wrapper .voice-play-circle {
    width: 28px !important;
    height: 28px !important;
    font-size: 12px !important;
}

.voice-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.voice-reply-container {
    gap: 6px;
}

.voice-equalizer {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border-radius: var(--radius-sm);
}

/* Стилизованный контейнер голосового сообщения (стеклянный) */
.voice-container {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-full);
    padding: 2px 10px 2px 6px;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all var(--transition);
    gap: 6px;
}

body.light-theme .voice-container {
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: var(--shadow-sm);
}

.voice-reply-container {
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(6px);
    border-radius: 10px;
    padding: 0px 8px 0px 4px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    gap: 4px;
}

body.light-theme .voice-reply-container {
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.voice-container:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.35);
}

body.light-theme .voice-container:hover {
    background: rgba(0, 0, 0, 0.07);
}

/* Альтернативный аудиоплеер для файлов */
.custom-audio-player {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-elevated);
    border-radius: var(--radius-xl);
    padding: 6px 12px;
    min-width: 220px;
}

.custom-audio-player .play-btn {
    background: var(--primary);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.custom-audio-player .play-btn:hover {
    transform: scale(1.05);
}

.custom-audio-player .progress-container {
    flex: 1;
    position: relative;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    cursor: pointer;
}

.custom-audio-player .progress-bar {
    position: absolute;
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    pointer-events: none;
}

.custom-audio-player .progress-slider {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    margin: 0;
}

.custom-audio-player .time-info {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* Адаптация для мобильных */
@media (max-width: 768px) {
    .voice-message {
        max-width: 260px;
        min-width: 200px;
        padding: 6px 12px;
    }
    .voice-play-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    .voice-circle-wrapper {
        width: 80px;
        height: 80px;
    }
    .voice-circle {
        width: 80px;
        height: 80px;
    }
    .voice-play-circle {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }
    .custom-audio-player {
        min-width: 180px;
        padding: 4px 10px;
    }
}

/* Уважение prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
    .voice-play-btn,
    .voice-play-circle,
    .voice-circle-pulse .voice-progress-fill,
    .voice-circle-pulse .voice-play-circle,
    .voice-loading-spinner {
        animation: none;
        transition: none;
    }
    .voice-play-btn:hover,
    .voice-play-circle:hover {
        transform: none;
    }
    .voice-circle-pulse .voice-progress-fill,
    .voice-circle-pulse .voice-play-circle {
        filter: none;
        box-shadow: none;
    }
}