/*
 * avide-saved: the button (both login states + the note/tags popover) and
 * the "Đã lưu" list page. Layout and state only: button colour and
 * shape come from the theme's own .btn / .btn--primary / .btn--secondary /
 * .btn--ghost classes so the saved button always matches the site's other
 * buttons, and the not-saved / saved / logged-out states stay one visual
 * family (docs/specs/2026-09-11-saved-items-design.md).
 */

.avide-saved {
  position: relative;
  display: inline-block;
  margin: 12px 0;
}

.avide-saved__toggle,
.avide-saved a.avide-saved__toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  list-style: none; /* the <summary> marker */
  user-select: none;
}
.avide-saved__toggle::-webkit-details-marker { display: none; }
.avide-saved__toggle::marker { content: ''; }

.avide-saved__toggle svg { flex: 0 0 auto; }

/* One icon path (button.php's avide_saved_icon()), outline by default;
   .is-saved fills it. The JS upgrade only ever toggles this class
   (assets/avide-saved.js), so a save/unsave updates the icon for free. */
.avide-saved__icon {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.is-saved .avide-saved__icon {
  fill: currentColor;
  stroke: none;
}

/* Saved state: same shape/size as not-saved, only the icon fills and the
   border tone shifts, so the page never jumps when the state changes. */
.avide-saved__toggle.is-saved {
  border-color: var(--avide-brand, #D83018);
  color: var(--avide-brand, #D83018);
}

.avide-saved__guest-note {
  margin: 6px 0 0;
  font-size: 0.85rem;
}

.avide-saved__details[open] > .avide-saved__toggle {
  border-radius: 8px 8px 0 0;
}

.avide-saved__popover {
  position: absolute;
  z-index: 40;
  top: calc(100% + 4px);
  left: 0;
  width: max-content;
  max-width: min(340px, calc(100vw - 24px));
  background: #fff;
  border: 1px solid #dfe5ef;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(16, 35, 60, 0.18);
  padding: 14px;
}

.avide-saved__popover label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 4px;
}

.avide-saved__popover textarea,
.avide-saved__popover input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #b9c2d4;
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  margin-bottom: 10px;
}
.avide-saved__popover textarea { min-height: 4.5rem; resize: vertical; }

.avide-saved__suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: -4px 0 10px;
}
.avide-saved__chip {
  border: 1px solid #b9c2d4;
  background: #f1f3f6;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.8rem;
  cursor: pointer;
}
.avide-saved__chip:hover { background: #e4e9f2; }

.avide-saved__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.avide-saved__edit-link {
  margin: 4px 0 0;
  font-size: 0.85rem;
}

/* Narrow viewport: a bottom sheet instead of an anchored dropdown, so the
   popover can never overflow the 375px viewport the design doc verifies at. */
@media (max-width: 480px) {
  .avide-saved__popover {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    top: auto;
    width: auto;
    max-width: none;
    max-height: calc(100vh - 24px);
    overflow-y: auto;
  }
}

/* ---- The list page ---- */

.avide-saved-list__flash {
  padding: 10px 14px;
  border-radius: 8px;
  margin: 0 0 16px;
}
.avide-saved-list__flash.is-ok { background: #e8f5e9; border-left: 4px solid #2e7d32; }
.avide-saved-list__flash.is-err { background: #fdecea; border-left: 4px solid #c62828; }

.avide-saved-list__controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
  align-items: center;
  margin-bottom: 20px;
}
.avide-saved-list__controls-label {
  font-weight: 700;
  font-size: 0.85rem;
  margin-right: 4px;
}
.avide-saved-list__sort { display: flex; align-items: center; gap: 6px; }
.avide-saved-list__sort-link,
.avide-saved-list__tag {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid #b9c2d4;
  font-size: 0.85rem;
  text-decoration: none;
}
.avide-saved-list__sort-link.is-active,
.avide-saved-list__tag.is-active {
  background: var(--avide-brand, #D83018);
  border-color: var(--avide-brand, #D83018);
  color: #fff;
}
.avide-saved-list__tags { display: flex; flex-wrap: wrap; gap: 6px; }

.avide-saved-list__empty {
  padding: 24px;
  text-align: center;
  color: #4a5568;
}

.avide-saved-list__rows {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.avide-saved-list__row {
  border: 1px solid #dfe5ef;
  border-radius: 10px;
  padding: 14px 16px;
}

.avide-saved-list__title {
  display: block;
  font-weight: 700;
  font-size: 1.05rem;
  margin: 6px 0 2px;
}
.avide-saved-list__date {
  display: block;
  font-size: 0.8rem;
  color: #64748b;
  margin-bottom: 6px;
}
.avide-saved-list__note {
  margin: 0 0 8px;
  color: #334155;
}
.avide-saved-list__row-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 10px;
}
.avide-saved-list__chip {
  background: #f1f3f6;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.78rem;
}

.avide-saved-list__row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}
.avide-saved-list__row-actions summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  list-style: none;
}
.avide-saved-list__row-actions summary::-webkit-details-marker { display: none; }
.avide-saved-list__edit-form,
.avide-saved-list__remove-confirm {
  margin-top: 10px;
  max-width: 420px;
}
.avide-saved-list__edit-form textarea,
.avide-saved-list__edit-form input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #b9c2d4;
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  margin-bottom: 8px;
}
