/* References Panel Styles */

.references {
  padding: 1rem;
}

.references__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border, #e5e5e5);
}

.references__title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.references__title svg {
  opacity: 0.7;
}

.references__count {
  font-size: 0.75rem;
  color: var(--color-text-secondary, #666);
  background: var(--color-bg-secondary, #f5f5f5);
  padding: 0.25rem 0.5rem;
  border-radius: 1rem;
}

.references__list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.references__empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--color-text-secondary, #666);
}

.references__empty p {
  margin: 0.25rem 0;
}

/* Reference Card */

.reference-card {
  background: var(--color-bg-secondary, #f9f9f9);
  border: 1px solid var(--color-border, #e5e5e5);
  border-radius: 0.5rem;
  overflow: hidden;
  transition: border-color 0.15s ease;
}

.reference-card:hover {
  border-color: var(--color-border-hover, #ccc);
}

.reference-card__content {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem;
}

.reference-card__image {
  flex-shrink: 0;
  width: 80px;
  height: 60px;
  border-radius: 0.25rem;
  overflow: hidden;
  background: var(--color-bg-tertiary, #eee);
}

.reference-card__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.reference-card__details {
  flex: 1;
  min-width: 0;
}

.reference-card__header {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin-bottom: 0.25rem;
}

.reference-card__favicon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border-radius: 2px;
}

.reference-card__domain {
  font-size: 0.75rem;
  color: var(--color-text-secondary, #666);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reference-card__title {
  margin: 0 0 0.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.3;
}

.reference-card__title a {
  color: inherit;
  text-decoration: none;
}

.reference-card__title a:hover {
  text-decoration: underline;
}

.reference-card__description {
  margin: 0;
  font-size: 0.75rem;
  color: var(--color-text-secondary, #666);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.reference-card__excerpt {
  margin-top: 0.5rem;
}

.reference-card__excerpt summary {
  cursor: pointer;
  color: var(--color-link, #22c55e);
}

.reference-card__excerpt summary:hover {
  text-decoration: underline;
}

.reference-card__excerpt p {
  margin: 0.5rem 0 0;
  padding: 0.5rem;
  background: var(--color-bg, white);
  border-radius: 0.25rem;
  font-size: 0.75rem;
  color: var(--color-text-secondary, #666);
  line-height: 1.5;
}

/* Reference Card Actions */

.reference-card__actions {
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem 0.75rem;
  background: var(--color-bg, white);
  border-top: 1px solid var(--color-border, #e5e5e5);
}

.reference-card__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: 0.25rem;
  color: var(--color-text-secondary, #666);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.reference-card__btn:hover {
  background: var(--color-bg-secondary, #f5f5f5);
  color: var(--color-text, #333);
}

.reference-card__btn--success {
  background: var(--color-success-bg, #d4edda);
  color: var(--color-success, #155724);
}

/* References Panel (for sidebar or modal) */

.references-panel {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 320px;
  max-width: 100vw;
  background: var(--color-bg, white);
  border-left: 1px solid var(--color-border, #e5e5e5);
  box-shadow: -4px 0 12px rgba(0, 0, 0, 0.1);
  z-index: 100;
  transform: translateX(100%);
  transition: transform 0.2s ease;
  overflow-y: auto;
}

.references-panel--open {
  transform: translateX(0);
}

.references-panel__close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 0.25rem;
  cursor: pointer;
  color: var(--color-text-secondary, #666);
}

.references-panel__close:hover {
  background: var(--color-bg-secondary, #f5f5f5);
}

/* References toggle button for toolbar */

.references-toggle {
  position: relative;
}

.references-toggle__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  font-size: 10px;
  font-weight: 600;
  line-height: 16px;
  text-align: center;
  background: var(--color-primary, #22c55e);
  color: white;
  border-radius: 8px;
}

/* Responsive adjustments */

@media (max-width: 768px) {
  .references-panel {
    width: 100%;
  }

  .reference-card__image {
    width: 60px;
    height: 45px;
  }
}
