/* Reusable components: cards, buttons, forms, tables, modals, toasts, badges.
   Shared by admin-ui and public-ui. */

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line-1);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  transition: var(--transition-theme), box-shadow 0.2s var(--ease-swift), transform 0.2s var(--ease-swift);
}

.card.pad { padding: 22px; }

.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line-2);
}
.card-head h2 { font-size: 15px; }
.card-body { padding: 18px 22px 22px; }

.section-gap { display: flex; flex-direction: column; gap: 20px; }

/* ---------- Stat cards ---------- */

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 14px; }

.stat-card { padding: 16px 18px 14px; display: flex; flex-direction: column; gap: 6px; }
.stat-card .stat-value {
  font-family: var(--font-display);
  font-size: 26px; font-weight: 650; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat-card .stat-meta { font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 5px; }
.stat-card .stat-meta .icon { width: 13px; height: 13px; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 15px;
  border-radius: var(--radius-ctl);
  border: 1px solid var(--line-1);
  background: var(--surface);
  color: var(--text-1);
  font-weight: 550; font-size: 13px;
  cursor: pointer;
  transition: background-color 0.15s var(--ease-swift), border-color 0.15s var(--ease-swift),
    transform 0.1s var(--ease-swift), box-shadow 0.15s var(--ease-swift);
  white-space: nowrap;
}
.btn:hover { background: var(--surface-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn .icon { width: 15px; height: 15px; }

.btn.primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-contrast);
}
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }

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

.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-hover); color: var(--text-1); }

.btn.block { width: 100%; }
.btn.small { padding: 5px 10px; font-size: 12px; border-radius: 7px; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px;
  border-radius: var(--radius-ctl);
  border: 1px solid transparent; background: transparent;
  color: var(--text-2); cursor: pointer;
  transition: background-color 0.15s var(--ease-swift), color 0.15s var(--ease-swift);
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text-1); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }

/* ---------- Forms ---------- */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 11.5px; color: var(--text-3); }

.input, .select {
  width: 100%;
  padding: 8.5px 12px;
  border-radius: var(--radius-ctl);
  border: 1px solid var(--line-1);
  background: var(--surface-2);
  color: var(--text-1);
  transition: border-color 0.15s var(--ease-swift), box-shadow 0.15s var(--ease-swift);
  outline: none;
}
.input:focus, .select:focus {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--surface);
}
.input::placeholder { color: var(--text-3); }
.input.mono { font-family: var(--font-mono); font-size: 12.5px; }

.form-error {
  display: none;
  padding: 9px 12px; border-radius: var(--radius-ctl);
  background: var(--danger-soft); color: var(--danger);
  font-size: 12.5px; margin-bottom: 14px;
}
.form-error.show { display: block; }

/* Toggle switch */
.switch { position: relative; display: inline-flex; flex: none; width: 38px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; border-radius: var(--radius-pill);
  background: var(--line-1); border: 1px solid var(--line-1);
  transition: background-color 0.18s var(--ease-swift), border-color 0.18s var(--ease-swift);
  cursor: pointer;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  transition: transform 0.18s var(--ease-swift);
}
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:disabled + .track { opacity: 0.5; cursor: not-allowed; }

.setting-row {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line-2);
}
.setting-row:last-child { border-bottom: 0; }
.setting-row .setting-label { font-weight: 600; font-size: 13.5px; display: flex; align-items: center; gap: 8px; }
.setting-row .setting-desc { font-size: 12px; color: var(--text-3); margin-top: 2px; max-width: 480px; }
.setting-row .input, .setting-row .select { width: 130px; text-align: right; }

/* ---------- Badges / pills ---------- */

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2.5px 9px;
  border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 600;
  background: var(--surface-2); color: var(--text-2);
  border: 1px solid var(--line-1);
}
.badge .icon { width: 11px; height: 11px; }
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.mono { font-family: var(--font-mono); font-weight: 500; }

.dl-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-variant-numeric: tabular-nums;
  font-size: 11.5px; color: var(--text-3);
}
.dl-badge .icon { width: 12px; height: 12px; }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; padding: 10px 14px;
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-3);
  border-bottom: 1px solid var(--line-1);
}
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr.row-hover:hover td { background: var(--surface-2); }
table.data td.num { font-variant-numeric: tabular-nums; }

/* ---------- Plugin cards ---------- */

.plugin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }

.plugin-card { padding: 18px; cursor: pointer; display: flex; flex-direction: column; gap: 12px; }
.plugin-card:hover { box-shadow: var(--shadow-card-hover); transform: translateY(-2px); border-color: var(--accent-line); }

