/* ---------------------------------- */
/* МЕДИА-КОНТЕНТ В СООБЩЕНИЯХ         */
/* ---------------------------------- */
.message-text img, .message-text video {
    max-width: 220px;
    max-height: 220px;
    border-radius: 16px;
    cursor: pointer;
    transition: transform 0.2s;
}
.message-text img:hover {
    transform: scale(1.02);
}
.message .message-bubble img {
    max-width: 100px;
    max-height: 100px;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 12px;
    cursor: pointer;
}
.message .message-bubble img[src*=".gif"],
.message .message-bubble img[src*=".GIF"] {
    max-width: 100px;
    max-height: 100px;
}
.chat-image-full {
    max-width: 200px;
    max-height: 200px;
    width: auto;
    height: auto;
    border-radius: 12px;
    cursor: pointer;
    object-fit: contain;
}
.image-message-container {
    margin: 4px 0;
}
/* Кастомный видеоплеер */
.custom-video-player {
    position: relative;
    display: block;
    width: 100%;
    max-width: 100%;
    border-radius: 14px;
    overflow: hidden;
    background: #000;
    min-height: 200px;
}
.video-element {
    width: 100%;
    height: auto;
    display: block;
    cursor: pointer;
}
.video-loading-overlay,
.video-error-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    z-index: 1;
}
.loading-spinner {
    border: 3px solid rgba(255,255,255,0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}
.video-top-controls {
    position: absolute;
    top: 4px;
    left: 4px;
    display: flex;
    align-items: center;
    gap: 2px;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    padding: 4px 8px;
    border-radius: 20px;
    transition: opacity 0.3s ease;
    z-index: 2;
}
.video-top-controls.hidden {
    opacity: 0;
    pointer-events: none;
}
.video-top-controls.visible {
    opacity: 1;
}
.video-mute-btn {
    background: none;
    border: none;
    color: white;
    font-size: 9px;
    cursor: pointer;
    padding: 2px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s;
}
.video-mute-btn:hover {
    transform: scale(1.1);
}
.video-remaining-time {
    color: white;
    font-size: 9px;
    font-family: monospace;
    font-weight: 500;
    text-shadow: 0 1px 2px black;
    letter-spacing: 0.5px;
}
.video-bottom-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1px 1px;
    background: linear-gradient(to top, rgba(0,0,0,0.6), transparent);
    transition: opacity 0.3s ease;
    z-index: 0;
}
.video-bottom-progress.hidden {
    opacity: 0;
    pointer-events: none;
}
.video-bottom-progress.visible {
    opacity: 1;
}
.video-progress-area {
    position: relative;
    height: 4px;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
    cursor: pointer;
}
.video-buffered-bar {
    position: absolute;
    height: 100%;
    background: rgba(255,255,255,0.5);
    border-radius: 2px;
    pointer-events: none;
}
.video-progress-fill {
    position: absolute;
    height: 100%;
    background: #3b82f6;
    border-radius: 2px;
    pointer-events: none;
}
.video-progress-slider {
    position: relative;
    width: 100%;
    height: 4px;
    opacity: 0;
    cursor: pointer;
    z-index: 1;
    margin: 0;
    padding: 0;
}
.video-caption {
    position: absolute;
    bottom: 60px;
    left: 12px;
    color: white;
    background: rgba(0,0,0,0.6);
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 12px;
    z-index: 2;
    pointer-events: none;
}
.message:has(.custom-video-player) .message-bubble {
    background: transparent !important;
    padding: 0 !important;
    border-radius: 14px !important;
    backdrop-filter: none !important;
    box-shadow: none !important;
}
.message.own:has(.custom-video-player) .message-bubble {
    background: transparent !important;
    background-image: none !important;
}
.message:has(.custom-video-player) {
    padding: 0 !important;
    margin: 4px 0 !important;
}
.message:has(.custom-video-player) .message-avatar {
    align-self: flex-start;
    margin-top: 8px;
}
/* Голосовое сообщение (линейное) */
.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;
}
.message:has(.voice-circle-wrapper) .message-bubble {
    background: transparent !important;
    padding: 0 !important;
    box-shadow: none !important;
}
.message:has(.voice-circle-wrapper) {
    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;
}
/* Файлы и документы */
.document-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-elevated);
    border-radius: 12px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.2s;
}
.document-preview:hover {
    background: var(--bg-surface);
}
.document-icon {
    font-size: 32px;
    color: var(--primary);
}
.document-info {
    flex: 1;
}
.document-name {
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 8px;
    word-break: break-all;
}
.document-actions {
    display: flex;
    gap: 8px;
}
.archive-download-btn {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    color: var(--text);
    cursor: pointer;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}
