/* Section heading used by list views (leaves, trainings). The task detail
   carries its own styles in board.css. */
.section-label {
  font-size: 12px; font-weight: 600; color: var(--slate-500);
  text-transform: uppercase; letter-spacing: 0.04em; margin: 0 0 6px;
}

/* Rich content */
.prose-modena h1 { font-size: 1.5rem; font-weight: 700; margin: 0.5rem 0; }
.prose-modena h2 { font-size: 1.25rem; font-weight: 700; margin: 0.5rem 0; }
.prose-modena h3 { font-size: 1.1rem; font-weight: 600; margin: 0.5rem 0; }
.prose-modena p  { margin: 0.5rem 0; line-height: 1.6; }
.prose-modena ul, .prose-modena ol { margin: 0.5rem 0; padding-left: 1.5rem; }
.prose-modena li { margin: 0.25rem 0; }
.prose-modena code {
  background: var(--slate-100); padding: 1px 4px; border-radius: 3px; font-size: 13px;
}
.prose-modena pre {
  background: var(--ink-block-bg); color: var(--ink-block-fg);
  padding: 8px 12px; border-radius: 6px; overflow-x: auto;
}
.prose-modena pre code { background: none; color: inherit; padding: 0; }
.prose-modena a { color: var(--text-primary); text-decoration: underline; }
.prose-modena blockquote {
  border-left: 3px solid var(--modena-mint); padding-left: 12px;
  color: var(--slate-600); margin: 8px 0;
}
.prose-modena img { max-width: 100%; border-radius: 6px; margin: 8px 0; display: block; }

/* Quill overrides for Modena */
.ql-editor { font-family: inherit; min-height: 120px; }
.ql-toolbar.ql-snow {
  border-color: var(--border); border-radius: var(--radius-md) var(--radius-md) 0 0;
  background: var(--surface);
  display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
}
.ql-container.ql-snow {
  border-color: var(--border); border-radius: 0 0 var(--radius-md) var(--radius-md);
}
/* Reset our global select width inside Quill toolbar so pickers stay inline */
.ql-toolbar.ql-snow select,
.ql-toolbar.ql-snow .ql-picker {
  width: auto; padding: 0; border: none; background: transparent; box-shadow: none;
}
.ql-toolbar.ql-snow button { padding: 0; }

/* Tables / lists */
.list { background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.list-row + .list-row { border-top: 1px solid var(--border-soft); }
.list-row .name { font-weight: 500; color: var(--text-primary); }
.list-row .email { color: var(--text-tertiary); font-size: 12px; }

/* Stats */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.stat {
  background: var(--surface-raised); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px;
}
.stat .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-tertiary); font-weight: 600; }
.stat .value { font-size: 26px; font-weight: 700; color: var(--text-primary); margin-top: 6px; letter-spacing: -0.01em; }
.stat .hint { font-size: 12px; color: var(--text-tertiary); margin-top: 4px; }

