/**
 * Component Library
 * Reusable component classes built on design tokens
 * Provides consistent UI patterns across the application
 */

/* ================================
 * Brand Logo
 * ================================ */

/*
 * AI Orb — smooth continuous animation via GPU-composited transforms.
 * Icon: blurred radial blobs rotated as a single layer (perfectly smooth).
 * Text: seamless tiling gradient with constant-rate position slide.
 * No @property keyframes = no stepping/pulsing artifacts.
 */

/* Icon blob layer: continuous rotation (single GPU-composited value) */
@keyframes blob-rotate {
  from { transform: rotate(0deg) scale(1); }
  to   { transform: rotate(360deg) scale(1); }
}

/* Subtle breathing layered on top of rotation */
@keyframes blob-breathe {
  0%, 100% { filter: blur(8px) saturate(1.1); }
  50%      { filter: blur(10px) saturate(1.25); }
}

/* Text gradient: constant-rate linear slide */
@keyframes gradient-slide {
  from { background-position: 0% 50%; }
  to   { background-position: 200% 50%; }
}

/* Glow pulse on hover */
@keyframes orb-glow {
  0%, 100% { box-shadow: 0 0 6px 2px oklch(0.55 0.20 285 / 0.3); }
  50%      { box-shadow: 0 0 14px 4px oklch(0.60 0.22 310 / 0.45); }
}

.hiroi-logo-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  background: oklch(0.48 0.16 285);
  transition: transform 0.4s ease, box-shadow 0.4s ease;
}

/*
 * Blob layer: 4 off-center radial gradients on a disc 2.2x the icon size.
 * Rotating the disc causes the blobs to orbit each other, creating
 * continuously shifting color mix — no keyframe color steps needed.
 */
.hiroi-logo-icon::before {
  content: "";
  position: absolute;
  inset: -60%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 20% 20%, oklch(0.58 0.24 285) 0%, transparent 55%),
    radial-gradient(circle at 80% 25%, oklch(0.67 0.22 315) 0%, transparent 55%),
    radial-gradient(circle at 65% 80%, oklch(0.72 0.18 350) 0%, transparent 55%),
    radial-gradient(circle at 25% 70%, oklch(0.70 0.16 55) 0%, transparent 55%),
    radial-gradient(circle at 50% 50%, oklch(0.60 0.18 220) 0%, transparent 65%);
  background-color: oklch(0.45 0.16 290);
  /* Continuous rotation: perfectly smooth, single GPU value */
  animation:
    blob-rotate 20s linear infinite,
    blob-breathe 8s ease-in-out infinite;
  pointer-events: none;
}

/* SVG icon sits above the blob layer */
.hiroi-logo-icon svg {
  position: relative;
  z-index: 1;
}

/* Hover: faster spin + glow */
.hiroi-logo-icon:hover,
.group:hover .hiroi-logo-icon {
  transform: scale(1.08);
  animation: orb-glow 2s ease-in-out infinite;
}
.hiroi-logo-icon:hover::before,
.group:hover .hiroi-logo-icon::before {
  animation:
    blob-rotate 6s linear infinite,
    blob-breathe 3s ease-in-out infinite;
}

.hiroi-logo-text {
  font-family: 'Nunito', system-ui, sans-serif;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.06em;
  /*
   * Seamless tiling gradient: 200% wide, last color = first color.
   * Linear slide at constant rate = perfectly smooth, no pulsing.
   * oklch stops avoid muddy gray midpoints.
   */
  background: linear-gradient(
    90deg,
    oklch(0.58 0.24 285),
    oklch(0.65 0.22 315),
    oklch(0.72 0.18 350),
    oklch(0.70 0.16 55),
    oklch(0.62 0.18 220),
    oklch(0.58 0.24 285)
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradient-slide 8s linear infinite;
  transition: transform 0.4s ease;
}

/* Hover: faster slide */
.hiroi-logo-text:hover,
.group:hover .hiroi-logo-text {
  animation: gradient-slide 3s linear infinite;
}

/* ================================
 * Buttons
 * ================================ */

/* Base button styles */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 6px 12px;
  font-family: var(--font-family-sans);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  line-height: 1.25rem;
  letter-spacing: -0.006em;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast), color var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  height: var(--button-height-md);
}

.btn:focus-visible {
  outline: 2px solid var(--color-border-focus);
  outline-offset: 2px;
}

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

