/* .cstm-upload and .imgprev come from the global stylesheet; only the trigger
 * needs rules here — it had no hit area or focus affordance before. */
.mc-file-field-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--textColor);
}

/* For call sites that drop the field into a fixed-size box. */
.mc-file-field--fill,
.mc-file-field--fill .cstm-upload,
.mc-file-field--fill .mc-file-field-trigger {
    width: 100%;
    height: 100%;
}

.mc-file-field-trigger:hover {
    background-color: var(--field-bg-disabled);
}

/* The input is hidden, so draw the focus ring on the visible label. */
.cstm-upload input[type="file"]:focus-visible + .mc-file-field-trigger {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

.cstm-upload input[type="file"]:disabled + .mc-file-field-trigger {
    opacity: .5;
    cursor: not-allowed;
}

/* variant="card": a full-width preview panel, e.g. Maps' floorplan. The image
 * is letterboxed (contain), since a cropped floorplan hides its edges. */
.mc-file-card {
    position: relative;
    width: 100%;
    /* Capped so the panel stays compact in wide columns (View spans the modal). */
    max-width: 280px;
}

.mc-file-card > input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
}

.mc-file-card-preview {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 150px;
    margin: 0;
    padding: 6px;
    overflow: hidden;
    border: 1.5px dashed var(--deepBorder);
    border-radius: 10px;
    background-color: var(--lightBG);
    cursor: pointer;
    transition: border-color .2s ease, box-shadow .2s ease;
}

/* Doubled class so it outranks the global `.mc-user-modal img` avatar rule
 * (margin-top: -45px, 100px circle, border), which lifted the image above the
 * panel's top edge inside the Maps modals. */
.mc-file-card .mc-file-card-preview img {
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    border: 0;
    object-fit: contain;
    border-radius: 6px;
}

/* Two (or more) images picked at once: separate boxes side by side instead of
 * one shared panel, each its own `.mc-file-card-preview` picker target. */
.mc-file-card-preview-grid {
    display: flex;
    width: 100%;
    gap: 8px;
}

/* Each box plus its own file name / caption underneath. */
.mc-file-card-slot {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1 1 0;
    min-width: 0;
}

.mc-file-card-slot-name {
    font-size: 12px;
    color: var(--textColor);
}

/* Marks the box the map tooltip will show. */
.mc-file-card .mc-file-card-preview.is-featured {
    border-style: solid;
    border-color: var(--primaryHEX);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primaryHEX) 12%, transparent);
}

/* A pill centred under the featured box, kept to one line (full text in the
 * title) so it doesn't wrap into a ragged two-line caption in narrow slots. */
.mc-file-card-badge {
    align-self: center;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: 100%;
    margin-top: 4px;
    padding: 3px 10px 3px 8px;
    border-radius: 999px;
    font-size: 11.5px;
    line-height: 1.3;
    font-weight: 600;
    color: var(--primaryHEX);
    background-color: color-mix(in srgb, var(--primaryHEX) 12%, transparent);
}

.mc-file-card-badge .material-icons {
    flex-shrink: 0;
    font-size: 14px;
}

.mc-file-card-badge-text {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* Sits in the gap between two filled boxes and swaps their order. Slots can
 * differ in height (captions), so it's centred on the 150px boxes by margin. */
.mc-file-card-preview-grid {
    align-items: flex-start;
}

.mc-file-card-swap {
    flex: 0 0 auto;
    margin-top: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid var(--deepBorder);
    border-radius: 50%;
    color: var(--primaryHEX);
    background-color: var(--lightBG);
    cursor: pointer;
    transition: border-color .2s ease, box-shadow .2s ease;
}

.mc-file-card-swap .material-icons {
    font-size: 18px;
}

.mc-file-card-swap:hover {
    border-color: var(--primaryHEX);
    box-shadow: 0 0 0 3px rgba(var(--primaryRGB), .12);
}

.mc-file-card-swap:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

.mc-file-card-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    line-height: 1;
    font-size: 16px;
    color: #fff;
    background-color: rgba(0, 0, 0, .55);
    cursor: pointer;
    z-index: 1;
}

.mc-file-card-remove:hover {
    background-color: rgba(0, 0, 0, .75);
}

.mc-file-card-preview:hover {
    border-color: var(--primaryHEX);
    box-shadow: 0 0 0 3px rgba(var(--primaryRGB), .12);
}

.mc-file-card > input[type="file"]:focus-visible + .mc-file-card-preview {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

.mc-file-card-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--textColor);
    opacity: .75;
    text-align: center;
}

.mc-file-card-empty .material-icons {
    font-size: 28px;
    color: var(--primaryHEX);
}

/* Fades in over a picked image, so it's clear the panel can be clicked again.
 * pointer-events: none so a remove button drawn on top of it stays clickable. */
.mc-file-card-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    background-color: rgba(0, 0, 0, .45);
    opacity: 0;
    transition: opacity .2s ease;
    pointer-events: none;
}

.mc-file-card-overlay .material-icons {
    font-size: 24px;
}

.mc-file-card-preview:hover .mc-file-card-overlay,
.mc-file-card > input[type="file"]:focus-visible + .mc-file-card-preview .mc-file-card-overlay {
    opacity: 1;
}

.mc-file-card-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 6px;
    font-size: 12px;
    color: var(--textColor);
}

.mc-file-card-name {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-weight: 600;
}

.mc-file-card-hint {
    flex-shrink: 0;
    margin-left: auto;
    opacity: .7;
}

/* With no file name beside it (e.g. names shown per box), the hint reads as a
 * caption for the whole field, so it starts at the left edge with the boxes. */
.mc-file-card-hint:only-child {
    margin-left: 0;
}

.mc-file-card-preview-grid + .mc-file-card-meta {
    margin-top: 10px;
}

.mc-file-card.is-error .mc-file-card-preview {
    border-color: var(--tone-danger-fg);
}

.mc-file-card.is-disabled .mc-file-card-preview {
    border-style: solid;
    cursor: default;
}

.mc-file-card.is-disabled .mc-file-card-preview:hover {
    border-color: var(--deepBorder);
    box-shadow: none;
}

/* A muted aside inside a field label, e.g. "(You can upload up to 2 images)". */
.mc-label-field-title .mc-label-field-note {
    font-size: 12px;
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
    opacity: .7;
}
