/* App shell: fixed sidebar, top bar, content column. */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: var(--space-5);
  padding: var(--space-4) var(--space-3);
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.sidebar__top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.sidebar__mark {
  display: inline-grid; place-items: center; width: 24px; height: 24px; flex: none;
  border-radius: var(--radius-sm); background: var(--accent); color: var(--accent-contrast); font-size: var(--text-sm);
}
.sidebar__brand {
  display: flex; align-items: center; gap: var(--space-2);
  padding: 0 var(--space-1);
  font-weight: 700; font-size: var(--text-md); letter-spacing: -0.02em;
  color: var(--text); text-decoration: none;
}

.sidebar__nav { display: flex; flex-direction: column; gap: 2px; }

.sidebar__link {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 6px var(--space-2);
  border-radius: var(--radius);
  color: var(--text-secondary); text-decoration: none;
  font-size: var(--text-sm); font-weight: 500;
}
.sidebar__link:hover { background: var(--surface-muted); color: var(--text); }
.sidebar__link[aria-current="page"] { background: var(--surface-muted); color: var(--text); }
.sidebar__link .icon { font-size: 16px; }
/* How many requests wait on you, beside Requests: plain, as it's there most days. */
.sidebar__count {
  margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--surface-muted); color: var(--text); font-size: var(--text-xs); font-weight: 600; text-align: center; font-variant-numeric: tabular-nums;
}
.sidebar__link[aria-current="page"] .sidebar__count { background: var(--surface); }

.sidebar__footer { margin-top: auto; }

/* Trash, at the end of the menu as an OS's sits at the end of its dock (issue #863): just above the person signed in. */
.sidebar__trash { display: flex; flex-direction: column; margin-top: auto; }
.sidebar__trash + .sidebar__user { margin-top: calc(var(--space-2) - var(--space-5)); }

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

.breadcrumbs ol { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); list-style: none; padding: 0; margin: 0; min-width: 0; }
.breadcrumbs li { display: flex; align-items: center; gap: var(--space-2); white-space: nowrap; }
.breadcrumbs li + li::before { content: "›"; color: var(--text-tertiary); }
.breadcrumbs a { color: var(--text-secondary); text-decoration: none; }
.breadcrumbs a:hover { color: var(--text); text-decoration: underline; }

/* The page's name and its actions. Actions that don't fit beside the name go on a line of their own, and the bar grows to hold them. */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-4);
  min-height: 56px; padding: var(--space-2) var(--space-6);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-page) 85%, transparent);
  backdrop-filter: blur(8px);
}

/* A link to a place on a page (a jurisdiction on Settings → Labor rules, a field to fill in) lands it below the
   sticky top bar, not under it. On a phone the bar scrolls away with the page, so there it needs no room. */
html { scroll-padding-top: calc(56px + var(--space-2)); }

.content { padding: var(--space-6); display: flex; flex-direction: column; gap: var(--space-6); }
.content--narrow { max-width: 640px; }

.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); }
.page-header p { color: var(--text-secondary); margin-top: var(--space-1); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.stack { display: flex; flex-direction: column; gap: var(--space-3); }
.stack--tight { gap: var(--space-1); }
.stack[hidden], .row[hidden] { display: none; }

/* A first-run guide: two ways to begin, side by side when there's room. */
.start-here { gap: var(--space-5); }
.start-here__choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--space-6); }
.start-here__choices > section + section { border-inline-start: 1px solid var(--border); padding-inline-start: var(--space-6); }
@media (max-width: 640px) {
  .start-here__choices > section + section { border-inline-start: 0; padding-inline-start: 0; border-top: 1px solid var(--border); padding-top: var(--space-5); }
}
.start-here__steps { display: flex; flex-direction: column; gap: var(--space-2); padding-inline-start: var(--space-5); margin: 0; color: var(--text-secondary); }
.start-here__steps--checklist { padding-inline-start: 0; list-style: none; color: var(--text); }
.start-here__steps--checklist li { display: flex; gap: var(--space-2); align-items: baseline; }
.start-here__steps--checklist .icon { flex: none; translate: 0 0.15em; color: var(--text-tertiary); }
.start-here__done { color: var(--text-tertiary); }
.start-here__done .icon { color: var(--success); }

