/**
 * Character Inventory – public display
 * Equipment grid, inventory grid, zen panel. Visible to all users viewing a character.
 * Uses CSS variables for scale/paths - override in view if needed.
 */
:root {
    --ace-inv-scale: 2;
    --ace-cell-size: calc(20px * var(--ace-inv-scale));
    --ace-window-width: calc(190px * var(--ace-inv-scale));
    --ace-window-height: calc(433px * var(--ace-inv-scale));
    --ace-top-panel-height: calc(256px * var(--ace-inv-scale));
    --ace-bottom-panel-height: calc(177px * var(--ace-inv-scale));
    --ace-grid-top: calc(200px * var(--ace-inv-scale));
    --ace-grid-left: calc(15px * var(--ace-inv-scale));
    --ace-zen-font-size: calc(12px * var(--ace-inv-scale));
}

/* -------------------------------------------------------------------------
   Wrapper & window
   ------------------------------------------------------------------------- */
.character-inventory-wrapper {
    text-align: center;
    margin: 16px 0;
}

/* Equipment-only: when viewing another player (no inventory/zen) */
.character-inventory-wrapper.equipment-only .character-inventory-window {
    min-height: auto;
}
.character-inventory-wrapper.equipment-only .character-inventory-body {
    min-height: auto;
}

.character-inventory-window {
    display: inline-block;
    width: var(--ace-window-width);
    min-height: var(--ace-window-height);
    position: relative;
    background-image: var(--ace-item-back01, url('/assets/images/Item_Back01.jpg')),
        var(--ace-item-back02, url('/assets/images/Item_Back02.jpg'));
    background-position: top center, center var(--ace-top-panel-height);
    background-repeat: no-repeat, no-repeat;
    background-size: var(--ace-window-width) var(--ace-top-panel-height),
        var(--ace-window-width) var(--ace-bottom-panel-height);
    border-radius: 2px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    padding: 0;
}

.character-inventory-header {
    background: transparent;
    padding: 8px 12px;
    text-align: center;
}

.character-inventory-title {
    font-family: Tahoma, Arial, sans-serif;
    font-size: calc(12px * var(--ace-inv-scale));
    font-weight: bold;
    color: #e0e0e0;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0;
}

.character-inventory-subtitle {
    font-size: calc(9px * var(--ace-inv-scale));
    color: #999;
    margin-top: 2px;
}

.character-inventory-body {
    position: relative;
    min-height: var(--ace-window-height);
    background: transparent;
    display: flex;
    flex-direction: column;
}

.inv-ext-content {
    flex: 1;
    min-height: 0;
}

/* -------------------------------------------------------------------------
   Equipment grid
   ------------------------------------------------------------------------- */
.character-equipment-grid {
    position: relative;
    width: var(--ace-window-width);
    height: calc(192px * var(--ace-inv-scale));
}

.character-equipment-slot {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default;
    overflow: hidden;
    box-sizing: border-box;
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
}

.character-equipment-slot .slot-icon-img,
.character-equipment-slot .item-icon-img {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.character-equipment-slot .item-level {
    position: absolute;
    bottom: 2px;
    right: 2px;
    font-size: 10px;
    color: #8cb0ea;
    text-shadow: 1px 1px 1px #000;
}

.character-equipment-slot.empty-slot .slot-icon-img {
    opacity: 0.9;
}

.character-equipment-slot.has-item {
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

/* -------------------------------------------------------------------------
   Inventory grid
   ------------------------------------------------------------------------- */
.character-inventory-grid {
    position: absolute;
    left: var(--ace-grid-left);
    top: var(--ace-grid-top);
    display: grid;
    grid-template-columns: repeat(8, var(--ace-cell-size));
    grid-auto-rows: var(--ace-cell-size);
    gap: 0;
    width: calc(8 * var(--ace-cell-size));
    height: calc(8 * var(--ace-cell-size));
}

/* Unified bag (slots 12–203): flow layout, variable row count */
.character-inventory-window.has-unified-bag .character-inventory-grid.bag-unified {
    position: relative;
    left: auto;
    top: auto;
    transform: none;
    margin: 8px auto 4px;
    height: auto;
    width: calc(8 * var(--ace-cell-size));
}

.character-inventory-window.has-unified-bag {
    width: auto;
    min-width: var(--ace-window-width);
    min-height: auto;
}

.inv-ext-content-unified {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.character-inv-slot.inv-slot-locked:not(.has-item) {
    opacity: 0.55;
    filter: grayscale(0.35);
    pointer-events: none;
}

.character-inv-slot.inv-slot-locked.has-item {
    opacity: 0.85;
}

.inv-bottom-bar .character-zen-panel {
    position: relative;
    bottom: auto;
    left: auto;
    right: auto;
    margin-top: 8px;
    min-height: 44px;
}

.character-inv-slot {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 0;
    box-sizing: border-box;
    overflow: hidden;
    background: var(--ace-empty-slot-bg, url('/assets/images/emptyslotbg.jpg')) center/100% 100% no-repeat;
    background-color: rgba(30, 28, 26, 0.9);
    border: 1px solid rgba(58, 53, 48, 0.6);
    position: relative;
}

.character-inv-slot.has-item {
    background: var(--ace-taken-slot-bg, url('/assets/images/takenslotbg.jpg')) center/100% 100% no-repeat;
}

.character-inv-slot .item-fill {
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    box-sizing: border-box;
}

.character-inv-slot .item-fill .item-icon-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* -------------------------------------------------------------------------
   Zen panel
   ------------------------------------------------------------------------- */
.character-zen-panel {
    position: absolute;
    bottom: 65px;
    left: 0;
    right: 0;
    background: var(--ace-item-money, url('/assets/images/Item_Money.jpg')) center center / contain no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
}

.character-zen-value {
    color: #e0e0e0;
    font-family: monospace;
    font-size: var(--ace-zen-font-size);
}
