/* Library, gallery, image viewer, chat images, moderation badges. */

.retention-notice {
    margin: 1rem 0;
    padding: 0.75rem 1rem;
    border-left: 4px solid var(--color-warning, #ffc107);
    background: var(--light-color, #f8f9fa);
    font-size: 0.9rem;
}
.retention-notice a { margin-left: 0.5rem; }

.dashboard-section-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem 1rem;
}
.dashboard-section-header h2 { margin-right: auto; }

.badge {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: var(--border-radius, 0.25rem);
    font-size: 0.75rem;
    font-weight: normal;
    vertical-align: middle;
    white-space: nowrap;
}
.badge-review { background: var(--color-warning, #ffc107); color: var(--color-black, #000); }

button.danger { color: var(--color-danger, #dc3545); }

.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 0.5rem;
    box-sizing: border-box;
    color: var(--secondary-color, #6c757d);
    font-size: 0.8rem;
    text-align: center;
}

/* Library */
.library-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 1rem; }
.library-item {
    display: grid;
    grid-template-columns: 8rem 1fr;
    gap: 1rem;
    padding: 0.75rem;
    border: 1px solid var(--color-left-aside, #dcdcdc);
    border-radius: var(--border-radius, 0.25rem);
}
.library-preview {
    display: block;
    width: 8rem;
    aspect-ratio: 1 / 1.414;
    overflow: hidden;
    background: var(--color-white, #fff);
    border: 1px solid var(--color-left-aside, #dcdcdc);
}
.library-preview img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.library-body h3 { margin: 0 0 0.25rem; }
.library-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; }
.library-attachments { margin: 0.25rem 0 0; padding-left: 1.25rem; }
.library-item.is-under-review { opacity: 0.75; }

/* Gallery */
.gallery-grid {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
    gap: 0.75rem;
}
.gallery-item { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.gallery-thumb {
    display: block;
    width: 100%;
    aspect-ratio: 1;
    padding: 0;
    border: 1px solid var(--color-left-aside, #dcdcdc);
    border-radius: var(--border-radius, 0.25rem);
    background: repeating-conic-gradient(#eee 0% 25%, #fff 0% 50%) 50% / 16px 16px;
    overflow: hidden;
    cursor: zoom-in;
}
.gallery-thumb:disabled { cursor: not-allowed; background: var(--light-color, #f8f9fa); }
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-name { font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gallery-grid .empty, .library-list .empty { color: var(--secondary-color, #6c757d); }

/* Image viewer */
.image-viewer-figure { margin: 0 0 1rem; text-align: center; }
.image-viewer-figure img {
    max-width: 100%;
    max-height: 60vh;
    background: repeating-conic-gradient(#eee 0% 25%, #fff 0% 50%) 50% / 16px 16px;
}
.image-viewer-figure figcaption { font-size: 0.8rem; color: var(--secondary-color, #6c757d); }
.image-viewer-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
/* `display: flex` above would otherwise defeat the hidden attribute (the Delete row stayed visible to non-owners). */
.image-viewer [hidden] { display: none !important; }
.image-viewer-row input { flex: 1 1 12rem; }
.image-viewer-dropzone.dropzone { min-height: 0; padding: 0.75rem; margin-top: 1rem; }
.image-viewer-dropzone .dz-message { margin: 0.5rem 0; }
#image-viewer footer { display: flex; justify-content: center; gap: 1.5rem; align-items: center; }

/* Upload picker */
.upload-picker [hidden] { display: none !important; }
.upload-picker-tabs { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.upload-picker-tabs [role=tab] { opacity: 0.6; }
.upload-picker-tabs [role=tab][aria-selected=true] { opacity: 1; font-weight: 600; }

/* Embedded in a page (the paper editor's side panel): small icon tabs and a tighter grid. */
.upload-picker-icon-tabs { gap: 0.4rem; margin-bottom: 0.75rem; }
.upload-picker-icon-tabs [role=tab] {
    width: 2.1rem;
    height: 2.1rem;
    padding: 0.4rem;
    border: 1px solid var(--color-left-aside, #cfd6e4);
    border-radius: var(--border-radius, 0.5rem);
    background: var(--light-color, #f8faff);
    color: var(--secondary-color, #4f5f80);
    cursor: pointer;
    opacity: 1;
}
.upload-picker-icon-tabs [role=tab][aria-selected=true] {
    background: #e8f0ff;
    border-color: #9fb6e4;
    color: var(--color-link, #2b6de0);
}
.upload-picker-icon-tabs svg { display: block; width: 100%; height: 100%; }
.upload-picker-inline .upload-picker-grid { grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr)); max-height: 40vh; }
.upload-picker-inline #upload-picker-status:empty { display: none; }
.upload-picker-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr));
    gap: 0.5rem;
    max-height: 50vh;
    overflow-y: auto;
}
.upload-picker-item { margin: 0; min-width: 0; }
.upload-picker-item label {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin: 0;
    padding: 0.25rem;
    border: 2px solid transparent;
    border-radius: var(--border-radius, 0.25rem);
    cursor: pointer;
}
.upload-picker-item.is-selected label { border-color: var(--color-link, #007bff); background: var(--light-color, #f8f9fa); }
.upload-picker-item input[type=checkbox] { position: absolute; top: 0.5rem; left: 0.5rem; margin: 0; width: 1.1rem; height: 1.1rem; }
.upload-picker-item img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--light-color, #f8f9fa); }
.upload-picker-name { font-size: 0.75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-picker-empty { color: var(--secondary-color, #6c757d); }
.upload-picker-link-form { display: grid; gap: 0.5rem; }
.upload-picker-link-form small { color: var(--secondary-color, #6c757d); }
.image-viewer-link-info { margin: 0.75rem 0 0; font-size: 0.85rem; color: var(--secondary-color, #6c757d); overflow-wrap: anywhere; }

/* Linked (external) images carry a small link badge wherever their thumbnail is shown. */
.gallery-item.is-link .gallery-thumb,
.upload-picker-item.is-link img { position: relative; }
.gallery-item.is-link .gallery-thumb::after,
.message-image.is-link::after,
.upload-picker-item.is-link label::before {
    content: "\1F517";
    position: absolute;
    right: 0.3rem;
    bottom: 0.3rem;
    padding: 0.05rem 0.3rem;
    border-radius: 0.6rem;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 0.7rem;
    line-height: 1.3;
    pointer-events: none;
}
.upload-picker-item.is-link label::before { bottom: auto; top: 0.4rem; right: 0.4rem; z-index: 1; }
.upload-picker-dropzone.dropzone { min-height: 0; padding: 1.5rem 0.75rem; }
#upload-picker footer { display: flex; justify-content: flex-end; gap: 1rem; align-items: center; }

/* Upload errors (UploadDropzone): stay until dismissed */
.upload-errors { list-style: none; margin: 0.5rem 0 0; padding: 0; display: grid; gap: 0.25rem; }
.upload-errors:empty { display: none; }
.upload-error {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    border-left: 3px solid var(--color-danger, #dc3545);
    background: #fff4f5;
    color: #8f2d37;
    font-size: 0.85rem;
    overflow-wrap: anywhere;
}
.upload-error span { flex: 1 1 auto; }
.upload-error-dismiss {
    flex: none;
    border: none;
    background: none;
    padding: 0 0.25rem;
    font-size: 1rem;
    line-height: 1;
    color: inherit;
    cursor: pointer;
}

/* Chat */
.message-image {
    display: block;
    position: relative;
    width: fit-content;
    max-width: 100%;
    margin: 0.25rem 0;
    padding: 0;
    border: none;
    background: none;
    cursor: zoom-in;
}
.message-image img { max-width: min(18rem, 100%); max-height: 14rem; border-radius: var(--border-radius, 0.25rem); }
.message-image img.image-failed { min-width: 6rem; min-height: 3rem; opacity: 0.4; background: rgba(128, 128, 128, 0.15); }
.message-under-review { color: var(--secondary-color, #6c757d); font-style: italic; }
.report-button { opacity: 0.5; }
.report-button:hover { opacity: 1; }
/* Already reported by this user: stays lit so it is clear the report went through. */
.report-button.is-reported,
#image-viewer-report.is-reported {
    opacity: 1;
    color: var(--color-danger, #dc3545);
    cursor: default;
}
.chat-attach {
    align-self: center;
    border: none;
    background: none;
    padding: 0 0.25rem;
    font-size: 1.25rem;
    cursor: pointer;
}
/* main.css positions every chat form button absolutely (for the send button). */
#chat-container form .chat-attach {
    position: static;
    transform: none;
    padding: 0 0.25rem;
    background: none;
}
#message-form.dz-drag-hover { outline: 2px dashed var(--primary-color, #007bff); outline-offset: 2px; }
.chat-upload-previews { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chat-upload-previews:empty { display: none; }
.chat-upload-previews .dz-preview { margin: 0.25rem 0 0; }
