/* ==========================================================================
   FLOREX.LAB — Components
   Buttons, cards, modals, tooltips, toasts, inputs, and all UI components
   ========================================================================== */

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 40px;
  padding: 0 var(--space-5);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  white-space: nowrap;
  text-decoration: none;
  position: relative;
  overflow: hidden;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Primary */
.btn-primary {
  background: var(--gradient-primary);
  color: #fff;
  border-color: transparent;
  box-shadow: var(--shadow-sm), 0 0 0 1px rgba(229, 62, 107, 0.1);
}

.btn-primary:hover {
  box-shadow: var(--shadow-md), var(--shadow-glow-red);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

/* Secondary */
.btn-secondary {
  background: var(--surface);
  color: var(--text-primary);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

.btn-secondary:active {
  transform: translateY(0);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--surface);
  color: var(--text-primary);
}

/* Danger */
.btn-danger {
  background: var(--accent-red);
  color: #fff;
  border-color: transparent;
}

.btn-danger:hover {
  background: #d1254f;
  box-shadow: var(--shadow-md), var(--shadow-glow-red);
  transform: translateY(-1px);
}

/* Icon button */
.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-md);
}

/* Small button */
.btn-sm {
  height: 32px;
  padding: 0 var(--space-3);
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
}

/* Large button */
.btn-lg {
  height: 48px;
  padding: 0 var(--space-8);
  font-size: var(--text-base);
  border-radius: var(--radius-lg);
}

/* Loading state */
.btn-loading {
  color: transparent !important;
  pointer-events: none;
}

.btn-loading::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  transition: all var(--duration-normal) var(--ease-out);
}

.card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
}

.card-interactive {
  cursor: pointer;
}

.card-interactive:hover {
  transform: translateY(-2px);
  border-color: var(--accent-red);
  box-shadow: var(--shadow-lg), var(--shadow-glow-red);
}

/* Experiment card */
.experiment-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-out);
  display: flex;
  flex-direction: column;
  position: relative;
}

.experiment-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--border);
  transition: background var(--duration-fast) var(--ease-out);
}

.experiment-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-hover);
  box-shadow: var(--shadow-lg);
}

.experiment-card:hover::before {
  background: var(--gradient-retro-stripe);
}

.experiment-card:hover .experiment-card-preview {
  border-bottom-color: var(--border-hover);
}

.experiment-card-preview {
  height: 200px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.experiment-card-preview-content {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.experiment-card-body {
  padding: var(--space-5);
  flex: 1;
  display: flex;
  flex-direction: column;
}

.experiment-card-number {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.experiment-card-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.experiment-card-desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-normal);
  margin-bottom: var(--space-4);
  flex: 1;
}

.experiment-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.experiment-card-tags {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.experiment-card-tag {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
  background: var(--bg-secondary);
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-subtle);
}

.experiment-card-category {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  padding: 2px 10px;
  border-radius: var(--radius-xs);
}

.experiment-card-category[data-category="CSS"] {
  color: var(--retro-teal);
  background: rgba(133, 178, 165, 0.15);
  border: 1px solid rgba(133, 178, 165, 0.3);
}

.experiment-card-category[data-category="JavaScript"] {
  color: var(--retro-yellow);
  background: rgba(255, 193, 59, 0.15);
  border: 1px solid rgba(255, 193, 59, 0.3);
}

.experiment-card-category[data-category="UI/UX"] {
  color: var(--retro-pink);
  background: rgba(216, 139, 162, 0.15);
  border: 1px solid rgba(216, 139, 162, 0.3);
}

.experiment-card-category[data-category="Animation"] {
  color: var(--retro-green);
  background: rgba(139, 195, 134, 0.15);
  border: 1px solid rgba(139, 195, 134, 0.3);
}

/* Coming soon state */
.experiment-card.coming-soon {
  opacity: 0.6;
  cursor: default;
}

.experiment-card.coming-soon:hover {
  transform: none;
  box-shadow: none;
  border-color: var(--border);
}

.experiment-card.coming-soon .experiment-card-preview::after {
  content: 'COMING SOON';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  color: var(--text-muted);
  letter-spacing: 0.15em;
  background: var(--bg-secondary);
}

/* ── Experiment Viewer ── */
.experiment-viewer {
  display: none;
  animation: fadeIn var(--duration-normal) var(--ease-out);
}

.experiment-viewer.active {
  display: block;
}

.experiment-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
  gap: var(--space-4);
}

