/* Dashboard toolbar: search, sort, chart period, favorites, price popover, reset.
   One layout for all widths; it stays pinned at the top while scrolling the cards. */

.dash-toolbar {
  position: sticky;
  top: 10px;
  z-index: 40;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin: 0 0 16px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-strong);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

/* ---------- search ---------- */

.dash-search {
  position: relative;
  flex: 1 1 280px;
  max-width: 440px;
  display: flex;
  align-items: center;
}

.dash-search-icon {
  position: absolute;
  left: 11px;
  width: 16px;
  height: 16px;
  color: var(--ink-soft);
  pointer-events: none;
}

.dash-search input {
  width: 100%;
  height: 38px;
  padding: 0 64px 0 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(9, 12, 18, 0.5);
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

:root.light-theme .dash-search input {
  background: rgba(255, 255, 255, 0.9);
}

.dash-search input::placeholder {
  color: var(--ink-soft);
}

.dash-search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.dash-search .search-clear-btn {
  right: 32px;
}

.dash-search .search-clear-btn:disabled {
  visibility: hidden;
}

.dash-search .search-regex-info-wrap {
  position: absolute;
  right: 10px;
}

/* The help sits at the right edge now, so open the tooltip to the left. */
.dash-search .search-regex-tooltip {
  left: auto;
  right: -10px;
}

/* ---------- controls ---------- */

.dash-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
}

.dash-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.dash-field-label {
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.dash-field select,
.dash-custom-period select,
.dash-custom-period input {
  height: 34px;
  padding: 0 30px 0 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(9, 12, 18, 0.5)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath d='M2 4l3 3 3-3' fill='none' stroke='%239eb2cc' stroke-width='1.4'/%3E%3C/svg%3E")
    no-repeat right 10px center;
  color: var(--ink);
  font: inherit;
  font-size: 0.82rem;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

:root.light-theme .dash-field select,
:root.light-theme .dash-custom-period select,
:root.light-theme .dash-custom-period input {
  background-color: rgba(255, 255, 255, 0.9);
}

.dash-field select option,
.dash-custom-period select option {
  background: var(--surface-strong);
  color: var(--ink);
}

.dash-field select:focus-visible,
.dash-custom-period select:focus-visible,
.dash-custom-period input:focus-visible {
  outline: none;
  border-color: var(--accent);
}

/* Segmented control for the chart period */
.dash-seg {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(9, 12, 18, 0.5);
}

:root.light-theme .dash-seg {
  background: rgba(15, 23, 42, 0.05);
}

.dash-seg button {
  min-width: 38px;
  height: 26px;
  padding: 0 9px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.dash-seg button:hover {
  color: var(--ink);
}

.dash-seg button[aria-checked="true"] {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.dash-seg button:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 1px;
}

.dash-custom-period {
  display: inline-flex;
  gap: 6px;
}

.dash-custom-period[hidden] {
  display: none;
}

.dash-custom-period input {
  width: 64px;
  padding: 0 8px;
  background-image: none;
  cursor: text;
}

/* Chips: favorites + price */
.dash-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(9, 12, 18, 0.5);
  color: var(--ink);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

:root.light-theme .dash-chip {
  background: rgba(255, 255, 255, 0.9);
}

.dash-chip:hover {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
}

.dash-chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.dash-chip[aria-pressed="true"],
.dash-chip.is-active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}

#favoritesOnly[aria-pressed="true"] > span {
  color: #ffcb48;
}

.dash-chip-value {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.76rem;
  color: var(--accent);
}

.dash-chip-value:empty {
  display: none;
}

.dash-chip-caret {
  color: var(--ink-soft);
  font-size: 0.7rem;
}

/* Price popover */
.dash-popover-wrap {
  position: relative;
}

.dash-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 60;
  width: min(320px, calc(100vw - 32px));
  display: grid;
  gap: 10px;
  padding: 12px 14px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.dash-popover[hidden] {
  display: none;
}

.dash-reset {
  height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.dash-reset:hover {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}

.dash-reset[hidden] {
  display: none;
}

/* ---------- narrow screens: search full width, controls scroll sideways ---------- */

@media (max-width: 760px) {
  .dash-toolbar {
    top: 6px;
    padding: 8px;
    gap: 8px;
  }

  .dash-search {
    flex-basis: 100%;
    max-width: none;
  }

  .dash-controls {
    flex-wrap: nowrap;
    width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .dash-controls::-webkit-scrollbar {
    display: none;
  }

  .dash-controls > * {
    flex: 0 0 auto;
  }

  .dash-field-label {
    display: none;
  }

  /* The popover can't live inside a sideways-scrolling row: pin it under the toolbar. */
  .dash-popover-wrap {
    position: static;
  }

  .dash-popover {
    position: absolute;
    left: 8px;
    right: 8px;
    width: auto;
  }
}
