/* HT Hälsoterapeuten – staff booking site. Builds on vendor/site.css (Kvällsljus tokens). */

.admin { min-height: 100dvh; }
.admin .brand { display: inline-flex; align-items: center; gap: 0.7rem; color: var(--text); text-decoration: none; }
.admin .brand__mark { width: 2.3rem; height: 2.3rem; color: var(--accent-ink); }
.admin .brand__name { font-family: var(--font-display); font-size: 1.35rem; line-height: 1; }

.link-btn { padding: 0.4rem 0; border: 0; background: none; color: var(--accent-ink); font: 600 1rem/1.3 var(--font-body); cursor: pointer; text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); text-underline-offset: 0.22em; }
.link-btn:hover { text-decoration-color: currentColor; }

.form-msg { margin-top: var(--s2); padding: 0.75rem 1rem; border-radius: var(--r-sm); background: var(--warn-bg); color: var(--error); font-weight: 600; font-size: 1rem; }
.form-msg.is-ok { background: color-mix(in srgb, var(--success) 12%, transparent); color: var(--success); }

.btn--danger { background: var(--error); color: var(--on-accent); }
:root[data-theme="light"] .btn--danger { color: #fff; }
@media (hover: hover) and (pointer: fine) {
  .btn--danger:hover { background: color-mix(in srgb, var(--error) 85%, var(--text)); }
}
select.input { appearance: none; padding-right: 2.75rem; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a593ab' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 1rem center; background-size: 1.2rem; cursor: pointer; }
input[type="date"].input { color-scheme: inherit; }

/* ---------- Sign in ---------- */
.auth { position: relative; display: grid; place-items: center; min-height: 100dvh; padding: var(--s4) var(--gutter); overflow: hidden; }
.auth__glow { position: absolute; inset: -20%; background: radial-gradient(40% 35% at 30% 30%, var(--glow-1), transparent 70%), radial-gradient(35% 30% at 75% 70%, var(--glow-2), transparent 70%); filter: blur(30px); animation: drift 18s var(--ease-calm) infinite alternate; pointer-events: none; }
@keyframes drift { to { transform: translate3d(4%, -3%, 0) scale(1.05); } }
@media (prefers-reduced-motion: reduce) { .auth__glow { animation: none; } }
.auth__box { position: relative; width: min(100%, 28rem); padding: clamp(1.5rem, 4vw, 2.5rem); box-shadow: var(--shadow); animation: fade-up 600ms var(--ease-out) both; }
.auth__brand { margin-bottom: var(--s4); }
.auth__form h1 { font-size: clamp(2rem, 3vw + 1rem, 2.6rem); }
.auth__lead { margin: 0.5rem 0 var(--s3); color: var(--text-soft); }
.auth__submit { width: 100%; margin-top: var(--s3); }
.auth__links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 1rem; margin-top: var(--s2); }
.auth__loading { color: var(--text-faint); }
.auth__theme { position: absolute; top: var(--s2); right: var(--s2); }

/* ---------- Top bar ---------- */
.a-top { position: sticky; top: 0; z-index: 20; border-bottom: 1px solid var(--border); background: var(--header-bg); -webkit-backdrop-filter: blur(14px) saturate(1.2); backdrop-filter: blur(14px) saturate(1.2); }
.a-top__bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 4.5rem; }
.a-top__actions { display: flex; align-items: center; gap: 0.6rem; }
.a-user { max-width: 16rem; overflow: hidden; text-overflow: ellipsis; color: var(--text-faint); font-weight: 500; }
.a-user:not(:empty)::after { content: "·"; margin-left: 0.6rem; }
.a-live { display: inline-flex; align-items: center; gap: 0.45rem; margin-right: 0.4rem; color: var(--text-faint); font-size: 0.95rem; }
.a-live__dot { width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 0 color-mix(in srgb, var(--success) 60%, transparent); animation: pulse 2.4s ease-out infinite; }
.a-live.is-off .a-live__dot { background: var(--text-faint); animation: none; }
@keyframes pulse { 70% { box-shadow: 0 0 0 0.5rem transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { .a-live__dot { animation: none; } }
@media (max-width: 720px) {
  .a-user, .a-live { display: none; }
}

.a-main { padding-block: var(--s4) var(--s6); }

/* ---------- Stats ---------- */
.a-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(0.75rem, 1.5vw, 1.25rem); }
.stat { display: grid; gap: 0.2rem; padding: 1.1rem 1.25rem; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); animation: fade-up 500ms var(--ease-out) both; }
.stat:nth-child(2) { animation-delay: 60ms; }
.stat:nth-child(3) { animation-delay: 120ms; }
.stat:nth-child(4) { animation-delay: 180ms; }
.stat__label { color: var(--text-faint); font-size: 0.98rem; }
.stat__value { font-family: var(--font-display); font-weight: 400; font-size: clamp(1.9rem, 2vw + 1rem, 2.5rem); line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat__sub { min-height: 1.4em; color: var(--text-soft); font-size: 0.98rem; }
@media (max-width: 900px) { .a-stats { grid-template-columns: 1fr 1fr; } }

/* ---------- Toolbar ---------- */
.a-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; margin-top: var(--s4); }
.a-tabs { display: flex; flex-wrap: wrap; gap: 0.35rem; padding: 0.3rem; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
.a-tab { display: inline-flex; align-items: center; gap: 0.45rem; min-height: 2.75rem; padding: 0.4rem 0.9rem; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--text-soft); font: 600 1rem/1.2 var(--font-body); cursor: pointer; transition: background-color 200ms ease, color 200ms ease; }
.a-tab:hover { color: var(--text); background: var(--surface-2); }
.a-tab[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.a-tab__n:empty { display: none; }
.a-tab__n { min-width: 1.6rem; padding: 0.05rem 0.4rem; border-radius: 6px; background: var(--surface-3); color: var(--text); font-size: 0.88rem; text-align: center; font-variant-numeric: tabular-nums; }
.a-tab[aria-pressed="true"] .a-tab__n { background: color-mix(in srgb, var(--on-accent) 16%, transparent); color: var(--on-accent); }
.a-tab__n.is-alert { background: var(--error); color: var(--on-accent); }
.a-toolbar__right { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; }
.a-search { position: relative; display: block; }
.a-search .icon { position: absolute; left: 0.9rem; top: 50%; translate: 0 -50%; color: var(--text-faint); pointer-events: none; }
.a-search .input { width: 16rem; min-height: 3.5rem; padding-left: 2.8rem; }
@media (max-width: 720px) {
  .a-toolbar__right, .a-search, .a-search .input { width: 100%; }
  .a-toolbar__right .btn { flex: 1; }
}

.a-listhead { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin: var(--s4) 0 var(--s2); }
.a-title { font-size: clamp(1.8rem, 2vw + 1rem, 2.4rem); }

/* ---------- Booking list ---------- */
.a-day { margin-top: var(--s3); animation: fade-up 450ms var(--ease-out) both; }
.a-day:first-child { margin-top: 0; }
.a-day__head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding: 0 0.25rem 0.6rem; }
.a-day__head h2 { font-size: 1.35rem; }
.a-day__head h2 .is-today { color: var(--accent-ink); }
.a-day__meta { color: var(--text-faint); font-size: 0.98rem; }
.a-day__closed { margin-left: 0.5rem; color: var(--error); font: 600 0.92rem var(--font-body); }
.a-rows { display: grid; gap: 0.5rem; margin: 0; padding: 0; list-style: none; }
.row {
  display: grid;
  grid-template-columns: 6.5rem minmax(0, 1.3fr) minmax(0, 1fr) 15rem;
  align-items: center;
  gap: 1rem;
  width: 100%;
  padding: 0.95rem 1.1rem 0.95rem 1.35rem;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  position: relative;
  transition: border-color 200ms ease, background-color 200ms ease, translate 260ms var(--ease-out);
}
.row::before { content: ""; position: absolute; left: 0.55rem; top: 0.9rem; bottom: 0.9rem; width: 3px; border-radius: 3px; background: var(--hue, var(--accent)); }
@media (hover: hover) and (pointer: fine) {
  .row:hover { border-color: var(--border-strong); background: var(--surface-2); translate: 2px 0; }
}
.row.is-muted { opacity: 0.62; }
.row.is-new { animation: arrive 1.6s var(--ease-out); }
@keyframes arrive { 0% { box-shadow: 0 0 0 0 var(--accent); } 40% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 35%, transparent); } 100% { box-shadow: 0 0 0 0 transparent; } }
.row.is-now { border-color: var(--accent); }
.row__time { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.1rem; }
.row__time span { display: block; color: var(--text-faint); font-weight: 500; font-size: 0.95rem; }
.row__svc { min-width: 0; }
.row__svc b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__svc span { color: var(--text-faint); font-size: 0.95rem; }
.row__who { min-width: 0; }
.row__who b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__who span { color: var(--text-soft); font-size: 0.95rem; font-variant-numeric: tabular-nums; }
.row__tags { display: flex; flex-wrap: wrap; justify-content: end; gap: 0.35rem; }
@media (max-width: 1000px) {
  .row { grid-template-columns: 6rem minmax(0, 1.2fr) minmax(0, 1fr); }
  .row__tags { grid-column: 2 / -1; justify-content: start; }
}
@media (max-width: 760px) {
  .row { grid-template-columns: 5.25rem minmax(0, 1fr); gap: 0.4rem 0.9rem; }
  .row__who { grid-column: 2; }
  .row__tags { grid-column: 1 / -1; justify-content: start; padding-left: 0; }
}

