/* ─── Favorites Button ──────────────────────────────────────────────────────── */

.dms-favorites-button-wrapper {
  display: inline-flex;
}

.dms-favorites-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  background: transparent;
  border: 1px solid currentColor;
  padding: 8px 16px;
  border-radius: 4px;
  font-size: inherit;
  transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.dms-favorites-button:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

.dms-favorites-button .dms-favorites-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  pointer-events: none;
}

.dms-favorites-button .dms-favorites-icon--active {
  display: none;
}

.dms-favorites-button.dms-is-favorite .dms-favorites-icon--default {
  display: none;
}

.dms-favorites-button.dms-is-favorite .dms-favorites-icon--active {
  display: inline-flex;
}

.dms-favorites-button .dms-favorites-button-label {
  white-space: nowrap;
  line-height: 1;
}

/* ─── Flyout Sidebar ────────────────────────────────────────────────────────── */

.dms-favorites-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: 340px;
  max-width: 100vw;
  height: 100%;
  background: #fff;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
  z-index: 999999;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  overflow: hidden;
}

.dms-favorites-sidebar.is-open {
  transform: translateX(0);
}

.dms-favorites-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.dms-favorites-sidebar-title {
  font-weight: 600;
  font-size: 16px;
}

.dms-favorites-sidebar-close {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  color: inherit;
  line-height: 0;
}

.dms-favorites-sidebar-close:hover {
  background: #f3f4f6;
}

.dms-favorites-sidebar-close:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

.dms-favorites-sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
}

.dms-favorites-sidebar-items {
  list-style: none;
  margin: 0;
  padding: 0;
}

.dms-favorites-sidebar-empty {
  padding: 32px 20px;
  text-align: center;
  color: #6b7280;
  font-size: 14px;
  margin: 0;
}

/* ─── Sidebar Footer ────────────────────────────────────────────────────────── */

.dms-favorites-sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.dms-favorites-sidebar-footer[hidden] {
  display: none;
}

.dms-favorites-compare-button {
  display: block;
  width: 100%;
  padding: 10px 16px;
  background: var(--dms-fav-compare-bg);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  transition: background-color 0.2s ease, filter 0.2s ease;
}

.dms-favorites-compare-button:hover {
  background: var(--dms-fav-compare-bg);
  filter: brightness(0.88);
}

.dms-favorites-compare-button:focus-visible {
  outline: 2px solid var(--dms-fav-compare-bg);
  outline-offset: 2px;
}

/* ─── Sidebar Items ─────────────────────────────────────────────────────────── */

.dms-favorites-item {
  display: flex;
  align-items: center;
  padding: 10px 20px;
  gap: 10px;
}

.dms-favorites-item:not(:last-child) {
  border-bottom: 1px solid #f3f4f6;
}

.dms-favorites-item-link {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}

.dms-favorites-item-link:hover .dms-favorites-item-title {
  text-decoration: underline;
}

.dms-favorites-item-image {
  width: 60px;
  height: 48px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
  background: #f3f4f6;
}

.dms-favorites-item-no-image {
  background: #e5e7eb;
}

.dms-favorites-item-title {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-clamp: 2;
}

.dms-favorites-item-remove {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  border-radius: 4px;
  color: #9ca3af;
  line-height: 0;
}

.dms-favorites-item-remove:hover {
  background: #f3f4f6;
  color: #374151;
}

.dms-favorites-item-remove:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* ─── Overlay ───────────────────────────────────────────────────────────────── */

.dms-favorites-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 99998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.dms-favorites-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

/* ─── Trigger animation ─────────────────────────────────────────────────────── */

@keyframes dms-favorites-trigger-pop {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.28); }
  60%  { transform: scale(0.94); }
  80%  { transform: scale(1.08); }
  100% { transform: scale(1); }
}

/* ─── Trigger Button ────────────────────────────────────────────────────────── */

.dms-favorites-trigger {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--dms-fav-trigger-bg);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  z-index: 9999;
  transition: background-color 0.2s ease, filter 0.2s ease, transform 0.2s ease;
}

.dms-favorites-trigger:hover {
  background: var(--dms-fav-trigger-bg);
  filter: brightness(0.88);
  transform: scale(1.04);
}

.dms-favorites-trigger.dms-favorites-trigger--pop {
  animation: dms-favorites-trigger-pop 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

.dms-favorites-trigger:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.dms-favorites-trigger[hidden] {
  display: none;
}

.dms-favorites-trigger-icon {
  flex-shrink: 0;
  display: flex;
}

.dms-favorites-trigger-count {
  font-size: 13px;
  font-weight: 600;
  min-width: 16px;
  text-align: center;
}

/* ─── Trigger position variants ─────────────────────────────────────────────── */

.dms-favorites-trigger--bottom-left {
  right: auto;
  left: 24px;
}

.dms-favorites-trigger--bottom-center {
  right: auto;
  left: 50%;
  translate: -50% 0;
}

/* ─── Body lock when sidebar is open ────────────────────────────────────────── */

body.dms-favorites-open {
  overflow: hidden;
}