.experiment-viewer-back {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease-out);
}

.experiment-viewer-back:hover {
  color: var(--text-primary);
}

.experiment-viewer-back svg {
  width: 16px;
  height: 16px;
}

.experiment-viewer-info {
  flex: 1;
}

.experiment-viewer-number {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: var(--space-1);
}

.experiment-viewer-title {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
}

.experiment-viewer-desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: var(--space-2);
}

.experiment-viewer-actions {
  display: flex;
  gap: var(--space-3);
}

.experiment-viewer-body {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: var(--space-6);
  min-height: 500px;
}

.experiment-preview-area {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
}

.experiment-preview-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
}

.experiment-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

/* Experiment Controls */
.experiment-controls {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.experiment-controls-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.experiment-controls-title svg {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

.control-group {
  margin-bottom: var(--space-4);
}

.control-group:last-child {
  margin-bottom: 0;
}

.control-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.control-value {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Experiment Code */
.experiment-code {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  flex: 1;
}

.experiment-code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}

.experiment-code-tabs {
  display: flex;
  gap: var(--space-1);
}

.experiment-code-tab {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}

.experiment-code-tab:hover {
  color: var(--text-secondary);
}

.experiment-code-tab.active {
  color: var(--text-primary);
  background: var(--bg-secondary);
}

.experiment-code-body {
  padding: var(--space-4);
  max-height: 300px;
  overflow-y: auto;
}

.experiment-code-body pre {
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  font-size: var(--text-xs);
}

/* ── Inputs ── */
.input {
  width: 100%;
  height: 40px;
  padding: 0 var(--space-3);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-sm);
  transition: border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}

.input:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px var(--accent-blue-soft);
}

.input::placeholder {
  color: var(--text-muted);
}

.input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.input-error {
  border-color: var(--accent-red);
}

.input-error:focus {
  box-shadow: 0 0 0 3px var(--accent-red-soft);
}

/* ── Range Slider ── */
.range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  outline: none;
  cursor: pointer;
}

.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-blue);
  border: 2px solid var(--bg-primary);
  cursor: pointer;
  box-shadow: 0 0 0 3px var(--accent-blue-soft);
  transition: box-shadow var(--duration-fast) var(--ease-out);
}

.range::-webkit-slider-thumb:hover {
  box-shadow: 0 0 0 5px var(--accent-blue-soft);
}

.range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-blue);
  border: 2px solid var(--bg-primary);
  cursor: pointer;
  box-shadow: 0 0 0 3px var(--accent-blue-soft);
}

/* ── Color Input ── */
.color-input {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.color-input input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 32px;
  height: 32px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 0;
  background: none;
}

.color-input input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.color-input input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 2px;
}

.color-input-hex {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ── Select ── */
.select {
  width: 100%;
  height: 40px;
  padding: 0 var(--space-8) 0 var(--space-3);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-sm);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%235c6478' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  transition: border-color var(--duration-fast) var(--ease-out);
}

.select:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px var(--accent-blue-soft);
}

/* ── Checkbox ── */
.checkbox-wrapper {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
}

.checkbox {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-hover);
  border-radius: var(--radius-xs);
  cursor: pointer;
  position: relative;
  transition: all var(--duration-fast) var(--ease-out);
  flex-shrink: 0;
}

.checkbox:checked {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
}

.checkbox:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 6px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.checkbox:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

.checkbox-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  user-select: none;
}

/* ── Switch/Toggle ── */
.switch {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}

.switch.active {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
}

.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform var(--duration-fast) var(--ease-spring);
}

.switch.active .switch-thumb {
  transform: translateX(20px);
}

/* ── Badge ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  height: 22px;
  padding: 0 var(--space-3);
  font-size: 0.7rem;
  font-weight: var(--weight-medium);
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.badge-default {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.badge-success {
  background: var(--accent-green-soft);
  color: var(--accent-green);
}

.badge-warning {
  background: var(--accent-yellow-soft);
  color: var(--accent-yellow);
}

.badge-danger {
  background: var(--accent-red-soft);
  color: var(--accent-red);
}

.badge-info {
  background: var(--accent-blue-soft);
  color: var(--accent-blue);
}

/* ── Tooltip ── */
.tooltip-trigger {
  position: relative;
  display: inline-block;
}

.tooltip {
  position: absolute;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: #fff;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out);
  z-index: var(--z-tooltip);
  box-shadow: var(--shadow-md);
}

