/* ----------------------------------------
   Grid Inventory
---------------------------------------- */

.ei-grid-wrapper {
  padding: 4px 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.ei-grid {
  position: relative;
  background-color: rgba(0, 0, 0, 0.08);
  background-image:
    repeating-linear-gradient(rgba(128,128,128,0.3) 0 1px, transparent 1px 100%),
    repeating-linear-gradient(90deg, rgba(128,128,128,0.3) 0 1px, transparent 1px 100%);
  background-size: var(--ei-cell) var(--ei-cell);
  border: 1px solid rgba(128,128,128,0.25);
  border-radius: 6px;
  margin: 0 auto;
  box-sizing: content-box;
}

/* ----------------------------------------
   Grid Items
---------------------------------------- */

.ei-grid-item {
  position: absolute;
  box-sizing: border-box;
  border: 1px solid rgba(128,128,128,0.45);
  border-radius: 4px;
  background: rgba(128, 128, 128, 0.06);
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  overflow: hidden;
  z-index: 1;
}

.ei-grid-item:hover {
  border-color: rgba(128, 128, 128, 0.5);
  background: rgba(128, 128, 128, 0.12);
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.3);
  z-index: 5;
}

/* Shaped tiles: the box border/outline can't follow the clip, so the
   SVG outline draws every edge (cuts included) and takes over the states */
.ei-grid-item.ei-shaped {
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.ei-shape-outline {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  overflow: visible;
}

.ei-shape-outline path {
  fill: none;
  stroke: rgba(128, 128, 128, 0.55);
  stroke-width: 2;
  transition: stroke 0.15s;
}

.ei-grid-item.ei-shaped:hover .ei-shape-outline path {
  stroke: rgba(180, 180, 180, 0.8);
}

.ei-grid-item.ei-shaped.ei-selected {
  outline: none;
}

.ei-grid-item.ei-shaped.ei-selected .ei-shape-outline path {
  stroke: rgba(74, 158, 255, 0.9);
  stroke-width: 3;
}

body.system-vtm-v20 .ei-grid-item.ei-shaped.ei-selected .ei-shape-outline path {
  stroke: rgba(196, 30, 58, 0.9);
}

.ei-grid-item.ei-shaped.ei-search-hit {
  outline: none;
  box-shadow: none;
}

.ei-grid-item.ei-shaped.ei-search-hit .ei-shape-outline path {
  stroke: rgba(255, 210, 80, 0.95);
  stroke-width: 3;
}

.ei-grid-item.ei-dragging {
  opacity: 0.35;
}

.ei-grid-item img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  pointer-events: none;
  image-rendering: auto;
  border: none !important;
}

.ei-grid-item img.ei-img-rotated {
  transform: rotate(90deg);
  max-width: none;
  max-height: none;
}

.ei-qty-badge {
  position: absolute;
  bottom: 1px;
  right: 3px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 3px #000, 0 0 3px #000;
  pointer-events: none;
}

.ei-charges-badge {
  position: absolute;
  top: 1px;
  left: 3px;
  font-size: 10px;
  font-weight: 700;
  color: #7fd4ff;
  text-shadow: 0 0 3px #000, 0 0 3px #000;
  pointer-events: none;
}

.ei-hover-popup {
  position: fixed;
  z-index: 1000;
  background: #1a1a1a;
  color: #ddd;
  font-size: 12px;
  line-height: 1.5;
  padding: 6px 10px;
  border-radius: 5px;
  border: 1px solid #444;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
  min-width: 120px;
}
.ei-ov-title {
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  margin-bottom: 4px;
  border-bottom: 1px solid #444;
  padding-bottom: 3px;
}
.ei-ov-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 1px 0;
}
.ei-ov-label {
  color: #999;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.ei-ov-clickable {
  cursor: pointer;
  text-decoration: underline;
}
.ei-ov-clickable:hover {
  color: #ffd866;
}
.ei-ov-reload {
  cursor: pointer;
  color: #999;
  margin-left: 4px;
  font-size: 10px;
}
.ei-ov-reload:hover {
  color: #ffd866;
}

.ei-rotate-btn {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.6);
  border-radius: 2px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 2;
  font-size: 9px;
  color: rgba(255,255,255,0.7);
}

.ei-grid-item:hover .ei-rotate-btn {
  opacity: 1;
}

.ei-rotate-btn:hover {
  background: rgba(100, 80, 200, 0.6);
  color: #fff;
}

/* ----------------------------------------
   Selection
---------------------------------------- */

.ei-grid-item.ei-selected,
.ei-overflow-item.ei-selected {
  outline: 2px solid rgba(74, 158, 255, 0.8);
  outline-offset: -2px;
  background: rgba(74, 158, 255, 0.15);
}

.ei-select-box {
  position: absolute;
  border: 1px dashed rgba(74, 158, 255, 0.7);
  background: rgba(74, 158, 255, 0.1);
  pointer-events: none;
  z-index: 50;
}

