/* Стили для файловых сообщений */
.file-message {
    max-width: 400px;
	display: flex;
	flex-direction: column;
}

.file-preview {
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.2s ease;
}

.file-preview:hover {
    transform: scale(1.02);
}

.file-preview img {
    transition: transform 0.3s ease;
}

.file-preview img:hover {
    transform: scale(1.02);
}

.file-info {
    font-size: 0.85em;
    max-width: 300px;
    min-width: 300px;
}

.file-icon {
    opacity: 0.7;
}

.document-message .file-preview {
    border: 1px solid #dee2e6;
}

.message.sent .document-message .file-preview {
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.file-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 5px;
}

.file-category {
    font-size: 0.7em;
    padding: 2px 6px;
    border-radius: 4px;
    background: #f8f9fa;
}

.file-size {
    font-size: 0.8em;
    color: #6c757d;
}

/* Стили для различных типов файлов */
.file-message.book-message .file-preview {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%) !important;
    border: 1px solid #dee2e6;
}

.file-message.book-message .file-icon {
    color: #7952b3 !important;
}

.file-message.text-message .file-preview {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%) !important;
    border: 1px solid #bbdefb;
    border-radius: 8px;
}

.file-message.text-message .file-icon {
    color: #1976d2 !important;
}

.message.sent .file-message.text-message .file-preview {
    background: linear-gradient(135deg, #e3f2fd 0%, #90caf9 100%) !important;
    border: 1px solid #90caf9;
}

.file-message.archive-message .file-preview {
    background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%) !important;
    border: 1px solid #ffcc80;
}

.file-message.archive-message .file-icon {
    color: #f57c00 !important;
}

.file-message.executable-message .file-preview {
    background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%) !important;
    border: 1px solid #ffcc80;
}

.file-message.executable-message .file-icon {
    color: #f57c00 !important;
}

.message.sent .file-message.executable-message .file-preview {
    background: linear-gradient(135deg, #fff3e0 0%, #ffcc80 100%) !important;
    border: 1px solid #ffb74d;
}

.file-message.torrent-message .file-preview {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%) !important;
    border: 1px solid #a5d6a7;
}

.file-message.torrent-message .file-icon {
    color: #4caf50 !important;
}

.message.sent .file-message.torrent-message .file-preview {
    background: linear-gradient(135deg, #e8f5e9 0%, #a5d6a7 100%) !important;
    border: 1px solid #81c784;
}

.file-message.document-message .file-preview {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%) !important;
    border: 1px solid #90caf9;
}

.file-message.document-message .file-icon {
    color: #1976d2 !important;
}

.message.sent .file-message.document-message .file-preview {
    background: linear-gradient(135deg, #e3f2fd 0%, #90caf9 100%) !important;
    border: 1px solid #64b5f6;
}

.file-message.audio-message .file-preview {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%) !important;
    border: 1px solid #90caf9;
    border-radius: 12px;
}

.file-message.audio-message .file-icon {
    color: #1976d2 !important;
}

.message.sent .file-message.audio-message .file-preview {
    background: linear-gradient(135deg, #e3f2fd 0%, #90caf9 100%) !important;
    border: 1px solid #64b5f6;
}

/* Аудио плеер в сообщениях */
.file-message.audio-message audio {
    width: 100%;
    /* border-radius: 8px; */
    background: #ffffff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Кастомизация аудио плеера */
.file-message.audio-message audio::-webkit-media-controls-panel {
    background: #ffffff;
}

.file-message.audio-message audio::-webkit-media-controls-play-button {
    background-color: #1976d2;
    border-radius: 50%;
}

.file-message.audio-message audio::-webkit-media-controls-current-time-display,
.file-message.audio-message audio::-webkit-media-controls-time-remaining-display {
    color: #1976d2;
    font-weight: 500;
}

.file-message.audio-message audio::-webkit-media-controls-timeline {
    background-color: #e3f2fd;
    border-radius: 2px;
    margin: 0 10px;
}

.file-message.audio-message audio::-webkit-media-controls-volume-slider {
    background-color: #e3f2fd;
    border-radius: 2px;
}

/* Предупреждение для исполняемых файлов */
.executable-warning {
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 4px;
    padding: 8px 12px;
    margin-top: 8px;
    font-size: 0.8em;
    color: #856404;
}

.executable-warning i {
    color: #f39c12;
    margin-right: 5px;
}


/* Стили для расшифрованных медиафайлов */
.decrypted-image {
    transition: transform 0.2s ease;
    cursor: pointer;
}

.decrypted-image:hover {
    transform: scale(1.02);
}

.decrypted-audio {
    border-radius: 8px;
    background: #f8f9fa;
    padding: 10px;
}

.decrypted-video {
    border-radius: 8px;
    background: #000;
}

/* Стили для модального окна изображения */
#imageModal .modal-content {
    background: transparent;
    border: none;
}

#imageModal .modal-header {
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border-bottom: none;
}

