/* ============================================================
   File Upload Component
   ============================================================ */

/* Drop Zone
   ------------------------------------------------------------ */
.rlb-file-upload-dropzone {
  border: 2px dashed var(--border-color-strong);
  border-radius: var(--border-radius);
  padding: 2rem;
  text-align: center;
  transition: border-color 0.2s ease, background-color 0.2s ease;
  background-color: var(--background-color);
  cursor: pointer;
}

.rlb-file-upload-dropzone:hover {
  border-color: var(--primary-color);
  background-color: var(--surface-muted);
}

.rlb-file-upload-dropzone.file-upload-dropzone--drag-over {
  border-color: var(--primary-color);
  background-color: var(--surface-subtle);
  border-style: solid;
  box-shadow: 0 0 0 3px rgba(34, 34, 34, 0.25);
}

.rlb-file-upload-dropzone__content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.rlb-file-upload-dropzone__icon {
  color: var(--text-color-subtle);
}

.rlb-file-upload-dropzone--drag-over .rlb-file-upload-dropzone__icon {
  color: var(--primary-color);
}

.rlb-file-upload-dropzone__text {
  margin: 0;
  font-size: 1rem;
  color: var(--text-color);
}

/* File Input
   ------------------------------------------------------------ */
.rlb-file-upload-input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.rlb-file-upload-input:focus + .rlb-file-upload-constraints,
.rlb-file-upload-input:focus-visible + .rlb-file-upload-constraints {
  outline: none;
}

/* Label / Button
   ------------------------------------------------------------ */
.rlb-file-upload-label {
  display: inline-block;
  cursor: pointer;
}

.rlb-file-upload-label__button {
  display: inline-block;
  padding: 0.625rem 1.5rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-color-inverse);
  background-color: var(--primary-color);
  border-radius: var(--border-radius);
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
  user-select: none;
}

.rlb-file-upload-label:hover .rlb-file-upload-label__button {
  background-color: var(--primary-color-hover);
}

.rlb-file-upload-input:focus-visible ~ .rlb-file-upload-label .rlb-file-upload-label__button,
.rlb-file-upload-input:focus ~ .rlb-file-upload-label .rlb-file-upload-label__button {
  outline: none;
}

/* The input is visually hidden but still focusable.
   Show a visible focus ring on the label button when input is focused. */
.rlb-file-upload-label__button:focus,
.rlb-file-upload-input:focus-visible + .rlb-file-upload-constraints + .rlb-file-upload-label .rlb-file-upload-label__button {
  outline: none;
}

/* Use a wrapper approach: focus indicator on the dropzone when input is focused */
.rlb-file-upload-dropzone:focus-within {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(34, 34, 34, 0.4);
}

/* Constraints text */
.rlb-file-upload-constraints {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--text-color-subtle);
}

/* Status / Live Region
   ------------------------------------------------------------ */
.rlb-file-upload-status {
  min-height: 1.5rem;
  padding: 0.5rem 0;
  font-size: 0.875rem;
  color: var(--text-color);
}

.rlb-file-upload-status:empty {
  padding: 0;
  min-height: 0;
}

/* Error
   ------------------------------------------------------------ */
.rlb-file-upload-error {
  margin: 0;
  padding: 0;
  font-size: 0.875rem;
  color: var(--primary-color);
  font-weight: 500;
  min-height: 0;
}

.rlb-file-upload-error:empty {
  display: none;
}

/* File List
   ------------------------------------------------------------ */
.rlb-file-upload-list-wrapper {
  margin-top: 1.5rem;
}

.rlb-file-upload-list__heading {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
  color: var(--text-color-strong);
}

.rlb-file-upload-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.rlb-file-upload-list__item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background-color: var(--background-color);
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius);
  transition: background-color 0.15s ease;
}

.rlb-file-upload-list__item:hover {
  background-color: var(--surface-muted);
}

/* File icon */
.rlb-file-upload-list__icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  color: var(--text-color-subtle);
}

/* File info */
.rlb-file-upload-list__info {
  flex: 1;
  min-width: 0;
}

.rlb-file-upload-list__name {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-color-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rlb-file-upload-list__meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-color-subtle);
  margin-top: 0.125rem;
}

.rlb-file-upload-list__size {
  white-space: nowrap;
}

.rlb-file-upload-list__status {
  white-space: nowrap;
}

.rlb-file-upload-list__status--uploading {
  color: var(--primary-color);
}

.rlb-file-upload-list__status--complete {
  color: var(--primary-color);
}

.rlb-file-upload-list__status--error {
  color: var(--primary-color);
}

/* Progress bar */
.rlb-file-upload-list__progress {
  flex-shrink: 0;
  width: 80px;
  height: 6px;
  background-color: var(--gray-200);
  border-radius: var(--border-radius);
  overflow: hidden;
}

.rlb-file-upload-list__progress-bar {
  height: 100%;
  background-color: var(--primary-color);
  border-radius: var(--border-radius);
  transition: width 0.3s ease;
}

.rlb-file-upload-list__progress-bar--complete {
  background-color: var(--primary-color);
}

/* Remove button */
.rlb-file-upload-list__remove {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  min-width: 24px;
  min-height: 24px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: var(--border-radius);
  background: none;
  color: var(--text-color-subtle);
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.rlb-file-upload-list__remove:hover {
  color: var(--primary-color);
  background-color: var(--surface-muted);
}

.rlb-file-upload-list__remove:focus-visible {
  outline: 2px solid var(--focus-color);
  outline-offset: 2px;
  color: var(--primary-color);
}

/* Ensure all interactive elements have >= 3:1 focus indicators */
.rlb-file-upload-input:focus-visible,
.rlb-file-upload-label__button:focus-visible,
.rlb-file-upload-list__remove:focus-visible {
  outline: 2px solid var(--focus-color);
  outline-offset: 2px;
}

/* Empty state */
.rlb-file-upload-list:empty + .rlb-file-upload-list__empty,
.rlb-file-upload-list-wrapper[data-empty="true"] .rlb-file-upload-list__empty-msg {
  display: block;
}

/* Responsive */
@media (max-width: 480px) {
  .rlb-file-upload-dropzone {
    padding: 1.25rem;
  }

  .rlb-file-upload-list__item {
    padding: 0.5rem 0.75rem;
  }

  .rlb-file-upload-list__progress {
    width: 60px;
  }
}
