/* ---------- Shared download-form fields (downloadFormFields.js) ----------
   Used both inside the download-confirm view (nested in the download action
   sheet, .dlc-*) and the Downloads manager settings section (.dlm-*). */
.dlf-location {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  margin-bottom: var(--space-4);
}

.dlf-location-label {
  font-size: var(--fs-base);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dlf-location-change {
  flex-shrink: 0;
  min-height: var(--tap-min);
}

/* A real radio list (circle indicator + label, row highlighted when checked) rather than a
   segmented pill-button pair — explicitly asked to move away from that "button" look. */
.dlf-mode {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.dlf-mode-opt {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: var(--tap-min);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--fs-base);
  font-weight: 600;
  text-align: start;
  transition: border-color var(--duration-fast) var(--ease-standard),
    background-color var(--duration-fast) var(--ease-standard);
}

.dlf-mode-opt.is-active {
  border-color: var(--color-accent);
  background: rgba(215, 163, 92, 0.1);
}

.dlf-mode-radio {
  position: relative;
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: var(--radius-full);
  border: 2px solid var(--color-border-strong);
  transition: border-color var(--duration-fast) var(--ease-standard);
}

.dlf-mode-opt.is-active .dlf-mode-radio {
  border-color: var(--color-accent);
}

.dlf-mode-radio::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: var(--radius-full);
  background: var(--color-accent);
  transform: scale(0);
  transition: transform var(--duration-fast) var(--ease-standard);
}

.dlf-mode-opt.is-active .dlf-mode-radio::after {
  transform: scale(1);
}

.dlf-mode-label {
  flex: 1;
}

.dlf-times {
  display: flex;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.dlf-times.is-hidden {
  display: none;
}

.dlf-time-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  font-size: var(--fs-sm);
  color: var(--color-text-secondary);
}

.dlf-time-field input[type='time'] {
  min-height: var(--tap-min);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--fs-base);
}

.dlf-checkbox-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-sm);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-2);
}

.dlf-checkbox-row.is-hidden {
  display: none;
}

.dlf-checkbox-row input[type='checkbox'] {
  width: 1.15rem;
  height: 1.15rem;
  flex-shrink: 0;
}

.dlf-note {
  font-size: var(--fs-xs);
  color: var(--color-text-tertiary);
}

/* ---------- Download-confirm view (nested inside .da-panel, downloadConfirmView.js) ---------- */
.dlc-view.is-hidden,
.da-options.is-hidden {
  display: none;
}

.dlc-filename {
  font-size: var(--fs-base);
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.dlc-size.is-hidden {
  display: none;
}

.dlc-section {
  margin-top: var(--space-4);
}

.dlc-section-title {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-2);
}

.dlc-error {
  margin-top: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: rgba(220, 90, 80, 0.12);
  color: #e58e86;
  font-size: var(--fs-sm);
}

.dlc-error.is-hidden {
  display: none;
}

.dlc-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.dlc-actions .btn {
  flex: 1;
  min-height: var(--tap-min);
}

/* ---------- Downloads manager page (Profile -> Downloads, downloadsManager.js) ---------- */
.dlm-body {
  padding-top: calc(env(safe-area-inset-top) + var(--space-7));
  padding-inline: var(--container-padding);
  padding-bottom: calc(env(safe-area-inset-bottom) + var(--space-6));
  max-width: 42rem;
  margin-inline: auto;
}

.dlm-empty-sub {
  margin-top: var(--space-2);
  font-size: var(--fs-sm);
  color: var(--color-text-secondary);
  text-align: center;
}

.dlm-filters {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-4);
  scrollbar-width: none;
}

.dlm-filters::-webkit-scrollbar {
  display: none;
}

.dlm-filter-btn {
  flex: 0 0 auto;
  min-height: 2.25rem;
  padding: var(--space-1) var(--space-4);
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  font-size: var(--fs-sm);
  font-weight: 700;
  white-space: nowrap;
  transition: background-color var(--duration-fast) var(--ease-standard),
    color var(--duration-fast) var(--ease-standard),
    border-color var(--duration-fast) var(--ease-standard);
}

