/* Transpora Design System — Components */

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 40px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  white-space: nowrap;
  transition: background var(--duration-fast) var(--ease-standard),
              border-color var(--duration-fast) var(--ease-standard),
              transform var(--duration-fast) var(--ease-standard);
  touch-action: manipulation;
}
.btn:active { transform: scale(0.98); }
.btn svg { width: 16px; height: 16px; flex: none; }

.btn-primary {
  background: var(--brand-600);
  color: var(--text-on-brand);
}
.btn-primary:hover { background: var(--brand-700); text-decoration: none; }

.btn-secondary {
  background: var(--surface-card);
  color: var(--text-primary);
  border-color: var(--border-default);
}
.btn-secondary:hover { background: var(--surface-muted); text-decoration: none; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--surface-muted); color: var(--text-primary); text-decoration: none; }

.btn-danger {
  background: var(--danger-fg);
  color: #fff;
}
.btn-danger:hover { background: #921d1d; text-decoration: none; }

.btn-sm { height: 32px; padding: 0 var(--space-3); font-size: var(--fs-xs); border-radius: var(--radius-sm); }
.btn-lg { height: 48px; padding: 0 var(--space-6); font-size: var(--fs-md); }
.btn-block { width: 100%; }
.btn-icon { width: 40px; padding: 0; }

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

.btn-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn-loading::after {
  content: "";
  position: absolute;
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  color: inherit;
  animation: spin 0.7s linear infinite;
}
.btn-primary.btn-loading::after,
.btn-danger.btn-loading::after { color: #fff; }
.btn-secondary.btn-loading::after,
.btn-ghost.btn-loading::after { color: var(--text-primary); }

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

/* ===== Cards ===== */
.card {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}
.card-pad { padding: var(--space-6); }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
}
.card-title { font-size: var(--fs-md); font-weight: var(--fw-semibold); }
.card-subtitle { font-size: var(--fs-sm); color: var(--text-secondary); margin-top: 2px; }
.card-body { padding: var(--space-6); }
.card-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-subtle);
  display: flex; gap: var(--space-3); justify-content: flex-end;
}
.card-interactive { transition: box-shadow var(--duration-base) var(--ease-standard), border-color var(--duration-base) var(--ease-standard); }
.card-interactive:hover { box-shadow: var(--shadow-sm); border-color: var(--border-default); }

/* Compact stat tile — grouped in a strip, not one giant card per metric */
.stat-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}
.stat-tile {
  padding: var(--space-5) var(--space-6);
  border-right: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
}
.stat-tile:last-child { border-right: none; }
.stat-label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.stat-value {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-semibold);
  margin-top: var(--space-1);
  font-variant-numeric: tabular-nums;
}
.stat-value.attn { color: var(--warning-fg); }
.stat-meta { font-size: var(--fs-xs); color: var(--text-tertiary); margin-top: 2px; }

/* ===== Badges / Status pills ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  height: 22px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge svg { width: 12px; height: 12px; }
.badge::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.badge-neutral { background: var(--surface-muted); color: var(--text-secondary); border-color: var(--border-subtle); }
.badge-info     { background: var(--info-bg);     color: var(--info-fg);     border-color: var(--info-border); }
.badge-success  { background: var(--success-bg);  color: var(--success-fg);  border-color: var(--success-border); }
.badge-warning  { background: var(--warning-bg);  color: var(--warning-fg);  border-color: var(--warning-border); }
.badge-danger   { background: var(--danger-bg);   color: var(--danger-fg);   border-color: var(--danger-border); }
.badge-progress { background: var(--progress-bg); color: var(--progress-fg); border-color: var(--progress-border); }

/* ===== Alert banner (form-level errors / success) ===== */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: var(--fs-sm);
  margin-bottom: var(--space-5);
}
.alert svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.alert-danger { background: var(--danger-bg); color: var(--danger-fg); border-color: var(--danger-border); }
.alert-success { background: var(--success-bg); color: var(--success-fg); border-color: var(--success-border); }

/* ===== Forms ===== */
.field { display: flex; flex-direction: column; gap: var(--space-2); }
.field + .field { margin-top: var(--space-4); }
.label {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-primary);
  display: flex; align-items: center; gap: var(--space-1);
}
.label .req { color: var(--danger-fg); }
.help-text { font-size: var(--fs-xs); color: var(--text-tertiary); }
.error-text {
  font-size: var(--fs-xs);
  color: var(--danger-fg);
  display: flex; align-items: center; gap: var(--space-1);
}
.error-text svg { width: 14px; height: 14px; flex: none; }