/* VTM: red selection to match system theme */
body.system-vtm-v20 .ei-grid-item.ei-selected,
body.system-vtm-v20 .ei-overflow-item.ei-selected {
  outline-color: rgba(196, 30, 58, 0.8);
  background: rgba(196, 30, 58, 0.15);
}
body.system-vtm-v20 .ei-select-box {
  border-color: rgba(196, 30, 58, 0.7);
  background: rgba(196, 30, 58, 0.1);
}

/* ----------------------------------------
   Drag Ghost
---------------------------------------- */

.ei-ghost {
  position: absolute;
  border-radius: 3px;
  pointer-events: none;
  z-index: 10;
  transition: left 0.06s, top 0.06s;
}

.ei-ghost-valid {
  background: rgba(80, 200, 80, 0.25);
  border: 2px solid rgba(80, 200, 80, 0.6);
}

.ei-ghost-invalid {
  background: rgba(220, 60, 60, 0.25);
  border: 2px dashed rgba(220, 60, 60, 0.6);
}

.ei-ghost-merge {
  background: rgba(150, 100, 220, 0.25);
  border: 2px solid rgba(150, 100, 220, 0.6);
}

/* Irregular shapes: the ghost shows per-cell silhouette instead of a box */
.ei-ghost.ei-ghost-shaped {
  background: transparent !important;
  border-color: transparent !important;
}

.ei-ghost-cell {
  position: absolute;
  pointer-events: none;
  border-radius: 2px;
}

.ei-ghost-valid .ei-ghost-cell {
  background: rgba(80, 200, 80, 0.25);
  outline: 1px solid rgba(80, 200, 80, 0.6);
}

.ei-ghost-invalid .ei-ghost-cell {
  background: rgba(220, 60, 60, 0.25);
  outline: 1px dashed rgba(220, 60, 60, 0.6);
}

.ei-ghost-merge .ei-ghost-cell {
  background: rgba(150, 100, 220, 0.25);
  outline: 1px solid rgba(150, 100, 220, 0.6);
}

/* Shape editor in the dimensions dialog */
.ei-shape-editor {
  display: grid;
  gap: 2px;
  margin: 2px 0;
}

.ei-shape-cell {
  width: 20px;
  height: 20px;
  background: rgba(120, 220, 160, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 2px;
  cursor: pointer;
}

.ei-shape-cell.off {
  background: rgba(0, 0, 0, 0.3);
  opacity: 0.45;
}

/* ----------------------------------------
   Overflow / Unplaced Items
---------------------------------------- */

.ei-overflow-section {
  margin-top: 8px;
}

.ei-overflow-header {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.55);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 4px 2px;
  border: none;
}

.ei-overflow {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 40px;
  padding: 6px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 6px;
  border: 1px dashed rgba(255,255,255,0.06);
}

.ei-overflow-empty {
  width: 100%;
  text-align: center;
  color: rgba(255,255,255,0.25);
  font-size: 11px;
  padding: 8px;
}

.ei-overflow-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 4px;
  cursor: grab;
  position: relative;
  max-width: 160px;
  transition: border-color 0.15s, background 0.15s;
}

.ei-overflow-item:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
}

.ei-overflow-item.ei-dragging {
  opacity: 0.35;
}

.ei-overflow-item img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  pointer-events: none;
  flex-shrink: 0;
}

.ei-overflow-label {
  font-size: 11px;
  color: rgba(255,255,255,0.8);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

/* ----------------------------------------
   Attunement Tracker
---------------------------------------- */

.ei-attunement-tracker {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.65);
  background: rgba(0, 0, 0, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  margin-bottom: 6px;
}

.ei-attunement-tracker i {
  color: rgba(255, 200, 60, 0.7);
  font-size: 13px;
}

/* ----------------------------------------
   Container Sub-Grids
---------------------------------------- */

.ei-container-section {
  margin-top: 8px;
}

.ei-container-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  background: rgba(0, 0, 0, 0.12);
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.75);
  margin-bottom: 4px;
  border: 1px solid rgba(255,255,255,0.06);
  transition: background 0.15s;
}

.ei-container-header:hover {
  background: rgba(0, 0, 0, 0.2);
}

.ei-container-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
  border: none !important;
}

.ei-container-cap {
  margin-left: auto;
  font-size: 10px;
  color: rgba(255,255,255,0.45);
  font-weight: 400;
}

.ei-container-header .ei-search-input {
  margin-left: auto;
  width: 78px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 400;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(128,128,128,0.3);
  border-radius: 3px;
  color: inherit;
  cursor: text;
  transition: width 0.15s, border-color 0.15s;
}

.ei-container-header .ei-search-input:focus {
  width: 110px;
  border-color: rgba(180, 160, 255, 0.6);
  outline: none;
  box-shadow: none;
}

/* When a search box is present it takes over the auto margin */
.ei-container-header .ei-search-input ~ .ei-container-cap {
  margin-left: 0;
}

