/* Daily Kafka Quiz Styles */

/* Quiz Container */
.quiz-container {
  max-width: 100%;
  margin: 2rem 0;
}

/* Question Card */
.question-card {
  background: var(--bg-tertiary);
  border-radius: 20px;
  border: 1px solid var(--border-primary);
  box-shadow: var(--shadow-md);
  padding: 2rem;
  margin-bottom: 2rem;
  position: relative;
  overflow: hidden;
}

.question-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary), var(--accent-tertiary));
}

/* Question Header */
.question-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.question-badges {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  text-transform: capitalize;
}

.badge-category {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: white;
}

.badge-difficulty {
  border: 1px solid var(--border-primary);
  color: var(--text-secondary);
  background: var(--bg-elevated);
}

.badge-difficulty.beginner {
  border-color: var(--accent-success);
  color: var(--accent-success);
}

.badge-difficulty.intermediate {
  border-color: var(--accent-warning);
  color: var(--accent-warning);
}

.badge-difficulty.advanced {
  border-color: var(--accent-tertiary);
  color: var(--accent-tertiary);
}

.badge-interactive {
  background: linear-gradient(135deg, #10b981, #3b82f6);
  color: white;
}

.question-day {
  font-size: 0.85rem;
  color: var(--text-tertiary);
}

/* Question Text */
.question-text {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.5;
  margin-bottom: 1.5rem;
}

/* Mode Toggle */
.mode-toggle {
  display: flex;
  background: var(--bg-elevated);
  border-radius: 12px;
  padding: 0.25rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border-primary);
}

.mode-btn {
  flex: 1;
  padding: 0.75rem 1rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 10px;
  transition: all 0.15s ease;
}

.mode-btn:hover {
  color: var(--text-primary);
}

.mode-btn.active {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: white;
  box-shadow: var(--shadow-sm);
}

/* Quiz Options */
.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.option-btn {
  display: flex;
  align-items: center;
  padding: 1rem 1.25rem;
  background: var(--bg-elevated);
  border: 2px solid var(--border-primary);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 1rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
}

.option-btn:hover:not(:disabled) {
  border-color: var(--accent-primary);
  background: var(--hover-overlay);
  transform: translateX(4px);
}

.option-btn.selected {
  border-color: var(--accent-secondary);
  background: rgba(167, 139, 250, 0.1);
}

.option-btn.correct {
  border-color: var(--accent-success);
  background: rgba(16, 185, 129, 0.15);
}

.option-btn.incorrect {
  border-color: var(--accent-tertiary);
  background: rgba(244, 114, 182, 0.15);
}

.option-btn:disabled {
  cursor: default;
}

.option-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-right: 1rem;
  background: var(--bg-tertiary);
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.option-btn.correct .option-letter {
  background: var(--accent-success);
  color: white;
}

.option-btn.incorrect .option-letter {
  background: var(--accent-tertiary);
  color: white;
}

/* Flashcard Mode */
.flashcard-container {
  display: none;
}

.flashcard-container.active {
  display: block;
}

.reveal-btn {
  width: 100%;
  padding: 1.25rem;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  border: none;
  border-radius: 12px;
  color: white;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.reveal-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.flashcard-answer {
  display: none;
  padding: 1.5rem;
  background: var(--bg-elevated);
  border-radius: 12px;
  border: 1px solid var(--border-primary);
}

.flashcard-answer.revealed {
  display: block;
}

.flashcard-answer h4 {
  color: var(--accent-success);
  margin-bottom: 0.75rem;
  font-size: 1.1rem;
}

/* Answer Feedback */
.answer-feedback {
  display: none;
  margin-top: 1.5rem;
  padding: 1.5rem;
  background: var(--bg-elevated);
  border-radius: 12px;
  border: 1px solid var(--border-primary);
}

.answer-feedback.visible {
  display: block;
}

.feedback-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.feedback-header.correct {
  color: var(--accent-success);
}

.feedback-header.incorrect {
  color: var(--accent-tertiary);
}

.feedback-explanation {
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 1rem;
}

.docs-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--accent-primary);
  font-weight: 500;
  transition: color 0.15s ease;
}

