/* ============================================
   Heroes - Hero Pool, Category Tabs, Icons
   ============================================ */

/* ============================================
   Hero Pool Container
   ============================================ */
.hero-pool {
  background: var(--bg-card);
  border-radius: 10px;
  padding: 15px;
  margin-top: 20px;
  border: 2px solid transparent;
  transition: border-color 0.3s, background-color 0.3s;
  user-select: none;
  -webkit-user-select: none;
}

[data-theme="light"] .hero-pool {
  box-shadow: 0 2px 8px var(--shadow-color);
}

.hero-pool.drag-over {
  border: 2px solid var(--color-highlight);
  background: rgba(74, 144, 217, 0.1);
}

.hero-pool.tap-target {
  border: 2px solid #00ff00;
  background: rgba(0, 255, 0, 0.05);
}

.hero-pool.hidden {
  display: none;
}

/* ============================================
   Pool Header
   ============================================ */
.pool-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
  margin-bottom: 12px;
  user-select: none;
  -webkit-user-select: none;
}

.pool-title {
  color: var(--text-secondary);
  font-size: 16px;
  font-weight: 600;
}

/* ============================================
   Hero Search
   ============================================ */
.pool-search {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.search-input {
  padding: 8px 32px 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  width: 100%;
  transition: border-color 0.2s, width 0.2s, box-shadow 0.2s;
}

.search-input:focus {
  outline: none;
  border-color: var(--color-highlight);
  box-shadow: 0 0 0 2px var(--color-highlight-glow);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-clear {
  position: absolute;
  right: 4px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  padding: 8px;
  line-height: 1;
  display: none;
}

.search-clear.visible {
  display: block;
}

.search-clear:hover {
  color: var(--text-secondary);
}

@media (min-width: 601px) {
  .pool-header {
    flex-direction: row;
    gap: 0;
    justify-content: space-between;
    align-items: center;
  }

  .pool-search {
    width: auto;
  }

  .search-input {
    width: 180px;
  }

  .search-input:focus {
    width: 220px;
  }
}

/* ============================================
   Category Tabs
   ============================================ */
.category-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 15px;
  flex-wrap: wrap;
  user-select: none;
  -webkit-user-select: none;
}

.category-tab {
  padding: 8px 16px;
  font-size: 14px;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  border: 2px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.category-tab:hover {
  background: var(--bg-interactive-hover);
  color: var(--text-secondary);
}

[data-theme="light"] .category-tab {
  background: #dfe1e6;
  color: #444;
  border-color: #c8ccd0;
}

[data-theme="light"] .category-tab:hover {
  background: #c8ccd0;
  color: #222;
}

.category-tab.active {
  background: var(--bg-active);
  color: #fff;
  border-color: var(--border-active);
}

.category-tab.mythic.active { background: var(--cat-mythic); border-color: var(--cat-mythic-hover); }
.category-tab.legendary.active { background: var(--cat-legendary); border-color: var(--cat-legendary-hover); }
.category-tab.epic.active { background: var(--cat-epic); border-color: var(--cat-epic-hover); }
.category-tab.rare.active { background: var(--cat-rare); border-color: var(--cat-rare-hover); }
.category-tab.common.active { background: var(--cat-common); border-color: var(--cat-common-hover); }

/* Focus styles for keyboard navigation */
.category-tab:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

/* ============================================
   Pool Content
   ============================================ */
.pool-content {
  display: flex;
  flex-wrap: wrap;
  max-height: 450px;
  overflow-y: auto;
  min-height: 80px;
  padding-bottom: 50px; /* Space for tooltip below last row */
}

.pool-content:empty::after {
  content: "No heroes to display";
  width: 100%;
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-style: italic;
  opacity: 0.6;
}

/* Category sections in pool */
.category-section {
  display: none;
  flex-wrap: wrap;
  width: 100%;
}

.category-section.active {
  display: flex;
}

.category-label {
  width: 100%;
  color: #666;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin: 10px 0 5px 5px;
  padding-bottom: 5px;
  border-bottom: 1px solid #333;
}

[data-theme="light"] .category-label {
  color: #555;
  border-color: #ccc;
}

.category-label:first-child {
  margin-top: 0;
}

/* ============================================
   Icons (Hero Cards)
   ============================================ */
.icon {
  position: relative;
  display: inline-block;
  width: 55px;
  height: 55px;
  margin: 3px;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: element;
  transition: transform 0.2s, opacity 0.2s;
}

@media (min-width: 601px) {
  .icon {
    width: 70px;
    height: 70px;
  }
}

/* The actual image inside wrapper */
.icon .icon-img {
  width: 100%;
  height: 100%;
  border: 2px solid #333;
  border-radius: 8px;
  overflow: hidden;
  object-fit: cover;
  display: block;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.icon:hover {
  transform: scale(1.08) translateY(-2px);
  z-index: 100;
}

.icon:hover .icon-img {
  border-color: #888;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Light theme icon borders */
[data-theme="light"] .icon .icon-img {
  border-color: #ccc;
}

[data-theme="light"] .icon:hover .icon-img {
  border-color: #888;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ============================================
   Hero Name Tooltip
   ============================================ */
.hero-tooltip {
  position: fixed;
  background: linear-gradient(135deg, #2a2a4a 0%, #1a1a2e 100%);
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  max-width: min(200px, 90vw);
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 1050;
  opacity: 0;
  transform: translateX(-50%) translateY(8px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.hero-tooltip.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.hero-tooltip::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-bottom-color: #2a2a4a;
}

/* Light theme hero tooltip */
[data-theme="light"] .hero-tooltip {
  background: linear-gradient(135deg, #ffffff 0%, #f0f2f5 100%);
  color: #1a1a2e;
  border-color: rgba(0, 0, 0, 0.15);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .hero-tooltip::before {
  border-bottom-color: #ffffff;
}

/* ============================================
   Icon States
   ============================================ */
.icon:active {
  cursor: grabbing;
}

.icon.dragging {
  opacity: 0.5;
  transform: scale(1.1);
}

.icon.dragging .icon-img {
  box-shadow: 0 0 20px rgba(74, 144, 217, 0.5);
}

.icon.selected .icon-img {
  border: 3px solid #00ff00;
  box-shadow: 0 0 15px rgba(0, 255, 0, 0.5);
}

.icon.selected {
  transform: scale(1.05);
}

.icon.readonly {
  cursor: default;
}

/* ============================================
   Category Border Colors
   ============================================ */
.icon.mythic .icon-img { border-color: var(--cat-mythic); }
.icon.mythic:hover .icon-img { border-color: var(--cat-mythic-hover); box-shadow: 0 0 10px var(--cat-mythic-glow); }
.icon.legendary .icon-img { border-color: var(--cat-legendary); }
.icon.legendary:hover .icon-img { border-color: var(--cat-legendary-hover); box-shadow: 0 0 10px var(--cat-legendary-glow); }
.icon.epic .icon-img { border-color: var(--cat-epic); }
.icon.epic:hover .icon-img { border-color: var(--cat-epic-hover); box-shadow: 0 0 10px var(--cat-epic-glow); }
.icon.rare .icon-img { border-color: var(--cat-rare); }
.icon.rare:hover .icon-img { border-color: var(--cat-rare-hover); box-shadow: 0 0 10px var(--cat-rare-glow); }
.icon.common .icon-img { border-color: var(--cat-common); }
.icon.common:hover .icon-img { border-color: var(--cat-common-hover); box-shadow: 0 0 10px var(--cat-common-glow); }

/* ============================================
   Icon Placement Animation
   ============================================ */
@keyframes placeIcon {
  0% {
    transform: scale(1.2);
    opacity: 0.7;
  }
  50% {
    transform: scale(0.95);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.icon.just-placed {
  animation: placeIcon 0.3s ease-out;
}

/* ============================================
   Drag Ghost Element
   ============================================ */
.drag-ghost {
  pointer-events: none !important;
  z-index: -9999 !important;
}
