/* Homeport App Shell
 * Shared layout: app-bar + persistent sidebar + viewport
 * Navy app-bar (56px), collapsible sidebar (280px expanded, 64px collapsed), 10px radius throughout.
 */

:root {
  --app-bar-height: 56px;
  --sidebar-width: 280px;
  --sidebar-width-collapsed: 64px;
}

/* === App Bar ===
   Navy fixed header with title (left) + logo (right). */
.app-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--app-bar-height);
  background: var(--sb-navy);
  display: flex; align-items: center; justify-content: space-between;
  /* Left inset is 12px, not the symmetric 16px the right side (logo) uses:
     the toggle button sits flush against this edge with no left margin of
     its own, and its icon needs to land at the same x as the collapsed
     sidebar rail's icon column below it -- that column centers a 24px icon
     in the 64px collapsed rail, i.e. at x=32. A 40px-wide toggle button
     centers its icon at (left-padding + 20px), so left-padding must be 12px
     for that to also land on x=32. Right side keeps the original 16px. */
  padding: 0 16px 0 12px;
  box-shadow: var(--sb-shadow-subtle);
}

.app-bar__title {
  font-family: var(--sb-font);
  font-size: var(--sb-fs-h3);
  font-weight: var(--sb-fw-bold);
  color: var(--sb-white);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

/* App-bar "currently tracking" indicator -- pulsing dot, hidden by default
   (JS shows it only while clocked in). Sits between the title and the
   logo; the title's flex:1 already pushes everything after it to the
   right edge, margin-right below just keeps clear space from the logo
   itself per the explicit "don't collide with the logo" requirement. */
.app-bar__tracking-indicator {
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 40px; height: 40px;
  margin-right: var(--sb-space-3);
  border-radius: var(--sb-radius);
  transition: background-color 150ms ease;
}

.app-bar__tracking-indicator:hover {
  background-color: rgba(255, 255, 255, .12);
}

.app-bar__tracking-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--sb-green);
  animation: app-bar-tracking-pulse 1.6s ease-in-out infinite;
}

/* Break state gets the same orange as the Kiosk break status dot, so the
   color language stays consistent between the two surfaces. */
.app-bar__tracking-indicator--break .app-bar__tracking-dot {
  background: var(--sb-orange);
}

@keyframes app-bar-tracking-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.35); }
}

@media (prefers-reduced-motion: reduce) {
  .app-bar__tracking-dot { animation: none; }
}

/* FR-37c-i: bell icon + badge + dropdown, sits left of
   .app-bar__tracking-indicator in the same header row. Wrap is the
   position:relative anchor for the dropdown below (so it opens "in place"
   under the bell, same idea as .sidebar__profile-btn's expand-in-place --
   but the positioning mechanics themselves are .sb-cal-popover's, the
   closer precedent for an absolutely-positioned overlay panel). */
.app-bar__notification-wrap {
  position: relative;
  flex-shrink: 0;
  margin-right: var(--sb-space-2);
}

.app-bar__notification-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 40px; height: 40px;
  padding: 0;
  background: none; border: none; cursor: pointer;
  -webkit-appearance: none; appearance: none;
  border-radius: var(--sb-radius);
  color: var(--sb-white);
  transition: background-color 150ms ease;
}

.app-bar__notification-btn:hover,
.app-bar__notification-btn.is-open {
  background-color: rgba(255, 255, 255, .12);
}

.app-bar__notification-icon {
  width: 24px; height: 24px;
  stroke: currentColor;
}

/* Count badge overlaying the bell's top-right corner -- var(--sb-radius),
   not a full circle: this app's CI rule is 10px everywhere, pill/fully-
   rounded shapes are reserved for the small named exception list (avatar,
   toggle switch), which this isn't. Hidden by default; JS shows/sets the
   text and toggles display none/flex based on unread count. */
.notification-badge {
  display: none;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 2px; right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--sb-radius);
  background: var(--sb-red);
  color: var(--sb-white);
  font-family: var(--sb-font);
  font-size: 10px;
  font-weight: var(--sb-fw-bold);
  line-height: 1;
}

/* Dropdown panel -- same positioning mechanics as .sb-cal-popover
   (day-list.css): absolute, anchored below its trigger, 10px radius,
   shadow, z-index 500. Anchored right (not left, .sb-cal-popover's
   default) since the bell sits near the app-bar's right edge -- a
   left-anchored panel here would overflow off-screen. */
