/* Henry – UI styles on top of Bootstrap 5.3.
   Ergonomics (font size, tap target size, contrast) are driven by CSS variables that are
   set per person on <html> (see base.html, "Bedienung" page). */

:root {
  --henry-primary: #2f6f8f;
  --henry-accent: #f2b84b;
  --henry-heart: #c8553d;
  --henry-bg: #f6f4ef;
  --henry-surface: #ffffff;
  --henry-text: #1f2a30;
  --henry-muted: #5d6b73;
  --henry-border: #dcd8cf;
  --henry-font-phone: 110%;
  --henry-font-tablet: 115%;
  --henry-tap: 48px;
  --henry-gap: .75rem;
  --henry-sidebar: 270px;
  --bs-primary: var(--henry-primary);
  --bs-primary-rgb: 47, 111, 143;
  --bs-link-color: #24597a;
  --bs-link-color-rgb: 36, 89, 122;
  --bs-body-bg: var(--henry-bg);
  --bs-body-color: var(--henry-text);
  --bs-border-color: var(--henry-border);
}

[data-bs-theme="dark"] {
  --henry-bg: #12191d;
  --henry-surface: #1b2429;
  --henry-text: #e8ecee;
  --henry-muted: #a7b4bb;
  --henry-border: #2e3a41;
  --bs-body-bg: var(--henry-bg);
  --bs-body-color: var(--henry-text);
  --bs-link-color: #8cc4e0;
  --bs-link-color-rgb: 140, 196, 224;
}

html { font-size: var(--henry-font-phone); scroll-padding-top: 80px; }
@media (min-width: 768px) { html { font-size: var(--henry-font-tablet); } }

html[data-touch="normal"] { --henry-tap: 40px; }
html[data-touch="large"] { --henry-tap: 52px; --henry-gap: 1rem; }
html[data-touch="xl"] { --henry-tap: 64px; --henry-gap: 1.25rem; }

html[data-contrast="1"] {
  --henry-text: #000; --henry-muted: #222; --henry-border: #555;
  --bs-link-color: #003a75; --bs-link-color-rgb: 0, 58, 117;
}
html[data-contrast="1"][data-bs-theme="dark"] { --henry-text: #fff; --henry-muted: #ddd; --bs-link-color: #bfe3ff; }
html[data-contrast="1"] a { text-decoration: underline; }

html[data-motion="reduce"] *, html[data-motion="reduce"] *::before { transition: none !important; animation: none !important; scroll-behavior: auto !important; }

body { background: var(--henry-bg); color: var(--henry-text); min-height: 100vh; display: flex; flex-direction: column; }

/* tap targets */
.btn, .form-control, .form-select, .nav-link, .dropdown-item, .list-group-item-action, .page-link {
  min-height: var(--henry-tap);
}
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; }
.btn-sm { min-height: calc(var(--henry-tap) * .78); }
.form-check-input { width: 1.5em; height: 1.5em; margin-top: .1em; }
html[data-touch="xl"] .form-check-input { width: 2em; height: 2em; }
.form-check { min-height: var(--henry-tap); display: flex; align-items: center; gap: .6rem; padding-left: 0; }
.form-check .form-check-input { margin-left: 0; float: none; flex-shrink: 0; }
.form-switch .form-check-input { width: 3em; }
.dropdown-menu { font-size: 1rem; }
.dropdown-item { display: flex; align-items: center; gap: .5rem; }

/* header */
.henry-header {
  position: sticky; top: 0; z-index: 1030; background: var(--henry-primary); color: #fff;
  min-height: 60px; display: flex; align-items: center; gap: .75rem; padding: .35rem .75rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .12);
}
.henry-header a, .henry-header .btn-link { color: #fff; text-decoration: none; }
.henry-brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.35rem; letter-spacing: .02em; }
.henry-brand img { width: 40px; height: 40px; border-radius: 10px; }
.henry-header .badge { font-size: .7rem; }
.henry-user { margin-left: auto; display: flex; align-items: center; gap: .4rem; }
.henry-avatar {
  width: 38px; height: 38px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; border: 2px solid rgba(255, 255, 255, .8); flex-shrink: 0;
}
.henry-avatar.lg { width: 72px; height: 72px; font-size: 2rem; }

