/* ==========================================================================
   IlmOS · sidebar.css
   The menu: a search box, Home, and one folding group per subject. The same
   markup (.side) sits in the desktop sidebar and in the phone sheet.
   ========================================================================== */

.side {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.rail .side {
  flex: 1;
}

/* The filter hides lines with [hidden]; the display rules below must not win. */
.side [hidden] {
  display: none !important;
}

/* ------------------------------------------------------------------ search */
.side__search {
  position: relative;
  display: flex;
  align-items: center;
  margin: 10px 10px 4px;
}

.side__search .icon {
  position: absolute;
  left: 11px;
  color: var(--rail-ink-3, var(--ink-3));
  pointer-events: none;
}

.side__search input {
  width: 100%;
  height: 38px;
  padding: 0 10px 0 34px;
  border: 1px solid var(--rail-rule, var(--rule));
  border-radius: 10px;
  background: var(--rail-surface-2, var(--surface-2));
  color: var(--rail-ink, var(--ink));
  font: inherit;
  font-size: 13.5px;
}

.side__search input:focus {
  outline: 2px solid var(--pine);
  outline-offset: -1px;
  background: var(--rail-bg, var(--surface));
}

/* -------------------------------------------------------------------- list */
.side__nav {
  flex: 1;
  overflow-y: auto;
  padding: 6px 10px 14px;
}

.side__home,
.side__head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 10px;
  border-radius: 10px;
  color: var(--rail-ink, var(--ink));
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.side__head::-webkit-details-marker {
  display: none;
}

.side__home .icon,
.side__head > .icon:first-child {
  color: var(--rail-ink-3, var(--ink-3));
  flex: 0 0 auto;
}

.side__title {
  flex: 1;
  min-width: 0;
}

.side__chevron {
  color: var(--rail-ink-3, var(--ink-3));
  transition: transform 0.15s ease;
}

.side__group[open] > .side__head .side__chevron {
  transform: rotate(180deg);
}

.side__group[open] > .side__head > .icon:first-child {
  color: var(--pine);
}

@media (hover: hover) {
  .side__home:hover,
  .side__head:hover {
    background: var(--rail-surface-2, var(--surface-2));
  }
}

.side__home.is-active {
  background: var(--rail-wash, var(--pine-wash));
  color: var(--rail-active-ink, var(--pine-ink));
}

.side__home.is-active .icon {
  color: var(--rail-active-icon, var(--pine));
}

/* The pages of a group hang off a thin line under its heading, so which group
   a page belongs to reads at a glance. */
.side__pages {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 2px 0 8px 19px;
  padding-left: 10px;
  border-left: 1px solid var(--rail-rule, var(--rule));
}

.side__link {
  display: block;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--rail-ink-2, var(--ink-2));
  font-size: 13.5px;
  line-height: 1.3;
}

@media (hover: hover) {
  .side__link:hover {
    background: var(--rail-surface-2, var(--surface-2));
    color: var(--rail-ink, var(--ink));
  }
}

.side__link.is-active {
  background: var(--rail-wash, var(--pine-wash));
  color: var(--rail-active-ink, var(--pine-ink));
  font-weight: 600;
}

.side__none {
  margin: 10px;
  color: var(--rail-ink-3, var(--ink-3));
  font-size: 13px;
}

/* Sheet (phone): bigger targets for a thumb. */
.sheet .side__search {
  margin: 0 0 8px;
}

.sheet .side__search input {
  height: 44px;
  font-size: 16px; /* 16px keeps iOS from zooming the page on focus */
}

.sheet .side__nav {
  padding: 0;
  overflow: visible;
}

.sheet .side__home,
.sheet .side__head {
  min-height: 48px;
  font-size: 15px;
}

.sheet .side__link {
  padding: 11px 12px;
  font-size: 15px;
}

/* ------------------------------------------------------------- phone bar */
button.tabs__tab {
  border: 0;
  background: none;
  font-family: inherit;
  cursor: pointer;
}

.topbar__search {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  color: var(--ink-2);
}

@media (min-width: 1024px) {
  /* The sidebar has its own search box. */
  .topbar__search {
    display: none;
  }
}

/* ------------------------------------------------------------ /search page */
.find-box {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 16px;
  padding: 6px 6px 6px 12px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--surface);
}

.find-box .icon {
  color: var(--ink-3);
  flex: 0 0 auto;
}

.find-box input {
  flex: 1;
  min-width: 0;
  height: 40px;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  outline: none;
}

.find-results {
  display: grid;
  gap: 14px;
}

.find-list {
  display: flex;
  flex-direction: column;
}

.find-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 4px;
  border-top: 1px solid var(--rule);
  color: var(--ink);
}

.find-row:first-child {
  border-top: 0;
}

.find-row span {
  color: var(--ink-3);
  font-size: 13px;
}

@media (hover: hover) {
  .find-row:hover strong {
    color: var(--pine);
  }
}

/* ------------------------------------------------------ Home quick actions */
.quick {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0 12px;
}