.notification-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 500;
  width: 340px;
  max-width: calc(100vw - 32px);
  max-height: 420px;
  overflow-y: auto;
  background: var(--sb-surface);
  border: 1px solid var(--sb-border);
  border-radius: var(--sb-radius);
  box-shadow: 0 8px 28px rgba(20, 40, 59, 0.16);
  display: none;
}

.notification-dropdown.is-open { display: block; }

.notification-dropdown__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sb-space-3);
  padding: var(--sb-space-4);
  border-bottom: 1px solid var(--sb-border);
  position: sticky;
  top: 0;
  background: var(--sb-surface);
}

.notification-dropdown__title {
  font-family: var(--sb-font);
  font-size: var(--sb-fs-body);
  font-weight: var(--sb-fw-bold);
  color: var(--sb-fg-primary);
}

.notification-mark-all-read {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  color: var(--sb-cyan-dark);
  font-family: var(--sb-font);
  font-size: var(--sb-fs-caption);
  font-weight: var(--sb-fw-bold);
  transition: color 150ms ease;
}

.notification-mark-all-read:hover {
  color: var(--sb-cyan-darker);
}

.notification-list {
  display: flex;
  flex-direction: column;
}

.notification-row {
  display: flex;
  align-items: flex-start;
  gap: var(--sb-space-3);
  padding: var(--sb-space-3) var(--sb-space-4);
  cursor: pointer;
  border-bottom: 1px solid var(--sb-border);
  transition: background-color 150ms ease;
}

.notification-row:last-child { border-bottom: none; }

.notification-row:hover {
  background-color: var(--sb-light-grey);
}

.notification-row--unread {
  background-color: var(--sb-surface-alt);
}

.notification-row--unread:hover {
  background-color: var(--sb-light-grey);
}

.notification-row__unread-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
  background: transparent;
}

.notification-row--unread .notification-row__unread-dot {
  background: var(--sb-cyan-dark);
}

.notification-row__body {
  min-width: 0;
  flex: 1;
}

.notification-row__message {
  margin: 0 0 var(--sb-space-1) 0;
  font-family: var(--sb-font);
  font-size: var(--sb-fs-body);
  color: var(--sb-fg-primary);
  word-break: break-word;
}

.notification-row--unread .notification-row__message {
  font-weight: var(--sb-fw-bold);
}

.notification-row__time {
  margin: 0;
  font-family: var(--sb-font);
  font-size: var(--sb-fs-caption);
  color: var(--sb-fg-muted);
}

.notification-empty {
  padding: var(--sb-space-6) var(--sb-space-4);
  text-align: center;
  font-family: var(--sb-font);
  font-size: var(--sb-fs-body);
  color: var(--sb-fg-muted);
}

/* FR-37k-m / DESIGN_GUIDELINES.md §7a: inline confirm/reject actions on an
   actionable notification row (request_submitted/cancellation_requested,
   admin/manager recipients only). The pair sits below the message/time
   text, inside the row's own body -- there's no table structure here to
   give them a dedicated column, unlike the same .sb-icon-action pair on a
   table row elsewhere in the app. */
.notification-row__actions {
  display: flex;
  align-items: center;
  gap: var(--sb-space-2);
  margin-top: var(--sb-space-2);
}

/* §7a: post-action state -- the row stays, it does not disappear or
   auto-collapse (FR-37m). The button pair is replaced with this small
   inline "handled" label instead, reusing the same green/red semantic the
   buttons already carry. */
.notification-row__decision {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: var(--sb-space-2);
  font-family: var(--sb-font);
  font-size: var(--sb-fs-caption);
  font-weight: var(--sb-fw-bold);
}
.notification-row__decision svg { width: 14px; height: 14px; }
.notification-row__decision--confirm { color: var(--sb-green); }
.notification-row__decision--reject { color: var(--sb-red); }

@media (max-width: 480px) {
  .notification-dropdown { width: calc(100vw - 32px); }
}

.app-bar__logo {
  /* Wide lockup's aspect ratio (7070:1233) computes to ~184px wide at this
     height -- max-width must stay above that or the fixed height would
     force a squashed/distorted render instead of a proportional shrink. */
  height: 32px;
  width: auto;
  max-width: 200px;
  flex-shrink: 0;
}

