/* Project-only CSS — daisyUI first, this file fills the gaps. Keep it small;
   component classes belong in the markup, not here. */

/* Edge-to-edge: Android 15+ forces it for targetSdk 35+, so the WebView draws
   under the status bar and the gesture bar. viewport-fit=cover in index.html
   is what makes env() resolve here — without it the insets are all zero.
   The Capacitor SystemBars plugin injects the real values as
   --safe-area-inset-* (its "css" insetsHandling, the default): on WebViews
   older than 140 env() stays 0 and the plugin pads natively, so the injected
   variables are the reliable source. env() is the fallback for the browser
   and for iOS. */
:root {
  --app-safe-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
  --app-safe-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
  --app-navbar-height: 4rem;
  /* The docked activities panel's width — the panel's max-width and the
     drawer content's strip margin read the same value, so the two cannot
     drift apart. */
  --app-activities-width: 30rem;
  /* The height a full-height page gets: the viewport minus the chrome — the
     navbar (which grows by the status bar inset) and main's padding. A page
     that uses it scrolls inside, not the window. */
  --app-content-height: calc(100dvh - var(--app-navbar-height) - 2rem - var(--app-safe-top) - var(--app-safe-bottom));
}

/* Below the lg breakpoint main's padding is p-3, not p-4. */
@media (width < 64rem) {
  :root {
    --app-content-height: calc(100dvh - var(--app-navbar-height) - 1.5rem - var(--app-safe-top) - var(--app-safe-bottom));
  }
}

/* daisyUI's navbar carries .5rem padding of its own — keep it, add the inset. */
.navbar {
  padding-top: calc(var(--app-safe-top) + 0.5rem);
}

/* The toast sits just under the system bar, not over the navbar's controls:
   narrow and centred, so the menu button and the right-hand buttons stay
   reachable. */
.toast-top {
  top: calc(var(--app-safe-top) + 0.5rem);
  max-width: 24rem;
}

/* The info toast wears the app's own colour — daisy's cyan reads as a
   different product next to the primary blue. */
.alert-info {
  background-color: var(--color-primary);
  color: var(--color-primary-content);
}

/* The slide-out menu starts at the very top — under the status bar. */
.drawer-side aside {
  padding-top: var(--app-safe-top);
}

/* The nav sidebar's scrollbar shows only while the pointer is on the menu:
   the menu column scrolls, and its permanent scrollbar sat exactly under
   the sale page's flush status frame and action bar — a second seam. The
   menu still scrolls by wheel and touch; an old Safari without
   scrollbar-width simply keeps the bar. */
.drawer-side {
  scrollbar-width: none;
}

.drawer-side:hover {
  scrollbar-width: thin;
}

/* The last row of a table must clear the gesture bar. */
.drawer-content main {
  padding-bottom: calc(1rem + var(--app-safe-bottom));
}

/* Full-bleed pages without the navbar (the login card). */
.safe-area-y {
  padding-top: var(--app-safe-top);
  padding-bottom: var(--app-safe-bottom);
}

/* Number fields carry no spinner arrows — the values are typed or scanned,
   the arrows only stole width in the dense table inputs. The keyboard's
   ↑/↓ keep working; this hides the mouse buttons (Firefox needs the
   textfield appearance, the rest the two pseudo-elements). */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* While a category is dragged, the rows ignore the pointer: the drag events
   then belong to the row itself, so the offset of the pointer is the
   position inside the row — the top and the bottom quarter move the category
   before or after the target, the middle makes it a child. */
.tree.dragging li > div > * {
  pointer-events: none;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-head h1 {
  font-size: 1.25rem;
  font-weight: 600;
}

.page-head p {
  margin: 0;
  font-size: 0.875rem;
  opacity: 0.65;
}

/* The sticky foot of a detail page (PageFoot): it breaks out of main's
   padding on both sides, cancels main's bottom padding (1rem + safe area)
   and carries the safe-area inset itself, so the bar — not blank space —
   sits on the bottom edge. The auto top margin pushes it down on short
   pages (the page root should be flex-col min-h-full for that), and once
   the content is taller than the viewport, sticky keeps it pinned while
   scrolling. Below the navbar (z-30) and the modals (z-40). */
.action-bar {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: auto -0.75rem calc(-1rem - var(--app-safe-bottom));
  padding: 0.75rem;
  padding-bottom: calc(0.75rem + var(--app-safe-bottom));
  border-top: 1px solid var(--color-base-300);
  background: var(--color-base-100);
}

@media (min-width: 64rem) {
  .action-bar {
    margin-left: -1rem;
    margin-right: -1rem;
    padding-left: 1rem;
    padding-right: 1rem;
  }
}

.table-wrap {
  border: 1px solid var(--color-base-300);
  border-radius: var(--radius-box);
  background: var(--color-base-100);
  overflow-x: auto;
}

table.admin {
  width: 100%;
  font-size: 0.875rem;
  border-collapse: collapse;
}

table.admin th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  background: var(--color-base-200);
  font-weight: 500;
  white-space: nowrap;
  opacity: 0.7;
}

