/* Reusable UI components: icon, buttons, cards, badges, page header, empty state. */

/* ---------- Icon ---------- */

.icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Emoji / text glyph used when an add-on stores a literal icon. */
.icon--glyph {
  display: inline-grid;
  place-items: center;
  font-size: 17px;
  line-height: 1;
  stroke: none;
}

/* ---------- Buttons: 40px, 8px radius, bold label ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 40px;
  padding: 0 18px;
  border: 1.5px solid transparent;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition:
    box-shadow var(--duration-fast),
    background var(--duration-fast),
    border-color var(--duration-fast);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn--primary:not(:disabled):hover {
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 35%, transparent);
}

.btn--ghost {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--border);
}

.btn--ghost:not(:disabled):hover {
  background: var(--surface-soft);
  border-color: var(--border-strong);
}

/* Icon-only button for toolbar actions (menu, theme toggle). */
.btn--icon {
  width: 40px;
  padding: 0;
  background: transparent;
  color: var(--body);
}

.btn--icon:not(:disabled):hover {
  background: var(--surface-soft);
  color: var(--ink);
}

/* ---------- Card ---------- */

.card {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: var(--space-5);
}

.card__title {
  margin: 0 0 var(--space-1);
  font-size: 16px;
}

.card__text {
  margin: 0 0 var(--space-4);
  font-size: 14px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-4);
}

/* ---------- Badge: the one place a pill shape is appropriate ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-2);
  background: var(--surface-soft);
}

.badge--success {
  color: var(--success);
  background: color-mix(in srgb, var(--success) 14%, transparent);
}

/* ---------- Page header ---------- */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.page-header__title {
  margin: 0;
}

.page-header__subtitle {
  margin: var(--space-1) 0 0;
  font-size: 14px;
}

/* ---------- Empty state: an invitation, not an apology ---------- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-8) var(--space-5);
  text-align: center;
  background: var(--paper);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-card);
}

.empty-state .icon {
  width: 28px;
  height: 28px;
  color: var(--muted);
}

.empty-state__title {
  margin: 0;
  font-size: 16px;
  color: var(--ink);
}

.empty-state__text {
  margin: 0 0 var(--space-3);
  max-width: 44ch;
  font-size: 14px;
}

/* ---------- Menu (dropdown) ---------- */

.menu {
  min-width: 220px;
  padding: var(--space-2);
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-menu);
}

.menu__header {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-2);
}

.menu__name {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

.menu__meta {
  display: block;
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.menu__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: 10px var(--space-3);
  border: 0;
  border-radius: var(--radius-md);
  background: none;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
}

.menu__item:hover {
  background: var(--surface-soft);
}

/* ---------- Theme toggle: shows the icon for the theme you would switch to ---------- */

.theme-toggle__sun {
  display: none;
}

:root[data-theme="dark"] .theme-toggle__moon {
  display: none;
}

:root[data-theme="dark"] .theme-toggle__sun {
  display: inline-flex;
}

.theme-toggle__moon {
  display: inline-flex;
}

/* ---------- Button variants and sizes ---------- */

.btn--sm {
  height: 32px;
  padding: 0 var(--space-3);
  font-size: 13px;
}

.btn--icon.btn--sm {
  width: 32px;
  padding: 0;
}

.btn--sm .icon {
  width: 16px;
  height: 16px;
}

.btn--danger {
  background: var(--danger);
  color: #ffffff;
}

.btn--danger:not(:disabled):hover {
  box-shadow: 0 2px 8px color-mix(in srgb, var(--danger) 35%, transparent);
}

.btn--danger-ghost {
  color: var(--danger);
}

.btn--danger-ghost:not(:disabled):hover {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
}

.badge--danger {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 14%, transparent);
}

/* ---------- Flash messages ---------- */

.flash-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.flash {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--paper);
  font-size: 14px;
  color: var(--ink);
}

.flash--success {
  border-color: color-mix(in srgb, var(--success) 45%, transparent);
  background: color-mix(in srgb, var(--success) 10%, var(--paper));
}

.flash--error {
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
  background: color-mix(in srgb, var(--danger) 10%, var(--paper));
}

.flash--warning {
  border-color: color-mix(in srgb, var(--warning) 45%, transparent);
  background: color-mix(in srgb, var(--warning) 10%, var(--paper));
}

/* ---------- Breadcrumbs ---------- */

.breadcrumbs {
  margin-bottom: var(--space-3);
  font-size: 13px;
}

.breadcrumbs__list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.breadcrumbs__item + .breadcrumbs__item::before {
  content: "/";
  margin-right: var(--space-2);
  color: var(--muted);
}

.breadcrumbs__item a {
  color: var(--body);
}

.breadcrumbs__item a:hover {
  color: var(--accent);
}

.breadcrumbs__item [aria-current] {
  font-weight: 700;
  color: var(--ink);
}

/* ---------- Notification bell ---------- */

.notifications {
  position: relative;
}

.bell {
  position: relative;
}

.bell__badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

.bell__badge[hidden] {
  display: none;
}

.notifications__popup {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  z-index: 50;
  width: min(360px, calc(100vw - 32px));
  padding: 0;
}