/* App-bar toggle — leftmost control, icon-only, on the navy bar.
   Icon is WHITE to match .app-bar__title's convention (navy background). */
.app-bar__toggle {
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  width: 40px; height: 40px;
  margin-right: var(--sb-space-2);
  padding: 0;
  background: none; border: none; cursor: pointer;
  /* Every other icon-in-button in this app is a dark icon on a light
     surface; this is the first light icon on a dark one. Reset native
     button chrome explicitly rather than relying on background/color
     alone to fully override it -- some mobile browsers keep a faint
     native control tint under custom styles unless appearance is reset,
     which would wash out a light icon specifically. */
  -webkit-appearance: none; appearance: none;
  border-radius: var(--sb-radius);
  color: var(--sb-white);
  transition: background-color 150ms ease;
}

.app-bar__toggle:hover {
  background-color: rgba(255, 255, 255, .12);
}

.app-bar__toggle-icon {
  width: 24px; height: 24px;
  stroke: currentColor;
  transition: transform 200ms ease;
}

html.sidebar-collapsed .app-bar__toggle-icon {
  transform: rotate(180deg);
}

/* === Sidebar ===
   Persistent collapsible icon rail (64px when collapsed, 280px when expanded). */
.sidebar {
  /* Extends to the very top (z-index below the app-bar's, which paints
     over the overlap) rather than starting exactly at the app-bar's
     bottom edge -- avoids any sub-pixel seam between the two. Content
     still starts below the app-bar via padding-top. */
  position: fixed; top: 0; left: 0; bottom: 0;
  padding-top: var(--app-bar-height);
  width: var(--sidebar-width);
  background: var(--sb-white);
  z-index: 90;
  display: flex; flex-direction: column;
  box-shadow: var(--sb-shadow-subtle);
  transition: width 200ms ease;
}

html.sidebar-collapsed .sidebar {
  width: var(--sidebar-width-collapsed);
}

/* --- Sidebar Nav List --- */
.sidebar__nav {
  flex: 1; overflow-y: auto;
  padding: var(--sb-space-2) 0;
  display: flex; flex-direction: column; gap: 0;
}

.sidebar__item {
  display: flex; align-items: center; justify-content: flex-start;
  /* Margin + radius are unconditional, not hover/active-only: every row --
     selected, hovered, or plain -- sits in the exact same inset "pill" slot.
     Only background-color/font-weight change on interaction, never
     position. (Previously margin only appeared on :hover/.active, which
     shifted that row's icon var(--sb-space-2) right of every plain row's --
     visible as icons not lining up, worst in the collapsed rail where
     there's no label to hide it.) */
  margin: 0 var(--sb-space-2);
  padding: var(--sb-space-3);
  border-radius: var(--sb-radius);
  color: var(--sb-navy);
  text-decoration: none;
  font-family: var(--sb-font);
  font-size: var(--sb-fs-body);
  transition: background-color 150ms ease, color 150ms ease;
  position: relative;
  gap: var(--sb-space-3);
  min-height: 44px;
}

.sidebar__icon {
  width: 24px; height: 24px; flex-shrink: 0;
  stroke: currentColor; color: inherit;
}

.sidebar__label {
  white-space: nowrap;
  flex-shrink: 0;
}

html.sidebar-collapsed .sidebar__label {
  display: none;
}

/* Collapsed: no label, so center the lone icon in its pill slot instead of
   left-aligning it -- same margin/padding box as expanded, just centered
   content instead of flex-start. */
html.sidebar-collapsed .sidebar__item,
html.sidebar-collapsed .sidebar__profile-btn {
  justify-content: center;
}

.sidebar__item:hover {
  background-color: var(--sb-light-grey);
}

.sidebar__item.active {
  background-color: var(--sb-cyan-dark);
  color: var(--sb-white);
  font-weight: var(--sb-fw-bold);
}

/* --- Sidebar Footer (profile + toggle) --- */
.sidebar__footer {
  flex-shrink: 0;
  border-top: 1px solid var(--sb-semi-light);
  padding: var(--sb-space-2) 0;
  display: flex; flex-direction: column;
}