.input, .select, .textarea {
  height: 44px;
  padding: 0 var(--space-3);
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: var(--fs-md);
  color: var(--text-primary);
  width: 100%;
  transition: border-color var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard);
}
.textarea { height: auto; min-height: 96px; padding: var(--space-3); resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--text-tertiary); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px var(--brand-100);
}
.input[aria-invalid="true"], .textarea[aria-invalid="true"] {
  border-color: var(--danger-fg);
}
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px var(--danger-bg); }
.input:disabled, .select:disabled, .textarea:disabled {
  background: var(--surface-muted);
  color: var(--text-tertiary);
  cursor: not-allowed;
}

.input-group { position: relative; display: flex; align-items: center; }
.input-group .input { padding-right: var(--space-10); }
.input-group-action {
  position: absolute;
  right: var(--space-1);
  height: 36px; width: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  background: transparent; border: none;
}
.input-group-action:hover { color: var(--text-primary); background: var(--surface-muted); }

.checkbox-row { display: flex; align-items: flex-start; gap: var(--space-2); }
.checkbox-row input[type="checkbox"] {
  margin-top: 2px;
  width: 18px; height: 18px;
  accent-color: var(--brand-600);
  flex: none;
}

/* ===== Table ===== */
.table-wrap {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  overflow: auto;
}
.table { min-width: 640px; }
.table th {
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface-muted);
  white-space: nowrap;
  position: sticky; top: 0;
}
.table td {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--fs-sm);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--duration-fast) var(--ease-standard); }
.table tbody tr:hover { background: var(--surface-muted); }
.table .cell-primary { font-weight: var(--fw-medium); color: var(--text-primary); }
.table .cell-muted { color: var(--text-tertiary); }

/* ===== Navigation (company workspace) ===== */
.sidebar {
  width: var(--sidebar-width);
  flex: none;
  background: var(--surface-card);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  height: 100dvh;
  position: sticky;
  top: 0;
}
.sidebar-brand {
  display: flex; align-items: center; gap: var(--space-2);
  height: var(--topbar-height);
  padding: 0 var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-md);
}
.sidebar-brand .mark {
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  background: var(--brand-600);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: var(--fw-bold);
  font-size: var(--fs-sm);
  flex: none;
}
.sidebar-nav { flex: 1; overflow-y: auto; padding: var(--space-4) var(--space-3); }
.nav-group + .nav-group { margin-top: var(--space-5); }
.nav-group-label {
  font-size: 11px;
  font-weight: var(--fw-semibold);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0 var(--space-3);
  margin-bottom: var(--space-2);
}
.nav-item {
  display: flex; align-items: center; gap: var(--space-3);
  height: 38px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  position: relative;
}
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item:hover { background: var(--surface-muted); color: var(--text-primary); text-decoration: none; }
.nav-item[aria-current="page"] {
  background: var(--brand-50);
  color: var(--brand-700);
}
.nav-item .count {
  margin-left: auto;
  font-size: 11px;
  font-weight: var(--fw-semibold);
  background: var(--surface-muted);
  color: var(--text-secondary);
  border-radius: var(--radius-full);
  padding: 1px 7px;
}
.nav-item[aria-current="page"] .count { background: var(--brand-100); color: var(--brand-700); }

.sidebar-footer {
  padding: var(--space-3);
  border-top: 1px solid var(--border-subtle);
}
.workspace-switch {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  width: 100%;
  background: transparent; border: none; text-align: left;
}
.workspace-switch:hover { background: var(--surface-muted); }
.avatar {
  width: 32px; height: 32px;
  border-radius: var(--radius-full);
  background: var(--brand-100);
  color: var(--brand-700);
  display: flex; align-items: center; justify-content: center;
  font-weight: var(--fw-semibold);
  font-size: var(--fs-xs);
  flex: none;
}
.workspace-switch .who { flex: 1; min-width: 0; }
.workspace-switch .name { font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workspace-switch .role { font-size: var(--fs-xs); color: var(--text-tertiary); }

.topbar {
  height: var(--topbar-height);
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-4);
  padding: 0 var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface-card);
  position: sticky; top: 0; z-index: var(--z-sticky);
}
.topbar-title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); }
.topbar-actions { display: flex; align-items: center; gap: var(--space-3); }
.icon-btn {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-md);
  background: transparent; border: 1px solid transparent;
  color: var(--text-secondary);
  position: relative;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: var(--surface-muted); color: var(--text-primary); }
