/* Editor de ícones de itens — página dedicada. */

:root {
  --ie-bg: #071018;
  --ie-panel: rgba(10, 18, 28, 0.94);
  --ie-panel-border: rgba(148, 163, 184, 0.2);
  --ie-card: #0c1520;
  --ie-text: #e2e8f0;
  --ie-text-dim: #94a3b8;
  --ie-accent: #5eead4;
  --ie-accent-soft: rgba(94, 234, 212, 0.14);
  --ie-warn: #fbbf24;
  --ie-danger: #f87171;
  --ie-ok: #34d399;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(45, 212, 191, 0.12), transparent),
    var(--ie-bg);
  color: var(--ie-text);
  font: 14px/1.45 "Segoe UI", system-ui, sans-serif;
}

.ie-app {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 100vh;
  padding: 12px;
}

.ie-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  padding: 12px 16px;
  background: var(--ie-panel);
  border: 1px solid var(--ie-panel-border);
  border-radius: 12px;
  position: sticky;
  top: 8px;
  z-index: 5;
  backdrop-filter: blur(8px);
}

.ie-header__meta {
  min-width: 0;
}

.ie-header__title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.ie-header__subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--ie-text-dim);
}

.ie-header__status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-left: auto;
}

.ie-status {
  font-size: 12px;
  color: var(--ie-text-dim);
}

.ie-dirty {
  font-size: 11px;
  font-weight: 650;
  color: var(--ie-warn);
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.28);
}

.ie-api {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
}

.ie-api.is-online {
  color: var(--ie-ok);
  background: rgba(52, 211, 153, 0.1);
  border-color: rgba(52, 211, 153, 0.28);
}

.ie-api.is-offline {
  color: var(--ie-danger);
  background: rgba(248, 113, 113, 0.1);
  border-color: rgba(248, 113, 113, 0.28);
}

.ie-header__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.ie-input {
  min-width: 180px;
  background: #0a121c;
  border: 1px solid var(--ie-panel-border);
  border-radius: 8px;
  color: var(--ie-text);
  padding: 7px 10px;
  font: inherit;
}

.ie-input--grow {
  flex: 1 1 200px;
  min-width: 160px;
}

.ie-tabs,
.ie-icon-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  background: var(--ie-panel);
  border: 1px solid var(--ie-panel-border);
  border-radius: 12px;
}

.ie-tabs {
  position: sticky;
  top: 88px;
  z-index: 4;
  backdrop-filter: blur(8px);
}

.ie-icon-tabs {
  flex: 1 1 auto;
  background: transparent;
  border: none;
  padding: 0;
}

.ie-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 7px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ie-text-dim);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.ie-tab:hover {
  color: var(--ie-text);
  background: rgba(148, 163, 184, 0.08);
}

.ie-tab.is-active {
  color: var(--ie-accent);
  background: var(--ie-accent-soft);
  border-color: rgba(94, 234, 212, 0.35);
}

.ie-tab__count {
  min-width: 1.4em;
  padding: 0 5px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.5;
  color: inherit;
  background: rgba(148, 163, 184, 0.14);
}

.ie-tab.is-active .ie-tab__count {
  background: rgba(94, 234, 212, 0.2);
}

.ie-btn {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--ie-panel-border);
  background: #0a121c;
  color: var(--ie-text);
  text-decoration: none;
  font: inherit;
  cursor: pointer;
}

.ie-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ie-btn--primary {
  background: var(--ie-accent-soft);
  border-color: rgba(94, 234, 212, 0.45);
  color: var(--ie-accent);
  font-weight: 650;
}

.ie-btn--primary:not(:disabled):hover {
  background: rgba(94, 234, 212, 0.22);
}

.ie-btn--ghost:not(:disabled):hover {
  border-color: rgba(248, 113, 113, 0.45);
  color: var(--ie-danger);
}

.ie-btn--link:hover {
  border-color: var(--ie-accent);
  color: var(--ie-accent);
}

.ie-body {
  display: grid;
  grid-template-columns: minmax(240px, 320px) 1fr;
  gap: 12px;
  align-items: start;
  min-height: 0;
  flex: 1;
}