#imageModal .modal-body {
    padding: 0;
    background: rgba(0, 0, 0, 0.9);
}

#imageModal .modal-footer {
    background: rgba(0, 0, 0, 0.7);
    border-top: none;
}

/* Индикатор загрузки */
.file-preview .spinner-border {
    width: 2rem;
    height: 2rem;
}

/* Адаптивность для медиафайлов */
@media (max-width: 768px) {
    .decrypted-video {
        max-height: 200px;
    }
    
    .decrypted-image {
        max-height: 200px;
    }
}


.mw{
	min-width:350px;
}
/* Mobile-safe optimistic upload card (QChat patch v325).
 * Legacy .file-info has a fixed 300px minimum; while a temporary outgoing
 * message is still encrypting/uploading that can push the Sending badge and
 * status text outside a narrow phone bubble. */
.temporary-file-message,
.temporary-file-message .file-preview {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.temporary-file-message .file-info {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

.temporary-file-message .file-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 4px 8px;
}

.temporary-file-message .file-meta .badge {
    margin-left: 0 !important;
    max-width: 100%;
    white-space: normal;
}

.temporary-file-message .encryption-status small,
.temporary-file-message .file-info > strong {
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
}

@media (max-width: 575.98px) {
    #messagesContainer .message.temporary-message .file-message,
    #messagesContainer .message.temporary-message .temporary-file-message,
    #messagesContainer .message.temporary-message .file-preview {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }
}


/* QChat patch v327: compact staged upload card with a visible progress bar. */
.temporary-file-message.qchat-file-upload-card {
    width: min(380px, 100%);
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.temporary-file-message.qchat-file-upload-card .qchat-file-upload-preview {
    display: grid !important;
    grid-template-columns: 44px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    padding: 10px 12px !important;
    margin: 0 !important;
    border: 1px solid rgba(59, 130, 246, 0.20) !important;
    border-radius: 12px !important;
    background: rgba(59, 130, 246, 0.055) !important;
    box-shadow: none !important;
    text-align: left !important;
    box-sizing: border-box !important;
    overflow: hidden;
}

.temporary-file-message.qchat-file-upload-card .qchat-file-upload-preview:hover {
    transform: none !important;
    box-shadow: none !important;
}

.temporary-file-message.qchat-file-upload-card .qchat-file-upload-icon {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 11px;
    background: rgba(13, 110, 253, 0.11);
    font-size: 20px !important;
    line-height: 1 !important;
}

.temporary-file-message.qchat-file-upload-card .qchat-file-upload-info {
    display: block !important;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    text-align: left !important;
    box-sizing: border-box !important;
}

.temporary-file-message.qchat-file-upload-card .qchat-file-upload-name {
    display: block !important;
    width: 100%;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap !important;
    font-size: 0.84rem;
    line-height: 1.25;
}

.temporary-file-message.qchat-file-upload-card .qchat-file-upload-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-width: 0;
    margin-top: 4px;
    font-size: 0.74rem;
    line-height: 1.15;
}

.temporary-file-message.qchat-file-upload-card .qchat-file-upload-progress {
    position: relative;
    display: block;
    width: 100%;
    height: 6px;
    margin-top: 7px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(100, 116, 139, 0.18);
}

.temporary-file-message.qchat-file-upload-card .qchat-file-upload-progress-bar {
    display: block;
    width: var(--qchat-upload-progress, 0%);
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #0d6efd 0%, #2f8cff 70%, #53a6ff 100%);
    transition: width 180ms ease-out;
    will-change: width;
}

@keyframes qchat-file-upload-indeterminate {
    0% { transform: translateX(-140%); }
    100% { transform: translateX(320%); }
}

.qchat-file-upload-progress.qchat-upload-indeterminate .qchat-file-upload-progress-bar {
    width: 36% !important;
    transition: none !important;
    animation: qchat-file-upload-indeterminate 1.05s ease-in-out infinite;
}

.temporary-file-message.qchat-file-upload-card .qchat-file-upload-status {
    display: block;
    min-width: 0;
    margin-top: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.73rem;
    line-height: 1.2;
}

body.dark-theme .temporary-file-message.qchat-file-upload-card .qchat-file-upload-preview,
[data-bs-theme="dark"] .temporary-file-message.qchat-file-upload-card .qchat-file-upload-preview {
    border-color: rgba(96, 165, 250, 0.20) !important;
    background: rgba(30, 64, 175, 0.10) !important;
}

body.dark-theme .temporary-file-message.qchat-file-upload-card .qchat-file-upload-icon,
[data-bs-theme="dark"] .temporary-file-message.qchat-file-upload-card .qchat-file-upload-icon {
    background: rgba(59, 130, 246, 0.16);
}

body.dark-theme .temporary-file-message.qchat-file-upload-card .qchat-file-upload-progress,
[data-bs-theme="dark"] .temporary-file-message.qchat-file-upload-card .qchat-file-upload-progress {
    background: rgba(148, 163, 184, 0.20);
}

@media (max-width: 575.98px) {
    #messagesContainer .temporary-file-message.qchat-file-upload-card {
        width: 100% !important;
        max-width: 100% !important;
    }

    #messagesContainer .temporary-file-message.qchat-file-upload-card .qchat-file-upload-preview {
        grid-template-columns: 38px minmax(0, 1fr);
        gap: 9px;
        padding: 9px 10px !important;
    }

    #messagesContainer .temporary-file-message.qchat-file-upload-card .qchat-file-upload-icon {
        width: 38px !important;
        height: 38px !important;
        min-width: 38px !important;
        font-size: 18px !important;
    }
}

