@import url("/procore-tokens.css");

/*
 * The page shell, in the same language as the other Knight Procore add-ons
 * (Programme to Forecast): a white sticky top bar, a bordered white toolbar,
 * grey secondary buttons, Procore-orange focus and selection, 2px inputs.
 * Everything is expressed in procore-tokens.css.
 */

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

/* Component display rules (flex) would otherwise defeat the hidden attribute. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: var(--pc-font);
  font-size: var(--pc-font-size);
  font-weight: var(--pc-font-weight);
  line-height: 1.35;
  color: var(--pc-text);
  background: var(--pc-surface);
}

button,
input,
select {
  font: inherit;
}

a {
  color: var(--pc-link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Shell -------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  min-height: 60px;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 1px solid var(--pc-rule);
  background: var(--pc-surface);
}

.topbar h1 {
  margin: 0;
  font-size: var(--pc-h1-size);
  font-weight: var(--pc-h1-weight);
  line-height: var(--pc-h1-line);
}

.subtitle {
  margin: 2px 0 0;
  color: var(--pc-text-muted);
  font-size: var(--pc-font-size-small);
}

.workspace {
  padding: 16px 16px 48px;
}

/* Controls ----------------------------------------------------------- */

/* Procore's secondary button: grey, semibold, 4px corners. */
button {
  min-height: var(--pc-control-height);
  padding: 7px 12px;
  border: 0;
  border-radius: var(--pc-radius);
  color: var(--pc-button-text);
  background: var(--pc-button-bg);
  font-size: var(--pc-font-size);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

button:hover {
  background: var(--pc-button-hover);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.primary {
  color: #fff;
  background: var(--pc-orange);
}

button.primary:hover {
  background: var(--pc-orange-dark);
}

/* Tertiary: text only, for the quiet "Clear filters". */
button.tertiary {
  color: var(--pc-orange-dark);
  background: transparent;
}

button.tertiary:hover {
  background: var(--pc-orange-wash);
}

input,
select {
  min-height: var(--pc-control-height);
  padding: 0 8px;
  border: 1px solid var(--pc-border);
  border-radius: var(--pc-input-radius);
  color: var(--pc-text);
  background: var(--pc-surface);
}

input[type="checkbox"] {
  min-height: 0;
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--pc-orange);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--pc-focus);
  outline-offset: 1px;
}

/* Toolbar ------------------------------------------------------------ */

.toolbar {
  position: sticky;
  top: 60px;
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 8px;
  border: 1px solid var(--pc-rule);
  background: var(--pc-surface);
}

.toolbar .spacer {
  flex: 1;
}

.search-wrap {
  display: flex;
  min-width: 260px;
  min-height: var(--pc-control-height);
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid var(--pc-border);
  border-radius: var(--pc-input-radius);
  background: var(--pc-surface);
}

.search-wrap:focus-within {
  outline: 2px solid var(--pc-focus);
  border-color: var(--pc-orange);
}

.search-wrap > span {
  color: var(--pc-text-faint);
  font-size: 20px;
  line-height: 1;
}

.search-wrap input {
  width: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  outline: 0;
}

/* A toggle button: grey off, orange-washed with an orange edge when on. */
button.toggle[aria-pressed="true"] {
  color: var(--pc-orange-dark);
  background: var(--pc-orange-wash);
  box-shadow: inset 0 0 0 1px var(--pc-orange);
}

/* Segmented control, as Procore's Programming tool zooms. */
.segmented {
  display: inline-flex;
  padding: 2px;
  border-radius: var(--pc-radius);
  background: var(--pc-surface-header);
}

.segmented button {
  min-height: calc(var(--pc-control-height) - 4px);
  padding: 4px 12px;
  background: transparent;
  color: var(--pc-text-muted);
}

.segmented button:hover {
  color: var(--pc-text);
  background: transparent;
}

.segmented button[aria-pressed="true"] {
  color: var(--pc-text);
  background: var(--pc-surface);
  box-shadow: 0 1px 2px rgb(35 39 41 / 20%);
}

/* Filter menus: a secondary button that drops a checkbox list. -------- */

.filter-menu {
  position: relative;
}

.filter-menu > summary {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: var(--pc-control-height);
  padding: 7px 10px 7px 12px;
  border-radius: var(--pc-radius);
  background: var(--pc-button-bg);
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  list-style: none;
}

.filter-menu > summary:hover {
  background: var(--pc-button-hover);
}

.filter-menu > summary::-webkit-details-marker {
  display: none;
}

/* A chevron drawn in CSS, as Procore's dropdowns have, not a text glyph. */
.filter-menu > summary::after {
  content: "";
  width: 6px;
  height: 6px;
  margin: -3px 2px 0 2px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}

.filter-menu[open] > summary::after {
  margin-top: 3px;
  transform: rotate(-135deg);
}

.filter-menu .count:empty {
  display: none;
}

/* An applied filter: the count shows in an orange chip. */
.filter-menu .count {
  padding: 0 6px;
  border-radius: 9px;
  color: #fff;
  background: var(--pc-orange);
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
}

.filter-menu.active > summary {
  color: var(--pc-orange-dark);
  background: var(--pc-orange-wash);
}

.filter-body {
  position: absolute;
  z-index: 50;
  top: calc(var(--pc-control-height) + 4px);
  left: 0;
  min-width: 260px;
  max-height: 360px;
  overflow-y: auto;
  padding: 4px 0;
  border: 1px solid var(--pc-border);
  border-radius: var(--pc-radius);
  background: var(--pc-surface);
  box-shadow: var(--pc-shadow-pop);
}

.filter-option {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 6px 12px;
  cursor: pointer;
}

.filter-option:hover {
  background: var(--pc-orange-wash);
}

/* States ------------------------------------------------------------- */

.empty-state {
  display: flex;
  min-height: 140px;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 30px;
  border: 1px dashed var(--pc-border);
  color: var(--pc-text-muted);
}

/* Side-panel width: the toolbar stacks, the search takes the full row. */
@media (max-width: 480px) {
  .topbar {
    min-height: 0;
    padding: 8px 10px;
  }

  .topbar h1 {
    font-size: 18px;
    line-height: 24px;
  }

  .workspace {
    padding: 10px;
  }

  .toolbar {
    position: static;
  }

  .search-wrap {
    min-width: 0;
    flex: 1 0 100%;
  }

  .toolbar .spacer,
  #expand-all,
  #collapse-all {
    display: none;
  }
}
