/**
 * Hypothesis Custom Styling
 * Customizes the appearance of Hypothesis annotations and interface for the dissertation site
 */

/* ============================================================================
   Hypothesis Sidebar Styling
   ============================================================================ */

.hypothesis-sidebar {
  box-shadow: -2px 0 8px rgba(0, 0, 0, 0.15);
}

.hypothesis-sidebar-iframe {
  border-left: 1px solid var(--color-border, #ddd);
}

/* Fix close button positioning in Hypothesis sidebar */
.annotator-frame,
.hypothesis-sidebar-frame,
.hypothesis-sidebar {
  position: fixed !important;
  top: 0 !important;
  right: 0 !important;
  height: 100% !important;
}

/* Ensure close button is positioned correctly within the iframe */
.hypothesis-sidebar .close-button,
.hypothesis-sidebar-iframe .close-button,
.annotator-frame .close-button {
  position: absolute !important;
  top: 10px !important;
  right: 10px !important;
  z-index: 10000 !important;
}

/* Override any conflicting positioning from Hypothesis */
.hypothesis-sidebar-frame {
  z-index: 9998 !important;
}

.hypothesis-adder-toolbar {
  z-index: 9999 !important;
}

/* ============================================================================
   Annotation Highlights
   ============================================================================ */

.hypothesis-highlight {
  background-color: rgba(255, 235, 0, 0.3);
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.hypothesis-highlight:hover {
  background-color: rgba(255, 235, 0, 0.5);
}

.hypothesis-highlight.hypothesis-focus {
  background-color: rgba(255, 200, 0, 0.5);
}

/* Dark theme support for highlights */
[data-theme="dark"] .hypothesis-highlight {
  background-color: rgba(255, 193, 7, 0.25);
}

[data-theme="dark"] .hypothesis-highlight:hover {
  background-color: rgba(255, 193, 7, 0.4);
}

[data-theme="dark"] .hypothesis-highlight.hypothesis-focus {
  background-color: rgba(255, 193, 7, 0.5);
}

/* ============================================================================
   Annotation Badge Styling
   ============================================================================ */

.annotation-badge {
  display: inline-block;
  background-color: #1976d2;
  color: white;
  padding: 0.3em 0.6em;
  border-radius: 14px;
  font-size: 0.85em;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: all 0.2s ease;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.annotation-badge:hover {
  background-color: #1565c0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transform: translateY(-1px);
}

.annotation-badge.loading {
  background-color: #999;
  cursor: wait;
  opacity: 0.7;
}

.annotation-badge.active {
  background-color: #ff6f00;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(255, 111, 0, 0.7);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(255, 111, 0, 0);
  }
}

/* Dark theme for badges */
[data-theme="dark"] .annotation-badge {
  background-color: #64b5f6;
  color: #1a1a1a;
}

[data-theme="dark"] .annotation-badge:hover {
  background-color: #90caf9;
}

[data-theme="dark"] .annotation-badge.loading {
  background-color: #666;
  color: #ccc;
}

/* ============================================================================
   Annotation Widget Styling
   ============================================================================ */

.hypothesis-evidence-widget {
  margin: 2rem 0;
  padding: 1.5rem;
  background-color: var(--color-background-secondary, #f5f5f5);
  border-left: 4px solid var(--color-primary, #1976d2);
  border-radius: 4px;
  transition: all 0.2s ease;
}

.hypothesis-evidence-widget:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .hypothesis-evidence-widget {
  background-color: #2a2a2a;
  border-left-color: #64b5f6;
}

.hypothesis-evidence-widget.empty {
  opacity: 0.7;
}

.hypothesis-evidence-widget.loading {
  position: relative;
  pointer-events: none;
}

.hypothesis-evidence-widget.loading::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: shimmer 2s infinite;
  border-radius: 4px;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* ============================================================================
   Annotation List Styling
   ============================================================================ */

.annotation-item {
  padding: 1rem;
  margin-bottom: 0.5rem;
  background-color: white;
  border-radius: 4px;
  border-left: 3px solid var(--color-primary, #1976d2);
  transition: all 0.2s ease;
}

.annotation-item:hover {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  transform: translateX(2px);
}

.annotation-item:last-child {
  margin-bottom: 0;
}

[data-theme="dark"] .annotation-item {
  background-color: #333;
  border-left-color: #64b5f6;
  color: #e0e0e0;
}

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

.annotation-user {
  font-weight: 600;
  color: var(--color-primary, #1976d2);
  font-size: 0.95em;
}

.annotation-user::before {
  content: '👤 ';
  margin-right: 0.25em;
}

.annotation-date {
  font-size: 0.85em;
  color: var(--color-text-muted, #666);
  white-space: nowrap;
}

.annotation-quote {
  padding: 0.75rem;
  margin: 0.75rem 0;
  background-color: var(--color-background-lighter, #f9f9f9);
  border-left: 3px solid var(--color-text-muted, #ccc);
  font-style: italic;
  font-size: 0.95em;
  color: var(--color-text-secondary, #555);
  border-radius: 2px;
}

.annotation-quote::before {
  content: '❝ ';
}

.annotation-quote::after {
  content: ' ❞';
}

[data-theme="dark"] .annotation-quote {
  background-color: #2a2a2a;
  border-left-color: #666;
  color: #999;
}

.annotation-text {
  font-size: 0.95em;
  line-height: 1.6;
  color: var(--color-text, #333);
  margin: 0.75rem 0;
}

[data-theme="dark"] .annotation-text {
  color: #e0e0e0;
}

/* ============================================================================
   Annotation Tags
   ============================================================================ */

.annotation-tags {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.annotation-tag {
  display: inline-block;
  background-color: var(--color-background-lighter, #f0f0f0);
  color: var(--color-text-muted, #666);
  padding: 0.3em 0.6em;
  border-radius: 14px;
  font-size: 0.8em;
  font-weight: 500;
  border: 1px solid var(--color-border, #ddd);
  transition: all 0.2s ease;
}

.annotation-tag:hover {
  background-color: var(--color-primary, #1976d2);
  color: white;
  border-color: var(--color-primary, #1976d2);
}

.annotation-tag.evidence-tag {
  background-color: rgba(25, 118, 210, 0.1);
  border-color: #1976d2;
  color: #1976d2;
}

.annotation-tag.chapter-tag {
  background-color: rgba(255, 111, 0, 0.1);
  border-color: #ff6f00;
  color: #ff6f00;
}

[data-theme="dark"] .annotation-tag {
  background-color: #3a3a3a;
  border-color: #555;
  color: #999;
}

[data-theme="dark"] .annotation-tag.evidence-tag {
  background-color: rgba(100, 181, 246, 0.15);
  border-color: #64b5f6;
  color: #64b5f6;
}

/* ============================================================================
   No Annotations Message
   ============================================================================ */

.no-annotations-message {
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--color-text-muted, #666);
  font-size: 0.95em;
}

.no-annotations-message p {
  margin: 0.75rem 0;
}

.no-annotations-message p:first-child {
  font-style: italic;
  font-weight: 500;
}

.hint-text {
  font-size: 0.9em;
  color: var(--color-text-muted, #999);
}

.hint-text a {
  color: var(--color-primary, #1976d2);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s ease;
}

.hint-text a:hover {
  text-decoration: underline;
  color: #1565c0;
}

[data-theme="dark"] .no-annotations-message {
  color: #999;
}

[data-theme="dark"] .hint-text {
  color: #666;
}

/* ============================================================================
   Annotation Header and Summary
   ============================================================================ */

.annotations-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 0 1.5rem 0;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--color-border, #ddd);
}

.annotations-title {
  font-size: 1.1em;
  font-weight: 600;
  color: var(--color-text, #333);
}

.annotations-title::before {
  content: '💬 ';
  margin-right: 0.5em;
}

[data-theme="dark"] .annotations-header {
  border-bottom-color: #444;
}

[data-theme="dark"] .annotations-title {
  color: #e0e0e0;
}

.annotation-summary {
  padding: 1.25rem;
  background-color: var(--color-background-lighter, #fafafa);
  border-radius: 4px;
  margin-bottom: 1.5rem;
  border: 1px solid var(--color-border, #eee);
}

.summary-text {
  margin: 0.5rem 0;
  color: var(--color-text, #333);
  font-weight: 500;
}

.summary-subtext {
  margin: 0.75rem 0 0 0;
  color: var(--color-text-muted, #666);
  font-size: 0.9em;
}

.view-all-link {
  color: var(--color-primary, #1976d2);
  text-decoration: none;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.25em;
  transition: all 0.2s ease;
}

.view-all-link:hover {
  text-decoration: underline;
  transform: translateX(2px);
}

[data-theme="dark"] .annotation-summary {
  background-color: #2a2a2a;
  border-color: #444;
}

[data-theme="dark"] .summary-text {
  color: #e0e0e0;
}

[data-theme="dark"] .summary-subtext {
  color: #999;
}

/* ============================================================================
   Responsive Design
   ============================================================================ */

@media (max-width: 768px) {
  .hypothesis-evidence-widget {
    margin: 1.5rem -1rem;
    padding: 1rem;
    border-radius: 0;
  }

  .annotations-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .annotation-count-badge {
    align-self: flex-start;
  }

  .annotation-item {
    padding: 0.75rem;
  }

  .annotation-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }

  .annotation-user,
  .annotation-date {
    font-size: 0.9em;
  }

  .annotation-tags {
    gap: 0.35rem;
  }

  .annotation-tag {
    font-size: 0.75em;
    padding: 0.25em 0.5em;
  }

  .annotation-quote {
    font-size: 0.9em;
    padding: 0.5rem;
  }
}

@media (max-width: 480px) {
  .hypothesis-evidence-widget {
    margin: 1rem -0.75rem;
    padding: 0.75rem;
  }

  .annotations-header {
    flex-direction: column;
  }

  .annotation-item {
    padding: 0.5rem;
    margin-bottom: 0.35rem;
  }

  .annotation-text {
    font-size: 0.9em;
  }

  .annotation-tags {
    gap: 0.25rem;
  }

  .annotation-tag {
    font-size: 0.7em;
  }
}

/* ============================================================================
   Print Styles
   ============================================================================ */

@media print {
  .hypothesis-evidence-widget {
    page-break-inside: avoid;
  }

  .hypothesis-sidebar,
  .hypothesis-adder-toolbar {
    display: none !important;
  }

  .annotation-item {
    page-break-inside: avoid;
    border: 1px solid #ccc;
    padding: 0.75rem;
    margin-bottom: 1rem;
  }

  .annotation-badge {
    display: none;
  }
}