/* Multi-file temporary bundles reuse the same staged progress language without
 * replacing their attachment grid. */
.qchat-file-bundle-upload-state {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin-top: 8px;
    padding: 0 2px 2px;
    box-sizing: border-box;
}

.qchat-file-bundle-upload-state .qchat-file-upload-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-width: 0;
    font-size: 0.74rem;
    line-height: 1.15;
}

.qchat-file-bundle-upload-state .qchat-file-upload-progress {
    position: relative;
    display: block;
    width: 100%;
    height: 6px;
    margin-top: 7px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(100, 116, 139, 0.18);
}

.qchat-file-bundle-upload-state .qchat-file-upload-progress-bar {
    display: block;
    width: var(--qchat-upload-progress, 0%);
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #0d6efd 0%, #2f8cff 70%, #53a6ff 100%);
    transition: width 180ms ease-out;
    will-change: width;
}

.qchat-file-bundle-upload-state .qchat-file-upload-status {
    margin-top: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.73rem;
    line-height: 1.2;
}

body.dark-theme .qchat-file-bundle-upload-state .qchat-file-upload-progress,
[data-bs-theme="dark"] .qchat-file-bundle-upload-state .qchat-file-upload-progress {
    background: rgba(148, 163, 184, 0.20);
}


/* v343: QChat-owned image context menu. This intentionally replaces the
 * browser image menu inside QChat viewers so Copy uses the native-MIME
 * clipboard path instead of Chrome's JPEG/WebP -> PNG conversion. */
#qchatImageContextMenu.qchat-image-context-menu {
    position: fixed;
    z-index: 2147483646;
    display: none;
    width: max-content;
    min-width: 210px;
    max-width: min(320px, calc(100vw - 16px));
    padding: 6px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 10px;
    background: rgba(20, 24, 31, 0.98);
    color: #f8f9fa;
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.42);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    user-select: none;
}

#qchatImageContextMenu.qchat-image-context-menu.show {
    display: block;
}

#qchatImageContextMenu .qchat-image-context-action {
    display: flex;
    width: 100%;
    min-height: 38px;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: inherit;
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
}

#qchatImageContextMenu .qchat-image-context-action:hover,
#qchatImageContextMenu .qchat-image-context-action:focus-visible {
    outline: none;
    background: rgba(13, 110, 253, 0.24);
}

#qchatImageContextMenu .qchat-image-context-action:disabled {
    opacity: 0.6;
    cursor: wait;
}

#qchatImageContextMenu .qchat-image-context-action > i {
    width: 18px;
    flex: 0 0 18px;
    text-align: center;
    color: #78adff;
}
