/* Custom lists: "Save to list" trigger, popover, list-page management, and the account
   "My Lists" section. Enqueued GLOBALLY because the trigger + popover appear on the
   frontpage, item/bundle pages, and the wishlist/locker/list pages, and the popover markup
   lives in the footer on every page. Kept self-contained (own overlay + .hidden rules)
   because the .user-avatar-popup / .popup / .hidden helpers only ship in user-styles.css,
   which most of these surfaces don't load. */

/* Preserve the case the user types for list names. The theme force-uppercases all inputs
   (style.css `input,button`) and everything inside .main-container, which would otherwise
   show every custom-list name in ALL CAPS regardless of what was entered. Applies to the
   name inputs and to the places a list name is displayed. */
#list-rename-input,
#account-new-list-name,
#save-to-list-new-name,
#list-name-heading,
.account-list-name,
.save-to-list-option-name {
  text-transform: none;
}

/* ---- Save-to-list trigger (icon-sized bookmark, right of +Locker) ---- */
.save-to-list-trigger {
  background: #fff;
  border: none;
  border-radius: 8px;
  padding: 5px;
  margin-left: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto; /* never stretch — stay icon-sized next to the buttons */
  line-height: 0;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.2), 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s ease;
}

.save-to-list-trigger:hover {
  transform: scale(1.08);
}

.save-to-list-icon {
  width: 18px;
  height: 18px;
  display: block;
  fill: none;
  stroke: #444;
  stroke-width: 2;
}

/* Single item/bundle pages: keep the (larger) wishlist/locker buttons and the small trigger
   on one row, trigger to the right. Carries the margin-top:auto the buttons used to have so
   the row still sits at the bottom of the info column. */
.collection-actions-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
}

/* On single item/bundle pages the wishlist/locker buttons are taller — match the trigger to
   their height (the row is align-items:center, so stretch the trigger itself). */
.collection-actions-row .save-to-list-trigger {
  align-self: stretch;
}

/* Painted client-side when the item is in at least one of the user's lists. */
.save-to-list-trigger.saved .save-to-list-icon {
  fill: #4caf50;
  stroke: #4caf50;
}

/* Match the grid's touch-device hiding of the collection buttons. */
@media (pointer: coarse) {
  .item-grid .save-to-list-trigger {
    display: none;
  }
}

/* ---- Save-to-list popover (footer, all pages) ---- */
#save-to-list-popup {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
}

#save-to-list-popup.hidden {
  display: none;
}

.save-to-list-popup-content {
  background: #222;
  color: #fff;
  padding: 20px;
  border-radius: 8px;
  position: relative;
  width: 90%;
  max-width: 360px;
  text-align: left;
}

.save-to-list-popup-content h3 {
  margin: 0 0 4px;
  font-size: 18px;
}

/* "Manage lists" link at the top of the popover → /custom-lists. */
.save-to-list-manage {
  display: inline-block;
  margin-bottom: 12px;
  font-size: 13px;
  color: #4caf50;
  text-decoration: none;
}

.save-to-list-manage:hover {
  text-decoration: underline;
}

/* Account page: "Manage all lists →" link under the My Lists block. */
.account-lists-manage-link {
  display: inline-block;
  margin-top: 10px;
  font-size: 14px;
  color: #4caf50;
  text-decoration: none;
}

.account-lists-manage-link:hover {
  text-decoration: underline;
}

.save-to-list-close,
#list-rename-popup .user-avatar-close {
  position: absolute;
  top: 8px;
  right: 14px;
  font-size: 24px;
  line-height: 1;
  color: #fff;
  cursor: pointer;
}

#save-to-list-options {
  max-height: 260px;
  overflow-y: auto;
  margin-bottom: 12px;
}

.save-to-list-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 4px;
  border-bottom: 1px solid #333;
}

.save-to-list-option:last-child {
  border-bottom: none;
}

/* Checkbox + name are a label (clicking toggles the box); the View link sits outside it. */
.save-to-list-option-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  min-width: 0; /* allow the name to shrink/wrap instead of pushing View off-row */
  flex: 1 1 auto;
}

.save-to-list-checkbox {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  cursor: pointer;
}

