/* Kit maker (/kits). Inventory sizes are multiples of --km-cell, one Unturned inventory cell. */

:root {
    --page-bg: url(/img/backgrounds/background-pricelist.webp);
}

.km {
    --km-cell: 44px;
}

/* Unturned's rarity colours (ItemTool.getRarityColorUI), common toned down for a dark page. */
.r0 { --rarity: #a3a3a3; }
.r1 { --rarity: #2fa82f; }
.r2 { --rarity: #4b64fa; }
.r3 { --rarity: #964bfa; }
.r4 { --rarity: #c832fa; }
.r5 { --rarity: #fa3219; }

/* ===== Toolbar ===== */

.km-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}

.km-title {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
}

.km-title h2 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 900;
    letter-spacing: 0.01em;
}

.km-map-select {
    width: auto;
    min-width: 150px;
}

/* Quiet buttons: icon plus a short word. */
.km-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border: 1px solid var(--ub-border);
    background: rgba(255, 255, 255, 0.04);
    color: #d6d6d6;
}

.km-btn:hover,
.km-btn:focus-visible {
    border-color: var(--ub-border-strong);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.km-btn-icon {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.km-toolbar .dropdown-menu {
    font-size: 0.85rem;
}

/* ===== Layout ===== */

.km-layout {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr) 340px;
    gap: 0.75rem;
    align-items: start;
}

.km-panel {
    background: rgba(18, 18, 18, 0.9);
    border: 1px solid var(--ub-border);
    border-radius: 0.6rem;
}

.km-panel-title {
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.km-panel-subtitle {
    font-weight: 700;
    font-size: 0.8rem;
    margin: 0.75rem 0 0.4rem;
}

.km-side {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.km-side > .km-panel {
    padding: 0.75rem;
}

@media (max-width: 1399.98px) {
    .km {
        --km-cell: 40px;
    }

    .km-layout {
        grid-template-columns: 290px minmax(0, 1fr) 310px;
    }
}

@media (max-width: 1199.98px) {
    .km-layout {
        grid-template-columns: 280px minmax(0, 1fr);
    }

    .km-side {
        grid-column: 1 / -1;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        align-items: start;
    }
}

@media (max-width: 767.98px) {
    .km {
        --km-cell: 34px;
    }

    .km-layout {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ===== Item list ===== */

.km-catalog {
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 70px;
    height: calc(100vh - 150px);
    min-height: 420px;
    overflow: hidden;
}

@media (max-width: 767.98px) {
    .km-catalog {
        position: static;
        height: 60vh;
    }
}

.km-panel-head {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.6rem;
    border-bottom: 1px solid var(--ub-border);
}

.km-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.km-chip {
    font-size: 0.75rem;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    border: 1px solid var(--ub-border-strong);
    background: transparent;
    color: #cfcfcf;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.km-chip:hover {
    background: rgba(255, 255, 255, 0.08);
}

/* "on", not "active": the site's .active forces white text. */
.km-chip.on {
    background: #fff;
    border-color: #fff;
    color: #000;
}

.km-fit {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.5rem;
    border: 1px solid rgba(108, 188, 255, 0.45);
    border-radius: 0.35rem;
    background: rgba(108, 188, 255, 0.08);
    font-size: 0.8rem;
}

.km-fit > i {
    color: var(--ub-blue);
}

.km-fit-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.km-fit .btn-close {
    font-size: 0.6rem;
}

.km-filtering {
    outline: 2px solid var(--ub-blue);
    outline-offset: 2px;
}

[data-drop="worn"]:not(:has(.km-item)),
.km-slot[data-drop="slot"]:not(:has(.km-item)),
.km-attach[data-hook="1"] {
    cursor: pointer;
}

.km-catalog-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.35rem;
}

.km-catalog-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.35rem 0.3rem 0.45rem;
    border-left: 3px solid var(--rarity);
    border-radius: 0.3rem;
    cursor: grab;
    user-select: none;
}

.km-catalog-item:hover,
.km-catalog-item.selected {
    background: rgba(255, 255, 255, 0.06);
}

.km-catalog-item.selected {
    box-shadow: inset 0 0 0 1px var(--ub-border-strong);
}

.km-catalog-visual {
    position: relative;
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.25rem;
    background: rgba(255, 255, 255, 0.04);
    color: var(--rarity);
}

.km-catalog-visual .km-icon {
    max-width: 100%;
    max-height: 100%;
}

.km-catalog-visual .km-glyph {
    position: static;
    font-size: 1.15rem;
    opacity: 0.85;
}

.km-catalog-text {
    min-width: 0;
    flex: 1;
}

.km-catalog-name {
    font-weight: 700;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.km-catalog-meta {
    font-size: 0.72rem;
    color: var(--ub-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* A round button; the circle shows on hover. Scoped to beat .km-icon-btn and .btn. */
.km-catalog-item .km-catalog-add {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.1rem;
    height: 2.1rem;
    padding: 0;
    border-radius: 50%;
    font-size: 1.2rem;
    opacity: 0;
    transition: opacity 0.15s ease, background-color 0.15s ease;
}

.km-catalog-item .km-catalog-add:hover,
.km-catalog-item .km-catalog-add:focus-visible {
    background-color: rgba(255, 255, 255, 0.12);
}

.km-catalog-item .km-catalog-add:active {
    background-color: rgba(255, 255, 255, 0.2);
}

.km-catalog-item:hover .km-catalog-add,
.km-catalog-item:focus-within .km-catalog-add,
.km-catalog-item.selected .km-catalog-add {
    opacity: 1;
}

@media (hover: none) {
    .km-catalog-item .km-catalog-add {
        opacity: 1;
    }
}

.km-loading {
    padding: 1rem;
    text-align: center;
    color: var(--ub-muted);
    font-size: 0.85rem;
}

.km-trash-hint {
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0.6rem;
    border-top: 1px dashed rgba(220, 53, 69, 0.6);
    color: #ea868f;
    font-size: 0.8rem;
}

.km-dragging-kit .km-trash-hint {
    display: flex;
}

.km-catalog.km-drop-ok {
    outline: 2px solid #dc3545;
    outline-offset: -2px;
}

/* ===== Inventory ===== */

.km-inventory {
    padding: 0.75rem;
}

/* Equipment on the left, storage on the right (below it when there isn't room). */
.km-inventory-scroll {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 1rem 1.5rem;
    min-height: 320px;
    padding: 0.25rem;
    border-radius: 0.4rem;
}

.km-inventory-scroll.km-drop-ok {
    background: rgba(108, 188, 255, 0.05);
}

.km-equipment {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex: 0 0 auto;
}

.km-storage {
    flex: 1 1 240px;
    min-width: 240px;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow-x: auto;
}

.km-clothing {
    display: grid;
    grid-template-columns: repeat(4, calc(var(--km-cell) * 2));
    gap: 0.4rem 0.5rem;
}

.km-weapons {
    display: flex;
    flex-direction: column;
}

.km-slot-label {
    font-size: 0.68rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ub-muted);
    margin-bottom: 0.2rem;
}

.km-weapons .km-weapon-row + .km-slot-label {
    margin-top: 0.5rem;
}

.km-weapon-row {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

/* ===== A weapon's attachment slots ===== */

.km-attachments {
    --km-attach: calc(var(--km-cell) - 2px);
    display: grid;
    grid-template-columns: repeat(3, var(--km-attach));
    grid-auto-rows: var(--km-attach);
    gap: 4px;
}

.km-attach {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 9px 2px 2px;
    border: 1px dashed var(--ub-border-strong);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.03);
    color: inherit;
    cursor: pointer;
    user-select: none;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.km-attach-label {
    position: absolute;
    top: 1px;
    left: 3px;
    font-size: 0.5rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ub-muted);
    pointer-events: none;
}

.km-attach.filled {
    border-style: solid;
    border-color: color-mix(in srgb, var(--rarity) 70%, transparent);
    background: color-mix(in srgb, var(--rarity) 16%, rgba(10, 10, 10, 0.75));
    cursor: grab;
}

.km-attach.filled:hover {
    border-color: var(--rarity);
}

.km-attach.locked {
    cursor: default;
}

.km-attach.locked::after {
    content: "\F47A"; /* bi-lock-fill */
    font-family: bootstrap-icons;
    position: absolute;
    right: 2px;
    bottom: 0;
    font-size: 0.55rem;
    color: var(--ub-muted);
}

.km-attach.none {
    cursor: not-allowed;
    opacity: 0.35;
    background: repeating-linear-gradient(45deg, transparent 0 4px, rgba(255, 255, 255, 0.05) 4px 8px);
}

.km-attach .km-icon {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.km-attach .km-glyph {
    font-size: calc(var(--km-cell) * 0.4);
    color: var(--rarity);
    pointer-events: none;
}

.km-attach-count {
    position: absolute;
    right: 2px;
    bottom: 0;
    font-size: 0.55rem;
    font-weight: 700;
    color: var(--ub-gold);
    pointer-events: none;
}

.km-attach-mode {
    font: inherit;
}

.km-attach-mode:not(:disabled):hover {
    border-color: var(--ub-blue);
}

.km-attach-mode:disabled {
    cursor: default;
    opacity: 0.6;
}

.km-attach-mode-name {
    font-size: 0.62rem;
    font-weight: 900;
    text-transform: uppercase;
}

.km-attach.km-drop-ok {
    outline: 2px solid var(--ub-blue);
    outline-offset: 1px;
    background-color: rgba(108, 188, 255, 0.12);
}

.km-slot {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3px;
    border: 1px dashed var(--ub-border-strong);
    border-radius: 0.35rem;
    background: rgba(255, 255, 255, 0.03);
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.km-slot-clothing {
    width: calc(var(--km-cell) * 2);
    height: calc(var(--km-cell) * 2);
}

.km-slot-primary {
    width: calc(var(--km-cell) * 6);
    height: calc(var(--km-cell) * 2.5);
}

.km-slot-secondary {
    width: calc(var(--km-cell) * 4);
    height: calc(var(--km-cell) * 2);
}

.km-slot-hint {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.25);
}

/* Columns of pages; the sizes match PAGE_TITLE and PAGE_GAP in kits.js. */
.km-pages {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.km-page-column {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.km-page {
    min-width: 0;
}

.km-page-title {
    display: flex;
    align-items: baseline;
    gap: 0.35rem;
    height: 20px;
    overflow: hidden;
    font-size: 0.68rem;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.km-page-name {
    font-weight: 700;
    text-transform: uppercase;
    color: #d6d6d6;
}

.km-page-size {
    color: var(--ub-muted);
}

.km-page-item {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--ub-muted);
}

.km-page-hint:empty {
    display: none;
}

.km-dropped-title {
    margin-bottom: 0.35rem;
    font-size: 0.8rem;
    color: var(--bs-warning);
}

/* content-box: the width is exactly the cells, and the border sits outside them. */
.km-grid {
    position: relative;
    box-sizing: content-box;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 2px;
    background-color: rgba(255, 255, 255, 0.025);
    background-image:
        linear-gradient(to right, rgba(255, 255, 255, 0.07) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255, 255, 255, 0.07) 1px, transparent 1px);
    background-size: var(--km-cell) var(--km-cell);
}

.km-grid.km-drop-ok {
    border-color: var(--ub-blue);
    background-color: rgba(108, 188, 255, 0.08);
}

.km-dropped {
    padding: 0.6rem;
    border: 1px dashed rgba(255, 193, 7, 0.5);
    border-radius: 0.4rem;
    background: rgba(255, 193, 7, 0.04);
}

.km-dropped-items {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.km-inventory-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--ub-border);
}

.km-inventory-foot #kmSummary {
    font-size: 0.8rem;
    color: var(--ub-muted);
}

.km-help {
    color: var(--ub-muted);
    cursor: help;
}

.km-help:hover,
.km-help:focus-visible {
    color: #fff;
}

.km-page-hint {
    font-size: 0.78rem;
    color: var(--ub-muted);
}


/* ===== Items in the inventory ===== */

.km-item {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2px;
    overflow: hidden;
    border: 1px solid color-mix(in srgb, var(--rarity) 70%, transparent);
    border-radius: 3px;
    background: color-mix(in srgb, var(--rarity) 16%, rgba(10, 10, 10, 0.75));
    cursor: grab;
    user-select: none;
}

.km-item:hover {
    border-color: var(--rarity);
    background: color-mix(in srgb, var(--rarity) 26%, rgba(10, 10, 10, 0.75));
}

.km-item.selected {
    outline: 2px solid #fff;
    outline-offset: -1px;
    z-index: 1;
}

.km-item-fill,
.km-item-loose {
    position: relative;
    width: 100%;
    height: 100%;
}

.km-item .km-icon {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.km-item.rot .km-icon {
    position: absolute;
    left: 50%;
    top: 50%;
    max-width: none;
    max-height: none;
    transform: translate(-50%, -50%) rotate(90deg);
}

.km-item .km-glyph {
    position: absolute;
    font-size: calc(var(--km-cell) * 0.6);
    color: var(--rarity);
    opacity: 0.22;
    pointer-events: none;
}

.km-item-name {
    position: relative;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
    font-size: 0.62rem;
    font-weight: 700;
    line-height: 1.15;
    text-align: center;
    overflow-wrap: anywhere;
    hyphens: auto;
    pointer-events: none;
}

.km-item-badge {
    position: absolute;
    right: 2px;
    bottom: 1px;
    font-size: 0.65rem;
    color: var(--ub-gold);
    pointer-events: none;
}

.km-ghost {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 2000;
    opacity: 0.9;
    pointer-events: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

body.km-dragging,
body.km-dragging * {
    cursor: grabbing !important;
    user-select: none;
}

.km-can-drop {
    border-color: var(--ub-blue) !important;
    border-style: solid !important;
}

.km-slot.km-drop-ok,
.km-item.km-drop-ok {
    outline: 2px solid var(--ub-blue);
    outline-offset: 1px;
    background-color: rgba(108, 188, 255, 0.12);
}

.km-drop-bad {
    outline: 2px solid #dc3545 !important;
    outline-offset: 1px;
}

/* ===== Kit settings ===== */

.km-settings .form-label {
    font-size: 0.75rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
}

.km-settings .form-text {
    font-size: 0.7rem;
    margin-top: 0.15rem;
}

.km-warnings:not(:empty) {
    margin-top: 0.6rem;
}

.km-warning {
    font-size: 0.78rem;
    margin-top: 0.3rem;
}

/* ===== Item details ===== */

.km-empty-details {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: 1rem 0.5rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--ub-muted);
}

.km-details-head {
    display: flex;
    gap: 0.6rem;
    align-items: center;
}

.km-details-visual {
    flex: 0 0 64px;
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid color-mix(in srgb, var(--rarity) 60%, transparent);
    border-radius: 0.35rem;
    background: color-mix(in srgb, var(--rarity) 14%, transparent);
    color: var(--rarity);
}

.km-details-visual .km-icon {
    max-width: 100%;
    max-height: 100%;
}

.km-details-visual .km-glyph {
    font-size: 1.8rem;
}

.km-details-name {
    font-weight: 900;
    font-size: 1rem;
    line-height: 1.2;
}

.km-details-meta {
    font-size: 0.72rem;
    color: var(--ub-muted);
}

.km-rarity {
    color: var(--rarity);
    font-weight: 700;
}

.km-details-desc {
    margin: 0.6rem 0 0;
    font-size: 0.8rem;
    color: #c9c9c9;
    white-space: pre-line;
}

.km-details-tip {
    margin: 0.6rem 0 0;
    font-size: 0.75rem;
    color: var(--ub-muted);
}

.km-stats {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.15rem 0.75rem;
    margin: 0.6rem 0 0;
    font-size: 0.78rem;
}

.km-stats dt {
    font-weight: 400;
    color: var(--ub-muted);
}

.km-stats dd {
    margin: 0;
    text-align: right;
}

.km-gun-row {
    display: grid;
    grid-template-columns: 80px minmax(0, 1fr);
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.km-gun-row .form-label {
    margin: 0;
    font-size: 0.75rem;
}

.km-details-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--ub-border);
}

.km-amount-input {
    max-width: 210px;
}

.km-icon-btn {
    padding: 0 0.3rem;
    line-height: 1.4;
    color: #bdbdbd;
    border: 0;
}

.km-icon-btn:hover:not(:disabled) {
    color: #fff;
}

.km-icon-btn:disabled {
    opacity: 0.25;
}

/* ===== Example kits ===== */

.km-example {
    display: grid;
    grid-template-columns: 5.5rem minmax(0, 1fr);
    grid-template-rows: auto auto;
    column-gap: 0.6rem;
    align-items: center;
    width: 100%;
    padding: 0.5rem 0.4rem;
    border: 0;
    border-bottom: 1px solid var(--ub-border);
    background: none;
    color: inherit;
    text-align: left;
}

.km-example:hover,
.km-example:focus-visible {
    background: rgba(255, 255, 255, 0.05);
}

.km-example-tag {
    grid-row: 1 / span 2;
    justify-self: start;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: #d6d6d6;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.km-tag-pvp { background: rgba(220, 53, 69, 0.18); color: #ff8a95; }
.km-tag-raid { background: rgba(253, 126, 20, 0.18); color: #ffb26b; }
.km-tag-vehicle { background: rgba(108, 188, 255, 0.18); color: var(--ub-blue); }
.km-tag-base,
.km-tag-resource,
.km-tag-fuse { background: rgba(47, 168, 47, 0.18); color: #7fd87f; }

.km-example-name {
    font-weight: 700;
}

.km-example-meta {
    font-size: 0.78rem;
    color: var(--ub-muted);
}

/* ===== Toasts ===== */

.km-toasts {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 2100;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    max-width: min(420px, calc(100vw - 2rem));
}

.km-toast {
    padding: 0.55rem 0.8rem;
    border: 1px solid var(--ub-border-strong);
    border-left-width: 4px;
    border-radius: 0.4rem;
    background: #151515;
    font-size: 0.82rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    transition: opacity 0.35s ease, transform 0.35s var(--ub-ease);
}

.km-toast-info { border-left-color: var(--ub-blue); }
.km-toast-success { border-left-color: #2fa82f; }
.km-toast-error { border-left-color: #dc3545; }

.km-toast-out {
    opacity: 0;
    transform: translateY(6px);
}

@media (prefers-reduced-motion: reduce) {
    .km-toast,
    .km-chip,
    .km-slot {
        transition: none;
    }
}

.km-gun-switch {
    margin: 0.2rem 0 0.35rem;
}

/* ===== Items players can't obtain ===== */

.km-catalog-item.km-unobtainable {
    cursor: not-allowed;
    opacity: 0.4;
    border-left-color: rgba(255, 255, 255, 0.15);
}

.km-catalog-item.km-unobtainable .km-icon,
.km-catalog-item.km-unobtainable .km-glyph {
    filter: grayscale(1);
}

.km-catalog-item.km-unobtainable:hover {
    opacity: 0.6;
}

.km-item.km-item-unobtainable {
    outline: 2px dashed rgba(220, 53, 69, 0.85);
    outline-offset: -2px;
}

.km-item.km-item-unobtainable .km-icon {
    filter: grayscale(0.6);
}


.km-unobtainable-note {
    font-size: 0.8rem;
    color: #ea868f;
}