.icon-btn .dot {
  position: absolute; top: 8px; right: 8px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger-fg);
  border: 2px solid var(--surface-card);
}
.menu-toggle { display: none; }

/* ===== Notification dropdown ===== */
.notif-panel {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  width: 340px;
  max-width: calc(100vw - var(--space-8));
  max-height: 400px;
  overflow-y: auto;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  z-index: var(--z-dropdown);
}
.notif-panel-header {
  padding: var(--space-3) var(--space-4);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  border-bottom: 1px solid var(--border-subtle);
}
.notif-panel-empty {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-5) var(--space-4);
  color: var(--text-tertiary);
  font-size: var(--fs-sm);
}
.notif-panel-empty svg { width: 18px; height: 18px; flex: none; }

/* ===== Modal ===== */
.modal-scrim {
  position: fixed; inset: 0;
  background: rgba(16, 17, 24, 0.44);
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-4);
  z-index: var(--z-modal);
}
.modal-scrim[hidden] { display: none; }
.modal {
  background: var(--surface-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90dvh;
  overflow-y: auto;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
}
.modal-title { font-size: var(--fs-md); font-weight: var(--fw-semibold); }
.modal-body { padding: var(--space-6); }
.modal-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-subtle);
  display: flex; gap: var(--space-3); justify-content: flex-end;
}

/* ===== Toast ===== */
.toast-region {
  position: fixed;
  right: var(--space-5); bottom: var(--space-5);
  display: flex; flex-direction: column; gap: var(--space-3);
  z-index: var(--z-toast);
  width: min(360px, calc(100vw - 40px));
}
.toast {
  display: flex; align-items: flex-start; gap: var(--space-3);
  background: var(--surface-inverse);
  color: #fff;
  padding: var(--space-4);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-sm);
}
.toast svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.toast.success svg { color: #6EE7A8; }
.toast.danger svg { color: #F9A8A8; }

/* ===== Empty & loading states ===== */
.empty-state {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: var(--space-3);
  padding: var(--space-12) var(--space-6);
  color: var(--text-secondary);
}
.empty-state .icon-wrap {
  width: 48px; height: 48px;
  border-radius: var(--radius-full);
  background: var(--surface-muted);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-tertiary);
}
.empty-state .icon-wrap svg { width: 22px; height: 22px; }
.empty-state h3 { font-size: var(--fs-md); color: var(--text-primary); }
.empty-state p { font-size: var(--fs-sm); max-width: 40ch; }

.skeleton {
  background: linear-gradient(90deg, var(--surface-muted) 25%, var(--gray-200) 37%, var(--surface-muted) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* ===== Timeline (tracking / status history) ===== */
.timeline { display: flex; flex-direction: column; }
.timeline-step { display: flex; gap: var(--space-3); position: relative; padding-bottom: var(--space-6); }
.timeline-step:last-child { padding-bottom: 0; }
.timeline-step::before {
  content: "";
  position: absolute;
  left: 11px; top: 26px; bottom: 0;
  width: 2px;
  background: var(--border-subtle);
}
.timeline-step:last-child::before { display: none; }
.timeline-dot {
  width: 24px; height: 24px; flex: none;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-muted);
  color: var(--text-tertiary);
  border: 2px solid var(--surface-canvas);
  z-index: 1;
}
.timeline-dot svg { width: 12px; height: 12px; }
.timeline-step.done .timeline-dot { background: var(--success-fg); color: #fff; }
.timeline-step.current .timeline-dot { background: var(--brand-600); color: #fff; box-shadow: 0 0 0 4px var(--brand-100); }
.timeline-step.done::before { background: var(--success-border); }
.timeline-label { font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-primary); }
.timeline-step:not(.done):not(.current) .timeline-label { color: var(--text-tertiary); font-weight: var(--fw-regular); }
.timeline-meta { font-size: var(--fs-xs); color: var(--text-tertiary); margin-top: 2px; }

/* ===== Utility ===== */
.divider { height: 1px; background: var(--border-subtle); border: none; margin: 0; }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