/* Button variants */
.btn-primary {
  background-color: var(--color-primary);
  color: var(--color-text-inverse);
  box-shadow: var(--shadow-xs);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--color-primary-hover);
}

.btn-primary:active:not(:disabled) {
  background-color: var(--color-primary-active);
}

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

.btn-secondary:hover:not(:disabled) {
  background-color: var(--color-surface-hover);
  border-color: var(--color-border-hover);
}

.btn-secondary:active:not(:disabled) {
  background-color: var(--color-background-secondary);
}

.btn-tertiary {
  background-color: transparent;
  color: var(--color-text-secondary);
}

.btn-tertiary:hover:not(:disabled) {
  background-color: var(--color-background-secondary);
  color: var(--color-text-primary);
}

.btn-tertiary:active:not(:disabled) {
  background-color: var(--color-background-tertiary);
}

.btn-danger {
  background-color: var(--color-error);
  color: var(--color-text-inverse);
  box-shadow: var(--shadow-xs);
}

.btn-danger:hover:not(:disabled) {
  background-color: var(--color-error-hover, #dc2626);
}

.btn-danger:active:not(:disabled) {
  background-color: var(--color-error-active, #b91c1c);
}

.btn-ghost {
  background-color: transparent;
  color: var(--color-text-secondary);
  border: 1px solid transparent;
}

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

.btn-ghost:active:not(:disabled) {
  background-color: var(--color-background-tertiary);
}

/* Button sizes */
.btn-sm {
  padding: 3px 8px;
  font-size: var(--font-size-xs);
  height: var(--button-height-sm);
}

.btn-md {
  padding: 6px 12px;
  font-size: var(--font-size-sm);
  height: var(--button-height-md);
}

.btn-lg {
  padding: 8px 16px;
  font-size: var(--font-size-base);
  height: var(--button-height-lg);
}

/* Button modifiers */
.btn-block {
  display: flex;
  width: 100%;
}

.btn-icon-only {
  padding: 6px;
  aspect-ratio: 1;
}

/* ================================
 * Cards
 * ================================ */

.card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-hover {
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

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

.card-interactive {
  cursor: pointer;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.card-interactive:hover {
  border-color: var(--color-border-hover);
  background-color: var(--color-surface-hover);
}

/* Card sections */
.card-header {
  padding: var(--space-5);
  border-bottom: 1px solid var(--color-border);
}

.card-body {
  padding: var(--space-5);
}

.card-footer {
  padding: var(--space-5);
  border-top: 1px solid var(--color-border);
}

/* Card padding variants */
.card-compact .card-header,
.card-compact .card-body,
.card-compact .card-footer {
  padding: var(--space-4);
}

/* ================================
 * Form Elements
 * ================================ */

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.form-label {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
}

.form-label-required::after {
  content: " *";
  color: var(--color-error);
}

.form-help {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  line-height: var(--line-height-normal);
}

/* Input fields */
.input,
.textarea,
.select {
  width: 100%;
  padding: 6px 10px;
  font-family: var(--font-family-sans);
  font-size: var(--font-size-sm);
  line-height: 1.25rem;
  color: var(--color-text-primary);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  height: var(--input-height-md);
}

.input:hover,
.textarea:hover,
.select:hover {
  border-color: var(--color-border-hover);
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--color-border-focus);
  box-shadow: var(--focus-ring-shadow);
}

.input:disabled,
.textarea:disabled,
.select:disabled {
  background-color: var(--color-background-tertiary);
  color: var(--color-text-disabled);
  cursor: not-allowed;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--color-text-tertiary);
}

/* Input with prefix icon (search, etc.) */
.input-icon-left {
  padding-left: 2.25rem; /* 36px — clears a 14-16px icon at left-3 */
}

.input-icon-left-sm {
  padding-left: 1.75rem; /* 28px — clears a 14px icon at left-2.5 */
}

/* Input sizes */
.input-sm {
  padding: 4px 8px;
  font-size: var(--font-size-xs);
  height: var(--input-height-sm);
}

.input-md {
  padding: 6px 10px;
  font-size: var(--font-size-sm);
  height: var(--input-height-md);
}

.input-lg {
  padding: 8px 12px;
  font-size: var(--font-size-base);
  height: var(--input-height-lg);
}

/* Input states */
.input-error,
.textarea-error,
.select-error {
  border-color: var(--color-error);
}

.input-error:focus,
.textarea-error:focus,
.select-error:focus {
  border-color: var(--color-error);
  box-shadow: 0 0 0 3px var(--color-error-bg);
}

.input-success,
.textarea-success,
.select-success {
  border-color: var(--color-success);
}

.input-success:focus,
.textarea-success:focus,
.select-success:focus {
  border-color: var(--color-success);
  box-shadow: 0 0 0 3px var(--color-success-bg);
}

/* Alias: .form-input maps to .input/.textarea/.select */
.form-input {
  width: 100%;
  padding: 6px 10px;
  font-family: var(--font-family-sans);
  font-size: var(--font-size-sm);
  line-height: 1.25rem;
  color: var(--color-text-primary);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  height: var(--input-height-md);
}

.form-input:hover {
  border-color: var(--color-border-hover);
}

.form-input:focus {
  outline: none;
  border-color: var(--color-border-focus);
  box-shadow: var(--focus-ring-shadow);
}

.form-input:disabled {
  background-color: var(--color-background-secondary);
  color: var(--color-text-disabled);
  cursor: not-allowed;
}

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

select.form-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23737373' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 8px center;
  background-repeat: no-repeat;
  background-size: 1em 1em;
  padding-right: 2rem;
}

textarea.form-input {
  min-height: 80px;
  height: auto;
  resize: vertical;
}

/* Error message */
.form-error {
  font-size: var(--font-size-xs);
  color: var(--color-error);
  margin-top: var(--space-1);
}

/* Textarea */
.textarea {
  resize: vertical;
  min-height: 120px;
}

/* Checkbox and Radio */
.checkbox,
.radio {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  cursor: pointer;
}

.checkbox input[type="checkbox"],
.radio input[type="radio"] {
  margin-top: 2px;
  width: 1rem;
  height: 1rem;
  accent-color: var(--color-primary);
  cursor: pointer;
}

.checkbox-label,
.radio-label {
  font-size: var(--font-size-sm);
  color: var(--color-text-primary);
  cursor: pointer;
}

/* ================================
 * Badges
 * ================================ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-2);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  line-height: 1;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.badge-primary {
  background-color: var(--color-primary-100);
  color: var(--color-primary-700);
}

.badge-success {
  background-color: var(--color-success-bg);
  color: var(--color-success);
}

.badge-warning {
  background-color: var(--color-warning-bg);
  color: var(--color-warning);
}

.badge-error {
  background-color: var(--color-error-bg);
  color: var(--color-error);
}

.badge-info {
  background-color: var(--color-info-bg);
  color: var(--color-info);
}

.badge-neutral {
  background-color: var(--color-background-tertiary);
  color: var(--color-text-secondary);
}

/* Badge sizes */
.badge-sm {
  padding: 2px var(--space-1);
  font-size: var(--font-size-xs);
}

.badge-lg {
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-sm);
}