/* Admin landing cards */
.admin-cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}
.admin-card {
  display: block; text-decoration: none; color: inherit;
  background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 22px;
  transition: box-shadow var(--dur-moderate) var(--spring-moderate),
              border-color var(--dur-moderate) var(--spring-moderate),
              transform var(--dur-moderate) var(--spring-moderate);
}
.admin-card:hover {
  border-color: var(--text-primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.admin-card-icon { font-size: 28px; line-height: 1; margin-bottom: 10px; opacity: 0.92; }
.admin-card h2 { margin: 0 0 6px; font-size: 15px; font-weight: 600; }
.admin-card p { margin: 0; color: var(--text-tertiary); font-size: 13px; line-height: 1.5; }

/* Tabbar (HTML/Preview switcher in notification editor etc.) */
.tabbar {
  display: inline-flex; border: 1px solid var(--slate-300); border-radius: 6px; overflow: hidden;
  font-size: 12px;
}
.tabbar-btn {
  background: var(--surface-raised); border: 0; padding: 4px 12px;
  color: var(--slate-500); cursor: pointer;
}
.tabbar-btn:hover { background: var(--slate-50); }
.tabbar-btn.active { background: var(--cta-bg); color: var(--cta-fg); }

/* Notifications: audience grouping (admin notifications page) */
.notif-group { margin-bottom: 22px; }
.notif-group-head {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 8px; padding: 0 4px;
}
.notif-group-head h3 {
  margin: 0; font-size: 13px; font-weight: 600;
  color: var(--text-primary); letter-spacing: 0.02em;
}
.notif-group-head .hint {
  font-size: 12px; color: var(--slate-500); font-weight: 400;
}
.notif-aud-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; white-space: nowrap;
}
.notif-aud-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  vertical-align: middle; margin-right: 2px;
}
.notif-aud-client { background: var(--tint-info-bg); color: var(--tint-info-fg); }
.notif-aud-client.notif-aud-dot { background: #2563EB; }
.notif-aud-agent  { background: var(--tint-ok-bg); color: var(--tint-ok-fg); }
.notif-aud-agent.notif-aud-dot  { background: #16A34A; }
.notif-aud-both   { background: var(--tint-warn-bg); color: var(--tint-warn-fg); }
.notif-aud-both.notif-aud-dot   { background: #D97706; }

/* User row badges + delete */
.user-badge {
  display: inline-block; padding: 1px 7px; border-radius: 999px;
  background: #00A4EF22; color: var(--tint-info-fg);
  font-size: 10px; font-weight: 600; letter-spacing: 0.04em;
  margin-left: 4px;
}
.btn-user-delete {
  background: var(--surface-raised); color: var(--tint-error-fg); border: 1px solid var(--slate-200);
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
  font-size: 18px; line-height: 1; display: inline-flex; align-items: center; justify-content: center;
}
.btn-user-delete:hover { background: var(--tint-error-bg); border-color: var(--tint-error-line); }

/* Audit log */
.audit-action {
  display: inline-block; padding: 1px 8px; border-radius: 4px;
  background: var(--modena-mint); color: var(--text-primary);
  font-size: 12px; font-weight: 500; margin: 0 4px;
}

/* Role checkboxes (chip-style multi-select) */
.role-checkboxes {
  display: inline-flex; flex-wrap: wrap; gap: 6px;
}
.role-chk {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--slate-300); background: var(--surface-raised);
  font-size: 12px; font-weight: 500; color: var(--slate-600);
  cursor: pointer; user-select: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.role-chk input { display: none; }
.role-chk:hover { border-color: var(--text-primary); }
.role-chk.on {
  background: var(--cta-bg); color: var(--cta-fg); border-color: var(--cta-bg);
}
.role-chk.disabled {
  opacity: 0.5; cursor: not-allowed;
}
.role-chk.disabled:hover { border-color: var(--slate-300); }

/* Modal */
.modal-bg {
  position: fixed; inset: 0; background: rgba(var(--ink-rgb), 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 32px 16px; overflow-y: auto; z-index: 50;
}
.modal {
  background: var(--surface-raised); border-radius: var(--radius-xl); max-width: 640px; width: 100%;
  box-shadow: var(--shadow-lg); margin: 16px auto;
  border: 1px solid var(--border-soft);
}
.modal-lg {
  max-width: 960px;
}
.modal .head { padding: 20px 24px; border-bottom: 1px solid var(--border-soft); display: flex; justify-content: space-between; align-items: center; }
.modal .body { padding: 22px 24px; }
.modal .actions { padding: 16px 24px; border-top: 1px solid var(--border-soft); display: flex; justify-content: flex-end; gap: 8px; }
.modal-lg .head { padding: 22px 28px; }
.modal-lg .body { padding: 26px 28px; }
.modal-lg .actions { padding: 18px 28px; }
.modal h2 { font-size: 18px; font-weight: 600; }
.modal-lg h2 { font-size: 20px; font-weight: 600; }
.field-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
@media (max-width: 600px) { .row { flex-direction: column; } }

/* Toast */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 100;
  background: var(--cta-bg); color: var(--cta-fg);
  padding: 12px 18px; border-radius: var(--radius-pill); box-shadow: var(--shadow-lg);
  font-size: 13px; font-weight: 500;
}
.toast.error { background: var(--error-solid); color: var(--on-status); }
/* Teavituste ala on aria-live piirkond; toast'id ise on fixed, nii et konteiner
   paigutust ei mõjuta. Telefonil tõstame nad ribamenüü kohale. */
#toast-region { position: fixed; inset: auto 0 0 0; height: 0; overflow: visible; z-index: 100; }
.toast.has-action { display: inline-flex; align-items: center; gap: 12px; }
.toast .toast-btn {
  background: var(--modena-accent); color: var(--text-primary); border: none;
  border-radius: var(--radius-pill); padding: 5px 12px; font: inherit; font-weight: 600; cursor: pointer;
}
@media (max-width: 720px) {
  .toast { left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom, 0px)); text-align: center; justify-content: center; }
}

/* Dashboard layout — 2 columns on desktop, 1 on mobile */
.dash-row {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 16px; margin-top: 24px;
}
@media (max-width: 720px) {
  .dash-row { grid-template-columns: 1fr !important; gap: 12px; }
}

/* PWA: bottom nav (mobile only) */
.bottom-nav { display: none; }
/* Riba enda elemendid on stiilitud tingimusteta; nähtavuse otsustab 720px
   päring allpool. */
.bottom-nav a, .bottom-nav button {
  flex: 1; background: none; border: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 6px 0;
  font-size: 11px; color: var(--slate-500); text-decoration: none;
  cursor: pointer;
}
.bottom-nav a.active { color: var(--text-primary); font-weight: 600; }
.bottom-nav .icon { font-size: 20px; line-height: 1; }
.bottom-nav .new-btn .icon {
  background: var(--cta-bg); color: var(--cta-fg); width: 36px; height: 36px;
  border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 22px; line-height: 1; margin-bottom: -4px;
}

@media (max-width: 720px) {
  .search-wrap { min-width: 0; }
  .modal-bg { padding: 0; }
  .modal { border-radius: 0; max-width: 100%; min-height: 100vh; min-height: 100dvh; margin: 0; }
  .modal .head, .modal .body, .modal .actions { padding-left: 16px; padding-right: 16px; }
  .btn, .btn-toggle, .role-chk { min-height: 40px; }
  .container { padding: 16px 12px; }
  .board { gap: 8px; }
  .column { min-width: 240px; }
  .task-grid { grid-template-columns: 1fr !important; }
  .filter-panel { grid-template-columns: 1fr 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}

/* PWA: install banner + offline indicator */
.install-banner {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 200;
  max-width: 520px; margin: 0 auto;
  background: var(--surface-raised); border: 1px solid var(--slate-200); border-radius: 12px;
  box-shadow: var(--shadow-md);
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  font-size: 13px;
}
.install-icon { font-size: 22px; }
.install-text { flex: 1; color: var(--text-primary); line-height: 1.4; }
.install-close {
  background: none; border: 0; color: var(--slate-500); font-size: 20px;
  cursor: pointer; padding: 0; width: 24px; height: 24px;
}
.install-close:hover { color: var(--text-primary); }

.offline-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 250;
  background: var(--error-solid-strong); color: var(--on-status);
  padding: 8px 16px; text-align: center;
  font-size: 13px; font-weight: 500;
}
.offline-bar + .app-header { top: 36px !important; }

/* Language switcher (used in header dropdown + login page) */
.lang-switch {
  display: inline-flex; align-items: center; gap: 0;
  border: 1px solid var(--slate-200); border-radius: 8px; overflow: hidden;
  background: var(--surface-raised);
}
/* Sama riba kannab nii keelevalikut (<a>) kui teemavalikut (<button>). */
.lang-switch a,
.lang-switch button {
  padding: 5px 10px; font-size: 12px; font-weight: 600; letter-spacing: 0.04em;
  color: var(--slate-500); text-decoration: none; line-height: 1;
  transition: background 0.12s, color 0.12s;
}
.lang-switch button { border: 0; background: none; font-family: inherit; }
.lang-switch a:hover,
.lang-switch button:hover { background: var(--slate-100); color: var(--text-primary); }
.lang-switch a.active,
.lang-switch button.active { background: var(--sel-bg); color: var(--sel-fg); }
.lang-switch-mini a,
.lang-switch-mini button { padding: 3px 8px; font-size: 11px; }
/* Kolm nuppu ei mahu ühele reale keelevaliku kõrvale, seega teemariba läheb
   oma reale ja venitab end laiuses täis. */
.dropdown-lang:has(.theme-switch) { flex-wrap: wrap; }
.theme-switch { flex: 0 0 auto; }

/* Dropdown row that pairs the "Language" label with the ET/EN toggle */
.dropdown-lang {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 6px 12px;
}
.dropdown-lang-label {
  font-size: 13px; color: var(--text-primary);
}

/* Utility */
.hidden { display: none !important; }
.text-right { text-align: right; }
.gap-8 { gap: 8px; }

/* ===========================================================================
   Mobile main menu
   ---------------------------------------------------------------------------
   The desktop nav is hidden below 1024px (it overflows the header long before
   that), so every destination it holds needs a home on touch screens. It lives
   behind the bottom bar's "Menüü" button rather than a top-right hamburger: on a
   phone held in one hand the bottom edge is the reachable one, and the bar is
   already where navigation happens. Rows are 52px so they are comfortable to hit.
   =========================================================================== */

/* Ribamenüü on ainult telefonil. Tabletil ja laual on külgmenüü (style.css),
   mis voldib kokku ikooniribaks, nii et mõõtmist enam vaja ei ole. */
@media (max-width: 720px) {
  .bottom-nav {
    display: flex; align-items: stretch;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--surface-raised); border-top: 1px solid var(--slate-200);
    padding: 4px 0 max(4px, env(safe-area-inset-bottom));
    box-shadow: var(--shadow-sm);
  }
  body { padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px)); }
  .install-banner { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
}
/* Puutega seadmel peab iga ikoon-nupp olema vähemalt 44px kõrge/lai (WCAG 2.5.5).
   Negatiivne veeris hoiab visuaalse suuruse, puuteala kasvab. */