.dlm-filter-btn.is-active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-accent-contrast);
}

.dlm-section-title {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--color-text-secondary);
  margin: var(--space-5) 0 var(--space-2);
}

.dlm-section-title:first-child {
  margin-top: 0;
}

.dlm-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  margin-bottom: var(--space-2);
}

.dlm-row-info {
  flex: 1 1 12rem;
  min-width: 0;
}

.dlm-row-name {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--fs-base);
  font-weight: 600;
  min-width: 0;
}

.dlm-row-name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* A pending item added while the app-wide schedule (§9) is on will start on its own later
   rather than right away — this little clock next to the name is what signals that. */
.dlm-row-clock {
  flex-shrink: 0;
  width: 0.95rem;
  height: 0.95rem;
  color: var(--color-text-secondary);
}

.dlm-row-clock svg {
  display: block;
  width: 100%;
  height: 100%;
}

.dlm-row-clock.is-hidden {
  display: none;
}

.dlm-row-status {
  margin-top: 2px;
  font-size: var(--fs-xs);
  color: var(--color-text-secondary);
}

/* The "123 MB / 4.5 GB" chunk is a self-contained LTR run (digits/unit/slash have no strong
   directional anchor of their own) — without this it reorders inside RTL flow, see the comment
   next to where this class is applied in downloadsManager.js. */
.dlm-row-size {
  direction: ltr;
  unicode-bidi: embed;
}

.dlm-progress-wrap {
  flex: 1 1 100%;
  order: 3;
}

.dlm-progress-wrap.is-hidden {
  display: none;
}

.dlm-progress-track {
  width: 100%;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--color-border);
  overflow: hidden;
}

.dlm-progress-fill {
  height: 100%;
  background: var(--color-accent);
  border-radius: var(--radius-full);
  transition: width var(--duration-base) var(--ease-standard),
    background-color var(--duration-fast) var(--ease-standard);
}

/* Actively downloading gets its own colour so it reads as "moving" at a glance, distinct from
   a merely-pending item sitting in the queue (which keeps the default accent colour). */
.dlm-progress-fill.is-downloading {
  background: var(--color-success);
}

.dlm-row-actions {
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
}

.dlm-row-btn {
  min-height: 2.25rem;
  padding: var(--space-1) var(--space-3);
  font-size: var(--fs-sm);
}

.dlm-confirm {
  width: 100%;
}

/* ---------- Scheduled tab's "Settings" entry (downloadsManager.js) ---------- */
.dlm-schedule-settings-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-height: var(--tap-min);
  padding: var(--space-3);
  margin-bottom: var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--fs-base);
  font-weight: 600;
}

.dlm-schedule-settings-btn svg {
  width: 1.15rem;
  height: 1.15rem;
  flex-shrink: 0;
}

.dlm-schedule-settings-btn.is-hidden {
  display: none;
}

/* ---------- Schedule settings dialog (scheduleSettingsDialog.js) — reuses .cf-* chrome from
   components.css, just needs the form fields inside to have breathing room. ---------- */
.ssd-panel .dlf-schedule-range {
  margin-top: var(--space-4);
}

.ssd-panel .cf-title {
  margin-bottom: var(--space-1);
}

/* ---------- Header row + "Stop All"/"Remove All" buttons (downloadsManager.js) ---------- */
.dlm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.dlm-header .page-title {
  margin-bottom: 0;
}

.dlm-header-actions {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: var(--space-2);
  margin-inline-start: auto;
}

.dlm-stop-all-btn,
.dlm-remove-all-btn {
  flex-shrink: 0;
  min-height: 2.25rem;
  padding: var(--space-1) var(--space-4);
  font-size: var(--fs-sm);
}

.dlm-stop-all-btn:disabled,
.dlm-remove-all-btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}
