/* ==========================================================================
   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(--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-matrix .perm-check {
  border: 0;
  padding: 0;
  min-height: 0;
  background: none;
}

/* Level pickers inside the matrix stay narrow enough for a phone. */
.perm-matrix select {
  max-width: 116px;
}

/* The "every teacher, by default" card: one labelled picker per feature. */
.perm-defaults {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px 16px;
}

.perm-default {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 36px;
  font-size: 13px;
  color: var(--ink-2);
}

.perm-modules {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}

.perm-group {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 8px;
  border: 1px solid var(--rule);
  border-radius: 10px;
}

.perm-group legend {
  padding: 0 4px;
  font-size: 12px;
  color: var(--ink-3);
}

.perm-group .perm-check {
  border: 0;
  padding: 0 4px;
  min-height: 30px;
  background: none;
}

.perm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