/* A plain list of things with an action at the end of each: time off, requests… */
.list { list-style: none; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.list__item { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-4); }
.list__item + .list__item { border-top: 1px solid var(--border); }
/* A row that opens something: the whole row is the link. */
.list__item--link { position: relative; }
.list__item--link:hover { background: var(--surface-muted); }
.list__item--link > .icon { color: var(--text-tertiary); flex: none; }
.list__link { font-weight: 600; text-decoration: none; }
.list__link::after { content: ""; position: absolute; inset: 0; }
.row { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.row--end { align-items: flex-end; }
.row--between { justify-content: space-between; } /* a heading at one end, its actions at the other */
.row--right { justify-content: flex-end; }

/* Collapsed: an icon rail, labels hidden (link titles show them on hover) */
.app { transition: grid-template-columns .15s ease; }
[data-sidebar="collapsed"] .app { grid-template-columns: 56px 1fr; }
[data-sidebar="collapsed"] .sidebar { padding-inline: var(--space-2); align-items: center; }
[data-sidebar="collapsed"] .sidebar__label { display: none; }
[data-sidebar="collapsed"] .sidebar__top { flex-direction: column; }
[data-sidebar="collapsed"] .sidebar__link { justify-content: center; padding: 8px; position: relative; }
[data-sidebar="collapsed"] .sidebar__count { position: absolute; top: 0; right: 0; min-width: 16px; padding: 0 4px; font-size: 10px; line-height: 16px; }
[data-sidebar="collapsed"] .sidebar__footer { flex-direction: column; }
[data-sidebar="collapsed"] .sidebar__toggle .icon { transform: scaleX(-1); }

/* On a phone the sidebar gives way to the phone bar (layouts/_phonebar); the theme follows the phone's. */
.phonebar { display: none; }

@media (max-width: 768px) {
  .app, [data-sidebar="collapsed"] .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar { display: none; }
  .topbar, .content { padding-inline: var(--space-4); }
  /* A page's actions can take a few lines on a phone: they scroll away with the page, like the phone bar. */
  .topbar { position: static; }
  html { scroll-padding-top: 0; }

  .phonebar {
    position: relative; z-index: 20; display: flex; align-items: center; gap: var(--space-2);
    min-height: 52px; padding: var(--space-2) var(--space-4);
    border-bottom: 1px solid var(--border); background: var(--surface);
  }
  .phonebar .sidebar__brand { flex: none; }
  .phonebar__name { flex: 1; font-weight: 600; }
  .phonebar__links { display: flex; gap: 2px; flex: 1; min-width: 0; }
  .phonebar__links .sidebar__link { gap: 6px; padding: 6px; } /* snug, so the bell and the account fit beside them */
  .phonebar__account { flex: none; }
  .phonebar__menu summary { list-style: none; cursor: pointer; }
  .phonebar__menu summary::-webkit-details-marker { display: none; }
  .phonebar__panel {
    position: absolute; top: 100%; left: 0; right: 0;
    display: flex; flex-direction: column; gap: 2px; padding: var(--space-2) var(--space-3) var(--space-3);
    border-bottom: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-raised);
  }
  .phonebar__panel .sidebar__link { padding: 10px var(--space-3); font-size: var(--text-base, 1rem); }
  .phonebar__user { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin-top: var(--space-2); padding: var(--space-3) var(--space-3) 0; border-top: 1px solid var(--border); color: var(--text-secondary); font-size: var(--text-sm); }
  .phonebar__user form { display: contents; }
}

/* Agents' three pages are words alone on the narrowest phones (360 pixels is common on Android, 375 on a small
   iPhone), and the bar's gaps are tighter, so search, the bell and the account still fit beside them. */
@media (max-width: 400px) {
  .phonebar__links .sidebar__link .icon { display: none; }
  .phonebar { gap: var(--space-1); }
}

/* A quiet link at the foot of a page, like Trash's on the pages things are deleted from (issue #863). */
.page-foot { margin: 0; text-align: center; font-size: var(--text-sm); }
.page-foot a { display: inline-flex; align-items: center; gap: var(--space-1); color: var(--text-secondary); text-decoration: none; }
.page-foot a:hover { color: var(--text); text-decoration: underline; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }

.segmented {
  display: inline-flex; flex-wrap: wrap; padding: 2px; gap: 2px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.segmented__item {
  padding: 4px var(--space-3); border-radius: var(--radius-sm); white-space: nowrap;
  color: var(--text-secondary); text-decoration: none; font-size: var(--text-sm); font-weight: 500;
}
.segmented__item:hover { color: var(--text); background: var(--surface-muted); }
.segmented__item[aria-current="page"] { background: var(--accent); color: var(--accent-contrast); }

.panel {
  position: fixed; right: var(--space-5); bottom: var(--space-5); z-index: 20; width: 320px;
  padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3);
  background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-raised);
}
.panel[hidden] { display: none; }
.panel__facts { display: grid; grid-template-columns: auto 1fr; gap: var(--space-1) var(--space-4); font-size: var(--text-sm); }
.panel__facts dt { color: var(--text-secondary); }
.panel__facts dd { margin: 0; }

.sidebar__user {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
  margin-top: auto; padding: var(--space-2) var(--space-2) 0; border-top: 1px solid var(--border);
  font-size: var(--text-sm); color: var(--text-secondary);
}
.sidebar__account { color: inherit; text-decoration: none; }
.sidebar__account:hover { text-decoration: underline; }
.sidebar__user .sidebar__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar__user form { display: contents; }
.sidebar__user + .sidebar__footer { margin-top: var(--space-2); }
[data-sidebar="collapsed"] .sidebar__user { justify-content: center; padding-inline: 0; }

/* Who the install is licensed to (LA-10): small print under the person signed in. Where the sidebar's words don't
   show, collapsed or on a phone, it's at the foot of the page instead; on paper, a printed schedule's header has it. */
.sidebar__licensee, .main__licensee { font-size: var(--text-xs); line-height: var(--leading-xs); color: var(--text-tertiary); overflow-wrap: anywhere; }
.sidebar__licensee { margin-top: calc(var(--space-2) - var(--space-5)); padding-inline: var(--space-2); } /* just under the theme buttons, inside the sidebar's gap */
.sidebar__licensee span { display: inline-block; } /* a name too long for the line starts the next one, whole */
.main__licensee { display: none; margin-top: auto; padding: 0 var(--space-6) var(--space-4); }
@media screen {
  [data-sidebar="collapsed"] .main__licensee { display: block; }
}
@media screen and (max-width: 768px) {
  .main__licensee { display: block; padding-inline: var(--space-4); }
}

/* On paper, the page alone: no sidebar, bars or their column (here, after the shell's own rules, so these win). */
@media print {
  .app, .main { display: block; }
  .sidebar, .phonebar, .topbar { display: none; }
}
