/* styles.css — Paginated Report extension
   Layout uses a flex column so the table area flexes to fill whatever height
   Tableau gives the extension; the header and pager keep fixed heights, which is
   exactly what pageSizer.js subtracts when computing rows-per-page. */

:root {
  --pr-row-height: 35px;
  --pr-header-height: 50px;
  --pr-pager-height: 50px;
  --pr-border: #e1e4e8;
  --pr-header-bg: #f6f8fa;
  --pr-accent: #1f77b4;
  --pr-text: #24292e;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 13px;
  color: var(--pr-text);
  background: #fff;
}

.pr-root {
  display: flex;
  flex-direction: column;
  height: 100vh;       /* fill the Tableau zone / browser viewport */
  overflow: hidden;
  position: relative;  /* anchor for the toast */
}

/* --- Header ------------------------------------------------------------- */
.pr-header {
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--pr-header-height);
  min-height: var(--pr-header-height);
  padding: 0 12px;
  border-bottom: 1px solid var(--pr-border);
  background: var(--pr-header-bg);
}
.pr-title { font-weight: 600; font-size: 14px; }
.pr-size-label { color: #586069; margin-left: auto; }
.pr-settings-btn {
  border: 1px solid var(--pr-border);
  background: #fff;
  border-radius: 4px;
  width: 28px; height: 28px;
  cursor: pointer;
  font-size: 14px;
}
.pr-settings-btn:hover { background: #f0f3f6; }

/* --- Table -------------------------------------------------------------- */
.pr-table-wrap {
  flex: 1 1 auto;
  overflow: hidden;     /* no internal scroll — paging replaces scrolling */
  min-height: 0;
}
.pr-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
.pr-table thead {
  height: var(--pr-header-height);
}
.pr-table th {
  text-align: left;
  padding: 0 10px;
  height: var(--pr-header-height);
  background: var(--pr-header-bg);
  border-bottom: 2px solid var(--pr-border);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: sticky;
  top: 0;
}
.pr-table td {
  padding: 0 10px;
  height: var(--pr-row-height);
  border-bottom: 1px solid var(--pr-border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pr-table tbody tr:nth-child(even) { background: #fbfcfd; }
.pr-table tbody tr:hover { background: #eef4fb; }

/* In-line filter row */
.pr-filter-row[hidden] { display: none; }
.pr-filter-cell {
  padding: 3px 6px; background: #f0f3f6;
  border-bottom: 1px solid var(--pr-border); position: sticky; top: var(--pr-header-height);
}
.pr-filter-input {
  width: 100%; height: 24px; box-sizing: border-box;
  border: 1px solid var(--pr-border); border-radius: 4px;
  padding: 0 6px; font: inherit; font-size: 12px; background: #fff;
}
.pr-filter-input:focus { outline: none; border-color: var(--pr-accent); }
.pr-filter-range { display: flex; align-items: center; gap: 3px; }
.pr-filter-num, .pr-filter-date { min-width: 0; }
.pr-filter-dash { color: #959da5; }
.pr-ms { display: block; }
.pr-ms-btn { text-align: left; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pr-ms-panel {
  position: fixed; z-index: 1200; max-height: 240px; overflow: auto;
  background: #fff; border: 1px solid var(--pr-border); border-radius: 6px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .18); padding: 4px;
}
.pr-ms-opt { display: flex; align-items: center; gap: 6px; padding: 3px 6px; font-size: 12px; cursor: pointer; white-space: nowrap; }
.pr-ms-opt:hover { background: #f0f3f6; }

/* Sortable headers */
.pr-th { position: relative; }
.pr-th.is-sortable { cursor: pointer; user-select: none; }
.pr-th-sort { color: #c2c9cf; font-size: 11px; }
.pr-th.is-sortable:hover .pr-th-sort { color: #6a737d; }
.pr-th-sort.is-active { color: var(--pr-accent); }

/* Drag-to-resize handle */
.pr-th-resizer {
  position: absolute; top: 0; right: 0; width: 7px; height: 100%;
  cursor: col-resize; user-select: none; touch-action: none;
}
.pr-th-resizer:hover, body.pr-resizing .pr-th-resizer { background: rgba(31, 119, 180, .35); }
body.pr-resizing { cursor: col-resize; user-select: none; }

/* --- Pagination --------------------------------------------------------- */
.pr-pager-area {
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--pr-pager-height);
  min-height: var(--pr-pager-height);
  padding: 0 12px;
  border-top: 1px solid var(--pr-border);
  background: var(--pr-header-bg);
}
.pr-range { color: #586069; }
.pr-pager {
  display: flex;
  gap: 4px;
  margin-left: auto;
  flex-wrap: nowrap;
}
.pr-pager[hidden] { display: none; }
.pr-page-btn {
  min-width: 30px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--pr-border);
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}
.pr-page-btn:hover:not(:disabled) { background: #f0f3f6; }
.pr-page-btn:disabled { opacity: .45; cursor: default; }
.pr-page-btn.is-current {
  background: var(--pr-accent);
  border-color: var(--pr-accent);
  color: #fff;
  font-weight: 600;
}
.pr-ellipsis { padding: 0 4px; color: #959da5; align-self: center; }

/* Go-to-page jump control */
.pr-goto { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; }
.pr-goto-label { color: #586069; font-size: 12px; }
.pr-goto-input {
  width: 52px; height: 28px;
  border: 1px solid var(--pr-border); border-radius: 4px;
  padding: 0 6px; font: inherit; text-align: center;
}
.pr-goto-total { color: #586069; font-size: 12px; }
.pr-goto-btn { min-width: 34px; }

/* Transient status / error toast */
.pr-toast {
  position: absolute; left: 50%; bottom: 64px; transform: translateX(-50%) translateY(8px);
  max-width: 90%; z-index: 1100;
  background: #24292e; color: #fff; font-size: 12px;
  padding: 8px 14px; border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
  opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s;
}
.pr-toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

.pr-demo-mode .pr-title::after {
  content: " · demo data";
  color: #959da5;
  font-weight: 400;
  font-size: 11px;
}

/* --- Config dialog ------------------------------------------------------ */
.pr-config-body { background: #fff; padding: 16px; height: auto; overflow-y: auto; }
.pr-config h2 { margin: 0 0 10px; font-size: 15px; }
.pr-config { display: flex; flex-direction: column; gap: 14px; }
.pr-section { border-top: 1px solid var(--pr-border); padding-top: 12px; }
.pr-section:first-child { border-top: 0; padding-top: 0; }
.pr-hint { margin: 0 0 10px; color: #586069; font-size: 12px; }
.pr-field { display: flex; align-items: center; gap: 10px; }
.pr-field > span { min-width: 80px; color: #586069; }
.pr-input {
  padding: 4px 6px;
  border: 1px solid var(--pr-border);
  border-radius: 4px;
  font: inherit;
  background: #fff;
}
select.pr-input { min-width: 90px; }
.pr-radio { display: flex; gap: 8px; align-items: flex-start; }
.pr-check { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.pr-col-filterable { display: inline-flex; gap: 4px; align-items: center; margin-left: 14px; font-size: 11px; color: #586069; }

/* Per-column formatting blocks */
.pr-columns { display: flex; flex-direction: column; gap: 8px; }
.pr-col { border: 1px solid var(--pr-border); border-radius: 6px; padding: 8px 10px; background: #fcfcfd; }
.pr-col.is-hidden { opacity: .55; }
.pr-col-head { margin-bottom: 8px; }
.pr-col-toggle { display: flex; align-items: center; gap: 8px; }
.pr-col-name { font-weight: 600; }
.pr-col-type {
  font-style: normal; font-size: 10px; text-transform: uppercase;
  letter-spacing: .04em; color: #6a737d;
  background: #eef1f4; border-radius: 3px; padding: 1px 6px;
}
.pr-col-body { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.pr-col-field { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: #586069; }
.pr-col-field input,
.pr-col-field select { width: 120px; }
.pr-col-field .c-width, .pr-col-field input.c-decimals { width: 70px; }

/* Colour controls */
.pr-col-colors {
  flex-basis: 100%; display: flex; flex-direction: column; gap: 8px;
  margin-top: 6px; padding-top: 8px; border-top: 1px dashed var(--pr-border);
}
.cc { display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
.cc-label { min-width: 78px; font-size: 11px; color: #586069; padding-top: 5px; }
.cc-single, .r-color {
  width: 34px; height: 26px; padding: 0; cursor: pointer;
  border: 1px solid var(--pr-border); border-radius: 4px; background: #fff;
}
.cc-rules { display: flex; flex-direction: column; gap: 6px; }
.cc-rule { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.cc-rule .pr-input { font-size: 11px; padding: 3px 5px; }
.cc-rule .r-value, .cc-rule .r-value2 { width: 64px; }
.cc-rule .r-field { max-width: 120px; }
.r-del {
  width: 24px; height: 24px; line-height: 1; cursor: pointer;
  border: 1px solid var(--pr-border); border-radius: 4px; background: #fff; color: #6a737d;
}
.cc-add {
  align-self: flex-start; font-size: 11px; padding: 3px 10px; cursor: pointer;
  border: 1px dashed var(--pr-border); border-radius: 4px; background: #fff; color: var(--pr-accent);
}

/* Colour-scale (diverging / sequential) control */
.cc-scale { display: flex; flex-direction: column; gap: 6px; font-size: 11px; color: #586069; }
.cc-scale .s-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cc-scale .pr-input { font-size: 11px; padding: 3px 5px; }
.cc-scale .s-field { max-width: 130px; }
.s-swatches { display: flex; gap: 12px; }
.s-swatches label { display: flex; align-items: center; gap: 4px; }
.s-swatches input[type="color"] {
  width: 34px; height: 24px; padding: 0; border: 1px solid var(--pr-border); border-radius: 4px; cursor: pointer;
}
.s-manual { display: flex; gap: 6px; }
.s-manual input { width: 64px; }
.s-domain { display: flex; align-items: center; gap: 6px; }
.pr-fixed-group {
  border: 1px solid var(--pr-border);
  border-radius: 6px;
  padding: 10px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
}
.pr-fixed-group:disabled { opacity: .5; }
.pr-fixed-group legend { padding: 0 4px; color: #586069; }
.pr-custom { display: flex; align-items: center; gap: 6px; }
.pr-custom input[type="number"] { width: 70px; }
.pr-advanced { font-size: 12px; color: #586069; }
.pr-advanced label { display: flex; justify-content: space-between; gap: 12px; margin: 6px 0; }
.pr-advanced input { width: 80px; }
.pr-config-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.pr-btn {
  padding: 6px 14px;
  border: 1px solid var(--pr-border);
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
}
.pr-btn-primary { background: var(--pr-accent); border-color: var(--pr-accent); color: #fff; }

/* Settings overlay (standalone in-page dialog) */
.pr-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(27, 31, 35, .45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.pr-overlay-card {
  width: min(760px, 96vw); height: min(680px, 92vh);
  background: #fff; border-radius: 8px; overflow: hidden;
  box-shadow: 0 12px 48px rgba(0, 0, 0, .3);
}
.pr-overlay-frame { width: 100%; height: 100%; border: 0; display: block; }

/* --- Responsive / orientation ------------------------------------------- */
@media (max-width: 600px) {
  .pr-header { gap: 6px; padding: 0 8px; }
  .pr-size-label { font-size: 11px; }
  .pr-page-btn { min-width: 26px; padding: 0 6px; }
}