.ei-container-header .ei-grid-cfg-btn {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  padding: 0;
  margin-left: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid rgba(128,128,128,0.35);
  border-radius: 3px;
  color: inherit;
  font-size: 10px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.ei-container-header .ei-grid-cfg-btn:hover {
  border-color: rgba(180, 160, 255, 0.6);
}

.ei-grid-item.ei-search-hit {
  outline: 2px solid rgba(255, 210, 80, 0.95);
  outline-offset: -2px;
  box-shadow: 0 0 8px rgba(255, 210, 80, 0.6);
  z-index: 3;
}

.ei-grid-item.ei-search-miss {
  opacity: 0.25;
}

.ei-default-inv-icon {
  font-size: 14px;
  width: 20px;
  text-align: center;
  color: rgba(255,255,255,0.6);
}

.ei-container-header.ei-collapsed::after {
  content: '\f054';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  font-size: 9px;
  margin-left: 4px;
}

.ei-container-header:not(.ei-collapsed)::after {
  content: '\f078';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  font-size: 9px;
  margin-left: 4px;
}

.ei-grid.ei-sub-grid {
  margin: 0 auto 4px;
  background-color: rgba(0, 0, 0, 0.08);
  background-image:
    repeating-linear-gradient(rgba(128,128,128,0.3) 0 1px, transparent 1px 100%),
    repeating-linear-gradient(90deg, rgba(128,128,128,0.3) 0 1px, transparent 1px 100%);
  background-size: var(--ei-cell) var(--ei-cell);
}

.ei-container-section.ei-reorder-above {
  box-shadow: 0 -2px 0 0 rgba(180, 160, 255, 0.9);
}

.ei-container-section.ei-reorder-below {
  box-shadow: 0 2px 0 0 rgba(180, 160, 255, 0.9);
}

.ei-sort-btn {
  position: absolute;
  top: 0;
  right: -26px;
  width: 22px;
  height: 22px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(25, 25, 30, 0.85);
  border: 1px solid rgba(128,128,128,0.35);
  border-radius: 4px;
  color: rgba(255,255,255,0.65);
  font-size: 11px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.ei-sort-btn:hover {
  color: #fff;
  border-color: rgba(180, 160, 255, 0.6);
}

.ei-container-overflow {
  margin-top: 2px;
}

/* ----------------------------------------
   Armor Pockets
---------------------------------------- */

.ei-pocket-row {
  display: flex;
  gap: 0;
  justify-content: center;
  padding: 6px 0;
}

.ei-pocket-pair {
  display: flex;
  flex-direction: row;
}

.ei-pocket-pair .ei-pocket-cell + .ei-pocket-cell {
  border-left: none;
}

.ei-pocket-cell {
  position: relative;
  box-sizing: border-box;
  background: rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(128,128,128,0.3);
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  transition: border-color 0.15s, background 0.15s;
  overflow: hidden;
}

.ei-pocket-cell:hover {
  border-color: rgba(128,128,128,0.5);
  background: rgba(128,128,128,0.1);
}

.ei-pocket-cell.ei-pocket-filled {
  background: rgba(128,128,128,0.06);
  border: 1px solid rgba(0,0,0,0.35);
  cursor: grab;
}

.ei-pocket-cell.ei-pocket-filled:hover {
  background: rgba(128,128,128,0.12);
  border-color: rgba(128,128,128,0.5);
  box-shadow: 0 0 6px rgba(0,0,0,0.25);
}

.ei-pocket-cell.ei-dragging {
  opacity: 0.35;
}

.ei-pocket-cell img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  pointer-events: none;
  image-rendering: auto;
  border: none !important;
}

/* ----------------------------------------
   Wear System (VTM)
---------------------------------------- */

.ei-wear-top,
.ei-wear-bottom {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  padding: 6px 0 0;
}

.ei-pocket-grid {
  border-radius: 4px;
  overflow: hidden;
}

.ei-pocket-grid .ei-pocket-cell {
  border-radius: 0;
}

.ei-wear-label {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  padding: 4px 8px 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ei-wear-separator {
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: 6px 12px;
}

/* Container pocket layout (pockets around main grid) */

.ei-container-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 0;
}

.ei-pocket-area {
  display: flex;
  gap: 4px;
  justify-content: center;
}

.ei-pocket-area.ei-pocket-vertical {
  flex-direction: column;
  align-items: center;
}

.ei-pocket-middle {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Pocket config dialog */

.ei-pocket-cfg {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ei-pocket-cfg-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ei-pocket-cfg-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: rgba(0,0,0,0.15);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 4px;
}

.ei-pcfg-idx {
  font-weight: 600;
  font-size: 12px;
  min-width: 16px;
  text-align: center;
  opacity: 0.5;
}

.ei-pcfg-field {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ei-pcfg-field label {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.6;
  min-width: auto;
}

.ei-pcfg-field input[type="number"] {
  width: 44px;
  text-align: center;
  padding: 3px 4px;
}

.ei-pcfg-field select {
  min-width: 76px;
  padding: 3px 4px;
  font-size: 12px;
}

.ei-pcfg-del {
  margin-left: auto;
  background: none;
  border: none;
  color: rgba(220,60,60,0.5);
  cursor: pointer;
  padding: 4px 6px;
  font-size: 11px;
  border-radius: 3px;
  transition: color 0.15s, background 0.15s;
}

.ei-pcfg-del:hover {
  color: rgba(220,60,60,1);
  background: rgba(220,60,60,0.1);
}

.ei-pocket-cfg-actions {
  display: flex;
  justify-content: center;
  padding: 4px 0;
}

/* ----------------------------------------
   Context Menu
---------------------------------------- */

.ei-context-menu {
  position: fixed;
  z-index: 9999;
  background: #1e1e2e;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  min-width: 160px;
  padding: 4px 0;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

.ei-ctx-option {
  padding: 6px 12px;
  font-size: 12px;
  color: rgba(255,255,255,0.8);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ei-ctx-option:hover {
  background: rgba(100, 80, 200, 0.3);
}

.ei-ctx-separator {
  height: 1px;
  background: rgba(255,255,255,0.1);
  margin: 4px 8px;
}

.ei-ctx-option i {
  width: 16px;
  text-align: center;
  font-size: 11px;
  opacity: 0.7;
}

body.system-vtm-v20 .ei-context-menu {
  background: #1a1a1a;
  border-color: rgba(196, 30, 58, 0.35);
}
body.system-vtm-v20 .ei-ctx-option:hover {
  background: rgba(196, 30, 58, 0.25);
}

/* PF2e / SF2e overrides: light-bg sheet */
body.system-pf2e .ei-overflow-header,
body.system-pf2e .ei-overflow-empty,
body.system-pf2e .ei-overflow-label,
body.system-pf2e .ei-container-header span,
body.system-pf2e .ei-container-cap,
body.system-pf2e .ei-attunement-tracker,
body.system-sf2e .ei-overflow-header,
body.system-sf2e .ei-overflow-empty,
body.system-sf2e .ei-overflow-label,
body.system-sf2e .ei-container-header span,
body.system-sf2e .ei-container-cap,
body.system-sf2e .ei-attunement-tracker {
  color: #1c1c1c;
}
body.system-pf2e .ei-overflow-item,
body.system-sf2e .ei-overflow-item {
  background: rgba(0,0,0,0.06);
  border-color: rgba(0,0,0,0.12);
}
body.system-pf2e .ei-overflow-item:hover,
body.system-sf2e .ei-overflow-item:hover {
  background: rgba(0,0,0,0.1);
}
body.system-pf2e .ei-slot,
body.system-sf2e .ei-slot {
  background: transparent;
  border-color: rgba(255,255,255,0.06);
}
body.system-pf2e .ei-slot:hover,
body.system-sf2e .ei-slot:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.2);
}
body.system-pf2e .ei-slot.ei-slot-filled,
body.system-sf2e .ei-slot.ei-slot-filled {
  background: rgba(0,0,0,0.25);
  border-color: rgba(255,255,255,0.12);
}
body.system-pf2e .ei-slot.ei-slot-equipped,
body.system-sf2e .ei-slot.ei-slot-equipped {
  border-color: rgba(100, 200, 120, 0.6);
  box-shadow: 0 0 8px rgba(100, 200, 120, 0.25);
}
body.system-pf2e .ei-slot-custom-icon,
body.system-sf2e .ei-slot-custom-icon {
  width: 90%;
  height: 90%;
  opacity: 0.5;
}
body.system-pf2e .ei-slot-item-img,
body.system-sf2e .ei-slot-item-img {
  width: 92%;
  height: 92%;
}
body.system-pf2e .ei-slot-icon,
body.system-sf2e .ei-slot-icon {
  color: rgba(255,255,255,0.15);
}
body.system-pf2e .ei-context-menu,
body.system-sf2e .ei-context-menu {
  background: #f5f0e6;
  border-color: rgba(0,0,0,0.2);
  color: #1c1c1c;
}
body.system-pf2e .ei-ctx-option,
body.system-sf2e .ei-ctx-option {
  color: #1c1c1c;
}
body.system-pf2e .ei-ctx-option:hover,
body.system-sf2e .ei-ctx-option:hover {
  background: rgba(100,80,50,0.15);
}

/* Mothership overrides: light-bg sheet */
body.system-mosh .ei-overflow-header,
body.system-mosh .ei-overflow-empty,
body.system-mosh .ei-overflow-label,
body.system-mosh .ei-container-header span,
body.system-mosh .ei-container-cap {
  color: #1c1c1c;
}
body.system-mosh .ei-grid-item img[src$=".svg"],
body.system-mosh .ei-overflow-item img[src$=".svg"],
body.system-mosh .ei-pocket-cell img[src$=".svg"] {
  filter: invert(1);
}
body.system-mosh .ei-overflow-item {
  background: rgba(0,0,0,0.06);
  border-color: rgba(0,0,0,0.12);
}
body.system-mosh .ei-overflow-item:hover {
  background: rgba(0,0,0,0.1);
}
body.system-mosh .ei-qty-badge {
  color: #1c1c1c;
  text-shadow: 0 0 2px #fff, 0 0 2px #fff;
}
body.system-mosh .ei-context-menu {
  background: #e8e8e8;
  border-color: rgba(0,0,0,0.2);
  color: #1c1c1c;
}
body.system-mosh .ei-ctx-option {
  color: #1c1c1c;
}
body.system-mosh .ei-ctx-option:hover {
  background: rgba(0,0,0,0.1);
}
body.system-mosh .ei-container-icon[src$=".svg"] {
  filter: invert(1);
}

/* ----------------------------------------
   Equipment Panel
---------------------------------------- */

.ei-equipment-panel {
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  width: 250px;
  background: var(--dnd5e-background, #222);
  border-right: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px 0 0 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 0;
  box-shadow: -4px 0 16px rgba(0,0,0,0.3);
}

.ei-equipment-panel:not(.ei-panel-inline) {
  transition: width 0.22s ease;
}

.ei-equipment-panel.ei-panel-minimized {
  width: 40px;
}

.ei-equipment-panel.ei-panel-minimized > .ei-panel-header {
  justify-content: center;
  padding: 6px 8px;
  gap: 0;
}

.ei-equipment-panel.ei-panel-minimized > .ei-panel-header > :not(.ei-minimize-btn) {
  flex: 0 0 0;
  width: 0;
  min-width: 0;
  padding: 0;
  border-width: 0;
  opacity: 0;
  visibility: hidden;
  overflow: hidden;
  pointer-events: none;
}

.ei-equipment-panel.ei-panel-minimized > .ei-body-container {
  min-height: 0;
  max-height: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: min-height 0.22s ease, max-height 0.22s ease, opacity 0.14s ease,
    visibility 0s linear 0.22s;
}

.ei-equipment-panel.ei-panel-minimized > .ei-equip-toggle {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-width: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: max-height 0.2s ease, padding 0.2s ease, border-width 0.2s ease,
    opacity 0.14s ease, visibility 0s linear 0.2s;
}

/* Side-by-side layout: equipment panel left, grids right */

.ei-inventory-layout {
  display: flex;
  gap: 6px;
}

.ei-inventory-layout > .ei-equipment-panel.ei-panel-inline {
  position: relative;
  right: auto;
  top: auto;
  transform: none;
  width: 220px;
  flex: 0 0 220px;
  margin: 0;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: none;
  overflow: visible;
}

.ei-inventory-layout > .ei-grid-wrapper {
  flex: 1;
  min-width: 0;
  padding: 0 2px;
}

.ei-panel-header {
  display: flex;
  align-items: center;
  padding: 6px 8px;
  gap: 4px;
  flex-shrink: 0;
  transition: gap 0.22s ease;
}

.ei-equipment-panel:not(.ei-panel-inline) > .ei-panel-header > :not(.ei-minimize-btn) {
  min-width: 0;
  transition: flex 0.22s ease, width 0.22s ease, padding 0.22s ease,
    border-width 0.22s ease, opacity 0.12s ease, visibility 0s linear 0s;
}

.ei-equipment-panel.ei-panel-minimized > .ei-panel-header > :not(.ei-minimize-btn) {
  transition: flex 0.22s ease, width 0.22s ease, padding 0.22s ease,
    border-width 0.22s ease, opacity 0.12s ease, visibility 0s linear 0.22s;
}

.ei-panel-title {
  flex: 1;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: rgba(255,255,255,0.4);
  text-align: center;
}

.ei-panel-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 4px;
  color: rgba(255,255,255,0.4);
  cursor: pointer;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  padding: 0;
  transition: all 0.15s;
}

.ei-panel-btn:hover {
  color: rgba(255,255,255,0.8);
  border-color: rgba(255,255,255,0.25);
}

.ei-panel-btn.active {
  background: rgba(100, 80, 200, 0.3);
  border-color: rgba(100, 80, 200, 0.5);
  color: rgba(180, 160, 255, 0.9);
}

/* Body silhouette container */

.ei-body-container {
  position: relative;
  min-height: 400px;
  max-height: 570px;
  overflow: hidden;
  transition: min-height 0.22s ease, max-height 0.22s ease, opacity 0.14s ease,
    visibility 0s linear 0s;
}

.ei-body-image {
  width: 100%;
  height: auto;
  display: block;
  pointer-events: none;
  border: none !important;
}

/* Circular slots overlaid on body */

.ei-slot {
  position: absolute;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: rgba(25, 25, 30, 0.85);
  border: 2px solid rgba(255,255,255,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  z-index: 1;
  overflow: hidden;
}

.ei-slot:hover {
  border-color: rgba(180, 160, 255, 0.5);
  background: rgba(35, 35, 40, 0.9);
}

.ei-slot-icon {
  font-size: 14px;
  color: rgba(255,255,255,0.2);
}

.ei-slot-custom-icon {
  width: 70%;
  height: 70%;
  object-fit: contain;
  pointer-events: none;
  border-radius: 50%;
}

.ei-slot.ei-slot-filled .ei-slot-icon,
.ei-slot.ei-slot-filled .ei-slot-custom-icon {
  display: none;
}

.ei-slot.ei-slot-filled {
  background: rgba(35, 35, 40, 0.9);
  border-color: rgba(255,255,255,0.2);
}

.ei-slot.ei-slot-equipped {
  border-color: rgba(100, 200, 120, 0.6);
  box-shadow: 0 0 8px rgba(100, 200, 120, 0.25);
}

.ei-slot-item-img {
  width: 82%;
  height: 82%;
  object-fit: contain;
  border-radius: 50%;
}

/* Inline panel: larger transparent slots */

.ei-panel-inline .ei-slot {
  width: 48px;
  height: 48px;
  background: none;
  border: 2px solid rgba(255,255,255,0.15);
}

.ei-panel-inline .ei-slot:hover {
  background: rgba(255,255,255,0.05);
}

.ei-panel-inline .ei-slot.ei-slot-filled {
  background: none;
}

.ei-panel-inline .ei-slot.ei-slot-equipped {
  border-color: rgba(100, 200, 120, 0.6);
}

.ei-panel-inline .ei-slot-icon {
  font-size: 18px;
}

.ei-panel-inline .ei-slot-item-img {
  width: 100%;
  height: 100%;
  border: none !important;
  border-radius: 50%;
}

.ei-panel-inline .ei-slot-custom-icon {
  width: 70%;
  height: 70%;
  border: none !important;
  border-radius: 50%;
}

.ei-slot-dragover {
  border-color: rgba(180, 160, 255, 0.7) !important;
  background: rgba(100, 80, 200, 0.2) !important;
}

/* Hovered inventory item: slots that accept its type */
.ei-equipment-panel .ei-slot.ei-slot-can-take {
  border-color: rgba(255, 200, 70, 0.95);
  animation: ei-can-take-pulse 1.2s ease-in-out infinite;
}

@keyframes ei-can-take-pulse {
  0%, 100% { box-shadow: 0 0 5px rgba(255, 200, 70, 0.4); }
  50% { box-shadow: 0 0 12px rgba(255, 200, 70, 0.85); }
}

.ei-slot-reject {
  border-color: rgba(220, 60, 60, 0.6) !important;
  background: rgba(220, 60, 60, 0.15) !important;
}

/* Edit mode */

.ei-edit-mode .ei-slot {
  cursor: move;
  border-style: dashed;
  animation: ei-edit-pulse 1.5s ease-in-out infinite;
}

@keyframes ei-edit-pulse {
  0%, 100% { border-color: rgba(180, 160, 255, 0.3); }
  50% { border-color: rgba(180, 160, 255, 0.7); }
}

/* Slot Folders */

.ei-slot-folder {
  overflow: visible;
}

.ei-slot-folder.ei-folder-open {
  z-index: 10;
  border-color: rgba(180, 160, 255, 0.5);
}

.ei-folder-badge {
  position: absolute;
  bottom: -4px;
  right: -4px;
  background: rgba(80, 60, 160, 0.9);
  color: #ddd;
  font-size: 9px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 6px;
  pointer-events: none;
  z-index: 2;
}

.ei-folder-children {
  position: absolute;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 3px;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 10;
  padding: 5px;
  background: rgba(20, 20, 25, 0.92);
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.1);
  min-width: 36px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.ei-slot-folder.ei-folder-open .ei-folder-children {
  pointer-events: all;
  opacity: 1;
}

.ei-folder-children .ei-slot {
  position: relative;
  width: 30px;
  height: 30px;
  transform: scale(0);
  opacity: 0;
  transition: transform 0.2s ease, opacity 0.15s ease;
}

.ei-slot-folder.ei-folder-open .ei-folder-children .ei-slot {
  transform: scale(1);
  opacity: 1;
}

.ei-folder-children .ei-slot-item-img {
  width: 80%;
  height: 80%;
}

.ei-folder-children .ei-slot-custom-icon {
  width: 60%;
  height: 60%;
}

/* Inline panel folder adjustments */
.ei-panel-inline .ei-folder-children .ei-slot {
  width: 36px;
  height: 36px;
}

/* Config view folder badge */
.ei-config-body-container .ei-folder-badge {
  background: rgba(100, 80, 180, 0.9);
}

/* ----------------------------------------
   Dark Dialog (matches template config style)
---------------------------------------- */

.ei-dark-dialog {
  background: #1a1a24 !important;
  color: #ddd !important;
  border-color: rgba(255,255,255,0.1) !important;
}

.ei-dark-dialog .window-header {
  background: #12121a !important;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.ei-dark-dialog .window-header .window-title {
  color: #ccc;
}

.ei-dark-dialog .window-content {
  background: #1a1a24 !important;
  color: #ddd;
}

.ei-dark-dialog .dialog-content {
  color: #ddd;
}

.ei-dark-dialog label {
  color: #bbb;
}

.ei-dark-dialog input,
.ei-dark-dialog select {
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.15);
  color: #ddd;
  border-radius: 3px;
}

.ei-dark-dialog select option {
  background: #1a1a24;
  color: #ddd;
}

.ei-dark-dialog input:focus,
.ei-dark-dialog select:focus {
  border-color: rgba(180,160,255,0.4);
  outline: none;
}

.ei-dark-dialog .dialog-buttons button {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  color: #ccc;
  border-radius: 4px;
  padding: 6px 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.ei-dark-dialog .dialog-buttons button:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.2);
}

.ei-dark-dialog .form-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  min-width: 0;
}

.ei-dark-dialog .form-group label {
  width: auto !important;
  flex: none !important;
  flex-shrink: 0;
  font-weight: 600;
  font-size: 12px;
}

.ei-dark-dialog .ei-dim-hint,
.ei-dark-dialog .ei-config-hint {
  color: rgba(255,255,255,0.35);
}

.ei-dark-dialog .ei-config-btn,
.ei-dark-dialog .ei-browse-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  color: #ccc;
  border-radius: 3px;
  cursor: pointer;
}

