:root {
  --gridsize: 8;
}

/* Container for Type Filters */
.item-type-filters {
  display: flex;
  flex-wrap: wrap; /* Allow wrapping if needed */
  gap: 10px; /* Space between type filter buttons */
  margin: 10px 0; /* Space below to separate from filter buttons */
}

/* Individual Type Options */
.type-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 15px 6px 15px;
  background-color: #3a3939;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 0.3s ease, transform 0.2s ease;
  text-align: center;
}

.type-option.selected {
  background-color: #555; /* Highlight selected button */
}

.type-option:hover {
  background-color: #444; /* Hover effect */
}

.type-option img {
  height: 30px;
  margin-bottom: 5px; /* Space between icon and text */
}

.search-bar {
  position: relative; /* Ensures .clear-search is positioned relative to this container */
  width: 100%; /* Makes the search bar responsive */
  max-width: 250px; /* Optional: cap the width for larger screens */
}

.search-bar input {
  min-width: 200px;
  width: 100%; /* Takes up the full width of the parent */
  padding-right: 40px; /* Adds space for the clear-search button */
  font-size: 14px;
  color: #fff;
  background-color: #333;
  border: none;
  border-radius: 20px;
  outline: none;
  transition: background-color 0.3s ease;
  text-transform: uppercase;
}

.search-bar input::placeholder {
  color: #aaa; /* Placeholder text color */
}

.search-bar input:focus {
  background-color: #444;

  /* Unset WP Astra default styles */
  border-color: unset !important;
  color: unset !important;
  border-style: unset !important;
  border-width: unset !important;
}

.clear-search {
  position: absolute;
  right: 5px; /* Keeps it within the bounds of the input */
  padding: 10px; /* Adjust padding for better alignment */
  top: 50%; /* Vertically centers the button */
  transform: translateY(-50%); /* Ensures proper centering */
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.3s ease;
}

.clear-search img {
  height: 20px;
}

.clear-search:hover {
  /* Unset WP Astra default styles */
  background-color: unset !important;
  border-color: unset !important;
}

/* Hide button if not needed */
.clear-search[style*="display: none"] {
  display: none !important;
}

.filter-select,
.sort-by-button,
.filter-badge,
.clear-filters {
  position: relative;
  cursor: pointer;
  padding: 8px 15px 6px 15px;
  background: #333;
  border-radius: 20px;
  color: #fff;
  text-align: center;
  user-select: none;
  transition: background-color 0.2s;
  flex: none; /* Buttons retain their natural width */
  height: 100%;
  width: max-content;
}

.filter-select:hover,
.sort-by-button:hover,
.filter-badge:hover {
  background-color: #444;
}

.filter-option {
  display: flex;
  align-items: center;
  gap: 10px; /* Space between icon and text */
  background: #333; /* Background color */
  border-radius: 5px; /* Rounded corners */
  padding: 10px 20px 10px 10px;
  cursor: pointer;
  transition: background-color 0.2s; /* Smooth hover effect */
}

.filter-option:hover {
  background: #444; /* Slightly lighter background on hover */
}

.filter-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.filter-name {
  color: #fff; /* Text color */
  font-size: 14px; /* Match font size */
}

/* Container for Sort By */
.sort-by-container {
  position: relative; /* Required for its dropdown alignment */
  margin-left: auto; /* Push button to the right */
  /*min-width: 100px;*/
}

.sort-by-button:focus {
  background-color: #444;

  /* Unset WP Astra default styles */
  border-color: unset !important;
}

/* Dropdown Options */
.sort-options {
  display: none; /* Hidden by default */
  grid-template-columns: repeat(2, 1fr); /* Two columns */
  gap: 10px; /* Space between options */
  white-space: nowrap;
}

/* Global Popup Specific Styling */
.sort-options.global-popup {
  display: grid !important; /* Display as grid */
  position: absolute; /* Ensure it is positioned absolutely */
  top: 100%; /* Position the popup below the button */
  background-color: #222; /* Popup background */
  border-radius: 5px;
  box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.5);
  z-index: 1000030; /* Ensure it is above all other elements */
  padding: 10px;
  overflow: hidden; /* Prevent content overflow */
  min-width: 200px; /* Ensure minimum width for content */
}

