/* widget.css — Arete Widget additions on top of the shared styles.css theme. */

/* The hidden attribute must ALWAYS win, even over `label { display: flex }`
   and friends — otherwise mode-toggled form rows (add-widget New/Join) render
   despite being hidden. */
[hidden] { display: none !important; }

.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.muted-note { color: var(--muted); font-size: 12px; }
.empty { color: var(--muted); font-style: italic; margin: 8px 0 2px; }
.dim { color: var(--muted); }

/* ---- chips ---- */
.chip {
  display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--border); vertical-align: 1px;
}
.chip.ok   { color: var(--green); border-color: rgba(62,207,142,.4); background: rgba(62,207,142,.08); }
.chip.wait { color: var(--amber); border-color: rgba(245,179,76,.4); background: rgba(245,179,76,.08); }
.chip.off  { color: var(--muted); }
.chip.bad  { color: var(--red); border-color: rgba(245,108,108,.4); background: rgba(245,108,108,.08); }
.chip.auto { color: var(--accent); border-color: rgba(76,139,245,.4); background: rgba(76,139,245,.08); }
.chip.src.library { color: var(--accent); border-color: rgba(76,139,245,.35); }
.chip.src.local   { color: var(--green); border-color: rgba(62,207,142,.35); }
.chip.src.bundled { color: var(--muted); }

