/* ═══════════════════════════════════════════════════════════════════
   widgets.css — the GTK4 / libadwaita / Yaru widget vocabulary
   ═══════════════════════════════════════════════════════════════════ */

/* ── buttons ──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 32px; padding: 0 12px;
  border-radius: 7px;
  background: var(--btn-bg);
  color: var(--win-fg);
  font-weight: 500; font-size: 13.5px;
  transition: background var(--t-fast) var(--ease), box-shadow var(--t-fast), transform var(--t-fast), opacity var(--t-fast);
  white-space: nowrap;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.04);
}
.btn:hover { background: var(--btn-bg-hover); }
.btn:active { background: var(--btn-bg-active); }
.btn:disabled, .btn.disabled { opacity: .45; pointer-events: none; }
.btn.flat { background: transparent; box-shadow: none; }
.btn.flat:hover { background: var(--hover); }
.btn.flat:active { background: var(--active); }
.btn.suggested { background: var(--accent-bg); color: var(--accent-fg); box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); }
.btn.suggested:hover { background: var(--accent-hl); }
.btn.suggested:active { filter: brightness(.92); }
.btn.destructive { background: var(--destructive); color: #fff; }
.btn.destructive:hover { filter: brightness(1.12); }
.btn.pill { border-radius: 999px; padding: 0 18px; }
.btn.circular { width: 32px; min-width: 32px; padding: 0; border-radius: 999px; }
.btn.icon { width: 32px; min-width: 32px; padding: 0; }
.btn.large { min-height: 40px; padding: 0 18px; font-size: 15px; }
.btn.small { min-height: 26px; padding: 0 9px; font-size: 12.5px; border-radius: 6px; }
.btn.toggled, .btn[aria-pressed="true"] { background: var(--btn-bg-active); box-shadow: inset 0 0 0 1px var(--border-strong); }
.btn .sym { opacity: .85; }
.btn.wide { width: 100%; }

.linked { display: inline-flex; }
.linked > .btn { border-radius: 0; box-shadow: inset 0 0 0 1px rgba(0,0,0,.06); }
.linked > .btn:first-child { border-radius: 7px 0 0 7px; }
.linked > .btn:last-child { border-radius: 0 7px 7px 0; }
.linked > .btn + .btn { margin-left: 1px; }

/* segmented / view switcher */
.segmented {
  display: inline-flex; padding: 2px; gap: 2px;
  background: var(--btn-bg); border-radius: 8px;
}
.segmented > button {
  min-height: 26px; padding: 0 12px; border-radius: 6px;
  font-size: 13px; font-weight: 500; color: var(--win-fg-dim);
  display: inline-flex; align-items: center; gap: 6px;
  transition: background var(--t-fast), color var(--t-fast);
}
.segmented > button:hover { background: var(--hover); color: var(--win-fg); }
.segmented > button.on {
  background: var(--view-bg); color: var(--win-fg);
  box-shadow: 0 1px 2px rgba(0,0,0,.14), inset 0 0 0 1px var(--border);
}

/* ── entries ─────────────────────────────────────────────────────── */
.entry {
  display: flex; align-items: center; gap: 7px;
  min-height: 34px; padding: 0 10px;
  background: var(--entry-bg);
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px var(--entry-border);
  transition: box-shadow var(--t-fast), background var(--t-fast);
}
.entry:focus-within { box-shadow: inset 0 0 0 2px var(--accent-bg); background: var(--view-bg); }
.entry input, .entry textarea {
  flex: 1; min-width: 0; border: 0; background: none; outline: none;
  font-size: 14px; color: var(--win-fg);
  user-select: text; -webkit-user-select: text;
}
.entry input::placeholder { color: var(--win-fg-faint); }
.entry .sym { color: var(--win-fg-faint); }
.entry.error { box-shadow: inset 0 0 0 2px var(--error); }
.entry.search { border-radius: 999px; padding: 0 12px; }
.entry-clear { opacity: .55; }
.entry-clear:hover { opacity: 1; }

textarea.code, .code-view {
  font-family: var(--font-mono); font-size: 13.5px; line-height: 1.5;
  background: var(--code-bg); color: var(--win-fg);
  user-select: text; -webkit-user-select: text;
}

