/* Shared UI components — requires tokens.css */

*,
*::before,
*::after {
  box-sizing: border-box;
}

.btn {
  font: inherit;
  font-size: 0.875rem;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

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

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

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

.btn--secondary {
  background: var(--bg-panel);
  border-color: var(--border);
  color: var(--text);
}

.btn--secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn--ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}

.btn--ghost:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
}

.btn--danger {
  background: var(--bg-panel);
  border-color: #fecaca;
  color: var(--error);
}

.btn--danger:hover {
  background: var(--error-soft);
}

.btn--block {
  width: 100%;
}

.btn--sm {
  padding: 0.2rem 0.5rem;
  font-size: 0.8rem;
}

/* Compact icon toolbar actions */
.icon-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.45rem;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: none;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}

.icon-action:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.icon-action:focus-visible {
  outline: 2px solid var(--accent-soft);
  outline-offset: 1px;
}

.icon-action--accent {
  color: var(--accent);
  background: var(--accent-soft);
}

.icon-action--accent:hover {
  background: #bfdbfe;
  color: var(--accent-hover);
}

.icon-action__glyph {
  width: 1.05rem;
  height: 1.05rem;
  flex-shrink: 0;
}

.icon-action__label {
  display: none;
}

@media (min-width: 900px) {
  .app-shell__toolbar .icon-action {
    min-width: auto;
    padding: 0 0.55rem;
  }

  .app-shell__toolbar .icon-action__label {
    display: inline;
  }
}

.toolbar-group {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  flex-wrap: wrap;
}

.toolbar-group--filters {
  gap: 0.5rem;
}

.toolbar-filters {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.toolbar-filter {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.toolbar-filter__label {
  white-space: nowrap;
  font-weight: 500;
}

.toolbar-filter__select,
.toolbar-filter input[type="date"] {
  height: 2rem;
  padding: 0 0.45rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
  font: inherit;
  font-size: 0.8rem;
  color: var(--text);
  max-width: 11rem;
}

.toolbar-filter input[type="date"] {
  max-width: 10.5rem;
}

.toolbar-filter__select:focus-visible,
.toolbar-filter input[type="date"]:focus-visible {
  outline: 2px solid var(--accent-soft);
  outline-offset: 1px;
}

.toolbar-divider {
  width: 1px;
  height: 1.25rem;
  background: var(--border);
  margin: 0 0.25rem;
}

/* Dropdown panels (nav more, programme switcher, user menu) */
.shell-dropdown {
  position: absolute;
  top: calc(100% + 0.35rem);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 40;
  padding: 0.35rem 0;
}

.shell-dropdown[hidden] {
  display: none;
}

.shell-dropdown__group-label {
  margin: 0;
  padding: 0.4rem 0.75rem 0.25rem;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.shell-dropdown__item {
  display: block;
  width: 100%;
  padding: 0.45rem 0.75rem;
  font-size: 0.85rem;
  color: var(--text);
  text-decoration: none;
  text-align: left;
  border: 0;
  background: transparent;
  cursor: pointer;
  box-sizing: border-box;
  font-family: inherit;
}

.shell-dropdown__item:hover {
  background: var(--accent-soft);
}

.shell-dropdown__item--active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.shell-dropdown__item-sub {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 0.1rem;
}

.shell-dropdown__footer {
  display: block;
  padding: 0.5rem 0.75rem;
  margin-top: 0.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--accent);
  text-decoration: none;
}

.shell-dropdown__footer:hover {
  background: var(--accent-soft);
}

/* Programme switcher */
.programme-switcher {
  position: relative;
}

.app-shell__brand-inner {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.app-shell__logo-link {
  display: flex;
  flex-shrink: 0;
  color: inherit;
  text-decoration: none;
  border-radius: var(--radius);
}

.app-shell__logo-link:hover {
  background: var(--accent-soft);
}

.app-shell__titles {
  min-width: 0;
  flex: 1;
}

.app-shell__title-row {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  min-width: 0;
}

.programme-switcher__trigger,
.programme-switcher__chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  cursor: pointer;
  border-radius: var(--radius);
  color: var(--text-muted);
  padding: 0.15rem 0.35rem;
  flex-shrink: 0;
}

.programme-switcher__trigger:hover,
.programme-switcher__chevron:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.programme-switcher__chevron-icon {
  width: 0.85rem;
  height: 0.85rem;
}

.programme-switcher__trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  max-width: 100%;
}

.programme-switcher__trigger .app-shell__title,
.programme-switcher__trigger .app-shell__subtitle {
  margin: 0;
  text-align: left;
}

.programme-switcher__dropdown {
  left: 0;
  min-width: 16rem;
  max-width: min(22rem, 90vw);
  max-height: 18rem;
  overflow-y: auto;
}

.programme-switcher__form {
  margin: 0;
}

/* Empty states */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 2.5rem 1.5rem;
  background: var(--bg-panel);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
}

.empty-state__icon {
  width: 3rem;
  height: 3rem;
  color: var(--accent);
  opacity: 0.85;
  margin-bottom: 0.85rem;
}

.empty-state__title {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  font-weight: 600;
}

.empty-state__hint {
  margin: 0 0 1rem;
  max-width: 26rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.empty-state__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

/* Role badges & programme cards */
.role-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  text-transform: capitalize;
  background: #e2e8f0;
  color: #475569;
  vertical-align: middle;
}

.role-badge--owner {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.role-badge--admin {
  background: #e0e7ff;
  color: #4338ca;
}

.role-badge--editor,
.role-badge--member {
  background: var(--bg-muted);
  color: #475569;
}

.role-badge--guest,
.role-badge--viewer {
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid #e2e8f0;
}

.programme-card {
  display: block;
  width: 100%;
  min-width: 12rem;
  text-align: left;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.programme-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.programme-card--active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.programme-card__title {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.3;
}

.programme-card__sub {
  display: block;
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.status {
  font-size: 0.8rem;
  color: var(--text-muted);
  min-width: 4rem;
}

.status--ok {
  color: var(--success);
}

.status--error {
  color: var(--error);
}

/* Segmented locale control */
.locale-switcher--segmented {
  display: inline-flex;
  align-items: center;
  padding: 2px;
  gap: 0;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.locale-switcher__form {
  margin: 0;
}

.locale-switcher--segmented .locale-switcher__btn {
  border: 0;
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  line-height: 1;
  min-width: 2.1rem;
  padding: 0.35rem 0.5rem;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.locale-switcher--segmented .locale-switcher__btn:hover {
  color: var(--text);
}

.locale-switcher--segmented .locale-switcher__btn--active {
  background: var(--bg-panel);
  box-shadow: var(--shadow-sm);
  color: var(--text);
}

.methodology-lint {
  margin-top: 0.5rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-muted);
}

.methodology-lint__title {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.methodology-lint__list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.8rem;
  line-height: 1.4;
}

.methodology-lint__item {
  margin: 0.15rem 0;
  color: var(--text-muted);
}

.methodology-lint__item--warn {
  color: #92400e;
}
