/* Interactive Widget Styles for Coding for MBA */

/* ============================================
   Interactive Code Widget
   ============================================ */

.interactive-widget {
  margin: 1.5rem 0;
  border: 2px solid var(--md-default-fg-color--lightest);
  border-radius: 8px;
  overflow: hidden;
  background: var(--md-code-bg-color);
}

.widget-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--md-default-fg-color--lightest);
  border-bottom: 1px solid var(--md-default-fg-color--lighter);
}

.widget-toolbar button {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.run-button {
  background: var(--md-primary-fg-color);
  color: var(--md-primary-bg-color);
}

.run-button:hover:not(:disabled) {
  background: var(--md-accent-fg-color);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.run-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.clear-button {
  background: var(--md-default-fg-color--lightest);
  color: var(--md-default-fg-color);
}

.clear-button:hover {
  background: var(--md-default-fg-color--lighter);
}

.status-indicator {
  margin-left: auto;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
}

.status-running {
  background: #fff3cd;
  color: #856404;
}

.status-success {
  background: #d4edda;
  color: #155724;
}

.status-error {
  background: #f8d7da;
  color: #721c24;
}

.code-input {
  width: 100%;
  padding: 1rem;
  border: none;
  font-family: var(--md-code-font-family);
  font-size: 0.9rem;
  line-height: 1.5;
  background: var(--md-code-bg-color);
  color: var(--md-code-fg-color);
  resize: vertical;
  min-height: 100px;
}

.code-input:focus {
  outline: 2px solid var(--md-accent-fg-color);
  outline-offset: -2px;
}

.code-output {
  padding: 1rem;
  border-top: 1px solid var(--md-default-fg-color--lightest);
  font-family: var(--md-code-font-family);
  font-size: 0.85rem;
  line-height: 1.6;
  min-height: 50px;
  max-height: 400px;
  overflow-y: auto;
  background: var(--md-default-bg-color);
}

.code-output:empty {
  display: none;
}

.output-success {
  color: var(--md-code-fg-color);
  white-space: pre-wrap;
  word-wrap: break-word;
}

.output-error {
  color: #dc3545;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.output-info {
  color: var(--md-default-fg-color--light);
  font-style: italic;
}

/* ============================================
   Progress Tracking
   ============================================ */

.progress-widget {
  padding: 1.5rem;
  margin: 1rem 0;
  background: var(--md-default-bg-color);
  border: 2px solid var(--md-primary-fg-color--light);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.progress-header h3 {
  margin: 0 0 1rem 0;
  font-size: 1.1rem;
  color: var(--md-primary-fg-color);
}

.progress-bar {
  width: 100%;
  height: 24px;
  background: var(--md-default-fg-color--lightest);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--md-primary-fg-color), var(--md-accent-fg-color));
  transition: width 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 0.5rem;
  color: white;
  font-size: 0.75rem;
  font-weight: bold;
}

.progress-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.completion-count {
  color: var(--md-default-fg-color--light);
}

.progress-percentage {
  font-weight: bold;
  font-size: 1.1rem;
  color: var(--md-primary-fg-color);
}

.progress-actions {
  display: flex;
  gap: 0.5rem;
}

.progress-actions button {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid var(--md-default-fg-color--lighter);
  border-radius: 4px;
  background: var(--md-default-bg-color);
  color: var(--md-default-fg-color);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.progress-actions button:hover {
  background: var(--md-default-fg-color--lightest);
  border-color: var(--md-primary-fg-color);
}

.lesson-complete-button {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  padding: 1rem 1.5rem;
  background: var(--md-primary-fg-color);
  color: var(--md-primary-bg-color);
  border: none;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
  z-index: 99;
}

.lesson-complete-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.lesson-complete-button.completed {
  background: #28a745;
}

.progress-notification {
  position: fixed;
  top: 5rem;
  right: 2rem;
  padding: 1rem 1.5rem;
  background: white;
  color: #333;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  font-weight: 500;
  opacity: 0;
  transform: translateX(100%);
  transition: all 0.3s ease;
  z-index: 1000;
  max-width: 300px;
}

.progress-notification.show {
  opacity: 1;
  transform: translateX(0);
}

.progress-notification.notification-success {
  border-left: 4px solid #28a745;
}

.progress-notification.notification-error {
  border-left: 4px solid #dc3545;
}

.progress-notification.notification-info {
  border-left: 4px solid #17a2b8;
}

/* ============================================
   JupyterLite Integration
   ============================================ */

.jupyter-launch-section {
  margin: 2rem 0;
  padding: 1.5rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 12px;
  color: white;
}

.jupyter-launch-section h3 {
  margin: 0 0 1rem 0;
  color: white;
}

.jupyter-launch-section p {
  margin: 0 0 1rem 0;
  opacity: 0.9;
}

.jupyter-buttons {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.jupyter-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  text-decoration: none;
  border: 2px solid white;
  border-radius: 8px;
  font-weight: 600;
  transition: all 0.3s ease;
}

.jupyter-button:hover {
  background: white;
  color: #667eea;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.jupyter-button-primary {
  background: rgba(255, 255, 255, 0.95);
  color: #667eea;
}

.jupyter-button-primary:hover {
  background: white;
}

/* ============================================
   Binder Badge
   ============================================ */

.binder-badge {
  margin: 1rem 0;
}

.binder-badge img {
  transition: transform 0.2s ease;
}

.binder-badge img:hover {
  transform: scale(1.05);
}

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

@media (max-width: 76.1875em) {
  .progress-widget {
    padding: 1rem;
  }

  .lesson-complete-button {
    bottom: 1rem;
    right: 1rem;
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
  }

  .interactive-widget {
    margin: 1rem 0;
  }

  .jupyter-buttons {
    flex-direction: column;
  }

  .jupyter-button {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 60em) {
  .widget-toolbar {
    flex-wrap: wrap;
  }

  .status-indicator {
    margin-left: 0;
    width: 100%;
    text-align: center;
  }

  .progress-notification {
    right: 1rem;
    left: 1rem;
    max-width: none;
  }
}

/* ============================================
   Dark Mode Adjustments
   ============================================ */

[data-md-color-scheme="slate"] .interactive-widget {
  border-color: rgba(255, 255, 255, 0.1);
}

[data-md-color-scheme="slate"] .widget-toolbar {
  background: rgba(255, 255, 255, 0.05);
  border-bottom-color: rgba(255, 255, 255, 0.1);
}

[data-md-color-scheme="slate"] .code-output {
  background: rgba(0, 0, 0, 0.2);
  border-top-color: rgba(255, 255, 255, 0.1);
}

[data-md-color-scheme="slate"] .progress-notification {
  background: #2d333b;
  color: #e6edf3;
}

/* ============================================
   Accessibility Enhancements
   ============================================ */

/* Focus indicators */
.interactive-widget button:focus,
.code-input:focus,
.lesson-complete-button:focus {
  outline: 3px solid var(--md-accent-fg-color);
  outline-offset: 2px;
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .interactive-widget {
    border-width: 3px;
  }

  .run-button,
  .lesson-complete-button {
    border: 2px solid currentColor;
  }

  .progress-bar {
    border: 2px solid currentColor;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .interactive-widget *,
  .progress-widget *,
  .lesson-complete-button,
  .progress-notification {
    transition: none !important;
    animation: none !important;
  }
}

/* Print styles */
@media print {
  .interactive-widget,
  .progress-widget,
  .lesson-complete-button,
  .progress-notification {
    display: none;
  }
}