.sidebar__profile-btn {
  display: flex; align-items: center; justify-content: flex-start;
  margin: 0 var(--sb-space-2);
  width: calc(100% - 2 * var(--sb-space-2));
  padding: var(--sb-space-3);
  border-radius: var(--sb-radius);
  background: none; border: none; cursor: pointer;
  color: var(--sb-navy);
  font-family: var(--sb-font);
  font-size: var(--sb-fs-body);
  transition: background-color 150ms ease, color 150ms ease;
  position: relative;
  gap: var(--sb-space-3);
  min-height: 44px;
}

.sidebar__profile-btn:hover,
.sidebar__profile-btn:active {
  background-color: var(--sb-light-grey);
}

/* Profile button is only a trigger for the collapsed state -- it replaces
   the full name/email/logout block, it doesn't sit alongside it. */
html:not(.sidebar-collapsed) .sidebar__profile-btn {
  display: none;
}

.sidebar__profile-info {
  display: none;
  padding: var(--sb-space-4) var(--sb-space-4);
}

html:not(.sidebar-collapsed) .sidebar__profile-info {
  display: block;
}

/* Row wrapper: avatar to the left, name+email stacked to its right.
   "Passwort ändern" and the logout form stay siblings of this wrapper
   (below it), not part of the row. */
.sidebar__profile-header {
  display: flex;
  align-items: center;
  gap: var(--sb-space-3);
  margin-bottom: var(--sb-space-3);
}

/* NF-12a: an avatar (initials now, a profile photo later) is always
   circular -- a deliberate, explicitly-requested exception to this app's
   "no pill/fully-rounded shapes" CI rule, same category of exception as
   the toggle-switch component and the Kiosk avatar. Sized to
   --sb-touch-min (44px) to match .kiosk-avatar exactly -- same role
   (initials avatar), same size everywhere it appears. */
.sidebar__avatar {
  width: var(--sb-touch-min);
  height: var(--sb-touch-min);
  border-radius: 50%;
  background: var(--sb-navy);
  color: var(--sb-white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--sb-font);
  font-weight: var(--sb-fw-bold);
  font-size: var(--sb-fs-label);
  flex-shrink: 0;
}

.sidebar__profile-text {
  min-width: 0;
}

.sidebar__profile-name {
  font-family: var(--sb-font);
  font-size: var(--sb-fs-body);
  font-weight: var(--sb-fw-bold);
  color: var(--sb-navy);
  margin: 0 0 var(--sb-space-1) 0;
}

.sidebar__profile-email {
  font-family: var(--sb-font);
  font-size: var(--sb-fs-caption);
  color: var(--sb-fg-body);
  margin: 0;
  word-break: break-word;
}

.sidebar__profile-link {
  display: block;
  padding: var(--sb-space-2) 0;
  color: var(--sb-cyan-dark);
  text-decoration: none;
  font-family: var(--sb-font);
  font-size: var(--sb-fs-body);
  transition: color 150ms ease;
  margin-bottom: var(--sb-space-2);
}

.sidebar__profile-link:hover {
  color: var(--sb-cyan-darker);
}

.sidebar__logout-form {
  margin: 0;
}

.sidebar__logout-btn {
  width: 100%;
  background: var(--sb-purple);
  color: var(--sb-white);
  border: none;
  border-radius: var(--sb-radius);
  padding: var(--sb-space-3) var(--sb-space-4);
  font-family: var(--sb-font);
  font-size: var(--sb-fs-body);
  font-weight: var(--sb-fw-bold);
  cursor: pointer;
  transition: background-color 150ms ease;
}

.sidebar__logout-btn:hover {
  background-color: var(--sb-purple-dark);
}

/* === Main Content Area ===
   Offset from sidebar width. Transitions smoothly when sidebar collapses. */
.app-content {
  margin-top: var(--app-bar-height);
  margin-left: var(--sidebar-width);
  min-height: calc(100vh - var(--app-bar-height));
  position: relative;
  z-index: 1;
  transition: margin-left 200ms ease;
}

html.sidebar-collapsed .app-content {
  margin-left: var(--sidebar-width-collapsed);
}

/* === Buttons ===
   Primary (purple), cyan variant (dark-cyan for light surfaces), ghost (transparent border). */