/* ================================
 * Alerts
 * ================================ */

.alert {
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  border-left: 4px solid;
  display: flex;
  gap: var(--space-3);
}

.alert-icon {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
}

.alert-content {
  flex: 1;
}

.alert-title {
  font-weight: var(--font-weight-semibold);
  margin-bottom: var(--space-1);
  color: inherit;
}

.alert-message {
  font-size: var(--font-size-sm);
  line-height: var(--line-height-normal);
}

.alert-info {
  background-color: var(--color-info-bg);
  border-color: var(--color-info);
  color: var(--color-info);
}

.alert-success {
  background-color: var(--color-success-bg);
  border-color: var(--color-success);
  color: var(--color-success);
}

.alert-warning {
  background-color: var(--color-warning-bg);
  border-color: var(--color-warning);
  color: var(--color-warning);
}

.alert-error {
  background-color: var(--color-error-bg);
  border-color: var(--color-error);
  color: var(--color-error);
}

/* ================================
 * Tables
 * ================================ */

.table-container {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

.table thead {
  background-color: var(--color-background-secondary);
  border-bottom: 1px solid var(--color-border);
}

.table th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-secondary);
  white-space: nowrap;
}

.table tbody tr {
  border-bottom: 1px solid var(--color-border);
  transition: background-color var(--transition-fast);
}

.table tbody tr:last-child {
  border-bottom: none;
}

.table tbody tr:hover {
  background-color: var(--color-background-secondary);
}

.table td {
  padding: var(--space-4);
  color: var(--color-text-primary);
}