.tooltip-trigger:hover .tooltip,
.tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.tooltip-top {
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
}

.tooltip-trigger:hover .tooltip-top,
.tooltip-top.visible {
  transform: translateX(-50%) translateY(0);
}

.tooltip-bottom {
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
}

.tooltip-trigger:hover .tooltip-bottom,
.tooltip-bottom.visible {
  transform: translateX(-50%) translateY(0);
}

/* ── Modal ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: var(--z-modal-backdrop);
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-out);
  display: none;
}

.modal-backdrop.open {
  display: block;
  opacity: 1;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  z-index: var(--z-modal);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  max-width: 480px;
  width: calc(100% - var(--space-8));
  max-height: calc(100vh - var(--space-16));
  overflow-y: auto;
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-out),
              transform var(--duration-normal) var(--ease-spring);
  display: none;
}

.modal.open {
  display: block;
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  transition: all var(--duration-fast) var(--ease-out);
}

.modal-close:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.modal-body {
  padding: var(--space-6);
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
}

/* ── Toast ── */
.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column-reverse;
  gap: var(--space-3);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  min-width: 320px;
  max-width: 420px;
  padding: var(--space-4);
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: slideInRight var(--duration-normal) var(--ease-spring);
  position: relative;
  overflow: hidden;
}

.toast-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 1px;
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.toast-message {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-normal);
}

.toast-close {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  flex-shrink: 0;
  transition: all var(--duration-fast) var(--ease-out);
}

.toast-close:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  border-radius: 0 0 0 var(--radius-lg);
  animation: barProgress linear forwards;
}

.toast-info .toast-icon { color: var(--accent-blue); }
.toast-info .toast-progress { background: var(--accent-blue); }

.toast-success .toast-icon { color: var(--accent-green); }
.toast-success .toast-progress { background: var(--accent-green); }

.toast-warning .toast-icon { color: var(--accent-yellow); }
.toast-warning .toast-progress { background: var(--accent-yellow); }

.toast-error .toast-icon { color: var(--accent-red); }
.toast-error .toast-progress { background: var(--accent-red); }

.toast-dismissing {
  animation: fadeOut var(--duration-fast) var(--ease-out) forwards;
}

@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateX(20px);
  }
}

/* ── Command Palette ── */
.command-palette-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: var(--z-command-palette);
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-out);
  display: none;
}

.command-palette-backdrop.open {
  display: block;
  opacity: 1;
}

.command-palette {
  position: fixed;
  top: 20%;
  left: 50%;
  transform: translateX(-50%) scale(0.98);
  z-index: calc(var(--z-command-palette) + 1);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  max-width: 560px;
  width: calc(100% - var(--space-8));
  max-height: 420px;
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-spring);
  display: none;
  overflow: hidden;
}

.command-palette.open {
  display: block;
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

.command-palette-input {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}

.command-palette-input svg {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.command-palette-input input {
  flex: 1;
  border: none;
  background: none;
  font-size: var(--text-base);
  color: var(--text-primary);
  outline: none;
}

.command-palette-input input::placeholder {
  color: var(--text-muted);
}

.command-palette-results {
  max-height: 340px;
  overflow-y: auto;
  padding: var(--space-2);
}

.command-palette-group {
  padding: var(--space-2) var(--space-3);
}

.command-palette-group-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: var(--space-2) var(--space-3);
}

.command-palette-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-out);
}

.command-palette-item:hover,
.command-palette-item.focused {
  background: var(--surface-hover);
}

.command-palette-item-icon {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.command-palette-item-text {
  flex: 1;
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.command-palette-item-shortcut {
  display: flex;
  gap: var(--space-1);
}

.command-palette-empty {
  padding: var(--space-8) var(--space-4);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
  position: relative;
}

.tab {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  padding: var(--space-3) var(--space-4);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}

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

.tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent-red);
}

.tab-panel {
  display: none;
  padding: var(--space-6) 0;
}

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

/* ── Accordion ── */
.accordion {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.accordion-item {
  border-bottom: 1px solid var(--border);
}

.accordion-item:last-child {
  border-bottom: none;
}

.accordion-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  background: transparent;
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-out);
  text-align: left;
}

.accordion-trigger:hover {
  background: var(--surface);
}

.accordion-icon {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  transition: transform var(--duration-normal) var(--ease-out);
  flex-shrink: 0;
}