table.admin td {
  padding: 0.5rem 0.75rem;
  border-top: 1px solid var(--color-base-200);
  vertical-align: middle;
}

table.admin tbody tr:hover {
  background: color-mix(in oklab, var(--color-base-200) 60%, transparent);
}

table.admin .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8125rem;
}

.delta-pos {
  color: var(--color-success);
}

.delta-neg {
  color: var(--color-error);
}

/* Sidebar menu on bg-primary: keep links readable on the brand colour. */
.menu li > a,
.menu li > details > summary {
  color: color-mix(in oklab, var(--color-primary-content) 85%, transparent);
  border-radius: var(--radius-field);
}

.menu li > a:hover,
.menu li > details > summary:hover {
  background: color-mix(in oklab, var(--color-primary-content) 15%, transparent);
  color: var(--color-primary-content);
}

.menu li > a.menu-active {
  background: color-mix(in oklab, var(--color-primary-content) 20%, transparent);
  color: var(--color-primary-content);
}

/* The statistics table carries three numbers per cell — keep the rows
   compact and the month column narrow. */
table.admin.compact td {
  padding: 0.25rem 0.6rem;
}

table.admin.compact td.month,
table.admin.compact th.month {
  width: 2.6rem;
  font-size: 0.75rem;
  opacity: 0.55;
}

h1:focus {
  outline: none;
}

/* The plain buttons of the app have no theme of their own — the browser
   would draw a black box around them when the keyboard reaches one (the
   names and the icons of the category tree, the items of the transfer
   page). The daisyUI buttons keep their own ring; a blue ring on a blue
   "primary" button would not be visible anyway. */
button:not(.btn):focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}

/* The version line in the sidebar sits on the brand colour — a blue ring on
   a blue background would not be visible. */
.drawer-side aside button:not(.btn):focus-visible {
  outline-color: var(--color-primary-content);
}

/* The item list's hover preview: a quick fade once it appears — the 300 ms
   hover-intent delay lives in the component (Items.razor.cs). */
.zoom-preview {
  animation: zoom-preview-in 0.15s ease;
}

@keyframes zoom-preview-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* The rows of the admin tables: the same hover everywhere, and one shared
   "selected" tint for the tables with selectable rows (the item list's
   multi-select, the supplier picker). Both read the theme's tokens, so the
   dark theme shades itself. */
table.admin tbody tr:hover {
  background-color: var(--color-base-200);
}

table.admin tbody tr.row-selected {
  background-color: color-mix(in oklab, var(--color-primary) 25%, transparent);
}

/* The Mindestbestand tab's flag — the old V1 app's warning tint on the rows
   whose article is already on the way in (Bestellt > 0). A tint of the
   theme's warning token, so the dark theme shades itself. */
table.admin tbody tr.ordered-warning {
  background-color: color-mix(in oklab, var(--color-warning) 15%, transparent);
}

/* The list rows' status line — the sale and the order overview: the old V1
   app's coloured bar on the row edge (green = closed/completed, amber =
   billed/ordered, red = open). An inset shadow instead of a border: the rows
   are a collapsed table, so a border would shift the cells, and the shadow
   survives the hover tint. The colours are the theme's tokens, so the dark
   theme shades itself. */
table.admin tbody tr.row-status-green {
  box-shadow: inset 4px 0 0 var(--color-success);
}

table.admin tbody tr.row-status-amber {
  box-shadow: inset 4px 0 0 var(--color-warning);
}

table.admin tbody tr.row-status-red {
  box-shadow: inset 4px 0 0 var(--color-error);
}

/* The detail pages' status ribbon — the sale and the order: the old V1
   frame's top edge, kept as the rounded top border of the content area: a
   4px line under the navbar whose ends bend down over 8px (the sale: green =
   closed, orange = billed, red = open; the order: green = completed, orange =
   ordered, red = open). It takes no clicks and stays visible while the page
   scrolls; the pill in the page's head names the state. From the lg
   breakpoint its left edge sits at the nav sidebar's. z-40 keeps it over the
   page's own fixed layers (the docked activities panel z-30, the action bar
   z-35) but under the navbar (z-50): the global search hangs out of the
   navbar, and its box and dropdown must paint over the band, not under it. */
.status-ribbon {
  position: fixed;
  top: calc(var(--app-navbar-height) + var(--app-safe-top));
  right: 0;
  left: 0;
  height: 8px;
  border-top: 4px solid transparent;
  border-radius: 8px 8px 0 0;
  z-index: 40;
  pointer-events: none;
}