.sb-btn {
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--sb-font); font-weight: var(--sb-fw-bold);
  font-size: var(--sb-fs-label);
  color: var(--sb-white);
  background: var(--sb-purple);
  border: none;
  border-radius: var(--sb-radius);
  cursor: pointer;
  padding: 12px 24px;
  line-height: 1;
  text-decoration: none;
  transition: background-color 150ms ease;
  letter-spacing: 0;
}

.sb-btn:hover {
  background-color: var(--sb-purple-dark);
}

.sb-btn:active {
  background-color: var(--sb-purple-xdark);
}

/* Cyan variant — uses dark-cyan for AA contrast on light surfaces. */
.sb-btn--cyan {
  background: var(--sb-cyan-dark);
  color: var(--sb-white);
}

.sb-btn--cyan:hover {
  background-color: var(--sb-cyan-darker);
}

/* Ghost variant — transparent background, border-based. */
.sb-btn--ghost {
  background: transparent;
  color: var(--sb-navy);
  border: 1px solid var(--sb-semi-light);
}

.sb-btn--ghost:hover {
  background-color: var(--sb-light-grey);
}

/* === Icon Action Buttons ===
   Confirm / reject / withdraw actions on a row are ALWAYS icon-only (check
   / x), never a text-labeled button -- saves horizontal space in dense
   tables and gives one consistent visual vocabulary for "this
   bestätigt/genehmigt something" vs "this ablehnt/zurückzieht something"
   everywhere in the app. Use this pattern for EVERY future confirm/reject/
   withdraw action, not just vacation approvals. The correct verb
   (Genehmigen vs. Bestätigen for Krankheit, Ablehnen, Zurückziehen) still
   goes in `title`/`aria-label` -- never drop the accessible name just
   because the visual label is icon-only. (Benjamin, 2026-07-10 feedback)
*/
.sb-icon-action {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  padding: 0;
  background: none;
  border: 1px solid var(--sb-semi-light);
  border-radius: var(--sb-radius);
  cursor: pointer;
  -webkit-appearance: none; appearance: none;
  transition: background-color 150ms ease, border-color 150ms ease;
}
.sb-icon-action svg { width: 18px; height: 18px; stroke: currentColor; }

.sb-icon-action--confirm { color: var(--sb-green); }
.sb-icon-action--confirm:hover { background-color: rgba(8, 189, 128, .1); border-color: var(--sb-green); }

.sb-icon-action--reject { color: var(--sb-red); }
.sb-icon-action--reject:hover { background-color: rgba(214, 30, 92, .1); border-color: var(--sb-red); }

.sb-icon-action--withdraw { color: var(--sb-fg-muted); }
.sb-icon-action--withdraw:hover { background-color: var(--sb-light-grey); border-color: var(--sb-fg-muted); }

/* === Responsive ===
   Below this width there isn't room for a 280px sidebar to push content
   over (would leave ~100px for the page on a typical phone). Content
   always stays offset by the collapsed width; "expanding" becomes an
   overlay on top of the content instead of pushing it. */
@media (max-width: 768px) {
  .app-content {
    margin-left: var(--sidebar-width-collapsed) !important;
  }

  html:not(.sidebar-collapsed) .sidebar {
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.2);
  }

  /* Criterion 3 (DESIGN_GUIDELINES.md §12): 44x44 minimum tap target at
     Phone/Tablet tiers. These were 40x40 (app-bar toggle/bell) or 32x32
     (icon-action/text buttons' min-size) at Desktop -- unchanged there. */
  .app-bar__toggle,
  .app-bar__notification-btn {
    width: var(--sb-touch-min);
    height: var(--sb-touch-min);
  }

  .sb-btn,
  .sb-btn--ghost {
    min-height: var(--sb-touch-min);
    min-width: var(--sb-touch-min);
  }

  .sb-icon-action {
    width: var(--sb-touch-min);
    height: var(--sb-touch-min);
  }
}

/* DESIGN_GUIDELINES.md §12: the one horizontal-scroll wrapper convention for
   any table. Defined once here (not per-template) as a deliberate, named
   one-time exception to §10a's "no-shared-CSS-file" convention -- this class
   has zero legitimate per-page variation and app-shell.css is already
   unconditionally loaded on every non-admin page. Not precedent for moving
   other shared components here. */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
