/**
 * quickView.css
 * All styling for the Quick View Reporting module.
 * Components hold no static inline styles - they only toggle the modifier
 * classes defined here.
 */

/* ── Lucide icon sizing ─────────────────────────────────────────────────────
 * A global rule in sidebar/common.css sets `svg { display:block; width:100%;
 * height:100% }`, which both stretches inline lucide icons to fill their (often
 * wide) container and drops them onto their own line above adjacent text. These
 * class-scoped rules win on specificity: they restore inline flow and pin each
 * icon to its intended size. The modal-scoped selectors also cover the export
 * dialog, which react-bootstrap portals outside .qv-root. */

.qv-header__title svg,
.qv-modal-title svg,
.qv-header__actions svg,
.qv-modal-footer svg,
.qv-summary-card__title svg,
.qv-sheet-mode__title svg,
.qv-module-cell__inner svg,
.qv-filters svg,
.qv-location-chip svg,
.qv-info-icon svg {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

.qv-header__title svg,
.qv-modal-title svg {
  width: 18px;
  height: 18px;
}

.qv-header__actions svg,
.qv-modal-footer svg,
.qv-summary-card__title svg,
.qv-sheet-mode__title svg,
.qv-module-cell__inner svg {
  width: 16px;
  height: 16px;
}

.qv-filters svg,
.qv-location-chip svg {
  width: 14px;
  height: 14px;
}

.qv-info-icon svg {
  width: 12px;
  height: 12px;
}

/* ── Shell ─────────────────────────────────────────────────────────────── */

.qv-root {
  display: flex;
  background: var(--surface-2, #f9fafb);
  min-height: 100vh;
  font-family: var(--font-sans, "Inter", sans-serif);
}

.qv-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--surface, #fff);
  border-right: 1px solid var(--rule, #e5e7eb);
  z-index: 100;
  transition: flex 0.2s ease;
}

.qv-sidebar--expanded {
  flex: 0 0 21%;
}

.qv-sidebar--collapsed {
  flex: 0 0 60px;
}

.qv-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.qv-content {
  flex: 1;
  padding: 20px;
}

/* ── Shared card ───────────────────────────────────────────────────────── */

.qv-card {
  background: var(--surface, #fff);
  border-radius: 12px;
  border: 1px solid var(--rule, #e5e7eb);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.05);
}

/* ── Loader ────────────────────────────────────────────────────────────── */

.qv-loader {
  text-align: center;
  padding: 60px;
}

.qv-loader__spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--accent-3, #f0f9ff);
  border-top-color: var(--accent, #3f88a5);
  border-radius: 50%;
  animation: qv-spin 1s linear infinite;
  margin: 0 auto 18px;
}

.qv-loader__label {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2, #3d3d3d);
}

@keyframes qv-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Page header ───────────────────────────────────────────────────────── */

.qv-header {
  padding: 18px 24px;
  margin-bottom: 20px;
}

.qv-header__inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.qv-header__title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 4px 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink, #0d0d0d);
}

.qv-header__subtitle {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-3, #6b7280);
}

/* ── Filter bar ────────────────────────────────────────────────────────── */

.qv-filters {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 20px;
  margin-bottom: 20px;
}

.qv-filters__controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px 14px;
  align-items: end;
}

.qv-field {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.qv-select {
  width: 100%;
  height: 40px;
  padding: 0 32px 0 13px;
  border-radius: 10px;
  border: 1.5px solid var(--rule, #e5e7eb);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-sans, "Inter", sans-serif);
  color: #374151;
  background-color: var(--surface, #fff);
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  cursor: pointer;
  outline: none;
  box-sizing: border-box;
}

.qv-select:focus {
  border-color: var(--accent, #3f88a5);
  box-shadow: 0 0 0 3px var(--accent-3, #f0f9ff);
}

.qv-search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  width: 100%;
  max-width: 320px;
  padding: 0 13px;
  border: 1.5px solid var(--rule, #e5e7eb);
  border-radius: 10px;
  background: var(--surface, #fff);
  box-sizing: border-box;
}

.qv-search:focus-within {
  border-color: var(--accent, #3f88a5);
  box-shadow: 0 0 0 3px var(--accent-3, #f0f9ff);
}

.qv-search__icon {
  font-size: 13px;
  color: var(--ink-4, #9ca3af);
  flex-shrink: 0;
}

.qv-search__input {
  border: none;
  outline: none;
  width: 100%;
  font-size: 13px;
  font-family: inherit;
  background: transparent;
  color: var(--ink, #0d0d0d);
}

.qv-search__input::placeholder {
  color: var(--ink-4, #9ca3af);
}

/* ── MultiSelect overrides (scoped to this page only) ───────────────────
   MultiSelect ships its own inline styles + indigo accent, so these need
   !important to win. Scoped to .qv-filters so other pages keep their look. */

.qv-filters .dropdown-toggle {
  height: 40px !important;
  padding: 0 13px !important;
  border-radius: 10px !important;
  border: 1.5px solid var(--rule, #e5e7eb) !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  font-family: var(--font-sans, "Inter", sans-serif) !important;
  color: var(--ink-2, #374151) !important;
  box-shadow: none !important;
}

.qv-filters .dropdown-toggle:focus,
.qv-filters .dropdown-toggle.show {
  border-color: var(--accent, #3f88a5) !important;
  box-shadow: 0 0 0 3px var(--accent-3, #f0f9ff) !important;
}

/* Show the MultiSelect's own <label> above the toggle so every filter
   (native selects included) carries a consistent heading. */
.qv-filters label {
  display: flex !important;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px !important;
  font-weight: 700 !important;
  font-size: 11.5px !important;
  letter-spacing: 0.02em !important;
  text-transform: uppercase !important;
  color: var(--ink-3, #6b7280) !important;
  line-height: 1 !important;
}

.qv-filters .dropdown-menu {
  min-width: 240px !important;
  border: 1px solid var(--rule, #e5e7eb) !important;
  border-radius: 10px !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12) !important;
  padding: 0 !important;
  overflow: hidden;
}

/* Teal accent instead of the component's default indigo */
.qv-filters .dropdown-menu input[type="checkbox"] {
  accent-color: var(--accent, #3f88a5) !important;
}

.qv-filters .dropdown-menu .btn-link {
  color: var(--accent, #3f88a5) !important;
  font-family: var(--font-sans, "Inter", sans-serif) !important;
}

.qv-filters .dropdown-menu .btn-link:disabled {
  color: var(--ink-4, #9ca3af) !important;
}

.qv-filters .search-input {
  border: 1.5px solid var(--rule, #e5e7eb) !important;
  border-radius: 8px !important;
  font-size: 12.5px !important;
  font-family: var(--font-sans, "Inter", sans-serif) !important;
}

.qv-filters .search-input:focus {
  border-color: var(--accent, #3f88a5) !important;
  box-shadow: 0 0 0 3px var(--accent-3, #f0f9ff) !important;
}

/* Every option row uses the teal band + teal text so the list reads as a
   consistent set even when nothing is checked (e.g. Sub Location, which starts
   empty). MultiSelect sets an inline background + indigo accent, so these need
   !important to win. */
.qv-filters .dropdown-item-custom {
  font-family: var(--font-sans, "Inter", sans-serif) !important;
  color: var(--accent, #3f88a5) !important;
  padding: 7px 10px !important;
  margin: 3px 6px !important;
  border-radius: 7px !important;
  gap: 9px !important;
  background-color: #eaf5f8 !important;
  border: 1px solid transparent !important;
  transition: background-color 0.12s ease, border-color 0.12s ease !important;
}

/* The component sets an inline 14px style on each row span; shrink both, but
   only let the label (first span) truncate — the count span must stay intact
   so "ALL SUB LOCATION (2)" never collapses to "(…)". */
.qv-filters .dropdown-item-custom > span {
  font-size: 12.5px !important;
  font-weight: 600 !important;
  color: var(--accent, #3f88a5) !important;
  min-width: 0 !important;
}

.qv-filters .dropdown-item-custom > span:first-of-type {
  flex: 1 1 auto !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.qv-filters .dropdown-item-custom > span:last-child {
  flex-shrink: 0 !important;
  white-space: nowrap !important;
}

.qv-filters .dropdown-item-custom:hover {
  background-color: #ddeef3 !important;
}

/* Selected rows keep the same teal band but gain a border to stand out. */
.qv-filters .dropdown-item-custom:has(input:checked) {
  border-color: #bcdfe9 !important;
}

.qv-filters .dropdown-menu input[type="checkbox"] {
  width: 14px !important;
  height: 14px !important;
  border-radius: 4px !important;
  flex-shrink: 0 !important;
}

/* ── Table ─────────────────────────────────────────────────────────────── */

.qv-table-card {
  overflow: visible;
}

.qv-table-scroll {
  padding: 0;
  overflow-x: visible;
}

.qv-table-wrap {
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--rule, #e5e7eb);
  width: 100%;
}

.qv-table {
  border-collapse: collapse;
  width: 100%;
  table-layout: fixed;
  background: var(--surface, #fff);
  font-family: var(--font-sans, "Inter", sans-serif);
}

/* ── Table head ────────────────────────────────────────────────────────── */

.qv-thead-row {
  background: var(--surface-3, #f3f4f6);
  border-bottom: 2px solid #e5e8ed;
}

.qv-th {
  padding: 10px 12px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-family: var(--font-mono, "Fira Code", monospace);
  text-align: center;
  border-right: 1px solid var(--rule, #e5e7eb);
}

.qv-th:last-child {
  border-right: none;
}

.qv-th--index {
  width: 3.5%;
  color: var(--ink-3, #6b7280);
  white-space: nowrap;
}

.qv-th--question {
  width: 22.5%;
  text-align: left;
  color: var(--ink-3, #6b7280);
}

/* Period labels are the key data dimension - accent-coloured so they read
   clearly against the muted "#" / "Question" labels.
   No fixed width here — they each take an equal share of the remaining
   74% spread over however many periods are rendered (1-12). */
.qv-th--period {
  white-space: normal;
  word-break: break-word;
  color: var(--accent, #3f88a5);
}

/* ── Module group row ──────────────────────────────────────────────────── */

.qv-module-row {
  cursor: pointer;
  user-select: none;
}

.qv-module-cell {
  padding: 10px 12px 10px 24px;
  background: var(--accent-3, #f0f9ff);
  font-weight: 700;
  font-size: 12.5px;
  color: var(--accent, #3f88a5);
  text-align: left;
  border-bottom: 1px solid var(--rule, #e5e7eb);
  transition: background 0.15s ease;
}

.qv-module-row:hover .qv-module-cell {
  background: #e3eff4;
}

.qv-module-cell__inner {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
}

.qv-chevron {
  display: inline-block;
  font-size: 9px;
  transition: transform 0.15s ease;
}

.qv-chevron--collapsed {
  transform: rotate(-90deg);
}

.qv-module-count {
  font-weight: 600;
  opacity: 0.75;
}

/* ── Body rows ─────────────────────────────────────────────────────────── */

.qv-row--even {
  background: var(--surface, #fff);
}

.qv-row--odd {
  background: var(--surface-2, #f9fafb);
}

.qv-td {
  border-bottom: 1px solid var(--rule, #e5e7eb);
  border-right: 1px solid var(--rule, #e5e7eb);
}

.qv-td:last-child {
  border-right: none;
}

.qv-td--index {
  padding: 10px 4px;
  width: 3.5%;
  text-align: center;
  font-weight: 600;
  font-size: 11.5px;
  color: var(--ink-4, #9ca3af);
  font-family: var(--font-mono, "Fira Code", monospace);
  white-space: nowrap;
}

.qv-td--question {
  padding: 10px 10px;
  width: 22.5%;
  font-weight: 700;
  font-size: 13px;
  color: var(--ink, #0d0d0d);
  word-break: break-word;
  overflow-wrap: break-word;
}

.qv-unit {
  margin-left: 4px;
  color: var(--accent, #3f88a5);
  font-weight: 600;
  font-size: 11px;
  white-space: nowrap;
}

/* ── Value cells ───────────────────────────────────────────────────────── */

.qv-cell {
  padding: 10px 4px;
  text-align: center;
  font-size: 11.5px;
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
}

.qv-cell--empty {
  color: #b42318;
  font-weight: 500;
  font-style: italic;
  background: #fef3f2;
}

.qv-cell--number {
  color: #067647;
  font-weight: 600;
  background: #ecfdf3;
}

.qv-cell--text {
  color: #085d3a;
  font-weight: 500;
  background: #f0fdf4;
}

.qv-empty {
  padding: 24px;
  text-align: center;
  color: var(--ink-3, #6b7280);
  font-size: 13px;
}

/* ── Export modal ──────────────────────────────────────────────────────── */

.qv-modal-header {
  background: var(--surface, #fff);
  border-bottom: 1px solid var(--rule, #e5e7eb);
}

.qv-modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink, #0d0d0d);
}

.qv-modal-body {
  padding: 24px;
  background: var(--surface-2, #f9fafb);
  font-family: var(--font-sans, "Inter", sans-serif);
}

.qv-modal-note {
  font-size: 12.5px;
  color: var(--ink-3, #6b7280);
  margin-bottom: 18px;
}

.qv-modal-footer {
  background: var(--surface-2, #f9fafb);
  border: none;
}

.qv-summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.qv-summary-card {
  background: var(--surface, #fff);
  border-radius: 10px;
  border: 1px solid var(--rule, #e5e7eb);
  padding: 14px 16px;
}

.qv-summary-card__title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--ink, #0d0d0d);
  font-weight: 600;
  font-size: 13px;
}

.qv-summary-card__body {
  font-size: 13px;
  color: var(--ink-2, #3d3d3d);
  word-break: break-word;
}

.qv-location-list {
  max-height: 120px;
  overflow-y: auto;
}

.qv-location-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  margin-bottom: 5px;
  border-radius: 6px;
  background: var(--accent-3, #f0f9ff);
  color: var(--accent, #3f88a5);
  font-weight: 500;
  font-size: 12px;
}

.qv-sheet-mode {
  margin-top: 18px;
  background: var(--surface, #fff);
  border-radius: 10px;
  border: 1px solid var(--rule, #e5e7eb);
  padding: 16px;
}

.qv-sheet-mode__title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 13px;
  color: var(--ink, #0d0d0d);
  margin-bottom: 10px;
}

.qv-radio {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: 8px;
  border: 1.5px solid var(--rule, #e5e7eb);
  background: var(--surface, #fff);
  cursor: pointer;
}

.qv-radio--active {
  border-color: var(--accent, #3f88a5);
  background: var(--accent-3, #f0f9ff);
}

.qv-radio__input {
  margin-top: 3px;
  accent-color: var(--accent, #3f88a5);
}

.qv-radio__title {
  display: block;
  font-weight: 600;
  font-size: 13px;
  color: var(--ink, #0d0d0d);
}

.qv-radio__desc {
  font-size: 12px;
  color: var(--ink-3, #6b7280);
}

/* ── Actions & Toggle ─────────────────────────────────────────────────── */

.qv-header__actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.qv-toggle-container {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2, #f9fafb);
  padding: 4px 8px;
  border-radius: 10px;
  border: 1px solid var(--rule, #e5e7eb);
}

.qv-toggle-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2, #3d3d3d);
}

.qv-toggle-pill {
  display: flex;
  background: #e5e7eb;
  padding: 3px;
  border-radius: 8px;
}

.qv-toggle-btn {
  border: none;
  background: transparent;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 6px;
  cursor: pointer;
  color: var(--ink-3, #6b7280);
  transition: all 0.2s ease;
}

.qv-toggle-btn:hover {
  color: var(--ink, #0d0d0d);
}

.qv-toggle-btn--active {
  background: var(--surface, #fff);
  color: var(--accent, #3f88a5) !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* ── Tooltip ─────────────────────────────────────────────────────────── */

.qv-info-tooltip-container {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.qv-info-icon {
  color: var(--accent, #3f88a5);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-3, #f0f9ff);
  transition: background 0.15s;
}

.qv-info-icon:hover {
  background: #e0f2fe;
}

.qv-info-tooltip {
  visibility: hidden;
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  background-color: #1e293b;
  color: #f8fafc;
  text-align: left;
  padding: 12px 14px;
  border-radius: 8px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  z-index: 1000;
  width: 260px;
  font-size: 11.5px;
  line-height: 1.5;
  opacity: 0;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  pointer-events: none;
}

.qv-info-tooltip p {
  margin: 0 0 6px 0;
}

.qv-info-tooltip p:last-child {
  margin: 0;
}

.qv-info-tooltip strong {
  color: #38bdf8;
}

/* Tooltip Arrow */
.qv-info-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: #1e293b transparent transparent transparent;
}

/* Show tooltip on hover */
.qv-info-tooltip-container:hover .qv-info-tooltip {
  visibility: visible;
  opacity: 1;
}

/* ── Partial-failure banner ────────────────────────────────────────────── */

.qv-partial {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid #fcd34d;
  background: #fffbeb;
  color: #92400e;
  font-family: var(--font-sans, "Inter", sans-serif);
}

.qv-partial__icon {
  display: inline-flex;
  flex-shrink: 0;
  color: #b45309;
}

.qv-partial svg {
  display: inline-block;
  flex-shrink: 0;
  vertical-align: middle;
}

.qv-partial__icon svg {
  width: 18px;
  height: 18px;
}

.qv-partial__retry svg {
  width: 14px;
  height: 14px;
}

@keyframes qv-partial-spin {
  to {
    transform: rotate(360deg);
  }
}

.qv-partial__spin {
  animation: qv-partial-spin 0.8s linear infinite;
}

.qv-partial__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  font-size: 13px;
}

.qv-partial__text strong {
  font-size: 13.5px;
  font-weight: 700;
}

.qv-partial__retry {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: auto;
  padding: 7px 16px;
  border-radius: 8px;
  border: 1px solid var(--accent, #3f88a5);
  background: var(--accent, #3f88a5);
  color: #fff;
  font-family: var(--font-sans, "Inter", sans-serif);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.qv-partial__retry:hover:not(:disabled) {
  background: #35748c;
}

.qv-partial__retry:focus-visible {
  outline: 2px solid var(--accent, #3f88a5);
  outline-offset: 2px;
}

.qv-partial__retry:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
