/* MEGA Digital Space — вложения и голосовые сообщения в чатах поддержки (chat-media-kit.js) */

.mcm-attachment {
    --mcm-accent: var(--bs-primary, #4f46e5);
    --mcm-surface: rgba(127, 127, 127, 0.1);
    --mcm-border: rgba(127, 127, 127, 0.22);
    margin-top: 6px;
    max-width: 100%;
}

.mcm-attachment:first-child {
    margin-top: 0;
}

/* Фото */
.mcm-image-link {
    display: inline-block;
    max-width: 100%;
    border-radius: 12px;
    overflow: hidden;
    line-height: 0;
}

.mcm-image {
    display: block;
    max-width: min(280px, 100%);
    max-height: 280px;
    width: auto;
    height: auto;
    object-fit: cover;
    border-radius: 12px;
}

/* Видео */
.mcm-video {
    display: block;
    width: min(320px, 100%);
    max-height: 260px;
    border-radius: 12px;
    background: #000;
}

.mcm-attachment-video .mcm-file {
    margin-top: 6px;
}

/* Документы */
.mcm-file {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    max-width: 300px;
    padding: 8px 10px;
    border: 1px solid var(--mcm-border);
    border-radius: 12px;
    background: var(--mcm-surface);
    color: inherit;
    text-decoration: none;
}

.mcm-file:hover,
.mcm-file:focus-visible {
    color: inherit;
    border-color: var(--mcm-accent);
}

.mcm-file-badge {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(100, 116, 139, 0.16);
    color: #64748b;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.mcm-file-badge-pdf { background: rgba(239, 68, 68, 0.14); color: #dc2626; }
.mcm-file-badge-doc, .mcm-file-badge-docx, .mcm-file-badge-txt, .mcm-file-badge-rtf, .mcm-file-badge-odt { background: rgba(37, 99, 235, 0.14); color: #2563eb; }
.mcm-file-badge-xls, .mcm-file-badge-xlsx, .mcm-file-badge-csv, .mcm-file-badge-ods { background: rgba(16, 185, 129, 0.14); color: #059669; }
.mcm-file-badge-ppt, .mcm-file-badge-pptx { background: rgba(234, 88, 12, 0.14); color: #ea580c; }
.mcm-file-badge-zip, .mcm-file-badge-rar, .mcm-file-badge-7z { background: rgba(245, 158, 11, 0.16); color: #d97706; }
.mcm-file-badge-mp4, .mcm-file-badge-webm, .mcm-file-badge-mov { background: rgba(99, 102, 241, 0.14); color: #4f46e5; }

.mcm-file-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1 1 auto;
}

.mcm-file-name {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-weight: 600;
    font-size: 0.875rem;
}

.mcm-file-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 10px;
}

.mcm-file-action {
    color: inherit;
    font-size: 0.75rem;
    opacity: 0.75;
    text-decoration: none;
}

.mcm-file-action:hover,
.mcm-file-action:focus-visible {
    opacity: 1;
    text-decoration: underline;
    color: inherit;
}

.mcm-file-icon {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: inherit;
    opacity: 0.65;
    text-decoration: none;
}

.mcm-file-icon:hover,
.mcm-file-icon:focus-visible {
    background: rgba(127, 127, 127, 0.15);
    color: inherit;
    opacity: 1;
}

.mcm-image-link {
    cursor: zoom-in;
}

/* Файл фото удалён или недоступен — показываем аккуратную заглушку вместо битой картинки */
.mcm-attachment.is-broken .mcm-image-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 160px;
    height: 100px;
    border-radius: 12px;
    background: var(--mcm-surface);
    cursor: default;
}

.mcm-attachment.is-broken .mcm-image {
    display: none;
}

.mcm-attachment.is-broken .mcm-image-link::before {
    content: "\f03e";
    font-family: FontAwesome, "Font Awesome 6 Free", sans-serif;
    font-weight: 900;
    font-size: 28px;
    opacity: 0.35;
}

.mcm-voice-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.mcm-voice-download {
    color: inherit;
    font-size: 0.8rem;
    opacity: 0.75;
}

.mcm-voice-download:hover,
.mcm-voice-download:focus-visible {
    color: inherit;
    opacity: 1;
}

/* lightbox2 поверх фиксированных виджетов и панелей чата */
.lightboxOverlay {
    z-index: 10000010 !important;
}

.lightbox {
    z-index: 10000011 !important;
}

/* Голосовые и аудио */
.mcm-voice {
    display: flex;
    align-items: center;
    gap: 10px;
    width: min(260px, 100%);
    min-width: 200px;
    padding: 4px 2px;
}

.mcm-voice audio {
    display: none;
}

.mcm-voice-play {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--mcm-accent);
    color: #fff;
    cursor: pointer;
    transition: transform 0.15s ease;
}

.mcm-voice-play:hover {
    transform: scale(1.05);
}

.mcm-voice-play .fa-play {
    margin-left: 2px;
}

.mcm-voice-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1 1 auto;
}

.mcm-voice-title {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 0.8rem;
    font-weight: 600;
}

.mcm-voice-track {
    position: relative;
    height: 6px;
    border-radius: 999px;
    background: var(--mcm-border);
    cursor: pointer;
    overflow: hidden;
}

.mcm-voice-track:focus-visible {
    outline: 2px solid var(--mcm-accent);
    outline-offset: 3px;
}

.mcm-voice-progress {
    position: absolute;
    inset: 0 auto 0 0;
    width: 0;
    border-radius: inherit;
    background: var(--mcm-accent);
}

.mcm-voice-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.72rem;
    opacity: 0.8;
    font-variant-numeric: tabular-nums;
}

.mcm-voice-speed {
    padding: 0 6px;
    border: 1px solid var(--mcm-border);
    border-radius: 999px;
    background: transparent;
    color: inherit;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1.5;
    cursor: pointer;
}

.mcm-voice-speed.is-fast {
    border-color: var(--mcm-accent);
    color: var(--mcm-accent);
}

/* На цветном пузыре собственного сообщения плеер инвертируется */
.mcm-on-accent .mcm-voice-play {
    background: #fff;
    color: var(--mcm-accent);
}

.mcm-on-accent .mcm-voice-track {
    background: rgba(255, 255, 255, 0.35);
}

.mcm-on-accent .mcm-voice-progress {
    background: #fff;
}

.mcm-on-accent .mcm-file {
    border-color: rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.14);
}