.accordion-item.open .accordion-icon {
  transform: rotate(180deg);
}

.accordion-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--duration-normal) var(--ease-out);
}

.accordion-body {
  padding: 0 var(--space-5) var(--space-5);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-normal);
}

/* ── Dropdown ── */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-trigger {
  cursor: pointer;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 200px;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-dropdown);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out);
  pointer-events: none;
  padding: var(--space-1);
}

.dropdown.open .dropdown-menu {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-out);
}

.dropdown-item:hover {
  background: var(--surface-hover);
}

.dropdown-separator {
  height: 1px;
  background: var(--border);
  margin: var(--space-1) 0;
}

/* ── Loaders ── */
.loader-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.loader-dots {
  display: flex;
  gap: var(--space-2);
}

.loader-dot {
  width: 8px;
  height: 8px;
  background: var(--accent-blue);
  border-radius: 50%;
  animation: dotPulse 1.4s ease-in-out infinite;
}

.loader-dot:nth-child(2) { animation-delay: 0.2s; }
.loader-dot:nth-child(3) { animation-delay: 0.4s; }

.loader-bar {
  width: 120px;
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.loader-bar-fill {
  height: 100%;
  width: 40%;
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
  animation: shimmer 1.5s ease-in-out infinite;
  background-size: 200% 100%;
}

.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-hover) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: skeletonWave 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
}

.skeleton-text {
  height: 14px;
  margin-bottom: var(--space-2);
}

.skeleton-text:last-child {
  width: 70%;
}

.skeleton-circle {
  border-radius: 50%;
}

/* ── Progress ── */
.progress {
  width: 100%;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
  transition: width var(--duration-slow) var(--ease-out);
}

/* ── Breadcrumb ── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.breadcrumb-item {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out);
}

.breadcrumb-item:hover {
  color: var(--text-primary);
}

.breadcrumb-separator {
  color: var(--text-muted);
}

.breadcrumb-current {
  color: var(--text-primary);
  font-weight: var(--weight-medium);
}

/* ── Component Section (Gallery) ── */
.component-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.component-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
}

.component-section-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}

.component-section-desc {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.component-preview {
  padding: var(--space-8);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  min-height: 120px;
}

.component-variants {
  padding: var(--space-6);
  border-top: 1px solid var(--border);
}

.component-variant-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-4);
}

.component-code-wrapper {
  border-top: 1px solid var(--border);
}

.component-code-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-out);
}

.component-code-toggle:hover {
  background: var(--surface-hover);
}

.component-code-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--duration-normal) var(--ease-out);
}

.component-code-content.open {
  max-height: 500px;
}

.component-code-content pre {
  margin: 0;
  border-radius: 0;
  border: none;
  border-top: 1px solid var(--border);
  font-size: var(--text-xs);
}

/* ── Empty State ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-16) var(--space-6);
  text-align: center;
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  color: var(--text-muted);
  margin-bottom: var(--space-6);
  opacity: 0.4;
}

.empty-state-title {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-3);
}

.empty-state-desc {
  font-size: var(--text-sm);
  color: var(--text-muted);
  max-width: 360px;
}

/* ── Playground Tool Card ── */
.playground-tool {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  transition: all var(--duration-normal) var(--ease-out);
}

.playground-tool:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
}

.playground-tool-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
}

.playground-tool-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-1);
}

.playground-tool-desc {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.playground-tool-preview {
  padding: var(--space-8);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  background: var(--bg-secondary);
}

.playground-tool-controls {
  padding: var(--space-5) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  border-bottom: 1px solid var(--border);
}

.playground-tool-output {
  padding: var(--space-4) var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  background: var(--bg-secondary);
}

.playground-tool-code {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Context Menu ── */
.context-menu {
  position: fixed;
  min-width: 180px;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-dropdown);
  padding: var(--space-1);
  animation: fadeInScale var(--duration-fast) var(--ease-spring);
  display: none;
}

.context-menu.open {
  display: block;
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-out);
}

.context-menu-item:hover {
  background: var(--surface-hover);
}

.context-menu-separator {
  height: 1px;
  background: var(--border);
  margin: var(--space-1) 0;
}

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.pagination-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}

.pagination-btn:hover {
  background: var(--surface);
  border-color: var(--border);
}

.pagination-btn.active {
  background: var(--accent-red-soft);
  color: var(--accent-red);
  border-color: var(--accent-red);
}

.pagination-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