.ei-dark-dialog .ei-config-btn:hover,
.ei-dark-dialog .ei-browse-btn:hover {
  background: rgba(255,255,255,0.1);
}

.ei-dark-dialog input[type="checkbox"] {
  accent-color: rgba(180,160,255,0.7);
}

/* ----------------------------------------
   Equip Toggle
---------------------------------------- */

.ei-equip-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  margin-top: auto;
  background: rgba(30, 30, 33, 0.8);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 4px;
  cursor: pointer;
  color: rgba(255,255,255,0.6);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  max-height: 40px;
  overflow: hidden;
  transition: max-height 0.2s ease, padding 0.2s ease, border-width 0.2s ease,
    opacity 0.14s ease, background 0.2s ease, color 0.2s ease,
    border-color 0.2s ease, visibility 0s linear 0s;
}

.ei-equip-toggle:hover {
  background: rgba(50, 50, 55, 0.8);
  color: rgba(255,255,255,0.8);
}

.ei-equip-toggle.ei-toggle-on {
  background: rgba(60, 140, 80, 0.3);
  border-color: rgba(100, 200, 120, 0.4);
  color: rgba(100, 220, 130, 0.9);
}

.ei-equip-toggle i {
  font-size: 13px;
}

/* ----------------------------------------
   Dimension Dialog
---------------------------------------- */

