/* Documents panel.
 *
 * Every colour, radius and space here is an existing token, not a new value: the panel has to
 * look like it was always part of the product, and a second palette is how AR Recon ended up
 * "almost, but not quite" the rest of the app.
 */

.app-attachments {
    display: flex;
    flex-direction: column;
    gap: var(--ui-space-sm, 8px);
    padding: var(--ui-card-padding, 16px);
    border: 1px solid var(--tbl-border, #bcc3cd);
    border-radius: var(--tbl-radius, 4px);
    background: var(--tbl-surface, #fff);
}

.app-attachments__head {
    display: flex;
    align-items: center;
    gap: var(--ui-space-sm, 8px);
}

.app-attachments__title {
    margin: 0;
    color: var(--tbl-text, #1a2026);
    font-size: var(--ui-font-size, 14px);
    font-weight: 700;
}

/* Same treatment as the filter count, for the same reason: a number that is only worth showing
   when it is not zero. */
.app-attachments__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--tbl-brand, #005c9e);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.app-attachments__count[hidden] { display: none; }

.app-attachments__upload {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--ui-space-sm, 8px);
}

.app-attachments__list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.app-attachments__list[hidden] { display: none; }

.app-attachments__item {
    display: flex;
    align-items: center;
    gap: var(--ui-space-sm, 8px);
    padding: var(--ui-space-xs, 6px) var(--ui-space-sm, 8px);
    border: 1px solid var(--tbl-row-line, #d8dde4);
    border-radius: var(--tbl-radius, 4px);
    background: var(--tbl-surface, #fff);
}

.app-attachments__item:hover { background: var(--app-surface-muted, #f0f2f5); }

.app-attachments__name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    color: var(--tbl-brand, #005c9e);
    font-size: var(--ui-small-font-size, 12px);
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-attachments__meta {
    flex: 0 0 auto;
    color: var(--tbl-text-muted, #6b7a8a);
    font-size: var(--ui-small-font-size, 12px);
    font-variant-numeric: tabular-nums;
}

.app-attachments__remove {
    flex: 0 0 auto;
    width: var(--ui-control-height-sm, 24px);
    height: var(--ui-control-height-sm, 24px);
    padding: 0;
    border: 1px solid var(--tbl-border, #bcc3cd);
    border-radius: var(--tbl-radius, 4px);
    background: var(--tbl-surface, #fff);
    color: var(--tbl-text-secondary, #3d4a5a);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
}

.app-attachments__remove:hover {
    border-color: var(--tbl-danger, #b1302a);
    color: var(--tbl-danger, #b1302a);
}

/* ---- view in place ------------------------------------------------------- */

.app-attachments__view {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--ui-control-height-sm, 24px);
    height: var(--ui-control-height-sm, 24px);
    flex: 0 0 auto;
    padding: 0;
    border: 1px solid var(--tbl-border, #bcc3cd);
    border-radius: var(--tbl-radius, 4px);
    background: var(--tbl-surface, #fff);
    color: var(--tbl-text-secondary, #3d4a5a);
    cursor: pointer;
}

.app-attachments__view:hover,
.app-attachments__view:focus-visible {
    border-color: var(--tbl-brand, #005c9e);
    color: var(--tbl-brand, #005c9e);
}

.app-attachments__view svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* The dialog is the shared one, so it is already bounded by the window with a scrolling body
   and a fixed header. What it needs on top is a body that gives all of its height to the
   document being shown. */
.app-attachments-viewer__dialog {
    height: calc(100vh - 2rem);
}

.app-attachments-viewer__body {
    display: flex;
    padding: 0;
    background: var(--app-surface-muted, #f0f2f5);
}

.app-attachments-viewer__frame {
    flex: 1 1 auto;
    width: 100%;
    border: 0;
}

/* Fits the pane and keeps its proportions; a scanned invoice is portrait and a photo is not. */
.app-attachments-viewer__img {
    margin: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.app-attachments-viewer__title {
    margin: 0;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: var(--ui-font-size, 14px);
    font-weight: 700;
}

.app-attachments-viewer__download {
    flex: 0 0 auto;
    margin-inline-start: auto;
    padding: 4px 10px;
    border: 1px solid var(--tbl-border, #bcc3cd);
    border-radius: var(--tbl-radius, 4px);
    color: var(--tbl-brand, #005c9e);
    font-size: var(--ui-small-font-size, 12px);
    font-weight: 600;
    text-decoration: none;
}
