/* ============================================================
   Kit Builder - Rust inventory aesthetic
   ============================================================ */

/* Layout */
.kb-wrap {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  min-height: 520px;
}

/* Left: inventory panel */
.kb-inventory {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Wear slots: arranged around a character silhouette */
.kb-wear {
  position: relative;
  display: grid;
  grid-template-columns: 64px 100px 64px;
  grid-template-rows: repeat(5, 64px);
  gap: 6px;
  justify-items: center;
  align-items: center;
}

/* Character silhouette column fills rows 1-5 center */
.kb-char {
  grid-column: 2;
  grid-row: 1 / 6;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.kb-char svg {
  width: 90px;
  height: auto;
  opacity: 0.18;
  filter: drop-shadow(0 0 8px rgba(150, 200, 255, 0.1));
}

/* Slot positions around the character */
.kb-slot[data-slot="head"]  { grid-column: 2; grid-row: 1; }
.kb-slot[data-slot="chest"] { grid-column: 2; grid-row: 2; }
.kb-slot[data-slot="legs"]  { grid-column: 2; grid-row: 3; }
.kb-slot[data-slot="feet"]  { grid-column: 2; grid-row: 4; }
.kb-slot[data-slot="back"]  { grid-column: 1; grid-row: 2; }
.kb-slot[data-slot="hands"] { grid-column: 3; grid-row: 2; }
.kb-slot[data-slot="face"]  { grid-column: 3; grid-row: 1; }

/* Belt bar */
.kb-belt {
  display: flex;
  gap: 6px;
  justify-content: center;
}

/* Individual slot */
.kb-slot {
  position: relative;
  width: 64px;
  height: 64px;
  background: #1a1f26;
  border: 1px solid #2e3740;
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.kb-slot:hover {
  border-color: #5a7fa0;
  background: #1e252e;
  box-shadow: 0 0 0 1px rgba(90, 127, 160, 0.3);
}
.kb-slot:focus-visible {
  outline: none;
  border-color: var(--accent, #5a9fd4);
  box-shadow: 0 0 0 2px rgba(90, 159, 212, 0.4);
}
.kb-slot.is-drag-over {
  border-color: #7db8e8;
  background: #1c2a38;
}
.kb-slot.is-dragging {
  opacity: 0.5;
}

/* Item icon inside slot */
.kb-slot-img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  pointer-events: none;
  image-rendering: pixelated;
}

/* Amount badge */
.kb-slot-qty {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #c8d4e0;
  text-shadow: 0 1px 3px #000, 0 0 6px #000;
  pointer-events: none;
}

/* Skin indicator dot */
.kb-slot-skin {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4fa8ff;
  box-shadow: 0 0 4px rgba(79, 168, 255, 0.7);
  pointer-events: none;
}

/* Empty slot icon */
.kb-slot-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #2e3740;
  transition: color 0.15s;
}
.kb-slot:hover .kb-slot-empty { color: #3d4f60; }

/* Slot label below (belt only) */
.kb-belt-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.kb-slot-label {
  font-size: 0.64rem;
  color: #3d5060;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

/* Right: kit panel */
.kb-panel {
  flex: 1;
  min-width: 240px;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.kb-panel-section {
  background: #151a20;
  border: 1px solid #232c36;
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.kb-panel-title {
  font-family: "Cinzel", serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #5a7fa0;
  margin: 0 0 0.25rem;
}

/* Inputs */
.kb-input,
.kb-textarea {
  width: 100%;
  box-sizing: border-box;
  background: #0f1318;
  border: 1px solid #2e3740;
  border-radius: 5px;
  color: #c8d4e0;
  font-family: inherit;
  font-size: 0.88rem;
  padding: 0.45rem 0.65rem;
  transition: border-color 0.15s;
  resize: vertical;
}
.kb-input:focus,
.kb-textarea:focus {
  outline: none;
  border-color: #5a7fa0;
}
.kb-input::placeholder,
.kb-textarea::placeholder { color: #3d5060; }
.kb-textarea { min-height: 60px; }

/* Toggle */
.kb-toggle-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.kb-toggle {
  position: relative;
  width: 38px;
  height: 20px;
  flex-shrink: 0;
  cursor: pointer;
}
.kb-toggle input { opacity: 0; width: 0; height: 0; }
.kb-toggle-track {
  position: absolute;
  inset: 0;
  background: #1e2a36;
  border: 1px solid #2e3740;
  border-radius: 10px;
  transition: background 0.2s, border-color 0.2s;
}
.kb-toggle input:checked + .kb-toggle-track {
  background: #1e4060;
  border-color: #4fa8ff;
}
.kb-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #3d5060;
  transition: transform 0.2s, background 0.2s;
}
.kb-toggle input:checked ~ .kb-toggle-thumb {
  transform: translateX(18px);
  background: #4fa8ff;
}
.kb-toggle-label {
  font-size: 0.84rem;
  color: #8fa8b8;
}

/* Action buttons */
.kb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid transparent;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
  text-decoration: none;
}
.kb-btn:disabled { opacity: 0.45; cursor: default; }
.kb-btn-primary {
  background: #1e4060;
  border-color: #4fa8ff;
  color: #c8e8ff;
}
.kb-btn-primary:not(:disabled):hover {
  background: #2a5678;
  border-color: #7dc8ff;
}
.kb-btn-ghost {
  background: #151a20;
  border-color: #2e3740;
  color: #8fa8b8;
}
.kb-btn-ghost:not(:disabled):hover {
  border-color: #5a7fa0;
  color: #c8d4e0;
}
.kb-btn-danger {
  background: #2a1515;
  border-color: #883030;
  color: #e8a8a8;
}
.kb-btn-danger:not(:disabled):hover {
  background: #3a1a1a;
  border-color: #bb4444;
}
.kb-btn-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.kb-btn-full { width: 100%; }

/* Share link */
.kb-share-link {
  display: flex;
  gap: 0.5rem;
}
.kb-share-input {
  flex: 1;
  min-width: 0;
  background: #0f1318;
  border: 1px solid #2e3740;
  border-radius: 5px;
  color: #8fa8b8;
  font-size: 0.78rem;
  padding: 0.4rem 0.6rem;
}
.kb-share-copy {
  flex-shrink: 0;
}

/* Status message */
.kb-status {
  font-size: 0.82rem;
  color: #8fa8b8;
  min-height: 1.2em;
}
.kb-status.ok { color: #6fc86f; }
.kb-status.err { color: #e07070; }

/* Export textarea */
.kb-export {
  font-family: Consolas, Menlo, monospace;
  font-size: 0.78rem;
  background: #0a0d10;
  border-color: #1e2a36;
  color: #5a7fa0;
  min-height: 80px;
}

/* Auth notice */
.kb-auth-notice {
  background: #151a20;
  border: 1px solid #2e3740;
  border-radius: 8px;
  padding: 0.9rem 1rem;
  font-size: 0.85rem;
  color: #8fa8b8;
  text-align: center;
}
.kb-auth-notice a { color: var(--accent, #5a9fd4); }

/* Read-only banner */
.kb-readonly-banner {
  background: #1a2232;
  border: 1px solid #2e4a6a;
  border-radius: 6px;
  padding: 0.7rem 1rem;
  font-size: 0.85rem;
  color: #8fa8b8;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.kb-readonly-banner strong { color: #c8d4e0; }

/* ============================================================
   Item Picker Modal
   ============================================================ */
.kb-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.kb-modal {
  background: #10151c;
  border: 1px solid #2e3740;
  border-radius: 10px;
  width: 100%;
  max-width: 520px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.8);
}
.kb-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.2rem 0.75rem;
  border-bottom: 1px solid #1e2a36;
  flex-shrink: 0;
}
.kb-modal-title {
  font-family: "Cinzel", serif;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #c8d4e0;
  margin: 0;
}
.kb-modal-close {
  background: none;
  border: none;
  color: #5a7fa0;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  line-height: 1;
  font-size: 1.2rem;
}
.kb-modal-close:hover { color: #c8d4e0; }
.kb-modal-search {
  padding: 0.75rem 1.2rem;
  flex-shrink: 0;
}
.kb-modal-search-input {
  width: 100%;
  box-sizing: border-box;
  background: #0f1318;
  border: 1px solid #2e3740;
  border-radius: 5px;
  color: #c8d4e0;
  font-family: inherit;
  font-size: 0.88rem;
  padding: 0.5rem 0.75rem;
}
.kb-modal-search-input:focus { outline: none; border-color: #5a7fa0; }
.kb-modal-cats {
  display: flex;
  gap: 0.4rem;
  padding: 0 1.2rem 0.6rem;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.kb-cat-btn {
  padding: 0.25rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 1px solid #2e3740;
  border-radius: 999px;
  background: #151a20;
  color: #5a7fa0;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.kb-cat-btn.active,
.kb-cat-btn:hover {
  background: #1e3050;
  border-color: #4fa8ff;
  color: #c8e8ff;
}
.kb-modal-list {
  overflow-y: auto;
  flex: 1;
  padding: 0.25rem 1.2rem 1.2rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 6px;
  align-content: start;
}
.kb-item-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 0.4rem 0.3rem 0.35rem;
  background: #151a20;
  border: 1px solid #232c36;
  border-radius: 5px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
  text-align: center;
}
.kb-item-btn:hover,
.kb-item-btn:focus-visible {
  border-color: #5a7fa0;
  background: #1a2232;
  outline: none;
}
.kb-item-btn img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  image-rendering: pixelated;
}
.kb-item-btn span {
  font-size: 0.62rem;
  color: #8fa8b8;
  line-height: 1.2;
  word-break: break-word;
  max-width: 68px;
}
.kb-modal-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: #3d5060;
  font-size: 0.88rem;
  padding: 2rem 0;
}

/* ============================================================
   Slot Editor Modal (click filled slot)
   ============================================================ */
.kb-editor {
  max-width: 380px;
}
.kb-editor-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid #1e2a36;
}
.kb-editor-img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  image-rendering: pixelated;
  background: #1a1f26;
  border: 1px solid #2e3740;
  border-radius: 4px;
  padding: 2px;
}
.kb-editor-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: #c8d4e0;
}
.kb-editor-cat {
  font-size: 0.75rem;
  color: #5a7fa0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.kb-editor-fields {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.kb-editor-label {
  font-size: 0.78rem;
  color: #8fa8b8;
  margin-bottom: 0.3rem;
  display: block;
}
.kb-qty-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.kb-qty-btn {
  width: 28px;
  height: 28px;
  background: #1e2a36;
  border: 1px solid #2e3740;
  border-radius: 4px;
  color: #c8d4e0;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.kb-qty-btn:hover { border-color: #5a7fa0; }
.kb-qty-input {
  width: 56px;
  text-align: center;
  background: #0f1318;
  border: 1px solid #2e3740;
  border-radius: 4px;
  color: #c8d4e0;
  font-family: inherit;
  font-size: 0.88rem;
  padding: 0.25rem;
}
.kb-qty-input:focus { outline: none; border-color: #5a7fa0; }

/* Skin list in editor */
.kb-skin-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(62px, 1fr));
  gap: 5px;
  max-height: 200px;
  overflow-y: auto;
}
.kb-skin-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 0.3rem;
  background: #151a20;
  border: 1px solid #232c36;
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
  text-align: center;
}
.kb-skin-btn:hover,
.kb-skin-btn:focus-visible { border-color: #5a7fa0; background: #1a2232; outline: none; }
.kb-skin-btn.active { border-color: #4fa8ff; background: #1e3050; }
.kb-skin-btn img { width: 44px; height: 44px; object-fit: contain; }
.kb-skin-btn span { font-size: 0.6rem; color: #8fa8b8; line-height: 1.2; max-width: 58px; word-break: break-word; }
.kb-skin-none {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #3d5060;
  font-size: 0.72rem;
}
.kb-skin-loading { color: #3d5060; font-size: 0.82rem; text-align: center; padding: 1rem; }

/* Editor footer */
.kb-editor-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 0.85rem;
  margin-top: 0.85rem;
  border-top: 1px solid #1e2a36;
}

/* Responsive */
@media (max-width: 720px) {
  .kb-wrap {
    flex-direction: column;
    align-items: stretch;
  }
  .kb-inventory {
    align-items: center;
  }
  .kb-panel {
    max-width: 100%;
  }
}
@media (max-width: 480px) {
  .kb-wear {
    grid-template-columns: 56px 88px 56px;
    grid-template-rows: repeat(5, 56px);
  }
  .kb-slot { width: 56px; height: 56px; }
  .kb-belt .kb-slot { width: 52px; height: 52px; }
}