.docs-link:hover {
  color: var(--accent-secondary);
}

/* Stats Section */
.quiz-stats {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}

.stat-card {
  flex: 1;
  min-width: 120px;
  padding: 1rem;
  background: var(--bg-tertiary);
  border-radius: 12px;
  border: 1px solid var(--border-primary);
  text-align: center;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-primary);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  margin-top: 0.25rem;
}

.streak-fire {
  color: var(--accent-warning);
}

/* Browse Toggle Button */
.browse-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: 10px;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  margin-left: auto;
}

.browse-toggle-btn:hover {
  border-color: var(--accent-primary);
  color: var(--text-primary);
  background: var(--hover-overlay);
}

.browse-toggle-btn.active {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  border-color: transparent;
  color: white;
}

.browse-toggle-btn svg {
  flex-shrink: 0;
}

/* Browse Header */
.browse-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.browse-counter {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  padding: 0.5rem 1rem;
  background: var(--bg-tertiary);
  border-radius: 8px;
  border: 1px solid var(--border-primary);
}

/* Browse Navigation */
.browse-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.browse-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.6rem 1rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.browse-nav-btn:hover:not(:disabled) {
  border-color: var(--accent-primary);
  background: var(--hover-overlay);
}

.browse-nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.browse-nav-btn svg {
  flex-shrink: 0;
}

/* Browse Select Dropdown */
.browse-select {
  flex: 1;
  min-width: 200px;
  max-width: 400px;
  padding: 0.6rem 1rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.5rem;
}

.browse-select:hover {
  border-color: var(--accent-primary);
}

.browse-select:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.browse-select option {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* Browse All Section */
.browse-section {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 2px dashed var(--text-tertiary);
}

.browse-section h2 {
  color: var(--text-primary);
  margin-bottom: 1.5rem;
}

/* Category Filters */
.category-filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.filter-btn {
  padding: 0.5rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-primary);
  border-radius: 20px;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-btn:hover {
  border-color: var(--accent-primary);
  color: var(--text-primary);
}

.filter-btn.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
}

/* Question List */
.question-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.question-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  background: var(--bg-tertiary);
  border-radius: 12px;
  border: 1px solid var(--border-primary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.question-item:hover {
  border-color: var(--accent-primary);
  transform: translateX(4px);
}

.question-item.answered {
  opacity: 0.7;
}

.question-item.answered::after {
  content: "Completed";
  font-size: 0.75rem;
  color: var(--accent-success);
  margin-left: 1rem;
}

.question-item-text {
  font-size: 0.95rem;
  color: var(--text-primary);
  flex: 1;
}

.question-item-badges {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
  margin-left: 1rem;
}

.question-item-badges .badge {
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--text-tertiary);
}

/* ========================================
   DIAGRAM QUESTIONS
   ======================================== */

/* Diagram Container */
.diagram-container {
  position: relative;
  width: 100%;
  min-height: 200px;
  margin: 1.5rem 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-primary);
  border-radius: 12px;
  padding: 1.5rem;
  overflow: visible;
}

.diagram-svg {
  width: 100%;
  height: auto;
  min-height: 180px;
}

/* Diagram Instructions */
.diagram-instructions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: var(--bg-tertiary);
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.diagram-instructions svg {
  flex-shrink: 0;
}

/* Diagram Nodes */
.diagram-node {
  cursor: pointer;
  transition: all 0.2s ease;
}

.diagram-node.selectable:hover .node-bg {
  stroke: var(--accent-primary);
  stroke-width: 3;
  filter: drop-shadow(0 0 8px rgba(59, 130, 246, 0.4));
}

.diagram-node.selected .node-bg {
  stroke: var(--accent-secondary);
  stroke-width: 3;
  fill: rgba(167, 139, 250, 0.15);
}

