/* ==========================================================================
 * Rent Ready Web Design System v1.0.0 . upload page
 *
 * Components for api/templates/upload.html only. Loaded after base.css.
 * Kept separate from rubrics.css because this file styles bare form, label,
 * input, and table elements; sharing one sheet would leak those rules onto
 * the rubrics page, which has its own labels and tables.
 *
 * The batch status panel is the focal element of this page. It carries the
 * accent because it is what an operator watches while a batch runs.
 * Everything above it stays quiet: white, navy text, hairline rules.
 * ========================================================================== */

/* ---- Auth bar ---------------------------------------------------------- */

.auth-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: 12px 16px;
  margin-bottom: 24px;
  font-size: var(--text-sm);
}

.auth-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---- Upload form ------------------------------------------------------- */

form > .primary-btn {
  align-self: stretch;
}

@media (min-width: 640px) {
  form > .primary-btn {
    align-self: flex-start;
  }
}

form {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

@media (min-width: 1024px) {
  form {
    padding: 32px;
  }
}

label {
  display: block;
  margin-bottom: 6px;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
}

input[type="email"],
input[type="file"] {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--color-border-input);
  border-radius: var(--radius-input);
  background: var(--color-surface);
  color: var(--color-text);
  font-family: inherit;
  font-size: var(--text-sm);
  transition: border-color var(--duration-fast) var(--ease-standard),
    box-shadow var(--duration-fast) var(--ease-standard);
}

input[type="email"]::placeholder {
  color: var(--color-navy-a40);
}

input[type="email"]:focus,
input[type="file"]:focus {
  outline: none;
  border-color: var(--color-cyan-500);
  box-shadow: 0 0 0 2px var(--color-cyan-ring);
}

.file-input-wrapper {
  position: relative;
  display: inline-block;
  width: 100%;
}

.clear-file-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: var(--radius-badge);
  background: var(--color-navy-a10);
  color: var(--color-text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--duration-fast) var(--ease-standard);
}

.clear-file-btn:hover {
  background: var(--color-coral-tint);
}

.clear-file-btn[hidden] {
  display: none;
}

/* ---- Batch status panel ------------------------------------------------ */

#status-panel {
  margin-top: 32px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: 24px;
  box-shadow: var(--shadow-card);
}

@media (min-width: 1024px) {
  #status-panel {
    padding: 32px;
  }
}

/* Progress bar.
 * The fill is full width and scaled on the X axis, driven by --progress set
 * from JS. The system forbids animating width, height, top, or left, so a
 * width transition is not an option here. */
.progress-track {
  position: relative;
  height: 8px;
  border-radius: var(--radius-badge);
  background: var(--color-navy-a05);
  overflow: hidden;
  margin-bottom: 20px;
}

.progress-fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--color-cyan-500);
  transform: scaleX(var(--progress, 0));
  transform-origin: left center;
  transition: transform var(--duration-reveal) var(--ease-entrance);
}

.progress-fill.has-failures {
  background: var(--color-coral-500);
}

/* The percentage reads as a metric beside the bar, not as white text on the
 * cyan fill, which would be 2.09:1. */
.progress-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.progress-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
}

.progress-value {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-cyan-800);
  font-variant-numeric: tabular-nums;
}

.progress-meta {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-bottom: 20px;
}

/* ---- State count pills ------------------------------------------------- */

#state-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.state-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-badge);
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  font-size: var(--text-caption);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* A dot carries the state colour so the label itself stays navy and legible. */
.state-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-navy-a40);
}

.state-pill[data-state="completed"] {
  background: var(--color-cyan-tint);
  border-color: var(--color-cyan-500);
}

.state-pill[data-state="completed"]::before {
  background: var(--color-cyan-600);
}

.state-pill[data-state="failed"] {
  background: var(--color-coral-tint);
  border-color: var(--color-coral-500);
}

.state-pill[data-state="failed"]::before {
  background: var(--color-coral-500);
}

