/* =================================
   Interactive Components Styles
   ================================= */

/* Base component styles */
[data-component] {
  margin: 1.5rem 0;
}

.component-error {
  color: var(--text-secondary);
  font-style: italic;
  padding: 1rem;
  background: var(--bg-secondary);
  border-radius: 8px;
}

/* Counter Component */
.interactive-counter {
  display: inline-flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: var(--bg-secondary);
  border-radius: 12px;
  font-family: inherit;
}

.counter-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s, opacity 0.2s;
}

.counter-btn:hover {
  opacity: 0.9;
  transform: scale(1.05);
}

.counter-btn:active {
  transform: scale(0.95);
}

.counter-value {
  font-size: 1.5rem;
  font-weight: 600;
  min-width: 3rem;
  text-align: center;
}

/* Toggle Content Component */
.toggle-content {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.toggle-btn {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-secondary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  color: var(--text);
  text-align: left;
  transition: background 0.2s;
}

.toggle-btn:hover {
  background: var(--bg-tertiary, var(--bg-secondary));
}

.toggle-icon {
  font-size: 0.75rem;
  transition: transform 0.2s;
}

.toggle-body {
  padding: 1rem;
  border-top: 1px solid var(--border);
}

/* Quiz Component */
.quiz-component {
  padding: 1.5rem;
  background: var(--bg-secondary);
  border-radius: 12px;
}

.quiz-question {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.quiz-option {
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  font-size: 1rem;
  color: var(--text);
  transition: border-color 0.2s, background 0.2s;
}

.quiz-option:hover {
  border-color: var(--accent);
}

.quiz-option.correct {
  border-color: #22c55e;
  background: rgba(34, 197, 94, 0.1);
}

.quiz-option.incorrect {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

.quiz-feedback {
  margin-top: 1rem;
  font-weight: 600;
  min-height: 1.5em;
}

.quiz-feedback.correct {
  color: #22c55e;
}

.quiz-feedback.incorrect {
  color: #ef4444;
}

/* Slider Component */
.slider-component {
  padding: 1rem;
  background: var(--bg-secondary);
  border-radius: 8px;
}

.slider-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.slider-value {
  font-family: monospace;
  color: var(--accent);
}

.slider-input {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: var(--border);
  appearance: none;
  cursor: pointer;
}

.slider-input::-webkit-slider-thumb {
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.slider-input::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}

/* Code Playground Component */
.code-playground {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.playground-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.playground-lang {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-family: monospace;
}

.playground-run {
  padding: 0.35rem 0.75rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: opacity 0.2s;
}

.playground-run:hover {
  opacity: 0.9;
}

.playground-editor {
  width: 100%;
  min-height: 120px;
  padding: 1rem;
  border: none;
  background: var(--bg);
  color: var(--text);
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  resize: vertical;
}

.playground-editor:focus {
  outline: none;
}

.playground-output {
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

.output-header {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}

.output-content {
  padding: 1rem;
  margin: 0;
  min-height: 2rem;
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.9rem;
  white-space: pre-wrap;
}

.output-content.error {
  color: #ef4444;
}

/* Tabs Component */
.tabs-component {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.tabs-header {
  display: flex;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  padding: 0.75rem 1.25rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--text-secondary);
  transition: color 0.2s, border-color 0.2s;
}

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

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tabs-content {
  padding: 1rem;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* Chart Component */
.chart-component {
  padding: 1rem;
  background: var(--bg-secondary);
  border-radius: 8px;
}

/* Bar Chart */
.bar-chart {
  display: flex;
  flex-direction: column;
}

.chart-bars {
  flex: 1;
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding-bottom: 1.5rem;
}

.chart-bar-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
}

.chart-bar {
  width: 100%;
  max-width: 60px;
  border-radius: 4px 4px 0 0;
  position: relative;
  transition: height 0.3s ease;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.bar-value {
  position: absolute;
  top: -1.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text);
}

.bar-label {
  position: absolute;
  bottom: -1.25rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* Line Chart */
.line-chart {
  display: flex;
  flex-direction: column;
}

.line-chart svg {
  flex: 1;
  width: 100%;
}

.line-chart polyline {
  vector-effect: non-scaling-stroke;
}

.chart-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.chart-error {
  text-align: center;
  color: var(--text-secondary);
  padding: 2rem;
}

/* =================================
   Pinhole Camera Component
   ================================= */

.pinhole-camera-component {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 1.5rem;
  overflow: hidden;
}

.pinhole-svg {
  width: 100%;
  max-width: 100%;
  height: auto;
  display: block;
  margin-bottom: 1.5rem;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.pinhole-svg .drag-handle {
  cursor: ew-resize;
  transition: opacity 0.2s;
}

.pinhole-svg .drag-handle:hover {
  opacity: 0.6 !important;
}

.pinhole-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.pinhole-slider-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.pinhole-slider-group label {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

.pinhole-slider-group .value-display {
  font-family: "SF Mono", "Fira Code", monospace;
  color: var(--accent);
}

.pinhole-slider {
  width: 100%;
  height: 8px;
  min-height: 8px;
  border-radius: 4px;
  background: var(--border, #e5e7eb);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  outline: none;
  display: block;
  visibility: visible;
  opacity: 1;
}

.pinhole-slider::-webkit-slider-runnable-track {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: var(--border, #e5e7eb);
}

.pinhole-slider::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent, #6366f1);
  cursor: pointer;
  transition: transform 0.1s;
  margin-top: -5px;
}

.pinhole-slider::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

.pinhole-slider::-moz-range-track {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: var(--border, #e5e7eb);
  border: none;
}

.pinhole-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent, #6366f1);
  cursor: pointer;
  border: none;
}

.pinhole-info {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1rem;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.pinhole-info .info-item {
  flex: 1;
  min-width: 120px;
  text-align: center;
}

.pinhole-info .info-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.pinhole-info .info-value {
  display: block;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  font-family: "SF Mono", "Fira Code", monospace;
}

/* Mobile adjustments */
@media (max-width: 480px) {
  .pinhole-camera-component {
    padding: 1rem;
  }

  .pinhole-controls {
    grid-template-columns: 1fr;
  }

  .pinhole-info {
    flex-direction: column;
    gap: 0.75rem;
  }

  .pinhole-info .info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
  }

  .pinhole-info .info-label {
    margin-bottom: 0;
  }
}

/* =================================
   Lens Camera Component
   ================================= */

.lens-camera-component {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 1.5rem;
  overflow: hidden;
}

.lens-camera-svg {
  width: 100%;
  max-width: 100%;
  height: auto;
  display: block;
  margin-bottom: 1.5rem;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.lens-camera-controls {
  display: flex;
  justify-content: center;
  margin-bottom: 1.5rem;
}

/* Toggle switch styling */
.lens-toggle-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
  padding: 0.75rem 1.25rem;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
  transition: border-color 0.2s;
}

.lens-toggle-label:hover {
  border-color: var(--accent);
}

.lens-toggle-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.lens-toggle-switch {
  position: relative;
  width: 48px;
  height: 26px;
  background: var(--border);
  border-radius: 13px;
  transition: background-color 0.2s;
}

.lens-toggle-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.lens-toggle-input:checked + .lens-toggle-switch {
  background: var(--accent, #6366f1);
}

.lens-toggle-input:checked + .lens-toggle-switch::after {
  transform: translateX(22px);
}

.lens-toggle-text {
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--text);
}

.lens-camera-sliders {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.lens-slider-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.lens-slider-group label {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

.lens-slider-group .value-display {
  font-family: "SF Mono", "Fira Code", monospace;
  color: var(--accent);
}

.lens-slider {
  width: 100%;
  height: 8px;
  min-height: 8px;
  border-radius: 4px;
  background: var(--border, #e5e7eb);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  outline: none;
}

.lens-slider::-webkit-slider-runnable-track {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: var(--border, #e5e7eb);
}

.lens-slider::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent, #6366f1);
  cursor: pointer;
  transition: transform 0.1s;
  margin-top: -5px;
}

.lens-slider::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

.lens-slider::-moz-range-track {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: var(--border, #e5e7eb);
  border: none;
}

.lens-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent, #6366f1);
  cursor: pointer;
  border: none;
}

.lens-camera-info {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1rem;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.lens-camera-info .info-item {
  flex: 1;
  min-width: 120px;
  text-align: center;
}

.lens-camera-info .info-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.lens-camera-info .info-value {
  display: block;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  font-family: "SF Mono", "Fira Code", monospace;
}

/* Mobile adjustments */
@media (max-width: 480px) {
  .lens-camera-component {
    padding: 1rem;
  }

  .lens-camera-sliders {
    grid-template-columns: 1fr;
  }

  .lens-camera-info {
    flex-direction: column;
    gap: 0.75rem;
  }

  .lens-camera-info .info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
  }

  .lens-camera-info .info-label {
    margin-bottom: 0;
  }

  .lens-toggle-label {
    padding: 0.5rem 1rem;
  }

  .lens-toggle-text {
    font-size: 0.85rem;
  }
}
