/* Stock history: the Stock History tab and an item's history window (js/stock-history.js).
   Plain cards and tables on the shared colour tokens, so dark mode follows them. */

.stock-history-range {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px 16px;
    margin: 12px 0;
}

.stock-history-dates {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.stock-history-dates label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
    color: var(--text-secondary);
}

.stock-history-dates input[type="date"] {
    min-width: 150px;
}

.stock-history-dates input[type="date"],
.stock-history-search input[type="text"],
.stock-history-filter select {
    padding: 9px 12px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text-primary);
    font: inherit;
    font-size: 14px;
}

[data-theme="dark"] .stock-history-dates input[type="date"],
[data-theme="dark"] .stock-history-filter select {
    color-scheme: dark;
}

.stock-history-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.stock-history-preset {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    min-height: 34px;
}

.stock-history-preset:hover {
    border-color: var(--text-secondary);
}

.stock-history-preset.active {
    background: var(--text-primary);
    border-color: var(--text-primary);
    color: var(--surface);
}

.stock-history-search {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 16px;
    margin-bottom: 12px;
}

.stock-history-search input[type="text"] {
    flex: 1 1 260px;
    max-width: 420px;
}

.stock-history-moved {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
}

.stock-history-cards {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin: 12px 0 16px;
}

.stock-history-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md, 8px);
    background: var(--surface);
}

.stock-history-card span {
    font-size: 13px;
    color: var(--text-secondary);
}

.stock-history-card strong {
    font-size: 20px;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.stock-history-intro {
    margin: 0 0 4px;
    max-width: 70ch;
    color: var(--text-secondary);
    font-size: 14px;
}

.stock-history-table th,
.stock-history-table td,
.stock-history-moves th,
.stock-history-moves td {
    text-align: left;
}

.stock-history-table .numeric,
.stock-history-moves .numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.stock-history-item-name {
    display: block;
    font-weight: 600;
}

.stock-history-item-sku {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
}

.stock-history-item-meta {
    margin: 0 0 4px;
    color: var(--text-secondary);
    font-size: 14px;
}

.stock-history-filter {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.stock-history-filter select {
    max-width: 260px;
}

.stock-history-moves .stock-history-boundary td {
    color: var(--text-secondary);
    background: var(--background);
}

.stock-history-change-in {
    font-weight: 600;
}

.stock-history-move-note {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
}

.stock-history-note {
    margin: 10px 0 0;
    font-size: 13px;
    color: var(--text-secondary);
}

.stock-history-loading {
    color: var(--text-secondary);
}

.stock-history-history-btn {
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 6px);
    background: var(--surface);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}

.stock-history-history-btn:hover {
    border-color: var(--text-secondary);
}

#inventoryStockHistoryBtn[hidden],
.stock-history-note[hidden] {
    display: none;
}

@media (max-width: 768px) {
    .stock-history-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .stock-history-dates input[type="date"] {
        min-width: 0;
        width: 100%;
    }

    .stock-history-dates {
        display: grid;
        grid-template-columns: 1fr 1fr;
        width: 100%;
    }

    .stock-history-search input[type="text"] {
        max-width: none;
    }

    /* The mobile card view right-aligns nothing; keep numbers readable. */
    .stock-history-table.mobile-cards .numeric,
    .stock-history-moves.mobile-cards .numeric {
        text-align: left;
    }

    .stock-history-moves.mobile-cards .stock-history-boundary td:empty {
        display: none;
    }
}
