.message-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.message-attachment-card {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    max-width: 280px;
}

.message.user .message-attachment-card {
    background: #eff6ff;
    border-color: #bfdbfe;
}

.message-attachment-card-clickable {
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.message-attachment-card-clickable:hover {
    background: #e5e7eb;
    border-color: #d1d5db;
}

.message.user .message-attachment-card-clickable:hover {
    background: #dbeafe;
    border-color: #93c5fd;
}

.message-attachment-card-clickable:focus {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.message-attachment-icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
}

.message-attachment-icon svg {
    width: 1.25em;
    height: 1.25em;
    color: currentColor;
}

.message-attachment-filename {
    flex: 1;
    color: #374151;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Image card with thumbnail */
.message-attachment-card-image {
    flex-direction: column;
    align-items: stretch;
    max-width: 140px;
    padding: 0.25rem;
}

.message-attachment-thumbnail-wrap {
    flex-shrink: 0;
    display: block;
    width: 100%;
    /* aspect-ratio: 1; */
    border-radius: 0.375rem;
    overflow: hidden;
    background: #e5e7eb;
}

.message-attachment-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 0.375rem;
    animation: message-attachment-fade-in 0.3s ease-out;
}

.message-attachment-card-image .message-attachment-filename {
    font-size: 0.7rem;
    margin-top: 0.25rem;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Skeleton while loading attachments */
.message-attachment-card-loading .message-attachment-icon,
.message-attachment-card-loading .message-attachment-skeleton {
    opacity: 0.7;
}

.message-attachment-skeleton {
    flex-shrink: 0;
    display: block;
    width: 100%;
    aspect-ratio: 1;
    border-radius: 0.375rem;
    background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
    background-size: 200% 100%;
    animation: message-attachment-skeleton-pulse 1.5s ease-in-out infinite;
}

.message.user .message-attachment-skeleton {
    background: linear-gradient(90deg, #dbeafe 25%, #eff6ff 50%, #dbeafe 75%);
    background-size: 200% 100%;
}

@keyframes message-attachment-skeleton-pulse {
    0%, 100% { background-position: 200% 0; }
    50% { background-position: -200% 0; }
}

@keyframes message-attachment-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.message-attachment-open {
    flex-shrink: 0;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    color: #2563eb;
    background: transparent;
    border: 1px solid #93c5fd;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.message-attachment-open:hover:not(:disabled) {
    background: #2563eb;
    color: #fff;
}

.message-attachment-open:disabled {
    color: #9ca3af;
    border-color: #e5e7eb;
    cursor: default;
}

/* File content modal */
.file-content-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.file-content-modal-overlay.open {
    display: flex;
}

.file-content-modal {
    background: #fff;
    border-radius: 0.75rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.file-content-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e5e7eb;
}

.file-content-modal-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #111827;
}

.file-content-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: #6b7280;
    cursor: pointer;
    padding: 0.25rem;
}

.file-content-modal-close:hover {
    color: #111827;
}

.file-content-modal-body {
    flex: 1;
    overflow: auto;
    margin: 0;
    padding: 1rem 1.25rem;
    font-size: 0.875rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    color: #374151;
}

/* File viewer modal (PDF / image via URL) */
.file-viewer-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.file-viewer-modal-overlay.open {
    display: flex;
}

.file-viewer-modal {
    background: #fff;
    border-radius: 0.75rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    width: 90vw;
    max-width: 900px;
    height: 85vh;
    max-height: 800px;
    display: flex;
    flex-direction: column;
}

.file-viewer-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.file-viewer-modal-title {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 600;
    color: #111827;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-viewer-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: #6b7280;
    cursor: pointer;
    padding: 0.25rem;
    flex-shrink: 0;
}

.file-viewer-modal-close:hover {
    color: #111827;
}

.file-viewer-modal-body {
    flex: 1;
    overflow: auto;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    min-height: 0;
}

.file-viewer-iframe {
    width: 100%;
    height: 100%;
    min-height: 400px;
    border: none;
}

.file-viewer-text {
    width: 100%;
    height: 100%;
    min-height: 200px;
    margin: 0;
    padding: 1rem;
    overflow: auto;
    font-size: 0.875rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    background: #f9fafb;
    border-radius: 0.25rem;
}

.file-viewer-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.file-viewer-download {
    padding: 1rem;
    color: #2563eb;
    text-decoration: underline;
}