/* Sort Options */
.sort-options .sort-option {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  background-color: #333;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.sort-options .sort-option:hover {
  background-color: #444;
}

/* Show Dropdown */
.sort-by-container.active .sort-options {
  display: grid; /* Default grid for non-global-popup dropdowns */
}

.active-filters-parent {
  display: flex;
  flex-wrap: wrap; /* Allow wrapping to new lines */
  gap: 10px; /* Space between badges and button */
  align-items: center; /* Align items vertically */
}

.active-filters {
  display: flex;
  gap: 10px; /* Space between badges */
}

.filter-badge,
.clear-filters {
  margin-top: 10px;
}

.remove-filter img {
  height: 20px;
  margin-bottom: 3px;
}

.filter-badge .remove-filter {
  margin-left: 5px;
  transition: color 0.3s ease;
}

.clear-filters {
  color: #d91717;
  background: transparent;
  height: unset;
  border: 1px solid #d91717;
}

.clear-filters:hover {
  color: #fff;
  background-color: #d91717;
  border: 1px solid #d91717;
}

/* General container styling for scrollable rows */
.scrollable-row {
  display: flex;
  overflow-x: auto; /* Allow horizontal scrolling */
  overflow-y: hidden; /* Prevent vertical scrolling */
  gap: 10px; /* Space between items */
  padding-bottom: 10px;
  -webkit-overflow-scrolling: touch; /* Enable smooth scrolling on iOS */
  scrollbar-width: auto; /* Wider scrollbar for non-WebKit browsers */
}

/* Custom scrollbar styling */
.scrollable-row::-webkit-scrollbar {
  height: 16px; /* Horizontal scrollbar height */
}

.scrollable-row::-webkit-scrollbar-thumb {
  background: #555; /* Scrollbar color */
  border-radius: 8px; /* Rounded corners */
  border: 4px solid transparent; /* Add spacing around the scrollbar thumb */
  background-clip: content-box; /* Prevent the border from overlapping the thumb */
}

.scrollable-row::-webkit-scrollbar-thumb:hover {
  background: #777; /* Hover color */
}

.scrollable-row::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 8px; /* Match the thumb's border-radius */
}

/* Disable scrollbar pointer events on mobile */
@media (pointer: coarse) {
  .scrollable-row {
    overflow-x: auto; /* Ensure touch dragging works */
    pointer-events: auto; /* Allow interaction with items inside */
  }

  .scrollable-row::-webkit-scrollbar {
    pointer-events: none; /* Disable interaction with the scrollbar */
  }
}

/* Item Type Filters */
.item-type-filters,
.filter-buttons,
.active-filters-parent {
  flex-wrap: nowrap; /* Prevent wrapping */
  overflow-x: auto; /* Horizontal scrolling only */
  overflow-y: hidden; /* Prevent vertical scrolling */
}

.filter-popup {
  position: absolute;
  top: calc(100% + 5px); /* Default positioning below the button */
  left: 0;
  background: #222;
  border: 1px solid #444;
  border-radius: 10px;
  display: none; /* Hidden by default */
  padding: 15px;
  z-index: 100;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
  width: max-content;
}

.filter-popup-list {
  text-align: left;
  display: grid;
  gap: 10px;
}

.filter-select.active .filter-popup {
  display: block; /* Show the popup when active */
}

.global-popup {
  z-index: 1000030; /* Ensure it is on top of everything */
  background: #222;
  border: 1px solid #444;
  border-radius: 8px;
  box-shadow: 0px 8px 24px rgba(0, 0, 0, 0.5);
  padding: 15px;
  text-align: center; /* Center content inside */
}

.heroes-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.role-grid {
  display: grid;
  grid-template-columns: repeat(
    auto-fit,
    minmax(150px, 1fr)
  ); /* Flexible grid */
  gap: 10px;
}