/* ---- Asset table ------------------------------------------------------- */

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

th,
td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--color-border);
  font-size: var(--text-sm);
  vertical-align: top;
}

th {
  font-size: var(--text-caption);
  font-weight: 600;
  color: var(--color-text-secondary);
  border-bottom-color: var(--color-border-medium);
  white-space: nowrap;
}

td a {
  color: var(--color-link);
  text-decoration: underline;
  text-decoration-color: var(--color-cyan-ring);
  text-underline-offset: 2px;
}

td a:hover {
  text-decoration-color: var(--color-cyan-500);
}

/* ---- Per-state cell treatments ----------------------------------------
 * Class names come from getStatusStyle() in upload.html. Navy text on a
 * tinted fill throughout. */

.status-icon-cell {
  text-align: center;
  font-size: var(--text-base);
  width: 44px;
}

.status-processing {
  background: var(--color-blue-tint);
  color: var(--color-text);
}

.status-completed {
  background: var(--color-cyan-tint);
  color: var(--color-text);
}

.status-deleted {
  background: var(--color-bg-subtle);
  color: var(--color-text-secondary);
}

.status-failed {
  background: var(--color-coral-tint);
  color: var(--color-text);
  font-weight: 600;
}

.status-cancelled {
  background: var(--color-coral-tint-soft);
  color: var(--color-text-secondary);
}

tr.cancelled-row {
  background-color: var(--color-coral-tint-soft);
}

/* ---- Spinner ----------------------------------------------------------- */

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.status-spinner,
.status-spinner-inline {
  display: inline-block;
  border-radius: 50%;
  border-style: solid;
  border-color: var(--color-navy-a10);
  border-top-color: var(--color-cyan-500);
  animation: spin 0.8s linear infinite;
}

.status-spinner {
  width: 18px;
  height: 18px;
  border-width: 3px;
}

.status-spinner-inline {
  width: 14px;
  height: 14px;
  border-width: 2px;
  vertical-align: middle;
  margin-right: 8px;
}

/* ---- Batch help notice -------------------------------------------------
 * Shown when a batch completes without report links. Coral is the system's
 * only warning colour; there is no amber in the palette. */

.batch-notice {
  margin-bottom: 24px;
  padding: 12px 16px;
  border: 1px solid var(--color-coral-500);
  border-radius: var(--radius-button);
  background: var(--color-coral-tint);
  color: var(--color-text);
  font-size: var(--text-sm);
}

/* ---- Mobile ------------------------------------------------------------ */

@media (max-width: 640px) {
  form,
  #status-panel {
    padding: 20px;
  }

  table {
    font-size: var(--text-caption);
  }

  th,
  td {
    padding: 10px 6px;
  }
}

/* Batch-level links under the progress bar. */
.batch-links {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 20px;
}

.batch-links a {
  color: var(--color-link);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--color-cyan-ring);
  text-underline-offset: 3px;
  transition: text-decoration-color var(--duration-fast) var(--ease-standard);
}

.batch-links a:hover {
  text-decoration-color: var(--color-cyan-500);
}

/* Panel header: title left, the destructive action right. */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 4px;
}

.panel-header h2 {
  margin: 0;
  font-size: var(--text-xl);
}

#status-panel .hint {
  margin: 0 0 20px;
}

#progress-section {
  margin-bottom: 20px;
}

#progress-section:empty {
  margin-bottom: 0;
}

/* State icons. Stroke weight 2, colour inherited from the cell, matching the
 * design system's icon rules. */
.state-icon {
  width: 18px;
  height: 18px;
  display: inline-block;
  vertical-align: middle;
  color: var(--color-text-secondary);
}

/* The icon stays neutral. The tinted state cell beside it already encodes
 * the state colour, and two colour signals for one fact reads as noise. */

/* The asset table has six columns and will not fit a phone. It scrolls
 * inside this container so the page body never scrolls sideways. */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