.ei-dim-form .form-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.ei-dim-form label {
  width: 60px;
  font-weight: 600;
}

.ei-dim-form input[type="number"] {
  width: 60px;
}

.ei-dim-hint {
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  margin: 4px 0 0;
}

.ei-split-total {
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  white-space: nowrap;
}

/* ----------------------------------------
   Sheet Integration Overrides
---------------------------------------- */

.dnd5e2.sheet.actor.character .application {
  overflow: visible !important;
}

.dnd5e2.sheet.actor.character > .window-content {
  overflow: visible;
}

/* Tidy 5e overrides */

.tidy5e-sheet.application {
  overflow: visible !important;
}

.tidy5e-sheet .window-content {
  overflow: visible !important;
}

/* ----------------------------------------
   Slot Template Config
---------------------------------------- */

.ei-config-layout {
  display: flex;
  gap: 12px;
  height: 100%;
}

.ei-template-list {
  width: 160px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ei-template-entry {
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  background: rgba(0,0,0,0.15);
  border: 1px solid transparent;
}

.ei-template-entry:hover {
  background: rgba(0,0,0,0.25);
}

.ei-template-entry.active {
  background: rgba(100, 80, 200, 0.2);
  border-color: rgba(100, 80, 200, 0.4);
}

.ei-template-editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ei-config-header {
  display: flex;
  gap: 6px;
  padding-bottom: 8px;
  align-items: center;
  flex-shrink: 0;
}

.ei-template-name-input {
  flex: 1;
  min-width: 0;
}

.ei-config-body-container {
  position: relative;
  width: 250px;
  margin: 0 auto;
  background: #111;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  overflow: hidden;
}

.ei-config-body-container .ei-slot {
  width: 38px;
  height: 38px;
  cursor: move;
  border-style: dashed;
  animation: ei-edit-pulse 1.5s ease-in-out infinite;
}

.ei-config-body-container .ei-slot-icon {
  color: rgba(255,255,255,0.5);
}

.ei-config-body-container .ei-slot-custom-icon {
  border: none !important;
}

.ei-config-hint {
  font-size: 10px;
  color: rgba(255,255,255,0.35);
  text-align: center;
  margin: 4px 0 0;
  flex-shrink: 0;
}

.ei-config-btn {
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.ei-config-save {
  background: rgba(60, 140, 80, 0.3);
  border-color: rgba(100, 200, 120, 0.4);
}

.ei-config-warn {
  background: rgba(140, 120, 30, 0.3);
  border-color: rgba(200, 180, 60, 0.4);
}

.ei-config-danger {
  background: rgba(140, 40, 40, 0.3);
  border-color: rgba(200, 80, 80, 0.4);
}

/* ----------------------------------------
   Item Summary Popout
---------------------------------------- */

.ei-item-popout {
  position: fixed;
  z-index: 1000;
  width: 320px;
  max-height: 460px;
  overflow-y: auto;
  background: #f5e6cb;
  border: 2px solid #8b7355;
  border-radius: 5px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  font-size: 13px;
  color: #1c1817;
}

.ei-popout-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.06);
  border-bottom: 1px solid #c4a97d;
}