.archive-download-btn:hover {
    background: var(--primary);
    color: white;
}
.text-preview {
    background: var(--bg-elevated);
    border-radius: 12px;
    padding: 8px 12px;
    max-width: 400px;
}
.text-preview-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}
.text-preview-content {
    font-size: 11px;
    font-family: monospace;
    white-space: pre-wrap;
    max-height: 200px;
    overflow-y: auto;
    margin: 0;
    color: var(--text-secondary);
}
.text-preview-loading {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 12px;
}
.file-preview-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-elevated);
    border-radius: 12px;
    padding: 10px 16px;
    min-width: 200px;
}
.file-preview-card .file-icon {
    font-size: 32px;
    color: var(--primary);
}
.file-preview-card .file-info {
    flex: 1;
}
.file-preview-card .file-name {
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 8px;
    word-break: break-all;
}
.file-preview-card .file-actions {
    display: flex;
    gap: 8px;
}
.file-preview-card .btn-sm {
    padding: 4px 10px;
    font-size: 11px;
    border-radius: 20px;
}
.download-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    margin-left: 8px;
    transition: color 0.2s;
    font-size: 14px;
}
.download-btn:hover {
    color: var(--primary);
}
.file-upload-indicator {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.circular-progress {
    animation: pulse 1.5s ease-in-out infinite;
}
.circular-progress svg {
    width: 100%;
    height: 100%;
}
.circle-bg {
    fill: none;
    stroke: var(--bg-elevated);
    stroke-width: 3;
}
.circle-progress {
    fill: none;
    stroke: var(--primary);
    stroke-width: 3;
    transition: stroke-dashoffset 0.2s ease;
    animation: pulse 1.5s ease-in-out infinite;
}
.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 14px;
    font-weight: bold;
    color: var(--text);
    text-shadow: 0 0 2px rgba(0,0,0,0.5);
}
.file-name {
    font-size: 11px;
    color: var(--text-secondary);
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.file-download-circle {
    width: 48px;
    height: 48px;
    background: var(--bg-elevated);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    position: relative;
}
.file-download-circle:hover {
    background: var(--primary);
    transform: scale(1.05);
}
.file-download-circle i {
    font-size: 24px;
    color: var(--text);
}
.file-download-circle:hover i {
    color: white;
}
.file-name-tooltip {
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-surface);
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}
.file-download-circle:hover .file-name-tooltip {
    opacity: 1;
}
.file-download-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.file-download-name {
    font-size: 12px;
    color: var(--text-secondary);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.file-click-effect i {
    animation: iconSpin 0.3s cubic-bezier(0.2, 0.9, 0.4, 1.1);
}
.recording-indicator-compact,
.recording-preview-compact {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-surface);
    border-radius: 40px;
    padding: 4px 12px;
    margin-left: 8px;
    backdrop-filter: blur(8px);
    animation: fadeIn 0.2s ease;
}
.recording-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #ff4444;
    animation: pulse 1s infinite;
}
.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;
}
/* Контейнер для голосового сообщения с эквалайзером */
.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-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: 24px 24px 0 0;
    min-height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    z-index: 1050;                    /* выше сообщений и input-area */
    animation: fadeSlideUp 0.25s 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: 12px;
    z-index: 2;
    padding: 16px 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: rgba(76, 154, 255, 0.65);
    backdrop-filter: blur(4px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    box-shadow: 0 0 20px rgba(76, 154, 255, 0.4);
    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: 8px;
    background: transparent;   /* убираем любой возможный фон */
    border-radius: 50%;        /* делаем круглой */
    overflow: hidden;          /* скрываем всё, что выходит за круг */
}

/* Красный canvas (эквалайзер вокруг кнопки) */
/* Красный canvas – должен быть круглым и прозрачным */
.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 0.2s ease;
    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 rgba(76, 154, 255, 0.5); }
    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 0.2s, transform 0.1s;
    margin-top: 12px;
    background: transparent;
    padding: 6px;
    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;
    }
}

/* Адаптация для тёмной/светлой темы – цвета через CSS-переменные */