/* Optitoo toolbox — shared components, taken from OptiChart as they were:
   icons, buttons, menus, form controls, segmented controls, modals, toasts.
   Link after tokens.css and before a tool's own stylesheet. */
* {
  box-sizing: border-box;
}

.sprite {
  display: none;
}

.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

button {
  font: inherit;
  color: inherit;
}

.icon-btn,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 9px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

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

.btn {
  padding: 0 11px;
  font-weight: 500;
  border-color: var(--border);
  background: var(--surface);
}

.icon-btn:hover,
.btn:hover {
  background: var(--surface-sunken);
  border-color: var(--border-strong);
}

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

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

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

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

.icon-btn[aria-checked="true"],
.icon-btn.is-active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: transparent;
}

button:disabled {
  opacity: 0.38;
  cursor: default;
  pointer-events: none;
}

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

.menu-wrap {
  position: relative;
}

/* `display` here would otherwise beat the UA rule for the `hidden` attribute. */
.menu[hidden] {
  display: none;
}

.menu {
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  min-width: 190px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.menu button {
  padding: 7px 10px;
  text-align: left;
  background: none;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.menu button:hover {
  background: var(--surface-sunken);
}

input[type="text"],
input[type="number"],
input[type="search"],
select,
textarea {
  width: 100%;
  min-width: 0;
  padding: 5px 7px;
  font: inherit;
  font-size: 12px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

textarea {
  resize: vertical;
  min-height: 54px;
  line-height: 1.4;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.seg {
  display: grid;
  grid-auto-flow: column;
  gap: 2px;
  padding: 2px;
  background: var(--surface-sunken);
  border-radius: var(--radius-sm);
}

.seg button {
  padding: 4px 0;
  font-size: 11px;
  background: none;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-dim);
}

.seg button.is-active {
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

/* ---------------------------------------------------------------- modals -- */

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgb(11 18 26 / 45%);
}

.modal-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(760px, 92vw);
  max-height: 82vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.modal-narrow {
  width: min(520px, 92vw);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-head h2 {
  margin: 0;
  font-size: 15px;
}

/* ---------------------------------------------------------------- toasts -- */

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 620px;
  padding: 10px 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}

.toast[hidden] {
  display: none;
}

.toast[data-kind="error"] {
  border-left-color: var(--danger);
}

.toast[data-kind="success"] {
  border-left-color: var(--ok);
}

.toast .btn {
  height: 26px;
  padding: 0 9px;
  white-space: nowrap;
}

/* -------------------------------------------------------------- user menu -- */

.user-avatar {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 20px;
  height: 20px;
  font-size: 10px;
  font-weight: 700;
  color: var(--accent-text);
  background: var(--accent);
  border-radius: 50%;
}

.user-menu-head {
  display: grid;
  gap: 2px;
  padding: 8px 10px 10px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.user-menu-head strong {
  font-size: 13px;
}

.user-menu-head span {
  font-size: 11px;
  color: var(--text-dim);
  overflow-wrap: anywhere;
}

.menu .menu-sep {
  height: 1px;
  margin: 4px 0;
  background: var(--border);
}

.menu button.menu-danger {
  color: var(--danger);
}

.menu button.menu-danger:hover {
  background: var(--danger-soft);
}

/* Links in a menu look like its buttons. */
.menu a {
  padding: 7px 10px;
  color: inherit;
  text-align: left;
  text-decoration: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.menu a:hover {
  background: var(--surface-sunken);
}

.menu a[aria-current="page"] {
  color: var(--accent);
  background: var(--accent-soft);
}

.menu .user-role {
  font-weight: 600;
  color: var(--accent);
}