.notifications__popup .menu__header {
  margin: 0;
  padding: var(--space-3) var(--space-4);
}

.notification-list {
  margin: 0;
  padding: 0;
  max-height: 360px;
  overflow-y: auto;
  list-style: none;
}

.notification {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}

.notification__message {
  margin: 0;
  font-size: 14px;
  color: var(--ink);
}

.notification__time {
  font-size: 12px;
  color: var(--muted);
}

.notification__actions {
  display: flex;
  flex-shrink: 0;
  gap: var(--space-1);
}

.notifications__footer {
  display: flex;
  justify-content: flex-end;
  padding: var(--space-2) var(--space-4);
}

.notifications__empty {
  margin: 0;
  padding: var(--space-5) var(--space-4);
  font-size: 14px;
  text-align: center;
}

/* ---------- Tooltip for the collapsed (icon-only) sidebar ---------- */

.tooltip {
  position: fixed;
  z-index: 60;
  padding: 6px var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--paper);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
  transform: translateY(-50%);
}

/* ---------- Global search ---------- */

.search {
  position: relative;
  width: min(420px, 100%);
}

.search > .icon {
  position: absolute;
  top: 50%;
  left: var(--space-3);
  width: 18px;
  height: 18px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

/* Two classes so it outranks the generic .input padding in forms.css. */
.search .search__input {
  padding-left: 40px;
  padding-right: 36px;
}

.search__shortcut {
  position: absolute;
  top: 50%;
  right: var(--space-3);
  padding: 0 6px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  line-height: 20px;
  transform: translateY(-50%);
  pointer-events: none;
}

.search__input:focus + .search__shortcut {
  display: none;
}

.search__popup {
  position: absolute;
  top: calc(100% + var(--space-2));
  left: 0;
  z-index: 50;
  width: 100%;
  max-height: 70vh;
  overflow-y: auto;
  padding: var(--space-2);
}

.search__hint {
  margin: 0;
  padding: var(--space-3);
  font-size: 14px;
}

.search-group + .search-group {
  margin-top: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid var(--border);
}

.search-group__title {
  margin: 0;
  padding: var(--space-1) var(--space-3);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.search-group__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.search-result {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 8px var(--space-3);
  border-radius: var(--radius-md);
  color: var(--ink);
}

.search-result:hover,
.search-result:focus-visible {
  background: var(--surface-soft);
}

.search-result .icon {
  color: var(--muted);
}

.search-result__label {
  display: block;
  font-size: 14px;
  font-weight: 700;
}

.search-group__more {
  display: block;
  padding: var(--space-2) var(--space-3);
  font-size: 13px;
  font-weight: 700;
}

.search-page {
  max-width: 640px;
}

.search-link {
  display: none;
}

.search-page__form {
  display: flex;
  gap: var(--space-3);
  max-width: 640px;
  margin-bottom: var(--space-5);
}

.badge--info {
  color: var(--info);
  background: color-mix(in srgb, var(--info) 14%, transparent);
}

.badge--warning {
  color: var(--warning);
  background: color-mix(in srgb, var(--warning) 14%, transparent);
}

/* ---------- Add-on cards ---------- */

.addon-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.addon-card__head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.addon-card__icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  color: var(--ink);
}

.addon-card__name {
  margin: 0;
}

/* Long descriptions are cut to three lines so the cards stay even. */
.addon-card__description {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  font-size: 14px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
}

.addon-card__footer {
  margin-top: auto;
}

.addon-group + .addon-group {
  margin-top: var(--space-7);
}

.addon-group__title {
  margin-bottom: var(--space-3);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Stat tile: a count on the Overview ---------- */

.stat-grid {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  margin-bottom: var(--space-5);
}

.stat-tile__label {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

.stat-tile__count {
  margin: var(--space-1) 0 var(--space-3);
  font-size: 28px;
  font-weight: 600;
}

.muted {
  color: var(--muted);
}

/* ---------- A screenshot attached to a record ---------- */

.screenshot {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
}


/* ---------- Several actions in a page header ---------- */

.page-header__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* ---------- A wrapping row of badges (a member's access levels) ---------- */

.badge-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.badge-list .badge {
  white-space: nowrap;
}

/* Card heading with an action beside it (e.g. "Questions" + "Add question"). */
.card__header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2, 8px);
  margin-bottom: var(--space-3, 12px);
}

.card__header .card__title {
  margin: 0;
}

/* Several small row actions in one form (e.g. move up/down, duplicate, delete). */
.inline-actions {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-1);
}

/* Turn an icon upside down (a chevron-down used as "move up"). */
.icon--flip {
  transform: rotate(180deg);
}

/* Cards stacked one after another on a page (Security, Meetings) keep a gap. */
.card + .card,
.card + h2,
.empty-state + h2,
.table-wrap + h2 {
  margin-top: var(--space-4);
}

/* QR tag detail: the two printable codes get their own colour.
   Product (-p, datasheet) is blue; On-product (-t, technical page) is the accent. */
.qr-link {
  color: #fff;
  border: 1px solid transparent;
}

.qr-link--product {
  background: var(--info);
}

.qr-link--technical {
  background: var(--accent);
}

.qr-link:hover {
  filter: brightness(0.92);
}
