/* === Annotation / Comment Mode === */

/* Ensure hidden attribute works even with display overrides */
.annotation-selbar[hidden],
.annotation-chat[hidden],
.annotation-queue[hidden] {
  display: none !important;
}

/* ─── FAB ─────────────────────────────────────────────────────── */

.annotation-fab {
  position: absolute;
  bottom: 80px;
  right: 20px;
  z-index: 50;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid var(--accent-amber);
  background: var(--bg-card);
  color: var(--accent-amber);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: background var(--transition-fast), box-shadow var(--transition-fast);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.annotation-fab:hover {
  background: var(--bg-surface);
  box-shadow: var(--glow-amber);
}

.annotation-fab--active {
  background: var(--accent-amber);
  color: var(--bg-deep);
}

.annotation-fab--active:hover {
  background: #e69900;
}

.annotation-fab__icon {
  line-height: 1;
}

.annotation-fab__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: var(--accent-rose);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* Unread pulse on FAB */
.annotation-fab--unread {
  animation: annotation-pulse 2s ease-in-out infinite;
}

.annotation-fab--unread .annotation-fab__badge {
  background: #00bcd4;
}

@keyframes annotation-pulse {
  0%, 100% { box-shadow: 0 2px 8px rgba(0,0,0,0.3); }
  50% { box-shadow: 0 0 16px rgba(0, 188, 212, 0.6); }
}

/* ─── Queue panel (thread list) ──────────────────────────────── */

.annotation-queue {
  position: absolute;
  bottom: 140px;
  right: 16px;
  z-index: 51;
  width: 320px;
  max-width: calc(100vw - 32px);
  max-height: 400px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--accent-amber);
  background: var(--bg-card);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.annotation-queue__header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.annotation-queue__title {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--accent-amber);
}

.annotation-queue__counts {
  flex: 1;
  font-size: 0.7rem;
  color: var(--text-dim);
  text-align: right;
}

.annotation-queue__close {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.annotation-queue__close:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text-primary);
}

.annotation-queue__list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.annotation-queue__list::-webkit-scrollbar {
  width: 4px;
}
.annotation-queue__list::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
}

.annotation-queue__empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.82rem;
  font-style: italic;
}

/* Queue item */
.annotation-queue__item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 14px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  font-family: var(--font-body);
  transition: background var(--transition-fast);
  border-left: 3px solid transparent;
}

.annotation-queue__item:hover {
  background: rgba(255,255,255,0.04);
}

.annotation-queue__item--unread {
  border-left-color: #00bcd4;
  background: rgba(0, 188, 212, 0.05);
}

.annotation-queue__item-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}

.annotation-queue__item-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.annotation-queue__item-status {
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 0.55rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.annotation-queue__item-status--open {
  background: rgba(255, 170, 0, 0.2);
  color: var(--accent-amber);
}

.annotation-queue__item-status--resolved {
  background: rgba(40, 200, 120, 0.2);
  color: #28c878;
}

.annotation-queue__item-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #00bcd4;
  flex-shrink: 0;
}