.cap-chip {
  display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--muted);
  font-family: var(--mono);
}
.cap-chip.provider { border-left: 3px solid var(--accent); }
.cap-chip.consumer { border-left: 3px solid #9b6ef5; }

/* ---- shared bits (picker rows + dialog) ---- */
.def-title { font-weight: 600; }
.def-desc { color: var(--muted); font-size: 12.5px; margin: 3px 0 7px; max-width: 60ch; }
.def-caps { display: flex; gap: 6px; flex-wrap: wrap; }
.def-error { color: var(--red); font-size: 12px; margin-top: 8px; }
.kv { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.kv .k { color: var(--text); }
.kv .v { color: var(--green); }
button.danger { color: var(--red); }

/* ---- the home-page tile grid ---- */
.tile-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px; margin-top: 4px;
}
.tile {
  position: relative; text-align: left; cursor: pointer;
  border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px 14px;
  background: var(--panel-2); color: var(--text);
  display: flex; flex-direction: column; gap: 4px; min-height: 128px;
  transition: border-color .12s, transform .12s;
  border-top: 3px solid var(--tile-accent, var(--border));
}
.tile:hover { border-color: var(--tile-accent, var(--accent)); transform: translateY(-1px); }
/* While its menu is open, the tile must sit above its neighbours (so the
   popover paints over adjacent tiles) and hold still (no hover lift). */
.tile.menu-open { z-index: 20; transform: none; border-color: var(--tile-accent, var(--accent)); }
.tile-top { display: flex; align-items: flex-start; justify-content: space-between; position: relative; }
.tile-icon { font-size: 26px; line-height: 1.2; }
.tile-more {
  padding: 0 8px; font-size: 16px; line-height: 1.4; border-radius: 6px;
  opacity: 0; transition: opacity .12s;
}
.tile:hover .tile-more, .tile-more:focus, .tile-menu { opacity: 1; }
.tile-name { font-weight: 600; font-size: 14px; margin-top: 2px; }
.tile-sub { color: var(--muted); font-size: 11.5px; }
.tile-chip { margin-top: 4px; }
.tile-state { margin-top: 4px; display: flex; gap: 8px; flex-wrap: wrap; }
.tile-peers { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.tile-menu {
  position: absolute; top: 28px; right: 0; z-index: 21; width: max-content; min-width: 150px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5); padding: 5px;
  display: flex; flex-direction: column; gap: 2px;
}
.tile-menu button {
  background: none; border: 1px solid transparent; text-align: left; padding: 8px 12px;
  border-radius: 7px; color: var(--text); font-size: 12.5px; cursor: pointer; width: 100%;
}
.tile-menu button:hover { background: var(--panel-2); border-color: var(--border); }
.tile-menu button.danger:hover { border-color: rgba(245,108,108,.4); }
/* remove-confirm view */
.tile-menu.confirm { padding: 10px 12px 8px; gap: 6px; min-width: 210px; }
.tile-menu .menu-q { font-weight: 600; font-size: 12.5px; }
.tile-menu .menu-note { color: var(--muted); font-size: 11px; line-height: 1.45; }
.tile-menu .menu-row { display: flex; gap: 6px; justify-content: flex-end; margin-top: 2px; }
.tile-menu .menu-row button { width: auto; text-align: center; padding: 6px 12px; }
.tile-menu .menu-row button.danger { color: white; background: var(--red); border-color: var(--red); }
.tile-menu .menu-row button.danger:hover { background: #e05555; }
/* ---- remove-all (card header) ---- */
.card-tools { display: flex; align-items: center; gap: 12px; }
.removeall { position: relative; display: inline-flex; }
.removeall > button.danger {
  background: none; border: 1px solid transparent; padding: 4px 10px;
  border-radius: 7px; font-size: 12.5px; cursor: pointer;
}
.removeall > button.danger:hover { background: var(--panel-2); border-color: rgba(245,108,108,.4); }
.removeall .tile-menu { top: calc(100% + 6px); }

.tile.plus {
  align-items: center; justify-content: center; gap: 2px;
  border-style: dashed; border-top-width: 1px; background: none; color: var(--muted);
}
.tile.plus:hover { color: var(--accent); border-color: var(--accent); }
.plus-sign { font-size: 40px; line-height: 1; font-weight: 300; }
.plus-label { font-size: 12.5px; }

/* ---- the add / edit dialog ---- */
.overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.45);
  display: flex; align-items: flex-start; justify-content: center; padding: 48px 16px;
}
.dialog {
  width: min(560px, 100%); max-height: calc(100vh - 96px); overflow: auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 16px 48px rgba(0,0,0,.5); padding: 16px 18px 14px;
  display: flex; flex-direction: column; gap: 12px;
}
.dlg-head { display: flex; align-items: center; justify-content: space-between; }
.dlg-head h2 { margin: 0; font-size: 16px; }
.dlg-close { font-size: 13px; padding: 4px 9px; }
.dlg-body { display: flex; flex-direction: column; gap: 10px; }
.dlg-body label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
.dlg-body label.checkbox { flex-direction: row; align-items: center; color: var(--text); }
.dlg-body input[type="text"], .dlg-body input[type="search"], .dlg-body select {
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 7px 9px; font-size: 13px;
}
.dlg-foot {
  display: flex; align-items: center; gap: 10px;
  border-top: 1px dashed var(--border); padding-top: 10px;
}
.dlg-foot .muted-note { margin: 0; }
.pick-list { display: flex; flex-direction: column; gap: 8px; max-height: 46vh; overflow: auto; }
.pick-row {
  display: flex; gap: 12px; align-items: flex-start; cursor: pointer;
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  background: var(--panel-2);
}
.pick-row:hover { border-color: var(--accent); }
.pick-row.invalid { opacity: .65; cursor: default; }
.pick-row.invalid:hover { border-color: var(--border); }
.pick-icon { font-size: 22px; line-height: 1.3; flex: none; }
.pick-main { min-width: 0; }
.dlg-chosen {
  display: flex; gap: 12px; align-items: center;
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  background: var(--panel-2);
}
.dlg-chosen .pick-main { flex: 1; }
.ctx-choice { display: flex; gap: 18px; flex-wrap: wrap; }
.ctx-info {
  font-size: 12px; color: var(--muted); line-height: 1.5;
  border-left: 2px solid var(--border); padding: 2px 0 2px 10px;
}
.ctx-info .mono { font-family: var(--mono); font-size: 11px; color: var(--text); word-break: break-all; }
.ctx-info strong { color: var(--text); }
.field-missing { outline: 2px solid var(--red); outline-offset: -1px; }