.diagram-node.correct .node-bg {
  stroke: var(--accent-success);
  stroke-width: 3;
  fill: rgba(16, 185, 129, 0.2);
  filter: drop-shadow(0 0 10px rgba(16, 185, 129, 0.5));
}

.diagram-node.incorrect .node-bg {
  stroke: var(--accent-tertiary);
  stroke-width: 3;
  fill: rgba(244, 114, 182, 0.2);
  filter: drop-shadow(0 0 10px rgba(244, 114, 182, 0.5));
}

.diagram-node.disabled {
  cursor: default;
  opacity: 0.7;
}

.diagram-node.fenced .node-bg {
  stroke-dasharray: 5, 5;
  opacity: 0.6;
}

/* Node Background Styles */
.node-bg {
  fill: var(--bg-tertiary);
  stroke: var(--border-primary);
  stroke-width: 2;
  transition: all 0.2s ease;
}

.node-bg.controller {
  stroke: #3b82f6;
}

.node-bg.broker {
  stroke: #10b981;
}

.node-bg.partition-leader {
  stroke: #f59e0b;
}

.node-bg.partition-follower {
  stroke: #6b7280;
}

/* Node Labels */
.node-label {
  fill: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
  font-family: inherit;
}

.node-sublabel {
  fill: var(--text-secondary);
  font-size: 10px;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
  font-family: inherit;
}

/* Node Icons */
.node-icon {
  fill: var(--text-secondary);
  pointer-events: none;
}

.node-icon.leader-crown {
  fill: #f59e0b;
}

/* Connection Lines */
.diagram-connection {
  stroke: var(--border-primary);
  stroke-width: 2;
  fill: none;
}

.diagram-connection.active {
  stroke: var(--accent-primary);
  stroke-width: 2.5;
}

.diagram-connection.fetch {
  stroke: #10b981;
  stroke-dasharray: 5, 3;
}

.diagram-arrow {
  fill: var(--text-tertiary);
}

/* Multi-select indicator */
.multi-select-hint {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  padding: 0.5rem 0.75rem;
  background: rgba(167, 139, 250, 0.1);
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--accent-secondary);
}

.multi-select-hint .count {
  font-weight: 600;
}

/* Diagram Submit Button */
.diagram-submit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
  padding: 0.75rem 1.5rem;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  border: none;
  border-radius: 10px;
  color: white;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.diagram-submit-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.diagram-submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ========================================
   DRAG AND DROP
   ======================================== */

/* Drag Zone */
.drag-zone {
  position: relative;
  min-height: 60px;
  border: 2px dashed var(--border-primary);
  border-radius: 10px;
  background: var(--bg-tertiary);
  transition: all 0.2s ease;
}

.drag-zone.drop-target {
  border-color: var(--accent-primary);
  background: rgba(59, 130, 246, 0.1);
}

.drag-zone.has-item {
  border-style: solid;
  border-color: var(--accent-secondary);
}

.drag-zone-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--text-tertiary);
  font-size: 0.85rem;
  pointer-events: none;
}

.drag-zone.has-item .drag-zone-label {
  display: none;
}

/* Draggable Items */
.draggable {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--bg-elevated);
  border: 2px solid var(--border-primary);
  border-radius: 8px;
  cursor: grab;
  user-select: none;
  -moz-user-select: none;
  -webkit-user-select: none;
  transition: all 0.15s ease;
  touch-action: none;
  -webkit-user-drag: element;
}

/* Ensure all children don't intercept drag events */
.draggable * {
  pointer-events: none;
}

.draggable:hover {
  border-color: var(--accent-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.draggable.dragging {
  opacity: 0.8;
  cursor: grabbing;
  transform: scale(1.05);
  box-shadow: var(--shadow-md);
  z-index: 100;
}

.draggable.placed {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.draggable.correct {
  border-color: var(--accent-success);
  background: rgba(16, 185, 129, 0.15);
}

.draggable.incorrect {
  border-color: var(--accent-tertiary);
  background: rgba(244, 114, 182, 0.15);
}

.draggable-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  pointer-events: none;
}

.draggable-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  pointer-events: none;
}

/* Draggable Source Area */
.draggable-source {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--bg-tertiary);
  border-radius: 10px;
  margin-bottom: 1rem;
}