/* Responsive table */
@media (max-width: 768px) {
  .table-container {
    border: none;
  }

  .table thead {
    display: none;
  }

  .table,
  .table tbody,
  .table tr,
  .table td {
    display: block;
  }

  .table tr {
    margin-bottom: var(--space-4);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
  }

  .table td {
    padding: var(--space-3);
    position: relative;
    padding-left: 50%;
  }

  .table td::before {
    content: attr(data-label);
    position: absolute;
    left: var(--space-3);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-secondary);
  }
}

/* ================================
 * Modals
 * ================================ */

/* Prevent space-y utilities from adding margin to fixed modal containers */
[class*="space-y"] > .fixed[style*="z-index"] {
  margin-top: 0 !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: var(--z-modal-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

.modal {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-2xl);
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  z-index: var(--z-modal);
}

.modal-sm {
  width: 400px;
}

.modal-md {
  width: 600px;
}

.modal-lg {
  width: 800px;
}

.modal-full {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  border-radius: 0;
}

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

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

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-md);
  background: transparent;
  border: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--transition-base);
}

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

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6);
}

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

/* ================================
 * Loading States
 * ================================ */

.spinner {
  display: inline-block;
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: var(--radius-full);
  animation: spin 0.75s linear infinite;
}

.spinner-sm {
  width: 1rem;
  height: 1rem;
  border-width: 1.5px;
}

.spinner-lg {
  width: 2rem;
  height: 2rem;
  border-width: 3px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Skeleton loader */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-background-secondary) 0%,
    var(--color-background-tertiary) 50%,
    var(--color-background-secondary) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

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

.skeleton-heading {
  height: 1.5rem;
  margin-bottom: var(--space-3);
  width: 60%;
}

.skeleton-avatar {
  width: 3rem;
  height: 3rem;
  border-radius: var(--radius-full);
}

/* ================================
 * Empty States
 * ================================ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) var(--space-6);
  text-align: center;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.empty-state-sm {
  padding: var(--space-8) var(--space-4);
}

.empty-state-lg {
  padding: var(--space-16) var(--space-8);
}

.empty-state-icon {
  width: 4rem;
  height: 4rem;
  margin-bottom: var(--space-4);
  color: var(--color-text-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--color-background-secondary);
  border-radius: var(--radius-lg);
}

.empty-state-sm .empty-state-icon {
  width: 3rem;
  height: 3rem;
  margin-bottom: var(--space-3);
}

.empty-state-lg .empty-state-icon {
  width: 5rem;
  height: 5rem;
  margin-bottom: var(--space-6);
}

.empty-state-icon svg {
  width: 2rem;
  height: 2rem;
}

.empty-state-sm .empty-state-icon svg {
  width: 1.5rem;
  height: 1.5rem;
}

.empty-state-lg .empty-state-icon svg {
  width: 2.5rem;
  height: 2.5rem;
}

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

.empty-state-sm .empty-state-title {
  font-size: var(--font-size-lg);
}

.empty-state-lg .empty-state-title {
  font-size: var(--font-size-2xl);
}

.empty-state-description {
  font-size: var(--font-size-base);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-6);
  max-width: 40ch;
  line-height: var(--line-height-relaxed);
}

.empty-state-sm .empty-state-description {
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-4);
  max-width: 32ch;
}

.empty-state-lg .empty-state-description {
  font-size: var(--font-size-lg);
  margin-bottom: var(--space-8);
  max-width: 48ch;
}

.empty-state-actions {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  justify-content: center;
}

/* ================================
 * Utility Classes
 * ================================ */

.text-primary { color: var(--color-text-primary); }
.text-secondary { color: var(--color-text-secondary); }
.text-tertiary { color: var(--color-text-tertiary); }
.text-disabled { color: var(--color-text-disabled); }

.bg-surface { background-color: var(--color-surface); }
.bg-background { background-color: var(--color-background); }
.bg-secondary { background-color: var(--color-background-secondary); }

.border-default { border-color: var(--color-border); }
.border-hover { border-color: var(--color-border-hover); }

.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }
.shadow-xl { box-shadow: var(--shadow-xl); }

.rounded-sm { border-radius: var(--radius-sm); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-full { border-radius: var(--radius-full); }

/* ================================
 * Breadcrumb Navigation
 * ================================ */

.breadcrumb {
  display: block;
}

.breadcrumb-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  list-style: none;
  padding: 0;
  margin: 0;
}