.ei-popout-header > img {
  width: 36px;
  height: 36px;
  border-radius: 3px;
  border: 1px solid #8b7355;
  object-fit: cover;
}

.ei-popout-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.ei-popout-name {
  font-weight: 700;
  font-size: 14px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ei-popout-level {
  font-size: 11px;
  opacity: 0.6;
}

.ei-popout-edit {
  background: none;
  border: none;
  color: #5c4a32;
  opacity: 0.5;
  cursor: pointer;
  padding: 4px 6px;
  font-size: 14px;
}
.ei-popout-edit:hover { opacity: 1; }

.ei-popout-traits {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 6px 10px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.ei-popout-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 2px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  background: #576293;
  color: #fff;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

.ei-popout-tag.ei-rarity-uncommon { background: #98513d; }
.ei-popout-tag.ei-rarity-rare { background: #002664; }
.ei-popout-tag.ei-rarity-unique { background: #54166e; }

/* D&D 5e rarity on grid items (inset shadow so selection outline stays visible) */
body.system-dnd5e .ei-grid-item.ei-rarity-common,
body.system-dnd5e .ei-overflow-item.ei-rarity-common { box-shadow: inset 0 0 0 2px #9e9e9e; }
body.system-dnd5e .ei-grid-item.ei-rarity-uncommon,
body.system-dnd5e .ei-overflow-item.ei-rarity-uncommon { box-shadow: inset 0 0 0 2px #1b8c2d; }
body.system-dnd5e .ei-grid-item.ei-rarity-rare,
body.system-dnd5e .ei-overflow-item.ei-rarity-rare { box-shadow: inset 0 0 0 2px #2454b0; }
body.system-dnd5e .ei-grid-item.ei-rarity-veryRare,
body.system-dnd5e .ei-overflow-item.ei-rarity-veryRare { box-shadow: inset 0 0 0 2px #7b2fb5; }
body.system-dnd5e .ei-grid-item.ei-rarity-legendary,
body.system-dnd5e .ei-overflow-item.ei-rarity-legendary { box-shadow: inset 0 0 0 2px #d4860b; }
body.system-dnd5e .ei-grid-item.ei-rarity-artifact,
body.system-dnd5e .ei-overflow-item.ei-rarity-artifact { box-shadow: inset 0 0 0 2px #be2020; }

/* PF2e / SF2e rarity on grid items */
body.system-pf2e .ei-grid-item.ei-rarity-uncommon,
body.system-pf2e .ei-overflow-item.ei-rarity-uncommon,
body.system-sf2e .ei-grid-item.ei-rarity-uncommon,
body.system-sf2e .ei-overflow-item.ei-rarity-uncommon { box-shadow: inset 0 0 0 2px #98513d; }
body.system-pf2e .ei-grid-item.ei-rarity-rare,
body.system-pf2e .ei-overflow-item.ei-rarity-rare,
body.system-sf2e .ei-grid-item.ei-rarity-rare,
body.system-sf2e .ei-overflow-item.ei-rarity-rare { box-shadow: inset 0 0 0 2px #002664; }
body.system-pf2e .ei-grid-item.ei-rarity-unique,
body.system-pf2e .ei-overflow-item.ei-rarity-unique,
body.system-sf2e .ei-grid-item.ei-rarity-unique,
body.system-sf2e .ei-overflow-item.ei-rarity-unique { box-shadow: inset 0 0 0 2px #54166e; }

.ei-popout-props {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  padding: 5px 10px;
  font-size: 11px;
  color: #5c4a32;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.ei-popout-desc {
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.5;
  max-height: 220px;
  overflow-y: auto;
}
.ei-popout-desc p { margin: 0 0 6px; }
.ei-popout-desc p:last-child { margin-bottom: 0; }

.ei-popout-buttons {
  display: flex;
  gap: 4px;
  padding: 6px 10px 8px;
  border-top: 1px solid #c4a97d;
}

.ei-popout-buttons button {
  flex: 1;
  padding: 5px 8px;
  border: 1px solid #8b7355;
  border-radius: 3px;
  background: rgba(139, 115, 85, 0.15);
  color: #1c1817;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: background 0.15s;
}
.ei-popout-buttons button:hover { background: rgba(139, 115, 85, 0.3); }
.ei-popout-buttons button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ei-popout-btn-secondary {
  flex: 0 !important;
  padding: 5px 10px !important;
  background: rgba(0, 0, 0, 0.04) !important;
  border-color: rgba(139, 115, 85, 0.4) !important;
  font-size: 11px !important;
}
