/* /tablecapture/pro/export-pdfs/. Everything is scoped under .pro-pdf-export,
   and neutral colors come from the --gm-* tokens in gm2.css so dark mode works. */

.pro-pdf-export {
  .big-heading .preface {
    display: block;
    color: var(--gm-heading);
    font-size: 19px;
    position: relative;
    top: 4px;
  }

  .panel {
    margin-bottom: 16px;
    background-color: var(--gm-surface);
    border-radius: 5px;
    padding: 16px;
  }

  .heading {
    font-family: "Roboto", "Noto Sans", sans-serif;
    font-weight: 300;
    font-size: 28px;
    line-height: 32px;
    margin: 8px 0 16px;
    color: var(--gm-heading);
  }

  .explanation {
    font-size: 17px;
    line-height: 24px;
    max-width: 560px;
    color: var(--gm-heading);
  }

  .caption {
    font-size: 13px;
    color: var(--gm-muted);
  }

  /* Gap rather than margins, so buttons stay apart when they wrap. */
  .buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    margin-top: 16px;
  }

  .steps-panel {
    .nav-link {
      cursor: default;
    }

    .nav-link .active-text {
      display: none;
    }

    .nav-link.active .active-text {
      display: block;
      margin-top: 2px;
      font-size: 13px;
    }
  }

  .usage-panel {
    .usage-plan {
      font-weight: 600;
    }

    .usage-bar {
      height: 6px;
      margin: 8px 0 6px;
      background-color: var(--gm-surface-alt);
    }
  }

  .privacy-note,
  .cloud-note {
    padding: 0 4px;
  }

  .privacy-note {
    margin-bottom: 8px;
  }

  /* Drop zone, as on /tablecapture/extract-pdf-data/. */
  .dropzone {
    min-height: 360px;
    background: linear-gradient(to bottom right, var(--gm-lavender), var(--gm-surface-alt));
    border: 2px dashed light-dark(lavender, #57518a);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
    cursor: pointer;
    transition: border-color 0.3s ease-in-out;

    &:hover,
    &.dragover {
      border-color: var(--gm-link);
    }

    .cta {
      max-width: 520px;
      text-align: center;
      font-size: 28px;
      line-height: 34px;
      font-family: "Roboto", "Noto Sans", sans-serif;
      color: var(--gm-heading);
    }
  }

  .viewer-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;

    .file-name {
      font-weight: 600;
      overflow-wrap: anywhere;
    }
  }

  .pdf-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    background: var(--gm-lavender);
    border-radius: 4px 4px 0 0;

    .page-indicator {
      display: inline-flex;
      align-items: center;
      gap: 6px;
    }

    .page-number {
      width: 72px;
    }
  }

  .canvas-wrapper {
    max-height: 640px;
    overflow: auto;
    background: var(--gm-lavender);
    border: 1px solid var(--gm-border);
    border-radius: 0 0 4px 4px;
    padding: 8px;

    canvas {
      display: block;
      width: 100%;
      height: auto;
      /* The page itself is paper: keep it light in dark mode. */
      color-scheme: light;
    }
  }

  .image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;

    figure {
      margin: 0;
    }

    img {
      width: 100%;
      height: 140px;
      object-fit: cover;
      border: 1px solid var(--gm-border);
      border-radius: 4px;
      background: var(--gm-surface-alt);
    }

    figcaption {
      font-size: 12px;
      color: var(--gm-muted);
      margin-top: 4px;
      overflow-wrap: anywhere;
    }
  }

  /* Native radios and checkboxes: the site's Bootstrap 4 beta predates
     custom-control-label. */
  label.choice {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    cursor: pointer;

    input {
      margin: 0;
      width: 16px;
      height: 16px;
      accent-color: var(--gm-link);
    }
  }

  .options-panel {
    .page-choice > label.choice {
      display: flex;
    }

    .choice-range-row {
      display: flex;
      align-items: center;
      gap: 8px;
      margin-top: 8px;

      .range-input {
        max-width: 200px;
      }
    }

    .selection-summary {
      margin-bottom: 12px;
      color: var(--gm-muted);
    }

    .selection-problem {
      margin-bottom: 12px;
      color: light-dark(#b02a37, #f1aeb5);
    }
  }

  .progress-header,
  .results-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
  }

  .run-bar {
    background-color: var(--gm-surface-alt);
  }

  .run-summary {
    margin: 8px 0 12px;
  }

  .page-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 320px;
    overflow-y: auto;
    border-top: 1px solid var(--gm-border);

    .page-row {
      display: flex;
      flex-wrap: wrap;
      align-items: baseline;
      gap: 4px 12px;
      padding: 6px 2px;
      border-bottom: 1px solid var(--gm-border);
      font-size: 14px;
    }

    .page-label {
      min-width: 72px;
      font-weight: 600;
    }

    .page-detail {
      color: var(--gm-muted);
    }

    .page-done .page-detail {
      color: var(--gm-text);
    }

    .page-failed .page-detail {
      color: light-dark(#b02a37, #f1aeb5);
    }

    .btn-retry {
      padding: 0;
      font-size: 14px;
    }
  }

  .results-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
  }

  .no-tables {
    color: var(--gm-muted);
    margin: 16px 0;
  }

  .table-card {
    margin-top: 20px;

    .table-card-header {
      display: flex;
      flex-wrap: wrap;
      align-items: flex-start;
      justify-content: space-between;
      gap: 8px;
      margin-bottom: 8px;
    }

    .table-card-name {
      color: var(--gm-muted);
      font-size: 14px;
    }

    .table-card-actions {
      display: flex;
      gap: 8px;
    }

    .table-scroller {
      max-height: 420px;
      overflow: auto;
      border: 1px solid var(--gm-border);
      border-radius: 4px;
    }

    table {
      margin-bottom: 0;
      font-size: 13px;
      color: var(--gm-text);
      white-space: nowrap;
    }

    th {
      position: sticky;
      top: 0;
      background: var(--gm-aliceblue);
    }

    th,
    td {
      border-color: var(--gm-border);
    }

    .more-rows {
      margin-top: 4px;
    }
  }

  /* Admins only: a sidebar summary that opens the admin dialog. */
  .admin-panel {
    margin-top: 16px;
    border: 1px dashed var(--gm-border);

    .admin-title {
      font-weight: 600;
    }

    .admin-status {
      margin: 2px 0 10px;
    }
  }

  /* A native <dialog>: showModal() gives the backdrop, Escape and focus.
     The padding is on the inner div so a click on the dialog itself is a
     click on the backdrop. */
  .admin-dialog {
    width: min(760px, calc(100vw - 32px));
    max-height: calc(100vh - 64px);
    padding: 0;
    border: 1px solid var(--gm-border);
    border-radius: 8px;
    background: var(--gm-surface);
    color: var(--gm-text);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);

    /* Bootstrap's reboot sets dialog { display: block }, which would show it
       closed, in the page flow. */
    &:not([open]) {
      display: none;
    }

    /* Focused itself when opened, so the × doesn't start with a focus ring. */
    &:focus {
      outline: none;
    }

    &::backdrop {
      background: rgba(0, 0, 0, 0.5);
    }

    .admin-dialog-body {
      padding: 16px 20px 20px;
    }

    .admin-dialog-header {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 16px;

      .heading {
        margin: 4px 0 12px;
      }

      .close {
        color: var(--gm-text);
        text-shadow: none;
        font-size: 28px;
        line-height: 1;
      }
    }

    .admin-switch-row {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 8px 12px;
      font-size: 17px;
    }

    .admin-error {
      margin-top: 8px;
      color: light-dark(#b02a37, #f1aeb5);
    }

    .admin-usage {
      margin: 8px 0 12px;
    }

    .admin-table-scroller {
      overflow-x: auto;
    }

    table {
      margin-bottom: 0;
      font-size: 13px;
      color: var(--gm-text);
      white-space: nowrap;
    }

    th,
    td {
      border-color: var(--gm-border);
    }

    .admin-empty {
      margin-top: 8px;
    }
  }
}

@media (max-width: 768px) {
  .pro-pdf-export {
    .dropzone {
      min-height: 200px;
      padding: 16px;

      .cta {
        font-size: 20px;
        line-height: 26px;
      }
    }
  }
}
