/* =========================================================
   TraceMi – Components
   Reusable UI components: cards, alerts, buttons, forms,
   tabs, chips, badges, tables and collapsibles.
   ========================================================= */

/* ---------- Cards ---------- */
.card {
  background: linear-gradient(180deg, var(--card-glow, rgba(79,140,255,0.06)), transparent), var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 12px;
}
a.card { display: block; text-decoration: none; color: inherit; }
.card.soft { box-shadow: none; }

/* Card glow override: uses --card-glow if present in variables, otherwise falls back */
.card.pop {
  background: linear-gradient(180deg, var(--card-glow-strong, rgba(79,140,255,0.10)), transparent), var(--panel-2);
}

/* ---------- Alerts / messages ---------- */
.flash {
  margin: 8px 0;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  color: var(--success-text);
  font-size: 12px;
}
.flash.err {
  background: var(--error-bg);
  border-color: var(--error-border);
  color: var(--error-text);
}
.msg {
  margin: 12px 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-2);
  font-size: 14px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--row);
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 12px;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: rgba(125, 138, 160, .08); }
.btn.primary {
  background: linear-gradient(180deg, var(--brand), var(--brand-2));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 8px 18px rgba(79, 140, 255, .25);
}
.btn.secondary { opacity: .95; }
.btn.danger {
  color: var(--error-text-dark);
  border-color: var(--error-border);
  background: var(--error-bg);
}
.btn.small { min-height: 34px; }

/* Icon buttons */
.iconbtn {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 14px;
}
.iconbtn:hover { background: rgba(125, 138, 160, .08); }

/* ---------- Forms ---------- */
.label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .3px;
  text-transform: uppercase;
  color: var(--muted);
}
.input, .select, .textarea {
  width: 100%;
  min-width: 0;
  background: transparent;
  color: inherit;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: var(--fz-13);
  padding: 10px 12px;
  min-height: var(--row);
  outline: none;
  transition: box-shadow .18s ease, border-color .18s ease, background-color .18s;
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.35; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(79, 140, 255, .25);
}

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; overflow-x: auto; padding-bottom: 6px; }
.tab {
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  text-decoration: none;
  color: inherit;
  font-weight: 800;
  font-size: 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .05);
  white-space: nowrap;
}
.tab:hover { background: rgba(125, 138, 160, .08); }
.tab.active {
  background: linear-gradient(180deg, var(--brand), var(--brand-2));
  color: #fff;
  border-color: transparent;
}

/* ---------- Chips & badges ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(125, 138, 160, .10);
  border: 1px solid var(--border);
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
}
.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--badge-border);
  color: var(--badge-text);
  background: var(--badge-bg);
}
.b-unused   { background: var(--badge-unused); }
.b-claimed  { background: var(--badge-claimed); }
.b-assigned { background: var(--badge-assigned); }
.b-disabled { background: var(--badge-disabled); }

/* ---------- Tables ---------- */
.table-scroll {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
}
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
  min-width: 720px;
}
.table th, .table td {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  text-align: left;
  vertical-align: middle;
}
.table th {
  font-size: 11.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .35px;
  font-weight: 800;
  background: var(--panel);
  position: sticky;
  top: 0;
}

/* ---------- Collapsible (details / fold) ---------- */
details > summary::-webkit-details-marker { display: none; }

.fold {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: transparent;
}
.fold summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  font-weight: 900;
  font-size: 12px;
  background: rgba(125, 138, 160, .06);
}
.fold[open] summary { background: rgba(125, 138, 160, .10); }
.fold .content { padding: 12px; display: grid; gap: 12px; }