.tag { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.22rem 0.6rem; border: 1px solid var(--border-strong); border-radius: 6px; color: var(--text-soft); font-size: 0.88rem; font-weight: 600; line-height: 1.3; white-space: nowrap; }
.tag--ok { color: var(--success); border-color: color-mix(in srgb, var(--success) 50%, transparent); }
.tag--done { color: var(--text); background: var(--surface-3); border-color: transparent; }
.tag--wait { color: var(--accent-ink); border-color: color-mix(in srgb, var(--accent) 55%, transparent); }
.tag--off { color: var(--text-faint); }
.tag--bad { color: var(--error); border-color: color-mix(in srgb, var(--error) 50%, transparent); }

.a-empty { padding: var(--s5) var(--s3); border: 1px dashed var(--border-strong); border-radius: var(--r-lg); text-align: center; color: var(--text-soft); }
.a-empty b { display: block; margin-bottom: 0.3rem; font-family: var(--font-display); font-weight: 400; font-size: 1.5rem; color: var(--text); }
.a-loading { padding: var(--s4) 0; color: var(--text-faint); animation: breathe-text 1.6s ease-in-out infinite alternate; }
.a-more { margin-top: var(--s3); text-align: center; }

/* ---------- Side sheets (dialogs) ---------- */
.sheet {
  width: min(34rem, 100vw);
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0 0 0 auto;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text);
  transform: translateX(0);
  transition: transform 460ms var(--ease-drawer), overlay 460ms allow-discrete, display 460ms allow-discrete;
}
.sheet:not([open]) { transform: translateX(100%); }
@starting-style { .sheet[open] { transform: translateX(100%); } }
.sheet::backdrop { background: rgba(8, 4, 10, 0.55); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); transition: opacity 460ms ease, overlay 460ms allow-discrete, display 460ms allow-discrete; }
.sheet:not([open])::backdrop { opacity: 0; }
@starting-style { .sheet[open]::backdrop { opacity: 0; } }
.sheet__inner { display: block; min-height: 100%; padding: var(--s3) clamp(1.1rem, 4vw, 2rem) var(--s5); }
.sheet__top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: var(--s2); }
.sheet h2 { font-size: clamp(1.7rem, 2vw + 1rem, 2.2rem); }
.sheet__when { margin-top: 0.4rem; color: var(--text-soft); font-size: 1.1rem; }
.sheet__lead { margin-bottom: var(--s3); color: var(--text-soft); }
.sheet .field + .field, .sheet .n-grid + .field, .sheet .field + .n-grid { margin-top: var(--s2); }
.sheet .check { margin-top: var(--s2); }