.hero-option {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #333;
  border-radius: 5px;
  padding-right: 10px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.hero-option:hover {
  background: #444;
}

.hero-icon {
  width: 40px;
  height: 40px;
}

.hero-name {
  color: #fff;
  font-size: 14px;
}

.role-icon {
  width: 24px;
  height: 24px;
}

/* Default arrow styling */
.arrow {
  display: inline-block;
  margin-left: 5px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  padding: 3px;
  transform: rotate(45deg);
  transition: transform 0.2s ease; /* Smooth rotation */
  margin-bottom: 4px;
}

/* Arrow pointing down */
.filter-select.active .arrow,
.sort-by-container.active .arrow {
  transform: rotate(225deg);
  margin-bottom: 0px;
}

/* Settings */
.filter-settings-container {
  padding-left: 8px;
  padding-right: 8px;
}

.settings-icon {
  width: 24px;
  height: 24px;
  margin-top: -2px;
}

.settings-icon-container {
  transition: transform 0.3s ease;
}

.filter-settings-container.active .settings-icon-container {
  transform: rotate(45deg);
}

.toggle-option {
  color: var(--ast-global-color-5);
  display: flex;
  gap: 10px;
  align-items: flex-end;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  font-size: 16px;
}

.toggle-option input {
  display: none;
}

.toggle-switch {
  position: relative;
  width: 50px;
  height: 25px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #666;
  border-radius: 20px;
  /*transition: background 0.3s;*/
}

.toggle-slider:before {
  content: "";
  position: absolute;
  width: 21px;
  height: 21px;
  left: 2px;
  bottom: 2px;
  background: white;
  border-radius: 50%;
  /*transition: transform 0.3s;*/
}

.toggle-switch input:checked + .toggle-slider {
  background: #0a84ff;
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(25.4px);
}

.item-grid {
  display: grid;
  gap: 10px;
  padding: 20px 0;
}

/* Item Card */
.item-card {
  position: relative;
  z-index: 1;
  border-radius: 10px;
  border: 1px solid #444; /* Regular border */
  outline: 0px solid transparent; /* Default outline */
  transition: outline 0.1s ease-out, transform 0.1s ease-out; /* Smooth outline and scale transition */
  box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
}

/* Hover Effect for Item Card */
.item-card:hover {
  z-index: 10;
  outline: 4px solid white; /* Smoothly apply the hover border effect */
  transform: scale(1.02); /* Subtle zoom effect */
}

/* Image Inside the Card */
.item-card img {
  width: 100%;
  height: auto;
  transition: filter 0.3s ease-out, transform 0.3s ease-out; /* Smooth transitions for hover-in and hover-out */
  will-change: transform, filter; /* Optimize for performance */
  image-rendering: -webkit-optimize-contrast; /* Keeps images sharp during scaling */
}

/* Image Wrapper */
.item-card-img-wrapper {
  overflow: hidden; /* Keeps zoom inside bounds */
  height: 100%;
  object-fit: contain; /* Maintain image aspect ratio */
  border-radius: 8px;
  align-content: center;
}

/* Hover Effect for Image */
.item-card:hover img {
  transform: scale(1.1); /* Smooth zoom on hover */
  filter: brightness(1.2); /* Slight brightness increase */
}

.tooltip {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  color: #000;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: bold;
  border-radius: 5px;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
}

/* Top tooltip */
.tooltip-top {
  top: -30px; /* Adjust this based on spacing */
  background-color: #fff;
  box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.3);
}

/* Ensure buttons in tooltip-bottom are aligned properly */
.tooltip-bottom {
  gap: 0px; /* Remove gap between buttons */
  bottom: -35px;
}

/* Show buttons on hover */
.item-card:hover .tooltip-bottom,
.tooltip-bottom:hover {
  pointer-events: auto; /* Allow clicking */
}

/* Button container */
.user-collection-buttons {
  display: flex;
  gap: 0px;
}

/* Buttons: General Styling */
.tooltip-bottom .wishlist-btn,
.tooltip-bottom .locker-btn {
  font-size: 16px;
  background: #fff;
  color: #000;
  padding: 8px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.3s ease; /* Only color changes on hover */
  border: none;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.2), 0 2px 4px rgba(0, 0, 0, 0.2);
  flex: 1; /* Make both buttons equal width */
}

/* Rounded corners */
.tooltip-bottom .wishlist-btn {
  border-radius: 8px 0 0 8px;
}

.tooltip-bottom .locker-btn {
  border-radius: 0 8px 8px 0;
}

/* Button hover effects */
.tooltip-bottom .wishlist-btn:hover {
  color: #4caf50; /* Green text for add */
}