@media (min-width: 640px) {
  .quick {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.quick__btn {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 60px;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
  box-shadow: var(--lift-1);
}

.quick__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 11px;
  background: var(--pine-wash);
  color: var(--pine);
}

@media (hover: hover) {
  .quick__btn:hover {
    border-color: var(--pine);
  }
}

.quick__btn:active {
  transform: translateY(1px);
}

/* ------------------------------------------------- row Edit / Delete buttons */
.row-actions__delete {
  color: var(--bad, #b42318);
}

/* A row's quick edit: the Edit button opens a one-line form under it. */
.row-edit > summary {
  list-style: none;
}

.row-edit > summary::-webkit-details-marker {
  display: none;
}

.row-edit__form {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  max-width: 420px;
}

.row-edit__form .input {
  width: 96px;
  flex: 1 1 96px;
}

/* ---------------------------------------------------------- Permissions */
.perm-form {
  display: grid;
  gap: 10px;
}

/* A grid child grows to its widest content unless told otherwise: without
   this the class grid pushed the whole form past a phone's edge instead of
   scrolling inside its own box. */
.perm-form > *,
.perm-panel {
  min-width: 0;
}

.perm-subhead {
  margin: 8px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}

.perm-hint {
  margin: 0;
  font-size: 13px;
  color: var(--ink-3);
}

.perm-choice {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.perm-choice__item {
  flex: 1 1 140px;
}

.perm-choice__item,
.perm-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--surface);
  font-size: 14px;
  cursor: pointer;
}

.perm-choice__item:has(input:checked) {
  border-color: var(--pine);
  background: var(--pine-wash);
}

.perm-choice__item--tall {
  align-items: flex-start;
  padding: 8px 12px;
}

.perm-choice__item--tall > span {
  display: grid;
  gap: 2px;
}

.perm-choice__item--tall small {
  font-size: 12px;
  color: var(--ink-3);
}

/* One numbered step of the person form. */
.perm-step {
  display: grid;
  gap: 8px;
  padding: 12px 0;
  border-top: 1px solid var(--rule);
  min-width: 0;
}

.perm-step__title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  color: var(--ink);
}

/* The class list only matters for "Only the classes I tick". */
.perm-classes {
  display: none;
  gap: 8px;
}

.perm-form:has(input[name="scope"][value="pick"]:checked) .perm-classes {
  display: grid;
}

.perm-classes__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 6px;
}

.perm-feature-group {
  margin: 0;
  padding: 4px 12px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  min-width: 0;
}

.perm-feature-group legend {
  padding: 0 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* One feature: name on the left, Off · View only · Can work on the right. */
.perm-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--rule);
}

.perm-row:last-child {
  border-bottom: 0;
}

.perm-row__text {
  display: grid;
  gap: 1px;
  flex: 1 1 220px;
  min-width: 0;
}

.perm-row__name {
  font-size: 14px;
  font-weight: 550;
  color: var(--ink);
}

.perm-row__hint {
  font-size: 12.5px;
  color: var(--ink-3);
}

.perm-row__flag {
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--warn-wash);
  color: var(--warn);
  font-size: 11px;
  font-weight: 600;
  vertical-align: 1px;
}

.perm-seg {
  display: inline-flex;
  flex: 0 0 auto;
  border: 1px solid var(--rule-2);
  border-radius: 10px;
  overflow: hidden;
}

.perm-seg__item {
  position: relative;
  cursor: pointer;
}

.perm-seg__item + .perm-seg__item {
  border-left: 1px solid var(--rule-2);
}

.perm-seg__item input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}

.perm-seg__item span {
  display: block;
  padding: 7px 9px;
  font-size: 12.5px;
  line-height: 1.25;
  text-align: center;
  white-space: nowrap;
  color: var(--ink-2);
  background: var(--surface);
}

.perm-seg__item input:focus-visible + span {
  outline: 2px solid var(--pine);
  outline-offset: -2px;
}

.perm-seg__item[data-level="0"]:has(input:checked) span {
  background: var(--paper-2);
  color: var(--ink);
  font-weight: 600;
}

.perm-seg__item[data-level="1"]:has(input:checked) span {
  background: var(--info-wash);
  color: var(--info);
  font-weight: 600;
}

.perm-seg__item[data-level="2"]:has(input:checked) span {
  background: var(--ok-wash);
  color: var(--ok);
  font-weight: 600;
}

.perm-seg__item[data-level="3"]:has(input:checked) span {
  background: var(--warn-wash);
  color: var(--warn);
  font-weight: 600;
}

.perm-seg__item[data-level="4"]:has(input:checked) span {
  background: var(--bad-wash);
  color: var(--bad);
  font-weight: 600;
}

/* Five steps on a phone: one row of equal cells, the long names wrap. */
@media (max-width: 640px) {
  .perm-seg {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    width: 100%;
  }

  .perm-seg__item span {
    height: 100%;
    padding: 6px 3px;
    font-size: 11.5px;
    white-space: normal;
  }
}

.perm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