@media (min-width: 64rem) {
  .status-ribbon {
    left: 16rem;
  }
}

.status-ribbon.status-green {
  border-top-color: var(--color-success);
}

.status-ribbon.status-amber {
  border-top-color: var(--color-warning);
}

.status-ribbon.status-red {
  border-top-color: var(--color-error);
}

/* The detail pages with a docked activities panel (detail-fixed-bar):
   their action bar is fixed, not sticky — always at the bottom edge, over
   the full width, the content scrolls underneath. Sticky cannot do it
   there: mid-scroll the bar's slot slides under the fixed activities
   panel's column (the panel docks at the right edge from xl and is always
   visible) and the panel covers its buttons. With the bar pinned, the
   panel ends above it instead. The safe-area inset rides in the bar's own
   bottom padding, so the bar touches the window's bottom edge. From the lg
   breakpoint it starts at the nav sidebar's edge. */
.detail-fixed-bar .action-bar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 35;
  margin: 0;
  padding: 8px 12px calc(8px + var(--app-safe-bottom));
}

/* The page reserves the bar's height plus a small gap at its bottom: the
   button row (2rem) plus the bar's own padding (16px) plus the safe-area
   inset, plus one rem of air — the last box ends just above the bar's top
   edge, and never under it. The rule lives here, beside the bar's own
   metrics, instead of a padding utility on every page's root. The root must
   not shrink (flex-shrink): a shrunk root keeps the window's height while
   its content overflows it, and then the padding lies inside the content and
   reserves nothing. */
.detail-fixed-bar {
  padding-bottom: calc(3rem + 16px + var(--app-safe-bottom));
}

/* The left action zone scrolls sideways when its buttons do not fit. Its
   scrollbar would grow the bar by its own height and break the reservation
   above, so it is hidden — the cut-off button at the zone's edge is the cue
   that more is there. The rule reaches the zone's inner scroll container
   too (the pages wrap their buttons in one). */
.action-bar-left,
.action-bar-left * {
  scrollbar-width: none;
}

.action-bar-left::-webkit-scrollbar,
.action-bar-left *::-webkit-scrollbar {
  display: none;
}

@media (min-width: 64rem) {
  .detail-fixed-bar .action-bar {
    left: 16rem;
  }
}

.detail-fixed-bar .activities-panel-host {
  bottom: calc(var(--app-safe-bottom) + 3.6rem);
}

/* The item page's activities panel — the old BackOffice's activities
   sidebar (Aufgaben, Aktivitäten, Systemaktivitäten). Small screens: a
   slide-over from the right, hidden until the bottom bar's toggle shows it
   (the .show class). Wide screens (from 96rem — Tailwind's 2xl): docked as
   the full-height column at the right edge, visible until the bottom bar's
   toggle hides it (the .hide class) — the page's root carries the
   .activities-strip marker and the rule below reserves the strip for it,
   the transition switches itself off. The cards tint themselves from the
   theme's tokens, so the dark theme shades itself. */
.activities-panel-host {
  position: fixed;
  top: calc(var(--app-navbar-height) + var(--app-safe-top));
  right: 0;
  bottom: 0;
  z-index: 30;
  width: 100%;
  max-width: var(--app-activities-width);
  overflow-y: auto;
  border-left: 1px solid var(--color-base-300);
  background: var(--color-base-200);
  box-shadow: -8px 0 24px rgb(0 0 0 / 0.12);
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 0.25s ease-out, visibility 0.25s;
}

.activities-panel-host.show {
  transform: translateX(0);
  visibility: visible;
}

@media (min-width: 96rem) {

  .activities-panel-host,
  .activities-panel-host.show {
    transform: none;
    visibility: visible;
    box-shadow: none;
    transition: none;
  }

  /* The docked panel can be hidden too — the page's remembered choice (its
     foot toggle) then frees the strip for the content. The rule comes
     after the one above, so it wins over the always-visible rule. */
  .activities-panel-host.hide,
  .activities-panel-host.hide.show {
    transform: translateX(100%);
    visibility: hidden;
  }

  /* Docked, the panel is a full-height side column: it starts at the
     viewport's top edge (only the status-bar inset stays above it), so the
     navbar — which ends at the panel's left edge, see the strip rule
     below — hands the whole right side over to it. The slide-over below
     2xl keeps its place under the navbar. */
  .activities-panel-host {
    top: var(--app-safe-top);
  }

  /* The docked panel covers the viewport's right edge — exactly where the
     drawer content's scrollbar sits, so the thumb hid behind the panel.
     While a page's root carries the .activities-strip marker (the dock is
     open — ActivitiesPageBase puts it there), the scroll container narrows
     by the strip instead of the page: its scrollbar then ends at the
     panel's left edge and stays reachable — and the navbar narrows with
     the container, so its bottom border stops at the panel instead of
     drawing across it. The :has() needs a modern browser — without it the
     scrollbar simply hides behind the panel like before, nothing
     breaks. */
  .drawer-content:has(> main > .activities-strip) {
    margin-right: var(--app-activities-width);
  }

  /* The status-ribbon (the state band under the navbar on Sale and Order)
     is fixed to the viewport's edges with z-40 — above the panel — and
     would draw straight across the docked column. The same condition pulls
     its right end to the panel's left edge, so everything left of the
     panel ends at one line: navbar border, scrollbar, ribbon. */
  .drawer-content:has(> main > .activities-strip) .status-ribbon {
    right: var(--app-activities-width);
  }
}

