/* The price list shares its look with the External Image Portal (/missing-resources):
   wine header bar, one card for the filters, and the table as its own scroll
   pane so the column headers stay put while a long list is read. */
:root {
    --wine: #5a002c;
    --wine-soft: #5a002c14;
    --line: #e3e0e2;
    --ink: #1d1a1c;
    --muted: #6b6469;
    --ok: #1f7a3d;
    --bad: #a3242b;
    color-scheme: light;
}

* { box-sizing: border-box; }
/* The option rows and the find box set their own display, which would beat the
   browser's own rule for [hidden] and leave filtered-out rows on screen. */
[hidden] { display: none !important; }

body {
    margin: 0;
    font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--ink);
    background: #faf8f9;
}

a { color: var(--wine); }

header {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 12px;
    padding: 14px 20px;
    background: var(--wine);
    color: #fff;
}
header h1 { font-size: 18px; margin: 0; font-weight: 600; }
header a { color: #fff; }

.chip {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #ffffff26;
    white-space: nowrap;
}
.spacer { flex: 1; }

main { padding: 0 20px; }

/* Filters -------------------------------------------------------------- */

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin: 14px 0;
    padding: 12px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.filters .search { display: flex; align-items: stretch; }
.filters .search input[type=search] {
    font: inherit;
    padding: 6px 10px;
    min-width: 260px;
    border: 1px solid var(--line);
    border-right: none;
    border-radius: 5px 0 0 5px;
    background: #fff;
    outline: none;
}
.filters .search input[type=search]:focus { border-color: var(--wine); }
.filters .search button { border-radius: 0 5px 5px 0; }

.filters select {
    font: inherit;
    padding: 6px 8px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
    max-width: 220px;
}

/* Multi-select filters: a <details> per filter, the summary as its button and
   the checkboxes in a panel that drops below it. */
.ms { position: relative; }
.ms summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: #fff;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.ms summary::-webkit-details-marker { display: none; }
.ms summary::after {
    content: "";
    margin-left: auto;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--muted);
}
.ms[open] summary::after { border-top: none; border-bottom: 5px solid var(--muted); }
.ms[open] summary,
.ms summary:focus-visible { border-color: var(--wine); outline: none; }
/* A filter that is actually narrowing the list is tinted, so a stale selection
   further along the bar is visible without opening every panel. */
.ms.on summary { background: var(--wine-soft); border-color: var(--wine); }
.ms .count {
    display: inline-grid;
    place-items: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--wine);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
}

.ms .panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 4; /* over the table's sticky header, under the page's */
    width: 260px;
    padding: 8px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 8px 24px #1d1a1c26;
}
.ms .panel.flip { left: auto; right: 0; }
.ms .find {
    width: 100%;
    margin-bottom: 6px;
    font: inherit;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 5px;
    outline: none;
}
.ms .find:focus { border-color: var(--wine); }
.ms .opts { max-height: 280px; overflow-y: auto; overscroll-behavior: contain; }
.ms .opts label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 6px;
    border-radius: 4px;
    cursor: pointer;
}
.ms .opts label:hover { background: var(--wine-soft); }
.ms .opts input { margin: 0; flex: none; accent-color: var(--wine); }
.ms .none { margin: 8px 6px; color: var(--muted); }
.ms .actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--line);
}

/* Applied filters: the shop's chip row, one chip per value, each one a link to
   the list without it. */
.applied {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: -4px 0 14px;
}
.applied .label { color: var(--muted); font-weight: 500; margin-right: 4px; }
.fchip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px 3px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    color: var(--ink);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}
.fchip .x { font-size: 16px; line-height: 1; color: var(--muted); }
.fchip:hover { border-color: var(--wine); }
.fchip:hover .x { color: var(--wine); }
.clear-all { margin-left: 4px; font-size: 13px; }

