/* ============================================================================
   BioForge v2 — Reusable Component Styles
   Linear/Vercel aesthetic: clean, minimal, generous whitespace
   All values reference tokens.css custom properties.
   ============================================================================ */

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--font-medium);
  line-height: var(--leading-tight);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}

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

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

/* Primary */
.btn-primary {
  background: var(--accent);
  color: var(--text-inverse);
  border-color: var(--accent);
}

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

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

.btn-secondary:hover {
  border-color: var(--gray-400);
  background: var(--bg-surface-hover);
}

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

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

/* Danger */
.btn-danger {
  background: var(--error);
  color: var(--text-inverse);
  border-color: var(--error);
}

.btn-danger:hover {
  background: var(--error-hover);
  border-color: var(--error-hover);
}

/* Sizes */
.btn-sm {
  padding: 5px 10px;
  font-size: var(--text-sm);
  gap: 4px;
}

.btn-lg {
  padding: 10px 20px;
  font-size: var(--text-md);
  gap: 8px;
}

/* Icon-only */
.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  flex-shrink: 0;
}


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

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  line-height: var(--leading-normal);
  border-radius: var(--radius-full);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* Status variants */
.badge-submitted {
  background: rgba(59, 130, 246, 0.1);
  color: #3B82F6;
}

.badge-review {
  background: rgba(245, 158, 11, 0.1);
  color: #D97706;
}

.badge-approved {
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
}

.badge-progress {
  background: rgba(139, 92, 246, 0.1);
  color: #7C3AED;
}

.badge-completed {
  background: rgba(16, 185, 129, 0.15);
  color: #059669;
}

.badge-blocked {
  background: rgba(239, 68, 68, 0.1);
  color: #DC2626;
}

.badge-draft {
  background: var(--bg-surface-raised);
  color: var(--text-tertiary);
}

/* Grade badges (A through F) */
.badge-grade-a {
  background: rgba(16, 185, 129, 0.15);
  color: #059669;
}

.badge-grade-b {
  background: rgba(16, 185, 129, 0.1);
  color: #10B981;
}

.badge-grade-c {
  background: rgba(245, 158, 11, 0.1);
  color: #D97706;
}

.badge-grade-d {
  background: rgba(249, 115, 22, 0.1);
  color: #EA580C;
}

.badge-grade-f {
  background: rgba(239, 68, 68, 0.1);
  color: #DC2626;
}


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

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: box-shadow var(--transition-base);
}

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

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-secondary);
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-body {
  padding: 20px;
}

.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-secondary);
  background: var(--bg-surface-raised);
}

.card-compact {
  padding: 12px 16px;
}

/* Stat card */
.card-stat {
  text-align: center;
  padding: 20px;
}

.stat-value {
  font-size: 28px;
  font-weight: var(--font-bold);
  color: var(--text-primary);
  line-height: var(--leading-tight);
}

.stat-label {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 4px;
}

.stat-change {
  font-size: var(--text-sm);
  margin-top: 4px;
}

.stat-change.positive {
  color: var(--success);
}

.stat-change.negative {
  color: var(--error);
}


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

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

table.table {
  width: 100%;
  border-collapse: collapse;
}

.table thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  background: var(--bg-surface-raised);
  border-bottom: 1px solid var(--border-primary);
  white-space: nowrap;
}

.table tbody td {
  padding: 12px 16px;
  font-size: var(--text-base);
  border-bottom: 1px solid var(--border-secondary);
  vertical-align: middle;
  color: var(--text-primary);
}

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

.table tbody tr:hover {
  background: var(--bg-surface-raised);
}

.table-row-clickable {
  cursor: pointer;
}


/* ============================================================================
   Form Inputs
   ============================================================================ */

.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: var(--text-base);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 8px 12px;
  font-family: var(--font-sans);
  font-size: var(--text-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
  box-sizing: border-box;
}

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

.form-input:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 153, 0, 0.1);
}

.form-textarea {
  width: 100%;
  padding: 8px 12px;
  font-family: var(--font-sans);
  font-size: var(--text-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
  min-height: 100px;
  resize: vertical;
  box-sizing: border-box;
}

.form-textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 153, 0, 0.1);
}

.form-select {
  width: 100%;
  padding: 8px 12px;
  font-family: var(--font-sans);
  font-size: var(--text-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23A3A3A3' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
  box-sizing: border-box;
}

.form-select:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 153, 0, 0.1);
}

.form-hint {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  margin-top: 4px;
}

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

.form-error-msg {
  color: var(--error);
  font-size: var(--text-sm);
  margin-top: 4px;
}


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

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-slow);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  max-width: 640px;
  width: 90%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  transform: scale(0.95);
  transition: transform var(--transition-spring);
}

.modal-overlay.active .modal {
  transform: scale(1);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-secondary);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.modal-header h2,
.modal-header h3 {
  flex: 1;
  margin: 0;
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
}

.modal-close {
  composes: btn btn-icon btn-ghost;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-secondary);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}


/* ============================================================================
   Slide-overs
   ============================================================================ */

.slideout-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  display: flex;
  justify-content: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-slow);
}

.slideout-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.slideout {
  width: 560px;
  max-width: 100%;
  height: 100vh;
  background: var(--bg-surface);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--transition-spring);
}

.slideout-overlay.active .slideout {
  transform: translateX(0);
}


/* ============================================================================
   Command Palette
   ============================================================================ */

.command-palette-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: var(--z-command);
  display: flex;
  justify-content: center;
  padding-top: 20vh;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-slow);
}

.command-palette-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.command-palette {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 560px;
  max-width: 90%;
  max-height: 400px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  align-self: flex-start;
}

