/* ==========================================================================
   Attachment preview popover (images/javascript/components/attachment_icon.js)
   Hover preview of an attachment. Anchored mode is a small thumbnail under the
   icon; centered mode is a draggable panel that pins to the full document on
   click. Not an app-dialog: it has no backdrop and stays non-modal.
   ========================================================================== */

/* ---------- Anchored (small hover thumbnail) ---------- */

.attachment-preview-popover--anchored {
    position: absolute;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 80px;
    min-height: 60px;
    padding: var(--spacing-xs);
    background: var(--bg-primary);
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    pointer-events: none;
}

.attachment-preview-popover--anchored .attachment-preview-popover__thumb {
    display: block;
    width: auto;
    height: auto;
    max-width: min(400px, 90vw);
    max-height: min(560px, 80vh);
    border-radius: var(--radius-sm);
}

/* ---------- Centered (draggable, pinnable panel) ---------- */

.attachment-preview-popover.attachment-preview-popover--centered {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10000;
    width: min(720px, 92vw);
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-primary);
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    pointer-events: auto;
}

/* JS sets explicit left/top once the panel has been dragged; drop the centring transform. */
.attachment-preview-popover.attachment-preview-popover--positioned {
    transform: none;
}

.attachment-preview-popover.attachment-preview-popover--dragging {
    user-select: none;
    box-shadow: 0 14px 48px rgba(0, 0, 0, 0.28);
}

/* Layout comes from app-dialog__header; this adds the drag handle behaviour. */
.attachment-preview-popover__header {
    justify-content: space-between;
    font-size: var(--font-body-sm-size);
    color: var(--text-secondary);
    cursor: move;
    user-select: none;
}

.attachment-preview-popover__header > * {
    cursor: default;
}

.attachment-preview-popover__header-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    min-width: 0;
}

.attachment-preview-popover__invoice-no {
    font-size: var(--font-body-md-size);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Colour-deficiency palette: paid swaps the green for teal, as in the list views. */
.attachment-preview-popover.color_deficiency .attachment-preview-popover__status-pill[data-status="paid"] {
    --badge-bg: color-mix(in srgb, #009292 14%, var(--bg-primary));
    --badge-fg: #006b6b;
}

.attachment-preview-popover__meta {
    padding: var(--spacing-lg) var(--spacing-lg) 0;
    color: var(--text-primary);
}

.attachment-preview-popover__counterparty {
    display: inline;
    font-size: var(--font-display-sm-size);
    font-weight: var(--font-weight-semibold);
}

.attachment-preview-popover__amount {
    float: right;
    font-size: var(--font-display-sm-size);
    font-weight: var(--font-weight-semibold);
}

.attachment-preview-popover__body {
    flex: 1 1 auto;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-lg);
    overflow: auto;
}

.attachment-preview-popover--centered .attachment-preview-popover__thumb {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 70vh;
}

.attachment-preview-popover__loading {
    width: 6rem;
    height: 6rem;
    background-image: url('../../images/loading/briox_logo_animated.gif');
    background-repeat: no-repeat;
    background-position: center center;
    background-size: contain;
}

.attachment-preview-popover__loading--anchored {
    width: 3rem;
    height: 3rem;
}

.attachment-preview-popover__iframe {
    width: 100%;
    height: 70vh;
    border: 0;
    background: var(--bg-primary);
}

.attachment-preview-popover__pinned-image {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 70vh;
    margin: 0 auto;
}