button, .btn {
    font: inherit;
    padding: 6px 12px;
    border-radius: 5px;
    border: 1px solid var(--line);
    background: #fff;
    cursor: pointer;
    text-decoration: none;
    color: var(--ink);
    white-space: nowrap;
}
button.primary { background: var(--wine); border-color: var(--wine); color: #fff; }
button:hover, .btn:hover { filter: brightness(0.97); }

/* Table ---------------------------------------------------------------- */

/* Its own scroll pane, so the column header pins to the top of the table.
   Offsetting it against the page header instead does not work: overflow makes
   this wrapper the sticky containing block, and the offset then pushes the
   header that far down inside the table. */
.table-wrap {
    overflow: auto;
    max-height: max(320px, calc(100vh - 220px));
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
}

table { border-collapse: collapse; width: 100%; font-size: 13px; }

thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--wine);
    color: #fff;
    text-align: left;
    white-space: nowrap;
    padding: 0;
    font-weight: 600;
}
/* The whole header cell is the sort link: a plain anchor rather than an onclick,
   so the column can be opened in a new tab and reached from the keyboard. */
thead th a {
    display: block;
    padding: 9px 12px;
    color: #fff;
    text-decoration: none;
}
thead th a:hover { background: #ffffff1f; }

td { padding: 8px 12px; border-top: 1px solid var(--line); vertical-align: middle; }
tbody tr:nth-child(even) { background: #fbfafb; }
tbody tr:hover { background: var(--wine-soft); }

td.name { min-width: 260px; font-weight: 500; }
th:first-child { min-width: 260px; }

/* Columns 6, 7 and 9-11 are Bottle Size, Case Size and the money/quantity
   columns. They are numbers, so they line up on the right with tabular figures.
   The order is the one in tableData.Headers. */
tbody td:nth-child(6),
tbody td:nth-child(7),
tbody td:nth-child(9),
tbody td:nth-child(10),
tbody td:nth-child(11),
thead th:nth-child(6) a,
thead th:nth-child(7) a,
thead th:nth-child(9) a,
thead th:nth-child(10) a,
thead th:nth-child(11) a {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
tbody td:nth-child(9),
tbody td:nth-child(10) { white-space: nowrap; }

.arrow {
    display: none;
    width: 0;
    height: 0;
    margin-left: 5px;
    vertical-align: middle;
}
.arrow-up {
    display: inline-block;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 5px solid white;
}
.arrow-down {
    display: inline-block;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid white;
}

.badge {
    display: inline-block;
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 999px;
    background: #eee;
    color: var(--muted);
    white-space: nowrap;
}
.badge.dp { background: #eaf6ee; color: var(--ok); }
.badge.ib { background: var(--wine-soft); color: var(--wine); }

.muted { color: var(--muted); }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* Pager ---------------------------------------------------------------- */

.pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 14px 0;
    color: var(--muted);
}
.pager .spacer { flex: 1; }
.pager .page { padding: 6px 10px; }
.pager .page.active {
    background: var(--wine);
    border-color: var(--wine);
    color: #fff;
}

/* Footer --------------------------------------------------------------- */

footer {
    /* Pulled up over the pager's own bottom margin: the credit line belongs with
       the table, not floating in the page's trailing whitespace. */
    margin-top: -42px;
    padding: 4px 20px 24px;
    text-align: center;
    font-size: 12px;
    color: var(--muted);
}
footer a { color: var(--muted); text-decoration: none; }
footer a:hover { color: var(--wine); text-decoration: underline; }

@media (max-width: 700px) {
    main { padding: 0 12px; }
    footer { padding: 4px 12px 20px; }
    .filters { gap: 6px; position: relative; }
    .filters .search { width: 100%; }
    .filters .search input[type=search] { min-width: 0; flex: 1; }
    .filters select { flex: 1 1 140px; max-width: none; }
    /* The panel spans the filter card instead of hanging off a button half its
       width: the card is the positioned box, the panel keeps its place below
       the button it belongs to. */
    .ms { position: static; flex: 1 1 140px; }
    .ms .panel,
    .ms .panel.flip { top: auto; left: 12px; right: 12px; width: auto; margin-top: 4px; }
}