.ie-roster {
  position: sticky;
  top: 148px;
  max-height: calc(100vh - 160px);
  overflow: auto;
  background: var(--ie-panel);
  border: 1px solid var(--ie-panel-border);
  border-radius: 12px;
  padding: 8px;
}

.ie-roster__list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ie-item {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 10px;
  align-items: center;
  width: 100%;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.ie-item:hover {
  background: rgba(148, 163, 184, 0.08);
}

.ie-item.is-selected {
  background: var(--ie-accent-soft);
  border-color: rgba(94, 234, 212, 0.35);
}

.ie-item.is-dirty {
  border-color: rgba(251, 191, 36, 0.55);
}

.ie-item__icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #0a121c;
  border: 1px solid rgba(148, 163, 184, 0.12);
  overflow: hidden;
}

.ie-item__icon img,
.ie-item__icon .item-icon--tileset,
.ie-detail__preview img,
.ie-detail__preview .item-icon--tileset,
.ie-preview-icon {
  width: 28px;
  height: 28px;
  image-rendering: pixelated;
  object-fit: contain;
}

.ie-detail__preview img,
.ie-detail__preview .item-icon--tileset,
.ie-detail__preview .ie-preview-icon {
  width: 48px;
  height: 48px;
}

.ie-icon__host {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
}

.ie-icon__host img,
.ie-icon__glyph {
  width: 40px;
  height: 40px;
  image-rendering: pixelated;
  object-fit: contain;
}

.ie-item__icon-empty {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  background: rgba(148, 163, 184, 0.25);
}

.ie-item__name {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
}

.ie-item__key {
  margin: 0;
  font-size: 11px;
  color: var(--ie-text-dim);
  font-family: ui-monospace, Consolas, monospace;
}

.ie-detail,
.ie-empty {
  background: var(--ie-panel);
  border: 1px solid var(--ie-panel-border);
  border-radius: 12px;
  padding: 14px;
  min-width: 0;
}

.ie-empty {
  display: grid;
  place-items: center;
  min-height: 280px;
  color: var(--ie-text-dim);
}

.ie-empty p {
  margin: 0;
}

.ie-detail__head {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  margin-bottom: 14px;
}

.ie-detail__preview {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background:
    linear-gradient(45deg, #121a24 25%, transparent 25%) 0 0 / 12px 12px,
    linear-gradient(-45deg, #121a24 25%, transparent 25%) 0 6px / 12px 12px,
    linear-gradient(45deg, transparent 75%, #121a24 75%) 6px -6px / 12px 12px,
    linear-gradient(-45deg, transparent 75%, #121a24 75%) -6px 0 / 12px 12px,
    #0a1018;
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.ie-detail__name {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.ie-detail__key,
.ie-detail__rel {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--ie-text-dim);
  font-family: ui-monospace, Consolas, monospace;
}

.ie-detail__meta .ie-btn {
  margin-top: 8px;
}

.ie-picker-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.ie-icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
  max-height: calc(100vh - 320px);
  overflow: auto;
  padding: 2px;
}

.ie-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 8px 6px;
  border: 1px solid var(--ie-panel-border);
  border-radius: 10px;
  background: var(--ie-card);
  color: inherit;
  font: inherit;
  cursor: pointer;
  min-width: 0;
}

.ie-icon:hover {
  border-color: rgba(94, 234, 212, 0.45);
}

.ie-icon.is-selected {
  border-color: rgba(94, 234, 212, 0.65);
  background: var(--ie-accent-soft);
  box-shadow: 0 0 0 1px rgba(94, 234, 212, 0.25);
}

.ie-icon__label {
  width: 100%;
  font-size: 10px;
  color: var(--ie-text-dim);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 900px) {
  .ie-body {
    grid-template-columns: 1fr;
  }

  .ie-roster {
    position: static;
    max-height: 240px;
  }

  .ie-header__status {
    margin-left: 0;
    width: 100%;
  }

  .ie-tabs {
    top: 8px;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .ie-tab {
    flex: 0 0 auto;
  }
}