.plugin-card .plugin-top { display: flex; gap: 13px; align-items: flex-start; }
.plugin-icon {
  width: 44px; height: 44px; border-radius: 10px; flex: none;
  background: var(--surface-2); border: 1px solid var(--line-2);
  display: grid; place-items: center;
  color: var(--text-3);
  overflow: hidden;
}
.plugin-icon img { width: 100%; height: 100%; object-fit: cover; }
.plugin-card .plugin-name { font-weight: 600; font-size: 14.5px; }
.plugin-card .plugin-publisher { font-size: 12px; color: var(--text-3); }
.plugin-card .plugin-desc {
  font-size: 12.5px; color: var(--text-2);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 2.6em;
}
.plugin-card .plugin-foot { display: flex; align-items: center; gap: 10px; margin-top: auto; }
.plugin-card .plugin-foot .spacer { flex: 1; }

/* ---------- Upload dropzone ---------- */

.dropzone {
  border: 1.5px dashed var(--line-1);
  border-radius: var(--radius-card);
  padding: 30px 24px;
  text-align: center;
  color: var(--text-2);
  cursor: pointer;
  transition: border-color 0.2s var(--ease-swift), background-color 0.2s var(--ease-swift);
  background: var(--surface);
}
.dropzone:hover, .dropzone.drag {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dropzone .icon { width: 26px; height: 26px; margin-bottom: 8px; color: var(--accent); }
.dropzone .dz-title { font-weight: 600; color: var(--text-1); font-size: 13.5px; }
.dropzone .dz-sub { font-size: 12px; color: var(--text-3); margin-top: 3px; }

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10, 13, 18, 0.55);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  padding: 24px;
  animation: fade-in 0.18s var(--ease-swift);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: 100%; max-width: 440px;
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line-1);
  border-radius: 14px;
  box-shadow: var(--shadow-pop);
  animation: modal-in 0.22s var(--ease-swift);
}
.modal.wide { max-width: 560px; }
@keyframes modal-in {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px 0;
}
.modal-head h3 { font-size: 15.5px; }
.modal-body { padding: 14px 22px 6px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 9px; padding: 12px 22px 20px; }

/* Key reveal block (shown once) */
.key-reveal {
  display: flex; align-items: center; gap: 8px;
  background: var(--ink-1); color: #d9fff8;
  font-family: var(--font-mono); font-size: 12px;
  border-radius: var(--radius-ctl);
  padding: 11px 13px;
  word-break: break-all;
}
.key-reveal .icon-btn { color: var(--ink-text); flex: none; }
.key-reveal .icon-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }

.recovery-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 7px;
  font-family: var(--font-mono); font-size: 12.5px;
  margin: 10px 0;
}
.recovery-grid .code {
  background: var(--surface-2); border: 1px solid var(--line-2);
  border-radius: 7px; padding: 7px 10px; text-align: center;
  font-variant-numeric: tabular-nums;
}