/* ---------- Ta betalt (card reader) ---------- */
.pos { margin-top: var(--s3); padding: 1.2rem 1.25rem; border: 1.5px solid color-mix(in srgb, var(--accent) 45%, var(--border)); border-radius: var(--r-md); background: var(--surface); animation: fade-up 400ms var(--ease-out) both; }
.pos__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.pos__head h3 { font-family: var(--font-body); font-size: 0.95rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-faint); }
.pos__reader { display: inline-flex; align-items: center; gap: 0.45rem; color: var(--text-faint); font-size: 0.95rem; }
.pos__reader::before { content: ""; width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--text-faint); }
.pos__reader:empty::before { display: none; }
.pos__reader.is-on::before { background: var(--success); }
.pos__amount { display: flex; align-items: baseline; gap: 1rem; margin: 0.5rem 0 0.9rem; }
.pos__amount b { font-family: var(--font-display); font-weight: 400; font-size: 2.4rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.pos__adjust { margin-bottom: var(--s2); }
.pos__adjust .field + .field { margin-top: 0; }
.pos__select { display: block; margin-bottom: var(--s2); }
.pos__send { width: 100%; }
.pos__status { display: flex; align-items: center; gap: 0.75rem; margin-top: 0.4rem; padding: 0.85rem 1rem; border-radius: var(--r-sm); background: var(--surface-2); font-weight: 600; }
.pos__pulse { flex: none; width: 0.8rem; height: 0.8rem; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent); animation: pulse 1.8s ease-out infinite; }
.pos__status.is-failed { background: var(--warn-bg); color: var(--error); }
.pos__status.is-failed .pos__pulse { background: var(--error); animation: none; }
@media (prefers-reduced-motion: reduce) { .pos__pulse { animation: none; } }
.pos__actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.75rem; }
.pos__actions:empty { display: none; }
.pos__none { color: var(--text-soft); }
.tag--now { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }

.d-section { margin-top: var(--s3); padding: 1rem 1.2rem; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
.d-section h3 { margin-bottom: 0.6rem; font-family: var(--font-body); font-size: 0.95rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-faint); }
.d-list { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); gap: 0.45rem 1rem; margin: 0; }
.d-list dt { color: var(--text-faint); }
.d-list dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.d-list a { color: var(--accent-ink); }
.d-note { margin-top: 0.8rem; padding: 0.75rem 0.9rem; border-radius: var(--r-sm); background: var(--surface-2); color: var(--text-soft); white-space: pre-line; }
.d-note::before { content: "Meddelande: "; color: var(--text-faint); }
.d-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: var(--s3); }
.d-actions:empty { display: none; }
.d-cancel { margin-top: var(--s3); padding: 1.1rem 1.2rem; border: 1px solid color-mix(in srgb, var(--error) 45%, transparent); border-radius: var(--r-md); background: var(--warn-bg); animation: fade-up 300ms var(--ease-out) both; }
.d-cancel h3 { margin-bottom: var(--s2); font-size: 1.35rem; }
.d-history { margin-top: var(--s3); border-top: 1px solid var(--border); padding-top: var(--s2); }
.d-history summary { min-height: 2.75rem; display: flex; align-items: center; cursor: pointer; font-weight: 600; color: var(--text-soft); }
.d-history ul { margin: 0.4rem 0 0; padding: 0; list-style: none; display: grid; gap: 0.45rem; }
.d-history li { display: grid; grid-template-columns: 8.5rem minmax(0, 1fr); gap: 0.75rem; font-size: 0.98rem; color: var(--text-soft); }
.d-history li time { color: var(--text-faint); font-variant-numeric: tabular-nums; }

.n-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
.sheet .n-grid .field + .field { margin-top: 0; }
@media (max-width: 520px) { .n-grid { grid-template-columns: 1fr; } }
.n-times { display: grid; grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr)); gap: 0.45rem; min-height: 3.25rem; }
.n-times p { grid-column: 1 / -1; color: var(--text-faint); }
.n-time { min-height: 3rem; border: 1.5px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface-2); color: var(--text); font: 600 1.05rem var(--font-body); font-variant-numeric: tabular-nums; cursor: pointer; transition: border-color 180ms ease, background-color 180ms ease; }
.n-time:hover { border-color: var(--accent); }
.n-time[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.n-pay { margin: var(--s2) 0 0; padding: 0; border: 0; }
.n-pay legend { margin-bottom: 0.2rem; font-weight: 600; font-size: 1.05rem; }
.n-pay .check { margin-top: 0.6rem; }
.n-pay .n-code { margin-top: var(--s2); }
.n-code .input { text-transform: uppercase; letter-spacing: 0.06em; }
.d-list .d-code { font-family: var(--font-body); font-size: 1.15rem; letter-spacing: 0.08em; font-variant-numeric: tabular-nums; }
.d-hint { margin-top: 0.7rem; color: var(--text-soft); font-size: 0.98rem; }

.cl-form { display: grid; gap: var(--s2); padding: 1.1rem 1.2rem; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
.cl-form .field + .field { margin-top: 0; }
.cl-form .btn { justify-self: start; }
.cl-head { margin: var(--s4) 0 var(--s2); font-size: 1.35rem; }
.cl-list { display: grid; gap: 0.5rem; margin: 0; padding: 0; list-style: none; }
.cl-list li { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.75rem 0.9rem 0.75rem 1.1rem; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
.cl-list b { font-weight: 600; }
.cl-list span { display: block; color: var(--text-faint); font-size: 0.95rem; }
.cl-list .is-warn { color: var(--error); }
.cl-list p { color: var(--text-faint); }

/* ---------- Toast ---------- */
.toast { position: fixed; inset: auto auto var(--s3) 50%; margin: 0; z-index: 60; translate: -50% 0; max-width: min(32rem, calc(100vw - 2rem)); padding: 0.9rem 1.2rem; border: 1px solid var(--border-strong); border-radius: var(--r-md); background: var(--surface-3); color: var(--text); box-shadow: var(--shadow); font-weight: 600; animation: toast-in 420ms var(--ease-out) both; }
@keyframes toast-in { from { opacity: 0; translate: -50% 1rem; } }

/* ---------- Print: today's list on paper ---------- */
@media print {
  :root { --bg: #fff; --surface: #fff; --text: #000; --text-soft: #222; --text-faint: #555; --border: #ccc; --border-strong: #999; }
  .a-top, .a-stats, .a-toolbar, #btn-print, .a-more, .toast, .sheet { display: none !important; }
  .a-main { padding: 0; }
  .row { break-inside: avoid; padding: 0.5rem 0.75rem; }
  .row::before { display: none; }
  .a-day { animation: none; }
}