.activity-card {
  display: grid;
  grid-template-columns: 1fr 2.4rem;
  border-radius: var(--radius-box);
  overflow: hidden;
}

.activity-card + .activity-card {
  margin-top: 0.5rem;
}

.activity-card-body {
  padding: 0.55rem 0.7rem;
  min-width: 0;
}

.activity-card-tint-warning {
  background: color-mix(in oklab, var(--color-warning) 16%, var(--color-base-100));
}

.activity-card-tint-error {
  background: color-mix(in oklab, var(--color-error) 13%, var(--color-base-100));
}

.activity-card-tint-success {
  background: color-mix(in oklab, var(--color-success) 15%, var(--color-base-100));
}

.activity-card-tint-info {
  background: color-mix(in oklab, var(--color-info) 14%, var(--color-base-100));
}

.activity-card-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-info);
  color: var(--color-info-content);
}

.activity-card-tint-warning .activity-card-tile {
  background: var(--color-warning);
  color: var(--color-warning-content);
}

.activity-card-tint-error .activity-card-tile {
  background: var(--color-error);
  color: var(--color-error-content);
}

.activity-card-tint-success .activity-card-tile {
  background: var(--color-success);
  color: var(--color-success-content);
}

.activity-meta {
  font-size: 0.72rem;
  opacity: 0.8;
}

.activity-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 999px;
  background: var(--color-primary);
  color: var(--color-primary-content);
  font-size: 0.6rem;
  font-weight: 600;
}

.activity-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  object-fit: cover;
}

.activity-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 0.45rem;
  font-size: 0.68rem;
  font-weight: 500;
  line-height: 1.1rem;
}

.activity-chip-error {
  background: color-mix(in oklab, var(--color-error) 16%, var(--color-base-100));
  color: var(--color-error);
}

.activity-chip-warning {
  background: color-mix(in oklab, var(--color-warning) 20%, var(--color-base-100));
  color: var(--color-warning);
}

.activity-chip-success {
  background: color-mix(in oklab, var(--color-success) 16%, var(--color-base-100));
  color: var(--color-success);
}

.activity-chip-neutral {
  background: color-mix(in oklab, var(--color-base-content) 12%, transparent);
}


/* The shift timeline — the hour lines of a day column. The blocks carry
   their own position (the time comes from the database — the documented
   exception to the no-inline-styles rule, like the label colours and the
   item thumbnail); the grid lines are a background, so they stay out of
   the markup. The step is a percentage: the day fills the window, so the
   lines follow its height (an hour is not a fixed number of pixels any
   more). */
.shift-timeline-day {
  background: repeating-linear-gradient(to bottom, transparent 0 calc(4.1667% - 1px), var(--color-base-200) calc(4.1667% - 1px) 4.1667%);
}

/* The height of the day: a **fixed** one (32 px an hour, 768 px for the
   whole day). The day keeps its height on every screen — the window
   scrolls, like the availability panel beside it. The hour lines follow it
   as a percentage (an hour is 4.1667 % of the day). */
.shift-timeline-grid {
  grid-template-rows: 768px;
}

.shift-timeline-axis {
  height: 768px;
}

/* The shift's own colour — solid, not a tint: a transparent background let
   the hour lines shine through the block. The mix takes the theme's primary
   and the theme's base (so it follows the light and the dark theme). */
.shift-timeline-shift {
  background: color-mix(in oklab, var(--color-primary) 30%, var(--color-base-100));
}

/* The published shift — the same green the house uses for „done" (the
   approval badge, the paid state). A draft keeps the blue: the planner
   sees at a glance which shifts the employees can see. */
.shift-timeline-shift-published {
  background: color-mix(in oklab, var(--color-success) 30%, var(--color-base-100));
}

/* The template slot behind the shift — a solid, cool light grey. It stays
   quiet next to the shift's blue, and next to the shadow of the closed
   hours it is the block that carries a shape. */
.shift-timeline-ghost {
  background: color-mix(in oklab, var(--color-secondary) 20%, var(--color-base-100));
}
