/* ==========================================================================
   Slice 3B — upload & review, bulk ZIP download, share links
   Built entirely from the shared tokens; no new colors.
   ========================================================================== */

/* ---- Shared progress bar ------------------------------------------------ */
.progress {
  width: 100%;
  height: 6px;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--color-text) 12%, transparent);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--color-primary);
  transition: width 120ms linear;
}

/* ---- Upload & review ---------------------------------------------------- */
.up {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.up-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: var(--space-5);
  border: 1.5px dashed var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-page);
  text-align: center;
  transition: border-color var(--duration-micro), background var(--duration-micro);
}

.up-dropzone:hover,
.up-dropzone:focus-visible,
.up-dropzone.is-dragover {
  border-color: var(--color-primary);
  background: var(--color-active-surface);
}

.up-dropzone-icon {
  color: var(--color-primary);
}

.up-dropzone strong {
  font-size: var(--app-text-base);
  color: var(--color-text-strong);
}

.up-dropzone-hint {
  margin-bottom: var(--space-1);
  font-size: var(--app-text-xs);
  color: var(--color-text-muted);
}

.up-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.up-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: var(--space-4);
  font-size: var(--app-text-sm);
  color: var(--color-text-muted);
}

.up-item {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-card);
}

.up-item-main {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 132px 68px;
  gap: var(--space-3);
  align-items: center;
  padding: var(--space-3);
}

.up-cover {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 60px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--color-surface-200);
  color: var(--color-text-muted);
}

.up-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.up-cover-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
}

.up-fields {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.up-field-row,
.up-isbn-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.up-field-row .input,
.up-isbn-row .input {
  flex: 1 1 auto;
  min-width: 0;
}

.up-format {
  flex-shrink: 0;
}

/* Destination library picker under the ISBN row. */
.up-library-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.up-library-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  font-size: var(--app-text-xs);
  color: var(--color-text-muted);
}

.up-library-select {
  flex: 1 1 auto;
  min-width: 0;
}

.up-status {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  font-size: var(--app-text-xs);
  color: var(--color-text-muted);
}

.up-status .progress {
  width: 100%;
}

.up-actions {
  display: flex;
  justify-content: flex-end;
  gap: 2px;
}

.up-actions .icon-button svg {
  transition: transform var(--duration-micro) var(--ease-glide);
}

.up-actions .icon-button.is-open svg {
  transform: rotate(180deg);
}

.up-item-extra {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-3);
  border-top: 1px dashed var(--color-border);
}

.up-extra-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.up-muted {
  font-size: var(--app-text-xs);
  color: var(--color-text-muted);
}

.up-matches {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.up-matches-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px var(--space-2) 4px var(--space-3);
  background: var(--color-page);
  font-size: var(--app-text-xs);
  font-weight: var(--weight-semibold);
  color: var(--color-text-secondary);
}

.up-match {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  text-align: left;
  border-top: 1px solid var(--color-border);
}

.up-match:hover {
  background: var(--color-surface-hover);
}

.up-match-cover {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 4px;
  overflow: hidden;
  background: var(--color-surface-200);
  color: var(--color-text-muted);
}

.up-match-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.up-match-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.up-match-title {
  font-size: var(--app-text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-strong);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.up-match-sub {
  font-size: var(--app-text-xs);
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.up-warning {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.up-warning-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: var(--app-text-xs);
  color: var(--color-warning);
}

.up-warning-row svg {
  flex-shrink: 0;
  margin-top: 1px;
}

.up-error {
  font-size: var(--app-text-xs);
  color: var(--color-danger);
}

.up-footer-note {
  font-size: var(--app-text-xs);
  color: var(--color-text-muted);
}

.up-footer-spacer {
  flex: 1 1 auto;
}

/* ---- Bulk ZIP download -------------------------------------------------- */
.dl {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.dl-summary {
  font-size: var(--app-text-sm);
  color: var(--color-text);
}

.dl-progress {
  height: 8px;
}

.dl-meta {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  font-size: var(--app-text-xs);
  color: var(--color-text-muted);
}

.dl-current {
  min-height: 1.2em;
  font-size: var(--app-text-xs);
  color: var(--color-text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Share links -------------------------------------------------------- */
.share {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.share-section-title {
  margin-bottom: var(--space-2);
  font-size: var(--app-text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text-strong);
}

.share-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.share-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.share-empty {
  padding: var(--space-3);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  text-align: center;
  font-size: var(--app-text-sm);
  color: var(--color-text-muted);
}

.share-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-card);
}

.share-item.is-inactive {
  opacity: 0.6;
}

.share-item-main {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.share-item-url {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: var(--app-text-sm);
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-item-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  font-size: var(--app-text-xs);
  color: var(--color-text-muted);
}

.share-item-actions {
  display: flex;
  flex-shrink: 0;
  gap: 2px;
}

.share-item-actions .icon-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.share-revoke:hover:not(:disabled) {
  color: var(--color-danger);
}

/* `hidden` must win over the flex displays above. */
.up-empty[hidden],
.up-item-extra[hidden],
.up-matches[hidden],
.up-warning[hidden],
.up-error[hidden] {
  display: none;
}

@media (max-width: 640px) {
  .up-item-main {
    grid-template-columns: 40px minmax(0, 1fr) 68px;
  }

  .up-status {
    grid-column: 1 / -1;
  }

  .up-actions {
    grid-column: 3;
    grid-row: 1;
  }

  .up-extra-grid,
  .share-form {
    grid-template-columns: minmax(0, 1fr);
  }

  .share-item {
    flex-direction: column;
    align-items: stretch;
  }

  .share-item-actions {
    justify-content: flex-end;
  }
}
