/* ---------------------------------- */
/* УТИЛИТЫ: запись, резервные стили  */
/* ---------------------------------- */

.recording-indicator-compact,
.recording-preview-compact {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    background: var(--bg-surface);
    border-radius: var(--radius-full);
    padding: var(--spacing-xs) var(--spacing-md);
    margin-left: var(--spacing-sm);
    backdrop-filter: blur(8px);
    animation: fadeIn var(--animation-duration) ease;
}

.recording-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--danger);
    animation: pulse 1s infinite;
}

/* Панель записи голоса */
.voice-recorder-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: transparent;
    backdrop-filter: blur(5px);
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    min-height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    z-index: var(--z-overlay);
    animation: fadeSlideUp var(--animation-duration-slow) ease;
}

.voice-recorder-panel-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.5;
}

.voice-recorder-panel-inner {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-md);
    z-index: 2;
    padding: var(--spacing-lg) 0;
}

.voice-recorder-panel-visual {
    position: relative;
    width: 180px;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.voice-recorder-panel-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.voice-recorder-panel-microphone {
    width: 70px;
    height: 70px;
    background: var(--primary-glow);
    backdrop-filter: blur(4px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    box-shadow: 0 0 20px var(--primary-glow);
    animation: micPulse 1.2s ease-in-out infinite;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.voice-recorder-panel-microphone i {
    font-size: 32px;
    color: white;
    text-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
}

.voice-recorder-panel-cancel {
    display: none;
}

.voice-recorder-panel-cancel-wrapper {
    position: relative;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: var(--spacing-sm);
    background: transparent;
    border-radius: 50%;
    overflow: hidden;
}

.voice-recorder-panel-red-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    background: transparent;
    border-radius: 50%;
}

.voice-recorder-panel-cancel-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(220, 53, 69, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: white;
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    box-shadow: 0 0 12px rgba(220, 53, 69, 0.6);
    z-index: 2;
    position: relative;
    background-clip: padding-box;
}

.voice-recorder-panel-cancel-btn:hover {
    transform: scale(1.05);
    background: rgba(220, 53, 69, 1);
    box-shadow: 0 0 18px rgba(220, 53, 69, 0.8);
}

.voice-recorder-panel-cancel-btn:active {
    transform: scale(0.95);
}

.voice-recorder-panel-cancel:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.02);
}

@keyframes micPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 var(--primary-glow);
    }
    50% {
        transform: scale(1.08);
        box-shadow: 0 0 0 18px rgba(76, 154, 255, 0);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(76, 154, 255, 0);
    }
}

.voice-recorder-cancel-icon {
    font-size: 28px;
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    transition: color var(--transition), transform var(--transition-fast);
    margin-top: var(--spacing-md);
    background: transparent;
    padding: var(--spacing-sm);
    border-radius: 50%;
    display: inline-block;
}

.voice-recorder-cancel-icon:hover {
    color: rgba(255, 255, 255, 1);
    transform: scale(1.05);
}

.voice-recorder-cancel-icon:active {
    transform: scale(0.95);
}

/* Резервный фон для браузеров без backdrop-filter */
@supports not (backdrop-filter: blur(5px)) {
    .voice-recorder-panel,
    .chat-header,
    .input-area,
    .message-bubble,
    .chats-panel {
        background: rgba(10, 15, 28, 0.95) !important;
    }
    body.light-theme .voice-recorder-panel,
    body.light-theme .chat-header,
    body.light-theme .input-area,
    body.light-theme .message-bubble,
    body.light-theme .chats-panel {
        background: rgba(242, 244, 248, 0.95) !important;
    }
}

/* Адаптация для сообщений – убираем фон для основных медиа-сообщений */
.message:has(.image-message-container) .message-bubble,
.message:has(.custom-audio-player):not(:has(.reply-indicator-compact)) .message-bubble,
.message:has(.document-preview) .message-bubble,
.message:has(.file-preview-card) .message-bubble,
.message:has(.text-preview) .message-bubble,
.message:has(.file-upload-indicator) .message-bubble {
    background: transparent !important;
    backdrop-filter: none !important;
    padding: 0 !important;
    box-shadow: none !important;
}

/* Уважение prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
    .recording-indicator-compact,
    .recording-preview-compact,
    .voice-recorder-panel,
    .voice-recorder-panel-microphone,
    .voice-recorder-panel-cancel-btn,
    .voice-recorder-cancel-icon {
        animation: none;
        transition: none;
    }
    .voice-recorder-panel-microphone {
        animation: none;
    }
    .voice-recorder-panel-cancel-btn:hover,
    .voice-recorder-cancel-icon:hover {
        transform: none;
    }
}