.tooltip-bottom .locker-btn:hover {
  color: #4caf50; /* Green text for add */
}

/* Default Green Add Icon */
.tooltip-bottom .collection-icon {
  color: #4caf50; /* ✅ Always green for adding */
}

/* Removed item button styling */
.tooltip-bottom .remove-from-collection {
  background: #fff;
  color: #000;
}

/* ✅ Icon turns red for removal */
.tooltip-bottom .remove-from-collection .collection-icon {
  color: #e74c3c;
}

/* ✅ Only text color changes on hover for remove */
.tooltip-bottom .remove-from-collection:hover {
  color: #e74c3c;
}

/* Show tooltips on hover */
.item-card:hover .tooltip {
  opacity: 1;
}

.cosmetics-title-container {
  margin: 20px;
  text-align: center;
}

.cosmetics-subtitle {
  color: var(--ast-global-color-1);
}

.upcoming-skins-button-wrapper {
  margin-bottom: 10px;
  text-align: center;
}

.upcoming-skins-button {
  display: inline-block;
  padding: 5px 10px;
  background-color: var(--ast-global-color-4);
  color: #000;
  border-radius: 6px;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.2s ease;
}

.upcoming-skins-button:hover {
  background-color: var(--ast-global-color-1);
  color: #000;
}

.bundle-collage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center; /* Ensure vertical centering if needed */
  gap: 5px;
}

.collage-costume {
  display: flex;
  justify-content: center; /* Center the costume image */
  width: 100%; /* Ensure it spans the full width for centering */
}

.collage-costume picture {
  width: 70%;
  height: auto;
  object-fit: cover;
}

.collage-row {
  display: flex;
  justify-content: center;
}

.collage-small-item img {
  width: 50px;
  height: auto;
  max-height: 41px;
  object-fit: cover;
}

.collection-header {
  text-align: center;
  padding: 40px 0;
  text-transform: none;
}

/* Visibility selector container */
.collection-visibility-container {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ccc;
}

/* Custom select dropdown */
#collection-visibility {
  background: transparent;
  border: unset;
  cursor: pointer;
  color: var(--ast-global-color-5);
  padding-bottom: 10px;
  box-shadow: none;
  font-weight: 600;
}

#collection-visibility option {
  margin: 40px;
  background: var(--ast-global-color-7);
  color: var(--ast-global-color-5);
}

.share-button {
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 5px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  cursor: pointer;
  width: max-content;
  margin: 10px auto;
}

.share-button img {
  width: 20px;
  height: 20px;
  margin-bottom: -2px;
}

.share-button:hover {
  opacity: 0.9;
}

.collection-error {
  display: block;
  width: 100%;
  text-align: center;
  padding: 50px 0;
  font-size: 28px;
}

/* Responsive Layouts */
@media (max-width: 599px) {
  .item-grid {
    grid-template-columns: repeat(calc(var(--gridsize, 8) - 5), 1fr);
  }
}

@media (max-width: 768px) {
  .item-grid {
    padding: 20px 5px;
  }

  .ast-container {
    padding: 0 5px;
  }

  .item-type-filters,
  .filter-buttons,
  .active-filters-parent {
    padding-left: 10px;
    padding-right: 10px;
  }

  .collection-visibility-container {
    flex-direction: column;
  }
}

@media (min-width: 600px) and (max-width: 768px) {
  .role-grid {
    grid-template-columns: repeat(2, 1fr); /* 2 heroes per row on mobile */
  }

  .item-grid {
    grid-template-columns: repeat(calc(var(--gridsize, 8) - 4), 1fr);
  }
}

@media (min-width: 769px) and (max-width: 1200px) {
  .role-grid {
    grid-template-columns: repeat(3, 1fr); /* 3 heroes per row on tablets */
  }

  .item-grid {
    grid-template-columns: repeat(calc(var(--gridsize, 8) - 3), 1fr);
  }
}

@media (min-width: 1201px) {
  .role-grid {
    grid-template-columns: repeat(4, 1fr); /* 4 heroes per row on desktop */
  }

  .item-grid {
    grid-template-columns: repeat(calc(var(--gridsize, 8) - 1), 1fr);
  }
}
