/* ==========================================================================
   REPORTS PAGE
   The export form on /data/export, and the progress overlay shared by every
   page that generates a file.
   ========================================================================== */

/* -------------------------------------------------------------------------
   Export form
   One surface: what to export on the left, operators and output on the
   right, then a bar that stays in view with the summary and the download
   button. Below 992px the parts stack.
   ------------------------------------------------------------------------- */
.stats-page--export {
  padding-bottom: var(--space-6);
}

.export-form {
  margin-top: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg);
}

.export-step {
  padding: var(--space-5) var(--space-6);
}

.export-step + .export-step,
.export-column {
  border-top: 1px solid var(--color-border);
}

.export-step__title {
  margin: 0 0 var(--space-3);
  color: var(--color-fg);
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
}

.export-step__help,
.export-field__help {
  margin: 0 0 var(--space-2);
  color: var(--color-fg-muted);
  font-size: var(--text-sm);
}

.export-field__help {
  margin: var(--space-1) 0 0;
  font-size: var(--text-xs);
}

.export-field__help:empty {
  display: none;
}

/* Each type is a card; the chosen one shows its own options inside it, so
   switching type never moves the other column. */
.export-choices {
  display: grid;
  gap: var(--space-2);
}

.export-choice {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.export-choice:hover {
  background: var(--color-bg-subtle);
}

.export-choice:has(> .export-choice__head input:checked) {
  border-color: var(--color-primary-border);
  background: var(--color-primary-subtle);
}

.export-choice__head {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin: 0;
  padding: var(--space-3);
  cursor: pointer;
}

.export-choice__head .form-check-input {
  flex: none;
  margin: 0.2rem 0 0;
}

.export-choice__title,
.export-choice__detail {
  display: block;
  font-size: var(--text-sm);
}

.export-choice__title {
  color: var(--color-fg);
  font-weight: var(--font-semibold);
}

.export-choice__detail {
  color: var(--color-fg-muted);
}

/* Lined up with the type's title, past the radio. */
.export-options {
  display: grid;
  gap: var(--space-3);
  margin: 0;
  padding: 0 var(--space-3) var(--space-3) calc(var(--space-3) * 2 + 1rem);
  border: 0;
}

.export-options fieldset,
fieldset.export-field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.export-field__label {
  display: block;
  float: none;
  width: auto;
  margin-bottom: var(--space-1);
  padding: 0;
  color: var(--color-fg);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
}

.export-checks,
.export-limit {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-5);
}

.export-check {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  color: var(--color-fg);
  font-size: var(--text-sm);
  cursor: pointer;
}

.export-check .form-check-input {
  margin: 0;
}

.export-limit .form-control {
  width: 6rem;
  margin-left: calc(-1 * var(--space-3));
}

.export-limit .form-control:disabled {
  background-color: var(--color-bg-subtle);
  color: var(--color-fg-muted);
}

.export-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-5) var(--space-6);
}

/* The operator menu floats over the form instead of pushing it down. */
#atlasOperatorFilterReports .operator-dropdown-container {
  position: relative;
}

#atlasOperatorFilterReports .operator-dropdown-menu {
  position: absolute;
  right: 0;
  left: 0;
}

.export-submit {
  position: sticky;
  bottom: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--color-border);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  background: var(--color-bg);
}

.export-submit__summary {
  margin: 0;
  color: var(--color-fg);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
}

.export-submit__note {
  margin: var(--space-1) 0 0;
  color: var(--color-fg-muted);
  font-size: var(--text-xs);
}

.export-submit .btn {
  flex: none;
}

@media (min-width: 992px) {
  .export-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .export-step--what {
    border-right: 1px solid var(--color-border);
  }

  .export-column {
    border-top: 0;
  }

  .export-submit {
    grid-column: 1 / -1;
  }
}

@media (max-width: 767.98px) {
  .export-step,
  .export-submit {
    padding-inline: var(--space-4);
  }

  .export-fields {
    grid-template-columns: 1fr;
  }

  .export-submit {
    flex-direction: column;
    align-items: stretch;
  }
}

/* -------------------------------------------------------------------------
   Loading Overlay
   ------------------------------------------------------------------------- */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--color-overlay);
  backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-content {
  background: var(--color-bg);
  padding: var(--space-6);
  border-radius: var(--radius-md);
  text-align: center;
  box-shadow: var(--shadow-xl);
  max-width: 420px;
  width: 90%;
}

.loading-content h4 {
  font-weight: var(--font-semibold);
  color: var(--color-fg);
  margin-bottom: var(--space-4);
}

.progress {
  height: 8px;
  border-radius: var(--radius-sm);
  background: var(--color-bg-muted);
  overflow: hidden;
}

.progress-bar {
  background: linear-gradient(90deg, var(--color-primary), var(--color-primary-hover));
  transition: width var(--transition-base);
}

/* -------------------------------------------------------------------------
   Operator Dropdown Container
   ------------------------------------------------------------------------- */
#atlasOperatorFilterReports {
  margin-top: var(--space-2);
}
