/* ── RFID Tag Tester Modal ─────────────────────────────────────────────────── */
/* Loaded via <link> in inventory.html alongside the main CSS stack.            */
/* icon_rfid.svg path: assets/svg/icons/icon_rfid.svg (3 levels up from here)  */

.rfid-test-card {
  width: 760px;
  max-width: 96vw;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

/* Header — icon, title + one line of help, close */
.rfid-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.rfid-head-ic {
  width: 42px; height: 42px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--primary-soft);
}
.rfid-head-ic .rfid-test-icon { width: 22px; height: 22px; }
.rfid-head-txt { flex: 1; min-width: 0; }
.rfid-head-txt h3 { margin: 0; font-size: 16px; font-weight: 700; color: var(--text); }
.rfid-head-txt p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.rfid-head .panel-close .icon { background: currentColor; }

/* The chip icon (masked, primary) — header, idle bodies, empty state */
.rfid-test-icon {
  width: 40px; height: 40px;
  display: block;
  position: relative;
  z-index: 1;
  background: var(--primary);
  -webkit-mask: url('../../../assets/svg/icons/icon_rfid.svg') center / contain no-repeat;
  mask: url('../../../assets/svg/icons/icon_rfid.svg') center / contain no-repeat;
}

/* Readers — one card each, side by side */
.rfid-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
  padding: 16px 20px 20px;
  overflow-y: auto;
  min-height: 0;
}
.rfid-reader {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
  overflow: hidden;
  transition: border-color .2s;
}
.rfid-reader.is-card { border-color: color-mix(in srgb, var(--success) 45%, var(--border)); }
.rfid-reader.is-off { opacity: .45; pointer-events: none; }

.rfid-reader-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 12px 14px;
  border-bottom: 1px solid var(--border);
}
.rfid-reader-dot {
  width: 8px; height: 8px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--muted);
}
.rfid-reader:not(.is-off) .rfid-reader-dot { background: var(--success); }
.rfid-reader.is-card .rfid-reader-dot { box-shadow: 0 0 0 4px var(--success-soft); }
.rfid-reader-id { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.rfid-reader-id b { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rfid-reader-state {
  font-size: 11.5px;
  color: var(--muted);
  font-family: var(--mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rfid-reader.is-card .rfid-reader-state { color: var(--success-text); }

.rfid-read-btn {
  flex-shrink: 0;
  min-width: 72px;
  padding: 7px 16px;
  border: none;
  border-radius: 9px;
  background: var(--primary);
  color: var(--on-accent);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, opacity .15s;
}
.rfid-read-btn:hover:not(:disabled) { background: var(--primary-hover); }
.rfid-read-btn:disabled { opacity: .35; cursor: default; }
.rfid-read-btn.is-reading { opacity: 1; animation: rfidReading 1s ease-in-out infinite; }
@keyframes rfidReading { 50% { opacity: .55; } }

/* Body — the idle state or the last result, scrolling on its own */
.rfid-reader-body {
  flex: 1;
  min-height: 230px;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
}

.rfid-idle {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
}
.rfid-idle-ic {
  position: relative;
  width: 84px; height: 84px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--primary-soft);
}
.rfid-idle.is-card .rfid-idle-ic { background: var(--success-soft); }
.rfid-idle.is-card .rfid-test-icon { background: var(--success); }
.rfid-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--primary);
  opacity: 0;
  animation: rfidRingPulse 2.4s ease-out infinite;
}
.rfid-ring--2 { animation-delay: 1.2s; }
@keyframes rfidRingPulse {
  0%   { transform: scale(.8);  opacity: .6; }
  100% { transform: scale(1.5); opacity: 0; }
}
.rfid-test-hint { margin: 0; font-size: 13px; color: var(--muted); }
.rfid-idle.is-card .rfid-test-hint { color: var(--text); font-weight: 600; }

/* No reader plugged in */
.rfid-no-reader {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 44px 20px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 14px;
}
.rfid-no-reader .rfid-test-icon { background: var(--muted); margin-bottom: 6px; }
.rfid-no-reader b { font-size: 14px; color: var(--text); }
.rfid-no-reader p { margin: 0; font-size: 12.5px; color: var(--muted); }

/* Result */
.rfid-res { display: flex; flex-direction: column; gap: 10px; }
.rfid-res-top { display: flex; align-items: center; gap: 12px; }
.rfid-res-swatch {
  width: 40px; height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--sw);
  opacity: var(--sw-a, 1);
  box-shadow: inset 0 0 0 1px var(--ink-15);
}
.rfid-res-swatch--none {
  display: grid;
  place-items: center;
  background: var(--surface-3);
  color: var(--muted);
  font-weight: 800;
}
.rfid-res-name { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.rfid-res-name b { font-size: 15px; color: var(--text); }
.rfid-res-name small { font-size: 12px; color: var(--muted); }
.rfid-version-badge {
  flex-shrink: 0;
  padding: 3px 9px;
  border-radius: 99px;
  background: var(--primary-soft);
  color: var(--primary-text);
  font-size: 11px;
  font-weight: 700;
}

.rfid-version-badge--cert { background: var(--success-soft); color: var(--success-text); }

.rfid-uid-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--surface);
}
.rfid-uid-lbl { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; color: var(--muted); }
.rfid-uid-row code { font-family: var(--mono); font-size: 12.5px; color: var(--text); word-break: break-all; }

.rfid-fields-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 0;
}
.rfid-field {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 7px 10px;
  border-radius: 9px;
  background: var(--surface);
  min-width: 0;
}
.rfid-field dt { font-size: 10.5px; color: var(--muted); }
.rfid-field dd { margin: 0; font-size: 12.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.rfid-result-error {
  margin: auto 0;
  padding: 12px;
  border-radius: 9px;
  background: var(--danger-soft);
  color: var(--danger-text);
  font-size: 13px;
  text-align: center;
}

/* Raw bytes */
.rfid-raw-block { font-size: 11.5px; color: var(--muted); }
.rfid-raw-block summary { cursor: pointer; padding: 2px 0; }
.rfid-raw-block summary:hover { color: var(--text); }
.rfid-raw-hex {
  margin: 6px 0 0;
  padding: 10px;
  border-radius: 9px;
  background: var(--surface);
  font-family: var(--mono);
  font-size: 11px;
  overflow-x: auto;
  white-space: pre;
}