/* layout with left menu */
.henry-layout { display: flex; flex: 1; align-items: stretch; }
.henry-sidebar {
  width: var(--henry-sidebar); flex-shrink: 0; background: var(--henry-surface); border-right: 1px solid var(--henry-border);
  position: sticky; top: 60px; height: calc(100vh - 60px); overflow-y: auto; padding: .5rem;
}
.henry-sidebar .nav-link { color: var(--henry-text); border-radius: .6rem; display: flex; align-items: center; gap: .6rem; padding: .45rem .7rem; }
.henry-sidebar .nav-link .bi { font-size: 1.2rem; width: 1.4rem; text-align: center; color: var(--henry-primary); }
.henry-sidebar .nav-link.active { background: rgba(47, 111, 143, .13); font-weight: 600; }
.henry-sidebar .nav-link:hover { background: rgba(47, 111, 143, .08); }
.henry-sidebar .menu-group { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--henry-muted); margin: .9rem .7rem .2rem; }
.henry-sidebar .sub .nav-link { padding-left: 2.6rem; font-size: .95rem; }
@media (max-width: 991.98px) {
  .henry-sidebar { position: fixed; left: 0; top: 60px; z-index: 1040; transform: translateX(-105%); transition: transform .2s; box-shadow: 4px 0 18px rgba(0,0,0,.18); width: min(86vw, 320px); }
  .henry-sidebar.open { transform: none; }
  .henry-backdrop { position: fixed; inset: 60px 0 0 0; background: rgba(0,0,0,.35); z-index: 1035; display: none; }
  .henry-backdrop.show { display: block; }
}
.henry-main { flex: 1; min-width: 0; padding: 1rem clamp(.75rem, 2vw, 2rem) 2rem; }
.henry-main > .container-narrow { max-width: 1100px; margin: 0 auto; }

/* footer */
.henry-footer { border-top: 1px solid var(--henry-border); color: var(--henry-muted); font-size: .85rem; padding: .8rem 1rem; text-align: center; background: var(--henry-surface); }
.henry-footer a { color: inherit; }

/* cards & lists */
.card { background: var(--henry-surface); border-color: var(--henry-border); border-radius: .9rem; }
.card-header { background: transparent; font-weight: 600; }
.henry-row { display: flex; gap: .75rem; align-items: flex-start; padding: .75rem; border-bottom: 1px solid var(--henry-border); background: var(--henry-surface); }
.henry-row:last-child { border-bottom: 0; }
.henry-row .grow { flex: 1; min-width: 0; }
.henry-row .title { font-weight: 600; hyphens: auto; overflow-wrap: break-word; }
.henry-row.done .title { text-decoration: line-through; color: var(--henry-muted); }
.henry-row.dropped { opacity: .65; }
.henry-row.urgency-danger { border-left: 6px solid var(--bs-danger); }
.henry-row.urgency-warning { border-left: 6px solid var(--bs-warning); }
.henry-row.urgency-info { border-left: 6px solid var(--henry-accent); }
.henry-meta { color: var(--henry-muted); font-size: .88rem; display: flex; flex-wrap: wrap; gap: .25rem .9rem; }
.henry-meta .bi { margin-right: .15rem; }
.code-badge { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--henry-primary); color: #fff; border-radius: .4rem; padding: .05rem .45rem; font-size: .85rem; font-weight: 700; }
.star { color: #d59a00; }
.big-check { width: var(--henry-tap); height: var(--henry-tap); border-radius: 50%; border: 3px solid var(--henry-primary); background: transparent; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--henry-primary); font-size: 1.4rem; }
.big-check.checked { background: var(--bs-success); border-color: var(--bs-success); color: #fff; }
.big-check.dropped { background: var(--henry-muted); border-color: var(--henry-muted); color: #fff; }

.progress { height: 1.1rem; border-radius: 1rem; background: rgba(0,0,0,.07); }
.progress-ring { --p: 0; width: 120px; height: 120px; border-radius: 50%; background: conic-gradient(var(--bs-success) calc(var(--p) * 1%), rgba(0,0,0,.08) 0); display: grid; place-items: center; }
.progress-ring > span { width: 92px; height: 92px; border-radius: 50%; background: var(--henry-surface); display: grid; place-items: center; font-size: 1.5rem; font-weight: 700; }

.countdown { font-size: 2.2rem; font-weight: 800; color: var(--henry-primary); line-height: 1; }
.action-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem; padding: 1rem .5rem; border-radius: .9rem; border: 1px solid var(--henry-border); background: var(--henry-surface); color: var(--henry-text); text-decoration: none; min-height: 96px; text-align: center; font-weight: 600; }
.action-tile .bi { font-size: 1.8rem; color: var(--henry-primary); }
.action-tile:hover { border-color: var(--henry-primary); }

/* input with clear button */
.henry-clear-wrap { position: relative; }
.henry-clear-wrap > .form-control { padding-right: 2.8rem; }
.henry-clear { position: absolute; right: .25rem; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--henry-muted); width: 2.4rem; height: 2.4rem; border-radius: 50%; display: none; font-size: 1.1rem; }
.henry-clear:hover { background: rgba(0,0,0,.06); }
.henry-clear-wrap.has-value > .henry-clear { display: inline-flex; align-items: center; justify-content: center; }
textarea + .henry-clear { top: .9rem; transform: none; }