.qr-holder { display: grid; place-items: center; padding: 12px 0 6px; }
.qr-holder svg, .qr-holder img { width: 184px; height: 184px; border-radius: 8px; background: #fff; padding: 10px; }

/* ---------- Toasts ---------- */

.toast-root {
  position: fixed; bottom: 22px; right: 22px; z-index: 200;
  display: flex; flex-direction: column; gap: 9px;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  min-width: 240px; max-width: 380px;
  background: var(--ink-1); color: #e7eaee;
  border: 1px solid var(--ink-line);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 13px;
  box-shadow: var(--shadow-pop);
  animation: toast-in 0.3s var(--ease-swift);
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
.toast.leaving { opacity: 0; transform: translateX(20px); transition: all 0.25s var(--ease-swift); }
.toast .icon { width: 16px; height: 16px; flex: none; }
.toast.success .icon { color: #4ade80; }
.toast.error .icon { color: #f87171; }
.toast.info .icon { color: #5eead4; }

/* ---------- Empty / loading states ---------- */

.empty-state {
  text-align: center; padding: 46px 20px;
  color: var(--text-3);
}
.empty-state .icon { width: 34px; height: 34px; margin-bottom: 10px; opacity: 0.6; }
.empty-state .empty-title { font-weight: 600; color: var(--text-2); font-size: 14px; }
.empty-state .empty-sub { font-size: 12.5px; margin-top: 3px; }

.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--line-1); border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-block { display: grid; place-items: center; padding: 50px; }

/* ---------- Charts ---------- */

.chart-card .card-body { padding-top: 10px; }
.chart-svg { width: 100%; height: auto; display: block; }
.chart-svg .grid-line { stroke: var(--chart-grid); stroke-width: 1; }
.chart-svg .axis-label { fill: var(--text-3); font-family: var(--font-mono); font-size: 9.5px; }
.chart-svg .area { fill: var(--accent-soft); }
.chart-svg .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart-svg .bar { fill: var(--accent); opacity: 0.85; rx: 3; }
.chart-svg .bar:hover { opacity: 1; }
.chart-svg .bar-label { fill: var(--text-2); font-size: 11px; }
.chart-svg .bar-value { fill: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-svg .spark-line { fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; }
.chart-svg .spark-area { fill: var(--accent-soft); }

.range-tabs { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line-1); border-radius: var(--radius-ctl); padding: 3px; gap: 2px; }
.range-tabs button {
  border: 0; background: transparent; color: var(--text-2);
  padding: 4px 12px; border-radius: 6px; font-size: 12px; font-weight: 600; cursor: pointer;
  transition: background-color 0.15s var(--ease-swift), color 0.15s var(--ease-swift);
}
.range-tabs button.active { background: var(--surface); color: var(--text-1); box-shadow: var(--shadow-card); }

/* ---------- Markdown (release notes) ---------- */

.markdown { font-size: 13.5px; line-height: 1.65; color: var(--text-1); }
.markdown h1, .markdown h2, .markdown h3, .markdown h4, .markdown h5, .markdown h6 { margin: 0.9em 0 0.4em; }
.markdown h1 { font-size: 18px; } .markdown h2 { font-size: 15.5px; } .markdown h3 { font-size: 14px; }
.markdown h4, .markdown h5, .markdown h6 { font-size: 13px; color: var(--text-2); }
.markdown p, .markdown ul, .markdown ol { margin: 0.5em 0; }
.markdown code { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 4px; padding: 1px 5px; font-size: 12px; }
.markdown pre { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 8px; padding: 12px; overflow-x: auto; }
.markdown pre code { background: none; border: 0; padding: 0; }
.markdown a { color: var(--accent); }
.markdown blockquote { margin: 0.6em 0; padding: 2px 14px; border-left: 3px solid var(--accent-line); color: var(--text-2); }
.markdown hr { border: 0; border-top: 1px solid var(--line-2); margin: 1em 0; }
.markdown table { border-collapse: collapse; margin: 0.6em 0; font-size: 12.5px; width: 100%; }
.markdown th, .markdown td { border: 1px solid var(--line-2); padding: 6px 10px; text-align: left; }
.markdown th { background: var(--surface-2); font-weight: 600; }

/* ---------- Misc ---------- */

.row { display: flex; align-items: center; gap: 10px; }
.row .spacer { flex: 1; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.hidden { display: none !important; }
.search-box { position: relative; width: 250px; }
.search-box .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--text-3); pointer-events: none; }
.search-box .input { padding-left: 32px; }

.theme-cycle { display: inline-flex; }

/* ---------- Checkboxes (inline, for modals) ---------- */

.checkbox-row { display: inline-flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.checkbox-row input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }

/* ---------- Metadata edit ---------- */

.icon-edit-row { align-items: center; gap: 12px; }
.icon-edit-row .plugin-icon { flex: none; }

.screenshot-thumbs { flex-wrap: wrap; gap: 12px; align-items: flex-start; }
.screenshot-thumb { width: 120px; }
.screenshot-thumb img {
  width: 100%; aspect-ratio: 16 / 10; object-fit: cover;
  border-radius: 8px; border: 1px solid var(--line-1); display: block;
}
.screenshot-remove { margin-top: 5px; font-size: 11.5px; }

/* Additional card-body sections stacked below a .dep-columns grid, e.g. the
   Requirements card's capabilities/external-services rows. */
.card-body.dep-extra { padding-top: 16px; border-top: 1px solid var(--line-2); }

/* ---------- Dependencies ---------- */

.dep-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.dep-columns .eyebrow { margin-bottom: 8px; }
.dep-list { flex-wrap: wrap; gap: 6px; }
.dep-list a.badge { text-decoration: none; }
.dep-list a.badge:hover { border-color: var(--accent-line); color: var(--accent); }

/* ---------- Compatibility matrix ---------- */
.detail-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line-1); }
.detail-tab { border-radius: var(--radius-ctl) var(--radius-ctl) 0 0; border-bottom: 2px solid transparent; }
.detail-tab.active { color: var(--accent); border-bottom-color: var(--accent); background: var(--accent-soft); }
[data-detail-panel][hidden] { display: none; }
[data-detail-panel="overview"] { display: flex; flex-direction: column; gap: 20px; }
.compat-notice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border: 1px solid var(--line-1); border-radius: var(--radius-card); background: var(--surface); }
.compat-notice.warn { border-color: var(--accent-line); background: var(--warn-soft); color: var(--warn); }
.compat-notice .icon { flex: none; margin-top: 2px; }
.compat-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.compat-toolbar-grid { display: grid; grid-template-columns: 1.1fr 1.4fr 1fr 0.9fr; gap: 14px; align-items: end; }
.compat-toolbar-foot { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line-2); }
.compat-matrix-card { overflow: hidden; }
.compat-matrix-wrap { overflow: auto; max-height: min(68vh, 760px); }
table.compat-matrix { width: max-content; min-width: 100%; }
table.compat-matrix th { position: sticky; top: 0; z-index: 3; background: var(--surface-2); white-space: nowrap; }
table.compat-matrix td { background: var(--surface); }
table.compat-matrix tr:hover td { background: var(--surface-2); }
table.compat-matrix { --compat-plugin-column-width: 240px; }
table.compat-matrix .sticky-plugin { position: sticky; left: 0; z-index: 2; width: var(--compat-plugin-column-width); min-width: var(--compat-plugin-column-width); max-width: var(--compat-plugin-column-width); border-right: 1px solid var(--line-1); }
table.compat-matrix th.sticky-plugin { z-index: 5; background: var(--surface-2); }
table.compat-matrix .sticky-version { position: sticky; left: var(--compat-plugin-column-width); z-index: 2; min-width: 116px; border-right: 1px solid var(--line-1); }
table.compat-matrix th.sticky-version { z-index: 5; background: var(--surface-2); }
.plugin-group > * { display: block; margin-bottom: 6px; }
.plugin-group a { color: var(--text-1); font-weight: 600; text-decoration: none; }
.plugin-group a:hover { color: var(--accent); }
.suite-column { min-width: 78px; text-align: center; }
.suite-column.target { background: var(--accent-soft) !important; box-shadow: inset 1px 0 var(--accent-line), inset -1px 0 var(--accent-line); }
.compat-cell { width: 26px; height: 26px; margin: auto; display: inline-grid; place-items: center; border-radius: 50%; font-weight: 700; border: 1px solid transparent; }
.compat-cell.compatible, .compat-legend.compatible { color: var(--ok); background: var(--ok-soft); }
.compat-cell.incompatible, .compat-legend.incompatible { color: var(--text-3); background: var(--surface-2); border-color: var(--line-1); }
.compat-cell.unknown, .compat-legend.unknown { color: var(--warn); background: var(--warn-soft); }
.compat-legend { padding: 4px 8px; border-radius: var(--radius-pill); font-size: 11px; font-weight: 600; white-space: nowrap; }
.compat-capabilities { display: flex; flex-wrap: wrap; gap: 4px; max-width: 280px; }
table.plugin-detail-compat-matrix { --compat-plugin-column-width: 116px; }
.public-plugin-compatibility { display: flex; flex-direction: column; gap: 18px; }
.plugin-compat-summary { display: flex; align-items: end; flex-wrap: wrap; gap: 12px; }
.plugin-compat-summary h2 { font-size: 16px; }
.plugin-compat-summary p { margin: 4px 0 0; }
.plugin-compat-target { display: flex; flex-direction: column; gap: 6px; min-width: 210px; }
.plugin-compat-target > span { font-size: 12px; font-weight: 600; color: var(--text-2); }
.plugin-compat-legend { flex-wrap: wrap; gap: 8px; }
@media (max-width: 1050px) { .compat-toolbar-grid { grid-template-columns: 1fr 1fr; } .compat-stats { grid-template-columns: 1fr 1fr; } }
@media (max-width: 650px) { .compat-toolbar-grid, .compat-stats { grid-template-columns: 1fr; } .compat-toolbar-foot { align-items: stretch; } }
.plugin-compat-filters .input { width: 112px; }
.plugin-compat-filters .select { width: 170px; }
@media (max-width: 850px) { .plugin-compat-filters { width: 100%; order: 3; } }

.graph-container {
  width: 100%;
  height: 440px;
  background-color: var(--surface-2);
  background-image: radial-gradient(var(--line-1) 1px, transparent 1px);
  background-size: 22px 22px;
  background-position: -11px -11px;
  border: 1px solid var(--line-1);
  border-radius: var(--radius-ctl);
  overflow: hidden;
}
.modal .graph-container { height: 400px; }

.graph-legend { display: inline-flex; align-items: center; gap: 14px; font-size: 12px; color: var(--text-2); }
.graph-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend-dot.dep { background: var(--accent); }
.legend-dot.draft { background: var(--surface); border: 2px solid var(--warn); }
.legend-dot.missing { background: var(--surface); border: 1.5px dashed var(--danger); }

@media (max-width: 720px) {
  .dep-columns { grid-template-columns: 1fr; }
}