/* ── switch (Yaru) ───────────────────────────────────────────────── */
.switch {
  position: relative; flex: none;
  width: 44px; height: 25px; border-radius: 999px;
  background: var(--btn-bg);
  box-shadow: inset 0 0 0 1px var(--border-strong);
  transition: background var(--t-med) var(--ease), box-shadow var(--t-med);
  cursor: pointer;
}
.switch::after {
  content: ''; position: absolute; top: 2.5px; left: 2.5px;
  width: 20px; height: 20px; border-radius: 999px; background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.3), 0 0 0 1px rgba(0,0,0,.06);
  transition: transform var(--t-med) var(--ease-out), background var(--t-med);
}
.switch.on { background: var(--accent-bg); box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
.switch.on::after { transform: translateX(19px); }
.switch:active::after { width: 22px; }
.switch.disabled { opacity: .45; pointer-events: none; }

/* checkbox / radio */
.check {
  width: 20px; height: 20px; border-radius: 6px; flex: none;
  background: var(--entry-bg); box-shadow: inset 0 0 0 1px var(--border-strong);
  display: grid; place-items: center; color: transparent;
  transition: background var(--t-fast), color var(--t-fast);
  cursor: pointer;
}
.check.on { background: var(--accent-bg); color: var(--accent-fg); box-shadow: none; }
.check.radio { border-radius: 999px; }
.check.radio.on { background: var(--accent-bg); }
.check.radio.on::after { content: ''; width: 8px; height: 8px; border-radius: 999px; background: #fff; }
.check.radio .sym { display: none; }

/* ── slider ──────────────────────────────────────────────────────── */
.slider {
  position: relative; flex: 1; height: 24px; display: flex; align-items: center;
  cursor: pointer; touch-action: none; min-width: 60px;
}
.slider .track {
  position: absolute; left: 0; right: 0; height: 5px; border-radius: 999px;
  background: var(--btn-bg); box-shadow: inset 0 0 0 1px rgba(0,0,0,.06);
}
.slider .fill {
  position: absolute; left: 0; height: 5px; border-radius: 999px;
  background: var(--accent-bg);
  transition: width 60ms linear;
}
.slider .knob {
  position: absolute; width: 18px; height: 18px; border-radius: 999px; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.35), 0 0 0 1px rgba(0,0,0,.08);
  transform: translateX(-50%);
  transition: width 60ms, height 60ms, left 60ms linear;
}
.slider:hover .knob, .slider.dragging .knob { box-shadow: 0 1px 4px rgba(0,0,0,.4), 0 0 0 1px rgba(0,0,0,.1), 0 0 0 6px var(--accent-dim); }
.slider.disabled { opacity: .45; pointer-events: none; }
.slider .marks { position: absolute; left: 0; right: 0; top: 15px; height: 6px; }
.slider .marks i { position: absolute; width: 1px; height: 4px; background: var(--win-fg-faint); }

/* ── listbox (boxed list) ────────────────────────────────────────── */
.listbox {
  background: var(--card-bg); border-radius: 12px; overflow: hidden;
  box-shadow: 0 0 0 1px var(--border), 0 1px 2px rgba(0,0,0,.04);
}
.listbox.flat { background: none; box-shadow: none; border-radius: 0; }
.row {
  display: flex; align-items: center; gap: 12px;
  min-height: 50px; padding: 8px 14px;
  border-top: 1px solid var(--border);
  transition: background var(--t-fast);
  position: relative;
}
.row:first-child { border-top: 0; }
.row.activatable { cursor: pointer; }
.row.activatable:hover { background: var(--hover); }
.row.activatable:active { background: var(--active); }
.row.selected { background: var(--accent-dim); }
.row.disabled { opacity: .5; pointer-events: none; }
.row-text { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 1px; }
.row-title { font-size: 14px; font-weight: 400; color: var(--win-fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-subtitle { font-size: 12.5px; color: var(--win-fg-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-suffix { display: flex; align-items: center; gap: 8px; color: var(--win-fg-dim); font-size: 13px; flex: none; }
.row-icon { color: var(--win-fg-dim); flex: none; }
.row.header-row { min-height: 34px; background: var(--view-alt); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--win-fg-dim); }
.row .drag-handle { opacity: .35; cursor: grab; }
.row:hover .drag-handle { opacity: .7; }

.pref-group { display: flex; flex-direction: column; gap: 8px; margin-bottom: 22px; }
.pref-group > .pref-title { font-size: 15px; font-weight: 500; padding: 0 4px; }
.pref-group > .pref-desc { font-size: 12.5px; color: var(--win-fg-dim); padding: 0 4px; margin-top: -4px; }
.pref-page { padding: 22px 18px 34px; max-width: 720px; margin: 0 auto; width: 100%; }

.expander-content { display: none; background: var(--view-alt); }
.row.expander.open + .expander-content { display: block; }
.row.expander .expander-arrow { transition: transform var(--t-med) var(--ease); }
.row.expander.open .expander-arrow { transform: rotate(180deg); }

/* combo (select) */
.combo {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 30px; padding: 0 8px 0 10px; border-radius: 7px;
  background: var(--btn-bg); font-size: 13.5px; color: var(--win-fg);
  cursor: pointer; transition: background var(--t-fast);
}
.combo:hover { background: var(--btn-bg-hover); }
.combo .sym { opacity: .6; }

/* ── separators, cards ──────────────────────────────────────────── */
.sep { height: 1px; background: var(--border); flex: none; }
.sep.vert { width: 1px; height: auto; align-self: stretch; }
.card {
  background: var(--card-bg); border-radius: 12px;
  box-shadow: 0 0 0 1px var(--border), 0 1px 3px rgba(0,0,0,.06);
}
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--accent-bg); color: var(--accent-fg);
  font-size: 11px; font-weight: 500;
}
.pill-label {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px;
  border-radius: 999px; background: var(--btn-bg); font-size: 12px; color: var(--win-fg-dim);
}
.pill-label.accent { background: var(--accent-dim); color: var(--win-fg); }
.pill-label.success { background: rgba(38,162,105,.18); color: #1c7d50; }
[data-color-scheme="dark"] .pill-label.success { color: #6ee7a8; }
.pill-label.warn { background: rgba(229,165,10,.2); color: #8a6200; }
[data-color-scheme="dark"] .pill-label.warn { color: #ffd166; }

/* ── progress / spinner / level ─────────────────────────────────── */
.progress { height: 5px; border-radius: 999px; background: var(--btn-bg); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 999px; background: var(--accent-bg); transition: width 180ms var(--ease); }
.progress.indeterminate > i { width: 35% !important; animation: prog-slide 1.3s var(--ease-in-out) infinite; }
@keyframes prog-slide { 0% { transform: translateX(-110%); } 100% { transform: translateX(320%); } }

.spinner {
  width: 18px; height: 18px; border-radius: 999px; flex: none;
  border: 2.5px solid var(--win-fg-faint); border-top-color: var(--win-fg);
  animation: spin .9s linear infinite;
}
.spinner.large { width: 34px; height: 34px; border-width: 3.5px; }
.spinner.small { width: 14px; height: 14px; border-width: 2px; }
.spinner.accent { border-color: var(--accent-dim); border-top-color: var(--accent-bg); }
@keyframes spin { to { transform: rotate(360deg); } }

.level-bar { height: 6px; border-radius: 999px; background: var(--btn-bg); overflow: hidden; }
.level-bar > i { display: block; height: 100%; background: var(--success); border-radius: 999px; transition: width 300ms var(--ease); }
.level-bar.warn > i { background: var(--warning); }
.level-bar.error > i { background: var(--error); }

/* ── empty state ────────────────────────────────────────────────── */
.empty-state {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 40px; text-align: center; color: var(--win-fg-dim);
}
.empty-state .es-icon { opacity: .3; margin-bottom: 6px; color: var(--win-fg); }
.empty-state .es-title { font-size: 17px; font-weight: 500; color: var(--win-fg); }
.empty-state .es-desc { font-size: 13.5px; max-width: 340px; }
.empty-state .es-actions { margin-top: 10px; display: flex; gap: 8px; }

/* ── menus (shell + app context menus) ─────────────────────────── */
.menu {
  position: absolute;
  min-width: 190px; max-width: 340px; padding: 6px;
  background: var(--menu-bg, var(--card-bg));
  border-radius: var(--radius-menu);
  box-shadow: 0 0 0 1px var(--border), var(--shadow-popover);
  transform-origin: top left;
  animation: menu-in 130ms var(--ease-out);
  max-height: min(70vh, 520px); overflow-y: auto;
}
.menu.dark {
  --menu-bg: var(--shell-popover);
  color: var(--shell-fg);
  box-shadow: 0 0 0 1px var(--shell-border), var(--shell-shadow);
}
.menu.up { transform-origin: bottom left; }
@keyframes menu-in { from { opacity: 0; transform: scale(.96) translateY(-4px); } to { opacity: 1; transform: none; } }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  min-height: 30px; padding: 4px 10px; border-radius: 6px;
  font-size: 13.5px; text-align: left; color: inherit;
  transition: background 90ms var(--ease);
}
.menu-item:hover, .menu-item.focus { background: var(--menu-hover, var(--hover)); }
.menu.dark .menu-item:hover, .menu.dark .menu-item.focus { background: var(--shell-popover-hover); }
.menu-item.disabled { opacity: .4; pointer-events: none; }
.menu-item .mi-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item .mi-accel { font-size: 12px; opacity: .5; }
.menu-item .mi-icon { opacity: .8; }
.menu-item .mi-check { width: 16px; }
.menu-item.destructive { color: #e05252; }
.menu-sep { height: 1px; margin: 5px 8px; background: currentColor; opacity: .12; }
.menu-title { padding: 5px 10px 3px; font-size: 12px; opacity: .55; text-transform: none; }

/* ── tooltip ────────────────────────────────────────────────────── */
.tooltip {
  position: absolute; padding: 5px 9px;
  background: rgba(20,20,20,.94); color: #fff;
  border-radius: 6px; font-size: 12.5px; line-height: 1.3;
  box-shadow: 0 2px 8px rgba(0,0,0,.4), 0 0 0 1px rgba(255,255,255,.08);
  max-width: 280px; white-space: pre-line;
  animation: tip-in 110ms var(--ease-out);
  pointer-events: none;
}
@keyframes tip-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; } }

/* ── dialogs (GNOME message dialog / adw AlertDialog) ──────────── */
.dialog-scrim {
  position: absolute; inset: 0; background: rgba(0,0,0,.35);
  display: grid; place-items: center;
  animation: fade-in 160ms var(--ease);
  backdrop-filter: blur(1px);
}
.dialog-scrim.in-window { position: absolute; border-radius: inherit; align-items: flex-start; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.dialog {
  min-width: 300px; max-width: 460px;
  background: var(--win-bg); color: var(--win-fg);
  border-radius: 14px; overflow: hidden;
  box-shadow: 0 0 0 1px var(--border), 0 12px 44px rgba(0,0,0,.45);
  animation: dialog-in 220ms var(--ease-out);
}
.dialog-scrim.in-window .dialog { border-radius: 0 0 14px 14px; animation: dialog-drop 260ms var(--ease-out); }
@keyframes dialog-in { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
@keyframes dialog-drop { from { opacity: 0; transform: translateY(-24px); } to { opacity: 1; transform: none; } }
.dialog-body { padding: 22px 22px 16px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.dialog-icon { margin-bottom: 4px; color: var(--win-fg-dim); }
.dialog-title { font-size: 16px; font-weight: 700; }
.dialog-text { font-size: 13.5px; color: var(--win-fg-dim); line-height: 1.45; }
.dialog-extra { width: 100%; margin-top: 10px; text-align: left; }
.dialog-actions { display: flex; border-top: 1px solid var(--border); }
.dialog-actions > button {
  flex: 1; min-height: 44px; font-size: 14px; font-weight: 500;
  color: var(--win-fg); transition: background var(--t-fast);
}
.dialog-actions > button + button { border-left: 1px solid var(--border); }
.dialog-actions > button:hover { background: var(--hover); }
.dialog-actions > button:active { background: var(--active); }
.dialog-actions > button.suggested { color: var(--accent-bg); font-weight: 700; }
.dialog-actions > button.destructive { color: #e01b24; font-weight: 700; }
.dialog-actions.vertical { flex-direction: column; }
.dialog-actions.vertical > button + button { border-left: 0; border-top: 1px solid var(--border); }

/* ── in-app toast ───────────────────────────────────────────────── */
.toast-area {
  position: absolute; left: 0; right: 0; bottom: 14px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; z-index: 40;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 12px;
  padding: 8px 10px 8px 16px; border-radius: 999px;
  background: #383838; color: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,.35), 0 0 0 1px rgba(255,255,255,.07);
  font-size: 13.5px;
  animation: toast-in 240ms var(--ease-out);
  max-width: 90%;
}
.toast.out { animation: toast-out 200ms var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(10px) scale(.97); } }
.toast .btn { background: rgba(255,255,255,.14); color: #fff; }
.toast .btn:hover { background: rgba(255,255,255,.22); }

/* ── OSD (volume / brightness) ─────────────────────────────────── */
.osd {
  position: absolute; left: 50%; bottom: 12%;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px;
  padding: 14px 20px; min-width: 300px;
  background: rgba(30,30,30,.92); color: #fff;
  border-radius: 16px; box-shadow: var(--shell-shadow), 0 0 0 1px rgba(255,255,255,.08);
  backdrop-filter: blur(12px);
  animation: osd-in 180ms var(--ease-out);
}
.osd.out { animation: osd-out 220ms var(--ease) forwards; }
@keyframes osd-in { from { opacity: 0; transform: translateX(-50%) scale(.94); } to { opacity: 1; transform: translateX(-50%); } }
@keyframes osd-out { to { opacity: 0; transform: translateX(-50%) scale(.97); } }
.osd .osd-bar { flex: 1; height: 8px; border-radius: 999px; background: rgba(255,255,255,.2); overflow: hidden; }
.osd .osd-bar > i { display: block; height: 100%; background: #fff; border-radius: 999px; transition: width 90ms linear; }
.osd .osd-value { min-width: 42px; text-align: right; font-variant-numeric: tabular-nums; font-size: 14px; }
.osd.osd-simple { min-width: 0; }

/* ── avatar ─────────────────────────────────────────────────────── */
.avatar {
  width: 40px; height: 40px; border-radius: 999px; flex: none;
  display: grid; place-items: center; overflow: hidden;
  background: linear-gradient(160deg, var(--accent-hl), var(--accent-bg));
  color: #fff; font-weight: 500; font-size: 17px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.1);
}
.avatar.large { width: 96px; height: 96px; font-size: 40px; }
.avatar.small { width: 26px; height: 26px; font-size: 12px; }

/* ── shell popovers (dark, always) ─────────────────────────────── */
.popover {
  position: absolute;
  background: var(--shell-popover);
  color: var(--shell-fg);
  border-radius: var(--radius-popover);
  box-shadow: var(--shell-shadow-lg), 0 0 0 1px var(--shell-border);
  padding: 10px;
  animation: pop-in 200ms var(--ease-out);
  transform-origin: top center;
  overflow: hidden;
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-8px) scale(.97); } to { opacity: 1; transform: none; } }
.popover.out { animation: pop-out 140ms var(--ease) forwards; }
@keyframes pop-out { to { opacity: 0; transform: translateY(-6px) scale(.98); } }
.popover .pop-title { font-size: 13px; color: var(--shell-dim); padding: 2px 6px 8px; }
.popover-scrim { position: absolute; inset: 0; }

.shell-row {
  display: flex; align-items: center; gap: 10px; text-align: left;
  min-height: 34px; padding: 5px 10px; border-radius: 8px;
  font-size: 13.5px; color: var(--shell-fg);
  transition: background var(--t-fast);
  width: 100%; text-align: left;
}
.shell-row:hover { background: var(--shell-popover-hover); }
.shell-row:active { background: var(--shell-popover-active); }
.shell-row.selected { background: var(--shell-popover-active); }
.shell-sep { height: 1px; margin: 6px 4px; background: rgba(255,255,255,.1); }

/* widgets living inside a shell popover are always dark-themed */
.popover .btn, .banner .btn, .switcher .btn { color: #fff; background: rgba(255,255,255,.1); box-shadow: none; }
.popover .btn.flat, .banner .btn.flat { background: transparent; }
.popover .btn:hover, .banner .btn:hover { background: rgba(255,255,255,.18); }
.popover .btn.flat:hover { background: rgba(255,255,255,.14); }
.popover .switch { background: rgba(255,255,255,.14); box-shadow: inset 0 0 0 1px rgba(255,255,255,.22); }
.popover .switch.on { background: var(--accent-shell); box-shadow: inset 0 0 0 1px rgba(0,0,0,.2); }
.popover .slider .track { background: rgba(255,255,255,.18); box-shadow: none; }
.popover .slider .fill { background: #fff; }
.popover .entry { background: rgba(255,255,255,.1); box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); }
.popover .entry input { color: #fff; }
.popover .spinner { border-color: rgba(255,255,255,.3); border-top-color: #fff; }
.popover .check { background: rgba(255,255,255,.12); box-shadow: inset 0 0 0 1px rgba(255,255,255,.24); }

.shell-slider { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }
.shell-slider .slider .track { background: rgba(255,255,255,.18); box-shadow: none; }
.shell-slider .slider .fill { background: #fff; }
.shell-slider .slider .knob { background: #fff; }
.shell-slider .slider:hover .knob { box-shadow: 0 1px 4px rgba(0,0,0,.4), 0 0 0 6px rgba(255,255,255,.18); }