/* back to top */
#henry-top { position: fixed; right: 1rem; bottom: 1rem; z-index: 1050; width: 56px; height: 56px; border-radius: 50%; display: none; box-shadow: 0 4px 12px rgba(0,0,0,.25); font-size: 1.5rem; }
#henry-top.show { display: inline-flex; }

/* hold-to-confirm */
.hold-btn { position: relative; overflow: hidden; }
.hold-btn .hold-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: rgba(255,255,255,.35); pointer-events: none; }

/* brochure viewer */
.page-frame { position: relative; width: 100%; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.15); border-radius: .4rem; overflow: hidden; touch-action: pan-y pinch-zoom; }
.page-frame img { width: 100%; height: auto; display: block; user-select: none; -webkit-user-drag: none; }
.hl-box { position: absolute; border: 2px solid rgba(47,111,143,.35); background: rgba(47,111,143,.06); border-radius: 4px; cursor: pointer; transition: background .15s; }
.hl-box:hover { background: rgba(47,111,143,.16); }
.hl-box.kind-ad { border-style: dashed; border-color: rgba(120,120,120,.35); background: transparent; }
.hl-box.kind-mark { border-color: rgba(200,85,61,.7); background: rgba(200,85,61,.08); }
.hl-box.active { border: 4px solid #e8590c; background: rgba(255, 212, 59, .28); box-shadow: 0 0 0 9999px rgba(0,0,0,.18); z-index: 2; animation: henry-pulse 1.6s ease-in-out 2; }
.page-frame.hide-ads .kind-ad { display: none; }
.page-frame.drawing { cursor: crosshair; touch-action: none; }
.draw-rect { position: absolute; border: 3px dashed var(--henry-heart); background: rgba(200,85,61,.12); }
@keyframes henry-pulse { 50% { border-color: #ffd43b; } }
.thumb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .75rem; }
.thumb-grid a { text-decoration: none; color: var(--henry-text); text-align: center; font-size: .85rem; }
.thumb-grid img { width: 100%; border-radius: .3rem; box-shadow: 0 1px 4px rgba(0,0,0,.2); background: #fff; aspect-ratio: 1.077; object-fit: cover; }
.clip-img { max-width: 100%; border: 1px solid var(--henry-border); border-radius: .4rem; background: #fff; }

.status-pill { font-size: .85rem; padding: .35rem .7rem; border-radius: 1rem; }
.sticky-actions { position: sticky; bottom: 0; background: var(--henry-bg); padding: .6rem 0; z-index: 5; border-top: 1px solid var(--henry-border); }
.mail-body { white-space: pre-wrap; font-family: inherit; }
.henry-placeholder::placeholder, .form-control::placeholder { color: #9aa4aa; opacity: 1; font-style: italic; }
.setting-source { font-size: .75rem; }
.timeline-week { border-left: 4px solid var(--henry-primary); padding-left: 1rem; margin-left: .5rem; }
.log-row pre { white-space: pre-wrap; font-size: .8rem; max-height: 300px; overflow: auto; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-block; }
.htmx-indicator { display: none; }
.speak-btn { border: 0; background: transparent; color: var(--henry-primary); }
html[data-speech="0"] .speak-btn { display: none; }
a.tel-link { white-space: nowrap; }
@media print { .henry-header, .henry-sidebar, .henry-footer, #henry-top, .no-print { display: none !important; } }

/* Henry colours for Bootstrap buttons */
.btn-primary { --bs-btn-bg: var(--henry-primary); --bs-btn-border-color: var(--henry-primary); --bs-btn-hover-bg: #275d78; --bs-btn-hover-border-color: #275d78; --bs-btn-active-bg: #214f66; --bs-btn-active-border-color: #214f66; --bs-btn-disabled-bg: var(--henry-primary); --bs-btn-disabled-border-color: var(--henry-primary); }
.btn-outline-primary { --bs-btn-color: var(--henry-primary); --bs-btn-border-color: var(--henry-primary); --bs-btn-hover-bg: var(--henry-primary); --bs-btn-hover-border-color: var(--henry-primary); --bs-btn-active-bg: var(--henry-primary); --bs-btn-active-border-color: var(--henry-primary); }
[data-bs-theme="dark"] .btn-outline-primary { --bs-btn-color: #8cc4e0; --bs-btn-border-color: #8cc4e0; }
.progress-bar.bg-primary, .bg-primary { background-color: var(--henry-primary) !important; }
.list-group-item.active { background-color: var(--henry-primary); border-color: var(--henry-primary); }
.form-check-input:checked { background-color: var(--henry-primary); border-color: var(--henry-primary); }

/* Dropdowns inside the blue header (personal menu): normal menu colours, not white header links */
.henry-header .dropdown-menu { --bs-dropdown-link-color: var(--henry-text); --bs-dropdown-link-hover-color: var(--henry-text); --bs-dropdown-link-hover-bg: rgba(47,111,143,.12); --bs-dropdown-bg: var(--henry-surface); font-size: 1.05rem; box-shadow: 0 6px 20px rgba(0,0,0,.18); }
.henry-header .dropdown-menu a, .henry-header .dropdown-menu .dropdown-item { color: var(--henry-text); }
.henry-header .dropdown-menu .dropdown-item .bi { color: var(--henry-primary); }
.henry-header .dropdown-menu .dropdown-item:hover, .henry-header .dropdown-menu .dropdown-item:focus { color: var(--henry-text); background: rgba(47,111,143,.12); }
[data-bs-theme="dark"] .henry-header .dropdown-menu .dropdown-item .bi { color: #8cc4e0; }

/* Star rating: reversed order so that hovering a star also highlights the ones before it */
.star-rating { display: inline-flex; flex-direction: row-reverse; gap: .25rem; }
.star-rating .star-input { position: absolute; opacity: 0; pointer-events: none; }
.star-rating label { font-size: 2.2rem; line-height: 1; color: #c9c4b8; cursor: pointer; min-width: var(--henry-tap); min-height: var(--henry-tap); display: inline-flex; align-items: center; justify-content: center; border-radius: .5rem; }
.star-rating .star-input:checked ~ label, .star-rating label:hover, .star-rating label:hover ~ label { color: #d59a00; }
.star-rating .star-input:focus-visible + label { outline: 3px solid var(--henry-primary); }
.stars-display { color: #d59a00; letter-spacing: .05em; }