@media (pointer: coarse) {
  .install-close, .btn-user-delete, .tabbar-btn, .lang-switch a, .mm-close, .sb-toggle { min-width: 44px; min-height: 44px; }
  .dropdown a, .dropdown button { min-height: 44px; display: flex; align-items: center; }
}

.bottom-nav a, .bottom-nav button { min-height: 48px; }
.bottom-nav button#mobile-menu-btn[aria-expanded="true"] { color: var(--text-primary); font-weight: 600; }

.mobile-menu-scrim {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(var(--ink-rgb), 0.45);
  animation: mm-fade var(--dur-moderate) var(--spring-moderate);
}
.mobile-menu {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  max-height: 86vh; max-height: 86dvh; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--surface-raised);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: 0 -12px 40px rgba(var(--ink-rgb), 0.22);
  padding: 8px 0 max(16px, env(safe-area-inset-bottom));
  animation: mm-rise var(--dur-moderate) var(--spring-fast);
}
@keyframes mm-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes mm-rise { from { transform: translateY(14px); opacity: 0.6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .mobile-menu, .mobile-menu-scrim { animation: none; }
}

.mm-grip {
  width: 38px; height: 4px; border-radius: 2px;
  background: var(--slate-300); margin: 2px auto 10px;
}
.mm-head {
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px 12px; border-bottom: 1px solid var(--border-soft);
}
.mm-who { flex: 1; min-width: 0; line-height: 1.3; }
.mm-who strong {
  display: block; font-size: 15px; color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mm-who span {
  display: block; font-size: 12px; color: var(--text-tertiary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mm-close {
  width: 40px; height: 40px; flex: none;
  border: 1px solid var(--border); background: var(--surface-raised); border-radius: 50%;
  font-size: 15px; color: var(--text-secondary); cursor: pointer;
}
.mm-close:active { background: var(--slate-100); }

/* Two columns: eight destinations stay on one screen without scrolling. */
.mm-links {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 6px; padding: 12px 12px 4px;
}
.mm-links a {
  display: flex; align-items: center; gap: 10px;
  min-height: 52px; padding: 8px 12px;
  border: 1px solid var(--border-soft); border-radius: var(--radius-md);
  background: var(--surface-raised); text-decoration: none;
  font-size: 14px; font-weight: 500; color: var(--text-primary);
}
.mm-links a:active { background: var(--slate-100); }
.mm-links a.is-active {
  background: var(--sel-bg); border-color: var(--sel-bg); color: var(--sel-fg);
}
.mm-icon { font-size: 18px; line-height: 1; flex: none; }
.mm-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.mm-section { padding: 10px 12px 0; }
.mm-section-label {
  display: block; padding: 8px 4px 4px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-label);
}
.mm-row {
  display: flex; align-items: center; gap: 10px;
  min-height: 52px; padding: 8px 8px;
  border-top: 1px solid var(--border-soft);
  font-size: 14px; color: var(--text-primary); text-decoration: none;
}
.mm-row:active { background: var(--slate-50); }
.mm-row-lang { justify-content: flex-start; }
.mm-row-lang .lang-switch { margin-left: auto; }
.mm-row-lang .lang-switch a { min-width: 42px; min-height: 34px; display: inline-flex; align-items: center; justify-content: center; }
.mm-row-logout { color: var(--tint-error-fg); }

/* Laiemal aknal on ☰-lehe ainus avaja (ribamenüü) peidus, nii et see on
   topeltkindlustus juhuks, kui aken venitatakse laiaks lahtise lehega
   (app.js sulgeb selle samuti). */
@media (min-width: 721px) {
  .mobile-menu, .mobile-menu-scrim { display: none !important; }
}
body.mm-open { overflow: hidden; }
.mobile-menu:focus { outline: none; }
.mm-close:focus-visible, .mm-links a:focus-visible, .mm-row:focus-visible {
  outline: 2px solid var(--focus-ring); outline-offset: 2px;
}

/* @-mentions: the stored form is <span class="mention">@Nimi</span> */
.prose-modena .mention, .ql-editor .mention {
  color: var(--text-primary); background: rgba(43,175,161,0.14);
  border-radius: 4px; padding: 0 3px; font-weight: 600; white-space: nowrap;
}
.mention-pop {
  position: absolute; z-index: 30; min-width: 240px; max-width: 320px;
  background: var(--surface-raised); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-md); padding: 4px; overflow: hidden;
}
.mention-pop.hidden { display: none; }
.mention-opt {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 6px 8px; border: none; border-radius: 6px; background: transparent;
  font: inherit; font-size: 13px; color: inherit; cursor: pointer;
}
.mention-opt:hover, .mention-opt.is-active { background: var(--surface); }
.mention-opt-name { font-weight: 500; white-space: nowrap; }
.mention-opt-mail {
  margin-left: auto; color: var(--text-tertiary); font-size: 11.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px;
}