.command-input {
  padding: 16px 20px;
  font-family: var(--font-sans);
  font-size: var(--text-lg);
  border: none;
  background: transparent;
  border-bottom: 1px solid var(--border-primary);
  color: var(--text-primary);
  outline: none;
  width: 100%;
  box-sizing: border-box;
}

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

.command-results {
  overflow-y: auto;
  padding: 8px;
  flex: 1;
}

.command-item {
  padding: 10px 16px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-size: var(--text-md);
  transition: background var(--transition-fast);
}

.command-item:hover,
.command-item.selected {
  background: var(--bg-surface-raised);
}

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

.command-item-title {
  color: var(--text-primary);
  flex: 1;
}

.command-item-subtitle {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
}

.command-section-label {
  padding: 8px 16px;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
}


/* ============================================================================
   Toasts
   ============================================================================ */

.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 12px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--text-base);
  min-width: 300px;
  max-width: 440px;
  transform: translateX(120%);
  transition: transform var(--transition-spring);
  pointer-events: auto;
}

.toast.show {
  transform: translateX(0);
}

.toast-success {
  border-left: 3px solid var(--success);
}

.toast-error {
  border-left: 3px solid var(--error);
}

.toast-info {
  border-left: 3px solid var(--info);
}

.toast-message {
  flex: 1;
  color: var(--text-primary);
}

.toast-close {
  color: var(--text-tertiary);
  cursor: pointer;
  flex-shrink: 0;
}


/* ============================================================================
   Tabs
   ============================================================================ */

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border-secondary);
}

.tab {
  padding: 10px 16px;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--font-medium);
  color: var(--text-tertiary);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color var(--transition-base), border-color var(--transition-base);
  white-space: nowrap;
}

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

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

.tab-badge {
  margin-left: 6px;
}


/* ============================================================================
   Progress Indicators
   ============================================================================ */

.progress-bar {
  height: 6px;
  background: var(--bg-surface-raised);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-full);
  transition: width 300ms ease;
}

/* Circular progress ring — set --progress (0 to 100) on the element */
.progress-ring {
  transform: rotate(-90deg);
}

.progress-ring-track {
  fill: none;
  stroke: var(--bg-surface-raised);
}

.progress-ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-linecap: round;
  transition: stroke-dashoffset 400ms ease;
}


/* ============================================================================
   Tags / Chips
   ============================================================================ */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: var(--bg-surface-raised);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  white-space: nowrap;
}

.tag-accent {
  background: var(--accent-light);
  color: var(--accent);
}

.tag-removable {
  padding-right: 4px;
}

.tag-remove {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  cursor: pointer;
  color: var(--text-tertiary);
  transition: color var(--transition-fast), background var(--transition-fast);
  border: none;
  background: none;
  padding: 0;
}

.tag-remove:hover {
  color: var(--error);
  background: var(--error-light);
}


/* ============================================================================
   Avatars
   ============================================================================ */

.avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  flex-shrink: 0;
  user-select: none;
}

.avatar-sm {
  width: 24px;
  height: 24px;
  font-size: var(--text-xs);
}

.avatar-lg {
  width: 40px;
  height: 40px;
  font-size: var(--text-lg);
}

.avatar-ai {
  background: linear-gradient(135deg, #7C3AED, #3B82F6);
}


/* ============================================================================
   Empty State
   ============================================================================ */

.empty-state {
  text-align: center;
  padding: 48px 24px;
}

.empty-state-icon {
  width: 48px;
  height: 48px;
  color: var(--text-tertiary);
  margin: 0 auto 16px;
}

.empty-state-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-state-description {
  font-size: var(--text-md);
  color: var(--text-secondary);
  max-width: 400px;
  margin: 0 auto 20px;
  line-height: var(--leading-relaxed);
}


/* ============================================================================
   Skeleton Loading
   ============================================================================ */

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

.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-surface-raised) 25%,
    var(--border-secondary) 50%,
    var(--bg-surface-raised) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
  border-radius: var(--radius-sm);
}

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

.skeleton-circle {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
}

.skeleton-rect {
  border-radius: var(--radius-md);
}


/* ============================================================================
   Dropdown
   ============================================================================ */

.dropdown {
  position: relative;
  display: inline-block;
}

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

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

.dropdown-item {
  padding: 8px 12px;
  font-size: var(--text-base);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
  transition: background var(--transition-fast);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-sans);
}

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

.dropdown-item-icon {
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.dropdown-item-danger {
  color: var(--error);
}

.dropdown-item-danger:hover {
  background: var(--error-light);
}

.dropdown-divider {
  height: 1px;
  background: var(--border-secondary);
  margin: 4px 0;
}

/* Right-aligned variant */
.dropdown-menu-right {
  left: auto;
  right: 0;
}


/* ============================================================================
   Stepper (Status Workflow)
   ============================================================================ */

.stepper {
  display: flex;
  align-items: center;
  gap: 0;
}

.step {
  display: flex;
  align-items: center;
  gap: 8px;
}

.step-circle {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  border: 2px solid var(--border-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-tertiary);
  transition: all var(--transition-base);
  flex-shrink: 0;
}

.step.completed .step-circle {
  background: var(--success);
  border-color: var(--success);
  color: var(--text-inverse);
}

.step.current .step-circle {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-inverse);
}

.step-label {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  white-space: nowrap;
}

.step.completed .step-label {
  color: var(--text-secondary);
}

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

.step-connector {
  flex: 1;
  height: 2px;
  background: var(--border-primary);
  margin: 0 8px;
  min-width: 24px;
}

.step.completed + .step-connector {
  background: var(--success);
}


/* ============================================================================
   Utility: Visually Hidden (for accessible labels)
   ============================================================================ */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}
