/* Shared components. Grows across tasks; starts with the button system. */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: 32px;
  padding: 0 var(--sp-3);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: var(--fs-14);
  font-weight: var(--fw-medium);
  cursor: pointer;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn-primary {
  background: var(--ink);
  color: var(--text-inverse);
}

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

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

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
}

.btn-ghost {
  color: var(--text-secondary);
}

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

.btn-danger {
  background: var(--status-failed-fg);
  color: var(--text-inverse);
}

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

.btn-lg {
  height: 40px;
  padding: 0 var(--sp-4);
}

.btn-sm {
  height: 26px;
  padding: 0 var(--sp-2);
  font-size: var(--fs-13);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* Chips (editorial pass: squares off the SaaS pill) */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius-sm);
  font-size: var(--fs-13);
  font-weight: var(--fw-medium);
  white-space: nowrap;
}

.chip-ready {
  color: var(--status-ready-fg);
  background: var(--status-ready-bg);
}

.chip-processing {
  color: var(--status-processing-fg);
  background: var(--status-processing-bg);
}

.chip-queued {
  color: var(--status-queued-fg);
  background: var(--status-queued-bg);
}

.chip-failed {
  color: var(--status-failed-fg);
  background: var(--status-failed-bg);
}

.chip-archived {
  color: var(--status-archived-fg);
  background: var(--status-archived-bg);
}

.chip-neutral {
  color: var(--text-secondary);
  background: var(--bg-hover);
}

.chip-dup {
  height: 18px;
  padding: 0 6px;
  font-size: var(--fs-11);
}

.chip-link {
  text-decoration: none;
}

.chip-link:hover {
  background: var(--border);
  text-decoration: none;
}

.status-chip {
  cursor: pointer;
}

.status-chip.is-static {
  cursor: default;
}

.status-pop {
  position: fixed;
  z-index: 60;
  width: 260px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-menu);
  padding: 10px 12px;
}

.status-pop strong {
  display: block;
  margin-bottom: 4px;
  font-size: var(--fs-13);
}

.status-pop p {
  color: var(--text-secondary);
  font-size: var(--fs-13);
}

.spin {
  animation: spin 1s linear infinite;
}

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

/* Motion: transitions are decorative here, but the spinner is a status
   affordance, so it keeps moving, just clearly slower. This block must stay
   after the .spin shorthand above: the shorthand would otherwise reset
   animation-duration and win the cascade. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
  .spin {
    animation-duration: 3s;
  }
}

/* Dropdown menus */
.menu {
  position: fixed;
  z-index: 70;
  min-width: 230px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-menu);
  padding: 4px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  background: transparent;
  border-radius: var(--radius-sm);
  text-align: left;
  font-size: var(--fs-14);
  cursor: pointer;
}

.menu-item:hover:not(:disabled) {
  background: var(--bg-hover);
}

.menu-item:disabled {
  opacity: 0.6;
  cursor: default;
}

.menu-item.is-danger {
  color: var(--status-failed-fg);
}

.menu-label {
  flex: 1;
}

.menu-hint {
  color: var(--text-muted);
  font-size: var(--fs-13);
}

.menu-sep {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 4px 0;
}

/* Progress */
.progress {
  height: 6px;
  background: var(--bg-hover);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-full);
  transition: width 0.4s linear;
}

/* Toasts */
.toast-stack {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 300px;
  max-width: 440px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-modal);
  padding: 10px 12px;
}

.toast-body {
  flex: 1;
}

.toast-title {
  font-weight: var(--fw-medium);
}

.toast-text {
  color: var(--text-secondary);
  font-size: var(--fs-13);
  margin-top: 2px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: var(--overlay);
  display: grid;
  place-items: center;
}

.modal {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  max-width: 92vw;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px 0;
}

.modal-head h2 {
  font-size: var(--fs-16);
}

.modal-body {
  padding: 12px 20px;
}

.modal-body p {
  color: var(--text-secondary);
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px 16px;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  padding: 56px 24px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
}

.empty-state h2 {
  font-size: var(--fs-16);
}

.empty-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  background: var(--accent-soft);
  color: var(--accent);
}

/* Plain variant: for empty lists that sit under an existing dashed surface
   (e.g. below the upload dropzone) and should not compete with it. */
.empty-state.is-plain {
  border: 0;
  background: transparent;
  padding: 24px 24px 0;
}

/* Card (shared by rail panels, the find card, viewer surfaces and metadata) */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card h2 {
  font-size: var(--fs-14);
}

/* Page header */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.page-sub {
  color: var(--text-secondary);
  margin-top: 4px;
}

.page-head-actions {
  display: flex;
  gap: 8px;
}

/* Avatar */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  border: 0;
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-13);
  cursor: pointer;
}

.avatar:hover {
  background: var(--accent-soft-strong);
}

/* Data table (editorial pass: quiet rules, typographic column labels) */
.table-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

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

table.data th {
  text-align: left;
  font-size: var(--fs-12);
  font-weight: var(--fw-medium);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px;
  border-bottom: 1px solid var(--border-strong);
  background: transparent;
  white-space: nowrap;
}

table.data td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

table.data tbody tr:hover {
  background: var(--bg-subtle);
}

table.data tbody tr.is-selected {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

table.data th.sortable {
  user-select: none;
}

table.data th.sortable .th-btn {
  display: inline-flex;
  align-items: center;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

table.data th .th-inner {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

table.data th .th-sort {
  color: var(--text-placeholder);
}

table.data th .th-sort.is-active {
  color: var(--accent);
}

table.data th .th-sort.asc {
  transform: rotate(180deg);
}

.col-check {
  width: 36px;
}

.col-menu {
  width: 44px;
  text-align: right;
}

input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}

.input {
  width: 100%;
  height: 34px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  font: inherit;
  background: var(--bg-surface);
  color: var(--text);
}

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

.choice-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  cursor: pointer;
}

.choice-list {
  max-height: 180px;
  overflow: auto;
  margin-bottom: 8px;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
