/* ---------------------------------- */
/* ГОЛОСОВЫЕ СООБЩЕНИЯ, АУДИОПЛЕЕРЫ  */
/* ---------------------------------- */

/* Линейное голосовое сообщение */
.voice-message {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 24px;
    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: 0.2s;
    flex-shrink: 0;
}
.voice-play-btn:hover {
    transform: scale(1.05);
    background: var(--primary-dark);
}
.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: rgba(255, 255, 255, 0.7);
    font-family: monospace;
    white-space: nowrap;
}
.voice-filename {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.voice-download-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    transition: 0.2s;
}
.voice-download-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

/* Круглый аудиоплеер */
.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: 2;
    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 0.2s, background 0.2s, box-shadow 0.2s;
    box-shadow: 0 0 8px rgba(76, 154, 255, 0.5);
}
.voice-play-circle:hover {
    transform: scale(1.05);
    background: var(--primary-dark);
    box-shadow: 0 0 12px rgba(76, 154, 255, 0.8);
}
.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 rgba(76, 154, 255, 0.4); 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: 20px;
    white-space: nowrap;
    z-index: 10;
    pointer-events: none;
    font-family: monospace;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.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;
}
/* ✅ ИСПРАВЛЕНО: фон убирается только если нет блока ответа (reply) */
.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: 8px;
}

/* ✅ Уже исправленное правило для .voice-container */
.message:has(.voice-container):not(:has(.reply-indicator-compact)) .message-bubble {
    background: transparent !important;
    backdrop-filter: none !important;
    padding: 0 !important;
    box-shadow: none !important;
}

/* Стеклянный фон для голосового сообщения */
.voice-container {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(10px);
    border-radius: 40px;
    padding: 2px 10px 2px 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.2s ease;
    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: 0 1px 4px rgba(0, 0, 0, 0.05);
}
.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: 24px;
    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 0.2s;
    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;
}