/* ── Trigger ─────────────────────────────────────────────────── */

.file-manager-trigger {
    position: relative;
    display: flex;
    width: 100%;
    height: 100%;
    align-items: flex-end;
    justify-content: center;
    gap: 6px;
    padding: 4px 10px;
    border: 1px dashed #ccc;
    border-radius: 6px;
    cursor: pointer;
    background-color: #fafafa;
    font-size: 0.8rem;
    color: #888;
    transition: border-color 0.2s, color 0.2s, background-color 0.2s;
    user-select: none;
}

.file-manager-trigger:hover {
    border-color: #6c757d;
    color: #333;
    background-color: #f0f0f0;
}

.file-manager-trigger-caption {
    position: absolute;
    top: 4px;
    left: 6px;
    padding: 1px 6px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #555;
    background-color: rgba(255, 255, 255, 0.85);
    border-radius: 3px;
    pointer-events: none;
}

/* Thumbnail shown inside the trigger when a file exists */
.file-manager-trigger-thumb {
    width: 100%;
    max-height: 200px;
    border-radius: 4px;
    object-fit: contain;
    display: block;
}


/* ── Modal chrome ────────────────────────────────────────────── */

.file-manager-modal-dialog {
    /* Shrink-wrap around the file content, but never overflow the viewport. */
    width: fit-content;
    max-width: min(90vw, 800px);
}

.file-manager-modal-header {
    padding: 0.55rem 1rem;
    border-bottom: 1px solid #e9ecef;
}

.file-manager-modal-header .modal-title {
    font-size: 0.88rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.file-manager-modal-body {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 12px;
}


/* ── File grid ──────────────────────────────────────────────── */

.file-manager-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* One card per item */
.file-manager-item {
    display: flex;
    flex-direction: column;
    /* Allow the card to shrink so it never overflows the modal. */
    min-width: 0;
}

.file-manager-preview {
    display: block;
    /* Cap both dimensions so large files never escape the modal. */
    max-width: min(75vw, 680px);
    max-height: 65vh;
    border-radius: 6px;
    object-fit: contain;
    background-color: #f4f4f4;
}

/* Delete button sitting below the preview */
.file-manager-remove-btn {
    margin-top: 6px;
    padding: 3px 0;
    font-size: 0.78rem;
    color: #dc3545;
    background: transparent;
    border: 1px solid #dc3545;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}

.file-manager-remove-btn:hover {
    background-color: #dc3545;
    color: #fff;
}


/* ── Read-only modal state ───────────────────────────────────── */
/*
 * Added by updateReadWrite() when the page is in read mode.
 * Hides the Delete button so the modal becomes a pure file viewer —
 * the trigger and grid remain visible.
 */
.fm-read-mode .file-manager-remove-btn {
    display: none !important;
}