.mcm-on-accent .mcm-file-badge {
    background: rgba(255, 255, 255, 0.92);
}

/* Кнопка микрофона (общая для всех композеров) */
.mcm-mic-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mcm-mic-button[aria-pressed="true"] {
    color: #ef4444;
}

/* Панель записи поверх композера */
.mcm-composer-host {
    position: relative;
}

.mcm-recording {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 10px;
    border-radius: inherit;
    background: var(--bs-body-bg, #fff);
    color: var(--bs-body-color, #212529);
    animation: mcm-fade-in 0.15s ease;
}

.mcm-recording[hidden] {
    display: none;
}

.mcm-recording-cancel,
.mcm-recording-send {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}

.mcm-recording-cancel {
    background: rgba(239, 68, 68, 0.12);
    color: #dc2626;
}

.mcm-recording-send {
    background: var(--bs-primary, #4f46e5);
    color: #fff;
}

.mcm-recording-status {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 auto;
    min-width: 0;
    font-variant-numeric: tabular-nums;
}

.mcm-recording-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ef4444;
    animation: mcm-pulse 1s ease-in-out infinite;
}

.mcm-recording-time {
    font-weight: 700;
}

.mcm-recording-label {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    opacity: 0.7;
}

/* Превью выбранного файла и прогресс загрузки */
.mcm-pending {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding: 6px 10px;
    border-radius: 10px;
    background: rgba(127, 127, 127, 0.1);
    font-size: 0.85rem;
}

.mcm-pending[hidden] {
    display: none;
}

.mcm-pending-thumb {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 8px;
    object-fit: cover;
}

.mcm-pending-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.mcm-pending-remove {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
}

.mcm-pending-remove:hover {
    background: rgba(127, 127, 127, 0.18);
}

@keyframes mcm-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

@keyframes mcm-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .mcm-recording,
    .mcm-recording-dot {
        animation: none;
    }
}

body.dark-theme .mcm-recording {
    background: var(--card-dark, #1f2937);
    color: var(--text-dark, #e5e7eb);
}