.draggable-source-label {
  width: 100%;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-tertiary);
  font-weight: 500;
}

/* Drag and Drop Layout */
.drag-drop-layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1rem;
}

.drag-drop-column {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.drag-drop-column-header {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-primary);
}

/* ========================================
   DIAGRAM SPECIFIC LAYOUTS
   ======================================== */

/* KRaft Quorum Layout */
.kraft-quorum-layout {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2rem;
  flex-wrap: wrap;
}

.kraft-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
  min-width: 100px;
}

/* Broker Cluster Layout */
.broker-cluster-layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 1rem;
  max-width: 500px;
  margin: 0 auto;
}

/* Partition Replica Layout */
.replica-layout {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.replica-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.replica-broker-label {
  min-width: 80px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Timeline Layout (for heartbeat diagrams) */
.timeline-container {
  position: relative;
  padding: 1rem 0;
}

.timeline-axis {
  position: absolute;
  left: 80px;
  right: 20px;
  top: 50%;
  height: 2px;
  background: var(--border-primary);
}

.timeline-row {
  display: flex;
  align-items: center;
  height: 50px;
  position: relative;
}

.timeline-label {
  width: 80px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.timeline-events {
  flex: 1;
  position: relative;
  height: 100%;
}

.timeline-event {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent-success);
  cursor: pointer;
  transition: all 0.2s ease;
}

.timeline-event.missed {
  background: var(--accent-tertiary);
  border: 2px dashed var(--accent-tertiary);
  background: transparent;
}

.timeline-event:hover {
  transform: translate(-50%, -50%) scale(1.3);
}

/* Timeline row clickable styles */
.timeline-row.selectable {
  cursor: pointer;
  border-radius: 8px;
  padding: 0.5rem;
  margin: -0.5rem;
  margin-bottom: 0.5rem;
  transition: background 0.2s ease;
}

.timeline-row.selectable:hover {
  background: var(--hover-overlay);
}

.timeline-row.selected {
  background: rgba(167, 139, 250, 0.15);
}

.timeline-row.correct {
  background: rgba(16, 185, 129, 0.15);
}

.timeline-row.incorrect {
  background: rgba(244, 114, 182, 0.15);
}

.timeline-row.disabled {
  opacity: 0.6;
  cursor: default;
}

/* Drag zone correct/incorrect states */
.drag-zone.correct {
  border-color: var(--accent-success);
  background: rgba(16, 185, 129, 0.1);
}

.drag-zone.incorrect {
  border-color: var(--accent-tertiary);
  background: rgba(244, 114, 182, 0.1);
}

/* Responsive */
@media (max-width: 600px) {
  .question-card {
    padding: 1.5rem;
  }

  .diagram-container {
    padding: 1rem;
  }

  .diagram-instructions {
    font-size: 0.85rem;
    padding: 0.5rem 0.75rem;
  }

  .drag-drop-layout {
    grid-template-columns: 1fr;
  }

  .draggable-source {
    padding: 0.75rem;
  }

  .draggable {
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
  }

  .timeline-label {
    width: 60px;
    font-size: 0.75rem;
  }

  .kraft-quorum-layout {
    gap: 1rem;
  }

  .question-text {
    font-size: 1.1rem;
  }

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

  .quiz-stats {
    flex-direction: column;
  }

  .stat-card {
    min-width: 100%;
  }

  .question-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .question-item-badges {
    margin-left: 0;
  }

  .browse-header {
    flex-direction: column;
    align-items: stretch;
  }

  .browse-toggle-btn {
    width: 100%;
    justify-content: center;
  }

  .browse-nav {
    flex-direction: column;
    width: 100%;
  }

  .browse-nav-btn {
    width: 100%;
    justify-content: center;
  }

  .browse-select {
    width: 100%;
    max-width: none;
  }
}
