/* Reusable UI components */

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
  font-size: 1.125rem;
  line-height: 1;
  transition: background var(--transition-fast);
}

.icon-btn:hover {
  background: var(--color-surface-alt);
}

.icon-btn:focus-visible,
.theme-toggle:focus-visible,
.nav-item:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ---------- Generic modal dialog chrome -----------------------------
   Shared shell for every in-app modal (session-io.js's import dialog,
   sessions.js's new-session dialog, and any future one) -- an app-level
   confirm/prompt reads as part of the app, not a browser chrome popup,
   and factoring the overlay/dialog/actions rules here once means a new
   modal only ever needs to add its own content-specific classes, never
   redeclare backdrop/box/button-row layout. Each caller adds its own
   feature-scoped class alongside `.modal-overlay`/`.modal-dialog` (e.g.
   `.session-add-modal`) only where it needs to select or override
   something these shared rules don't cover. */

.modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-scrim);
  padding: 1rem;
  z-index: 100;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-dialog {
  width: 100%;
  max-width: 26rem;
  max-height: 100%;
  overflow-y: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 1.25rem;
}

.modal-dialog h2 {
  margin-block: 0 0.375rem;
  font-size: 1.0625rem;
}

.modal-hint {
  margin-block: 0 0.875rem;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-block-start: 1.125rem;
}

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

/* ---------- Language switch (EN | BM): two-option segmented pill ---------- */

.lang-switch {
  display: inline-flex;
  flex: 0 0 auto;
  padding: 0.1875rem;
  gap: 0.125rem;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-alt);
}

.lang-switch__option {
  min-width: 2.25rem;
  padding-block: 0.1875rem;
  padding-inline: 0.5rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--color-text-muted);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.lang-switch__option:hover {
  color: var(--color-text);
}

/* Keyed off <html lang> (stamped before first paint), not aria-pressed (set by
   JS later), so a BM page never flashes EN as the selected option on load. */
:root[lang="en"] .lang-switch__option[data-lang="en"],
:root[lang="ms"] .lang-switch__option[data-lang="ms"] {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
}

.lang-switch__option:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

.lang-switch__option:disabled {
  cursor: progress;
}

/* ---------- Theme toggle: pill track + sliding circular knob ---------- */

.theme-toggle {
  position: relative;
  width: 3.25rem;
  height: 1.75rem;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-alt);
  cursor: pointer;
  padding: 0;
  flex: 0 0 auto;
  transition: background var(--transition-medium), border-color var(--transition-medium);
}

.theme-toggle__knob {
  position: absolute;
  inset-block-start: 50%;
  inset-inline-start: 0.1875rem;
  transform: translateY(-50%);
  width: 1.3125rem;
  height: 1.3125rem;
  border-radius: 50%;
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  transition: inset-inline-start var(--transition-medium);
}

[data-theme="dark"] .theme-toggle__knob {
  inset-inline-start: calc(100% - 1.3125rem - 0.1875rem);
}

.theme-toggle__icon {
  position: absolute;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.theme-toggle__icon--sun {
  opacity: 1;
}

[data-theme="dark"] .theme-toggle__icon--sun {
  opacity: 0;
}

[data-theme="dark"] .theme-toggle__icon--moon {
  opacity: 1;
}

/* ---------- Notice (a standing reminder, e.g. the heir disclaimers) ---------- */

.notice {
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--color-notice-border);
  border-inline-start-width: 4px;
  border-radius: var(--radius-sm);
  background: var(--color-notice-bg);
  color: var(--color-notice-text);
  font-size: 0.8125rem;
  line-height: 1.45;
}

.notice__title {
  margin: 0 0 0.375rem;
  font-weight: 600;
}

.notice__item {
  margin: 0;
}

.notice__item + .notice__item {
  margin-block-start: 0.375rem;
}

.notice__list {
  margin-block: 0.125rem 0.375rem;
  padding-inline-start: 1.25rem;
}