.breadcrumb-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  line-height: 1.25rem;
}

.breadcrumb-link {
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.breadcrumb-link:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

.breadcrumb-link:focus {
  outline: 2px solid var(--color-border-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.breadcrumb-separator {
  color: var(--color-border);
  user-select: none;
  font-weight: 300;
}

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

/* ================================
 * Enhanced Loading Spinner
 * ================================ */

.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-8);
}

.loading-spinner-sm {
  padding: var(--space-4);
  gap: var(--space-2);
}

.loading-spinner-lg {
  padding: var(--space-12);
  gap: var(--space-4);
}

.spinner-icon {
  animation: spinner-rotate 1.5s linear infinite;
}

.loading-spinner-sm .spinner-icon {
  width: 2rem;
  height: 2rem;
}

.loading-spinner-md .spinner-icon {
  width: 3rem;
  height: 3rem;
}

.loading-spinner-lg .spinner-icon {
  width: 4rem;
  height: 4rem;
}

.spinner-path {
  stroke: var(--color-primary);
  stroke-linecap: round;
  stroke-dasharray: 90, 150;
  stroke-dashoffset: 0;
  animation: spinner-dash 1.5s ease-in-out infinite;
}

.spinner-text {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  font-weight: var(--font-weight-medium);
}

@keyframes spinner-rotate {
  100% {
    transform: rotate(360deg);
  }
}

@keyframes spinner-dash {
  0% {
    stroke-dasharray: 1, 150;
    stroke-dashoffset: 0;
  }
  50% {
    stroke-dasharray: 90, 150;
    stroke-dashoffset: -35;
  }
  100% {
    stroke-dasharray: 90, 150;
    stroke-dashoffset: -124;
  }
}

/* ================================
 * Enhanced Skeleton Loaders
 * ================================ */

.skeleton-card,
.skeleton-table,
.skeleton-list {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.skeleton-card {
  padding: var(--space-6);
}

.skeleton-header {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.skeleton-avatar {
  width: 3rem;
  height: 3rem;
  background: linear-gradient(90deg, var(--color-background-secondary) 0%, var(--color-background-tertiary) 50%, var(--color-background-secondary) 100%);
  background-size: 200% 100%;
  border-radius: var(--radius-lg);
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

.skeleton-text-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.skeleton-text {
  height: 1rem;
  background: linear-gradient(90deg, var(--color-background-secondary) 0%, var(--color-background-tertiary) 50%, var(--color-background-secondary) 100%);
  background-size: 200% 100%;
  border-radius: var(--radius-sm);
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

.skeleton-text-sm {
  height: 0.75rem;
  width: 60%;
}

.skeleton-text-lg {
  height: 1.25rem;
  width: 80%;
}

.skeleton-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.skeleton-footer {
  display: flex;
  gap: var(--space-3);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
}

.skeleton-button {
  width: 5rem;
  height: 2.5rem;
  background: linear-gradient(90deg, var(--color-background-secondary) 0%, var(--color-background-tertiary) 50%, var(--color-background-secondary) 100%);
  background-size: 200% 100%;
  border-radius: var(--radius-md);
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

/* Table Skeleton */
.skeleton-table {
  padding: 0;
}

.skeleton-table-header {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-background-secondary);
}

.skeleton-table-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--color-border);
}

.skeleton-table-row:last-child {
  border-bottom: none;
}

/* List Skeleton */
.skeleton-list {
  padding: 0;
}

.skeleton-list-item {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--color-border);
}

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

@keyframes skeleton-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* ================================
 * Dark Mode: Chatbot Editor Integration Tab
 * Alpine.js strips dark: prefix classes from dynamic :class bindings,
 * so these overrides use [data-theme="dark"] selectors instead.
 * ================================ */
[data-theme="dark"] .auth-card-active {
  background-color: var(--color-primary-bg);
  border-color: var(--color-primary);
}
[data-theme="dark"] .auth-card-inactive {
  background-color: var(--color-surface);
  border-color: var(--color-border);
}
[data-theme="dark"] .auth-card-inactive:hover {
  border-color: var(--color-primary);
}
[data-theme="dark"] .domains-container {
  background-color: var(--color-background-secondary);
  border-color: var(--color-border);
}
[data-theme="dark"] .domain-item {
  background-color: var(--color-surface-hover);
  border-color: var(--color-border);
}
[data-theme="dark"] .domain-item span {
  color: var(--color-text-secondary);
}
[data-theme="dark"] .domain-input {
  background-color: var(--color-surface-hover);
  border-color: var(--color-border);
  color: var(--color-text-primary);
}
[data-theme="dark"] .domain-input::placeholder {
  color: var(--color-text-disabled);
}

/* ================================
 * Global Focus-Visible Styles
 * Consistent focus indicators across all interactive elements
 * ================================ */

:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
  border-radius: var(--radius-xs);
}

/* Ensure buttons and links get focus ring */
button:focus-visible,
a:focus-visible,
[role="button"]:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}