.save-to-list-option-name {
  overflow-wrap: anywhere;
}

.save-to-list-view {
  flex: 0 0 auto;
  font-size: 13px;
  color: #4caf50;
  text-decoration: none;
  white-space: nowrap;
}

.save-to-list-view:hover {
  text-decoration: underline;
}

.save-to-list-empty {
  color: #aaa;
  margin: 6px 0 12px;
}

.save-to-list-new {
  display: flex;
  gap: 8px;
  border-top: 1px solid #333;
  padding-top: 12px;
}

.save-to-list-new input {
  flex: 1;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #555;
  background: #1a1a1a;
  color: #fff;
}

.save-to-list-new button,
#account-create-list {
  background: #4caf50;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  white-space: nowrap;
}

.save-to-list-new button:hover,
#account-create-list:hover {
  background: #43a047;
}

/* ---- List page: "Community List" subtitle under the list name ---- */
.community-list-label {
  color: #ccc;
  font-size: 14px;
  letter-spacing: 1px;
  margin: -8px 0 10px;
}

/* ---- List page: owner management controls ---- */
.list-manage-controls {
  display: inline-flex;
  gap: 8px;
  margin: 0 12px;
}

.list-manage-btn {
  background: #333;
  color: #fff;
  border: 1px solid #555;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
}

.list-manage-btn:hover {
  background: #444;
}

/* Rename dialog (its own overlay — user-styles.css isn't loaded on the list page). */
#list-rename-popup {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
}

#list-rename-popup.hidden,
#list-delete-popup.hidden {
  display: none;
}

#list-rename-popup .user-avatar-popup-content {
  background: #222;
  color: #fff;
  padding: 20px;
  border-radius: 8px;
  position: relative;
  width: 90%;
  max-width: 360px;
  text-align: left;
}

#list-rename-input {
  width: 100%;
  padding: 8px;
  margin: 10px 0;
  border-radius: 6px;
  border: 1px solid #555;
  background: #1a1a1a;
  color: #fff;
}

/* Delete confirm dialog. */
#list-delete-popup {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
}

#list-delete-popup .popup-content {
  background: #222;
  color: #fff;
  padding: 20px;
  border-radius: 8px;
  width: 90%;
  max-width: 340px;
  text-align: center;
}

#list-delete-popup .popup-content button {
  margin: 10px 6px 0;
}

/* ---- Dedicated /custom-lists management page ---- */
/* Scoped under .custom-lists-page so these win over user-styles.css's generic .account-link
   (display:block) without !important. */
.custom-lists-page {
  max-width: 720px;
  margin: 40px auto;
  padding: 0 20px;
}

.custom-lists-page .custom-lists-heading {
  font-size: 28px;
  margin: 0 0 20px;
}

.custom-lists-page #account-lists-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.custom-lists-page .account-list-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 0;
  background: #1f1f1f;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 14px 16px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.custom-lists-page .account-list-link:hover {
  background: #2a2a2a;
  border-color: #4caf50;
  text-decoration: none;
}

.custom-lists-page .account-list-name {
  overflow-wrap: anywhere;
}

.custom-lists-page .account-list-visibility {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 500;
  color: #aaa;
  border: 1px solid #555;
  border-radius: 10px;
  padding: 2px 10px;
  white-space: nowrap;
}

.custom-lists-page #account-lists-empty {
  color: #aaa;
  margin: 0 0 24px;
}

.custom-lists-page .account-lists-new {
  display: flex;
  gap: 10px;
  max-width: 460px;
}

.custom-lists-page .account-lists-new input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid #555;
  background: #1a1a1a;
  color: #fff;
}

.custom-lists-page #account-create-list {
  white-space: nowrap;
}

/* ---- Account page: My Lists ---- */
.account-lists-heading {
  margin: 0 0 8px;
  font-size: 16px;
}

.account-list-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.account-list-visibility {
  font-size: 12px;
  color: #aaa;
  border: 1px solid #555;
  border-radius: 10px;
  padding: 2px 8px;
  white-space: nowrap;
}

.account-lists-new {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.account-lists-new input {
  flex: 1;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #555;
}