.annotation-queue__item-preview {
  font-size: 0.72rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.annotation-queue__item-meta {
  font-size: 0.65rem;
  color: var(--text-dim);
  opacity: 0.6;
  margin-top: 1px;
}

/* Work status indicators */
.annotation-queue__item-work {
  font-size: 0.7rem;
  flex-shrink: 0;
}

.annotation-queue__item-work--active {
  animation: work-pulse 1.5s ease-in-out infinite;
}

.annotation-queue__item-work--replied {
  opacity: 0.7;
}

.annotation-queue__item-work--done {
  color: #28c878;
  font-weight: 700;
}

@keyframes work-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* Queue footer */
.annotation-queue__footer {
  display: flex;
  gap: 8px;
  padding: 8px 14px;
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.annotation-queue__footer-btn {
  flex: 1;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--text-dim);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-family: var(--font-body);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.annotation-queue__footer-btn:hover {
  background: rgba(255,255,255,0.05);
}

.annotation-queue__footer-btn--danger {
  border-color: var(--accent-rose);
  color: var(--accent-rose);
}

.annotation-queue__footer-btn--danger:hover {
  background: rgba(255, 68, 136, 0.15);
}

/* ─── Selection bar ───────────────────────────────────────────── */

.annotation-selbar {
  position: absolute;
  z-index: 55;
  pointer-events: auto;
}

.annotation-selbar__btn {
  padding: 4px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent-amber);
  background: var(--bg-card);
  color: var(--accent-amber);
  font-size: 0.8rem;
  font-family: var(--font-body);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  transition: background var(--transition-fast);
}

.annotation-selbar__btn:hover {
  background: rgba(255, 170, 0, 0.15);
}

/* ─── Chat modal ─────────────────────────────────────────────── */

.annotation-chat {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
}

.annotation-chat__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.annotation-chat__panel {
  position: relative;
  width: 420px;
  max-width: calc(100vw - 24px);
  height: 520px;
  max-height: calc(100vh - 60px);
  border-radius: var(--radius-lg);
  border: 1px solid var(--accent-amber);
  background: var(--bg-card);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header */
.annotation-chat__header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.annotation-chat__title {
  flex: 1;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.annotation-chat__status {
  padding: 2px 8px;
  border-radius: 9px;
  font-weight: 600;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.annotation-chat__status--open {
  background: rgba(255, 170, 0, 0.2);
  color: var(--accent-amber);
}

.annotation-chat__status--resolved {
  background: rgba(40, 200, 120, 0.2);
  color: #28c878;
}

.annotation-chat__work-status {
  padding: 2px 8px;
  border-radius: 9px;
  font-weight: 600;
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
  animation: work-pulse 2s ease-in-out infinite;
}

.annotation-chat__work-status--in-progress {
  background: rgba(100, 149, 237, 0.25);
  color: #6495ed;
}

.annotation-chat__work-status--done {
  background: rgba(40, 200, 120, 0.2);
  color: #28c878;
  animation: none;
}

.annotation-chat__work-status--replied {
  background: rgba(255, 170, 0, 0.15);
  color: var(--accent-amber);
  animation: none;
}

@keyframes work-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.annotation-chat__resolve-btn {
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid #28c878;
  background: transparent;
  color: #28c878;
  font-size: 0.7rem;
  font-family: var(--font-body);
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition-fast);
}

.annotation-chat__resolve-btn:hover {
  background: rgba(40, 200, 120, 0.15);
}

.annotation-chat__close-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.annotation-chat__close-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.annotation-chat__delete-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.annotation-chat__delete-btn:hover {
  background: rgba(255, 68, 136, 0.15);
  color: var(--accent-rose);
}

/* Context quote */
.annotation-chat__context {
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.annotation-chat__context-text {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-style: italic;
  line-height: 1.4;
  max-height: 3em;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Messages area */
.annotation-chat__messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.annotation-chat__messages::-webkit-scrollbar {
  width: 4px;
}
.annotation-chat__messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
}

/* Message bubble */
.annotation-msg {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 0.82rem;
  line-height: 1.5;
  word-break: break-word;
}

.annotation-msg--user {
  align-self: flex-end;
  background: rgba(255, 170, 0, 0.15);
  border: 1px solid rgba(255, 170, 0, 0.3);
  color: var(--text-primary);
  border-bottom-right-radius: 4px;
}

.annotation-msg--claude {
  align-self: flex-start;
  background: rgba(0, 188, 212, 0.1);
  border: 1px solid rgba(0, 188, 212, 0.25);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.annotation-msg__author {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
  opacity: 0.6;
}

.annotation-msg__time {
  font-size: 0.6rem;
  opacity: 0.4;
  margin-top: 4px;
  text-align: right;
}

/* Empty state */
.annotation-chat__empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 0.8rem;
  font-style: italic;
}

/* Input bar */
.annotation-chat__input-bar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.annotation-chat__input {
  flex: 1;
  padding: 8px 12px;
  border-radius: 18px;
  border: 1px solid var(--text-dim);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.82rem;
  line-height: 1.4;
  resize: none;
  min-height: 36px;
  max-height: 80px;
}

.annotation-chat__input:focus {
  outline: none;
  border-color: var(--accent-amber);
}

.annotation-chat__send-btn {
  align-self: flex-end;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--accent-amber);
  color: var(--bg-deep);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition-fast);
}

.annotation-chat__send-btn:hover {
  background: #e69900;
}

/* ─── Text highlight ──────────────────────────────────────────── */

.annotation-highlight {
  background: rgba(255, 170, 0, 0.25);
  border-bottom: 2px solid var(--accent-amber);
  cursor: pointer;
  border-radius: 2px;
  transition: background var(--transition-fast);
}

.annotation-highlight:hover {
  background: rgba(255, 170, 0, 0.4);
}

/* ─── Element badge ───────────────────────────────────────────── */

.annotation-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  min-width: 22px;
  height: 22px;
  border-radius: 11px;
  background: var(--accent-amber);
  color: var(--bg-deep);
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  cursor: pointer;
  z-index: 10;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  transition: transform var(--transition-fast);
}

.annotation-badge:hover {
  transform: scale(1.2);
}

/* Unread reply indicator on badge */
.annotation-badge--has-reply {
  background: #00bcd4;
}

/* ─── Resolved styling ───────────────────────────────────────── */

.annotation-highlight--resolved {
  background: rgba(40, 200, 120, 0.2);
  border-bottom-color: #28c878;
}

.annotation-highlight--resolved:hover {
  background: rgba(40, 200, 120, 0.35);
}

.annotation-badge--resolved {
  background: #28c878;
}

.annotation-badge--resolved::after {
  content: ' \2713';
}

/* ─── Annotation mode — element hover styling ─────────────────── */

body.annotation-mode .slide.active .diagram-container,
body.annotation-mode .slide.active .interactive-container,
body.annotation-mode .slide.active .chapter-hero-img,
body.annotation-mode .slide.active .analogy-illustration {
  cursor: crosshair;
  transition: outline var(--transition-fast);
}

body.annotation-mode .slide.active .diagram-container:hover,
body.annotation-mode .slide.active .interactive-container:hover,
body.annotation-mode .slide.active .chapter-hero-img:hover,
body.annotation-mode .slide.active .analogy-illustration:hover {
  outline: 2px dashed var(--accent-amber);
  outline-offset: 4px;
}

/* Disable interactive canvas pointer events in annotation mode */
body.annotation-mode .interactive-canvas {
  pointer-events: none;
}

/* ─── Toast notification ─────────────────────────────────────── */

.annotation-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  z-index: 160;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid #00bcd4;
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: var(--font-body);
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  cursor: pointer;
}

.annotation-toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}