/* Inputs get a subtle ring instead of outline */
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: none;
  border-color: var(--color-border-focus);
  box-shadow: var(--focus-ring-shadow);
}

/* ================================
 * Error State Component
 * Reusable error state for failed data loads
 * ================================ */

.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) var(--space-6);
  text-align: center;
  background-color: var(--color-surface);
  border: 1px solid var(--color-error-border);
  border-radius: var(--radius-lg);
}

.error-state-icon {
  width: 4rem;
  height: 4rem;
  margin-bottom: var(--space-4);
  color: var(--color-error);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-error-bg);
  border-radius: var(--radius-lg);
}

.error-state-icon svg {
  width: 2rem;
  height: 2rem;
}

.error-state-title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  margin-bottom: var(--space-2);
}

.error-state-description {
  font-size: var(--font-size-base);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-6);
  max-width: 40ch;
  line-height: var(--line-height-relaxed);
}

.error-state-actions {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  justify-content: center;
}

/* ================================
 * Theme Toggle Icons
 * Works with [data-theme] attribute
 * ================================ */

.theme-icon-sun { display: none; }
.theme-icon-moon { display: block; }

[data-theme="dark"] .theme-icon-sun { display: block; }
[data-theme="dark"] .theme-icon-moon { display: none; }

/* ================================
 * Sub-Navigation
 * Shared pattern for in-page vertical sidebar nav
 * with sliding indicator + mobile horizontal pills.
 * Used by: chatbot editor, settings, any tabbed page.
 * ================================ */

/* Desktop sidebar wrapper */
.subnav-wrap,
.editor-nav-wrap {
  gap: 4px;
}

/* Sliding active indicator */
.subnav-indicator,
.editor-nav-indicator {
  position: absolute;
  top: calc(var(--active-idx, 0) * (36px + 4px));
  left: 0;
  right: 0;
  height: 36px;
  background: var(--color-primary-100);
  border-radius: var(--radius-md);
  transition: top 300ms cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 0;
  pointer-events: none;
}

/* Left accent bar on indicator */
.subnav-indicator::before,
.editor-nav-indicator::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--color-primary);
  border-radius: 0 2px 2px 0;
}

/* Nav item */
.subnav-item,
.editor-nav-item {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: inherit;
  transition: color 200ms ease;
  cursor: pointer;
  border: none;
  width: 100%;
  text-align: left;
  height: 36px;
  background: transparent;
  color: var(--color-text-secondary);
}

.subnav-item:hover,
.editor-nav-item:hover {
  color: var(--color-text-primary);
}

.subnav-item:focus-visible,
.editor-nav-item:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}

.subnav-active,
.editor-nav-active {
  color: var(--color-primary);
  font-weight: 600;
}

/* Mobile pills */
.subnav-mobile,
.editor-tab-mobile {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 9999px;
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: inherit;
  white-space: nowrap;
  transition: all 200ms ease;
  cursor: pointer;
  border: 1px solid var(--color-border);
  flex-shrink: 0;
  background-color: var(--color-surface);
  color: var(--color-text-secondary);
}

.subnav-mobile:hover,
.editor-tab-mobile:hover {
  border-color: var(--color-border-hover);
  color: var(--color-text-primary);
}

.subnav-mobile:focus-visible,
.editor-tab-mobile:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

.subnav-mobile-active,
.editor-tab-active {
  background-color: var(--color-primary-100);
  color: var(--color-primary);
  border-color: var(--color-primary-200);
  font-weight: 600;
}

[data-theme="dark"] .subnav-mobile-active,
[data-theme="dark"] .editor-tab-active {
  background-color: var(--color-primary-100);
  color: var(--color-primary);
  border-color: var(--color-primary-300);
}
