/* ── Digital Twin / Product Profile Panel ───────────────────────────────── */

/* ── Results split layout ────────────────────────────────────────────────── */
.eu-results-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 24px;
  align-items: start;
}

.eu-results-layout.aside-hidden {
  grid-template-columns: 1fr 0;
}

.eu-results-layout.aside-hidden .eu-results-aside {
  display: none;
}

.eu-results-layout.aside-expanded {
  grid-template-columns: 1fr 460px;
}

/* ── Results header with toggle button ───────────────────────────────────── */
.eu-results-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.eu-results-header__left {
  flex: 1;
}

.eu-twin-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #475569;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
  margin-top: 4px;
}

.eu-twin-toggle-btn:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.eu-twin-toggle-btn.is-active {
  background: #eef2ff;
  border-color: #a5b4fc;
  color: #4f46e5;
}

/* ── Side pane (aside) ───────────────────────────────────────────────────── */
.eu-results-aside {
  position: sticky;
  top: 72px;
  max-height: calc(100vh - 96px);
  display: flex;
  flex-direction: column;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.eu-aside-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #fafbfc;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}

.eu-aside-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #374151;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.eu-aside-controls {
  display: flex;
  gap: 4px;
}

.eu-aside-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: none;
  border: 1px solid transparent;
  border-radius: 5px;
  cursor: pointer;
  color: #94a3b8;
  transition: background 0.1s, color 0.1s;
}

.eu-aside-btn:hover {
  background: #f1f5f9;
  color: #475569;
}

.eu-aside-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  scroll-behavior: smooth;
}

/* ── Regulation section banners ──────────────────────────────────────────── */
.eu-reg-section {
  margin-bottom: 16px;
}

.eu-reg-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: 8px 8px 0 0;
  border: 1px solid transparent;
}

.eu-reg-banner--act {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.eu-reg-banner--cra {
  background: #f5f3ff;
  border-color: #ddd6fe;
}

.eu-reg-banner--full {
  padding: 14px 20px;
  border-radius: 10px 10px 0 0;
}

.eu-reg-section > .eu-panel__items,
.eu-reg-section > #eu-items-full,
.eu-reg-section > #cra-items-full {
  border: 1px solid #e2e8f0;
  border-top: none;
  border-radius: 0 0 8px 8px;
}

.eu-reg-banner__left {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.eu-reg-banner__tag {
  font-size: 0.8125rem;
  font-weight: 700;
}

.eu-reg-banner--act .eu-reg-banner__tag {
  color: #1d4ed8;
}

.eu-reg-banner--cra .eu-reg-banner__tag {
  color: #6d28d9;
}

.eu-reg-banner__stat {
  font-size: 0.8125rem;
  color: #64748b;
}

.eu-reg-banner__desc {
  font-size: 0.75rem;
  color: #6b7280;
}

.eu-reg-banner__link {
  font-size: 0.75rem;
  font-weight: 600;
  color: #6b7280;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s;
}

.eu-reg-banner__link:hover {
  color: #374151;
}

/* Items area borders to connect to banner */
.eu-reg-section .eu-panel__items:not(:empty),
.eu-reg-section .eu-panel__pass-count:not(:empty) {
  padding: 8px 12px;
  border-left: 1px solid #e2e8f0;
  border-right: 1px solid #e2e8f0;
}

.eu-reg-section .eu-panel__pass-count:not(:empty) {
  border-bottom: 1px solid #e2e8f0;
  border-radius: 0 0 8px 8px;
  padding: 8px 16px 12px;
}

/* Full-details items area */
#eu-items-full,
#cra-items-full {
  border: 1px solid #e2e8f0;
  border-top: none;
  border-radius: 0 0 10px 10px;
  padding: 12px;
}

/* ── Highlighted field (hover on finding → field glows in side pane) ─────── */
.twin-field--highlighted {
  background: #fefce8 !important;
  border-left: 3px solid #eab308;
  padding-left: 13px;
  transition: background 0.2s, border-color 0.2s;
}

.twin-field--highlighted .twin-field__label {
  color: #92400e;
}

/* ── Twin panel container ────────────────────────────────────────────────── */
#product-twin-panel {
  /* inside the aside body, no fixed width needed */
}

/* ── Section ─────────────────────────────────────────────────────────────── */
.twin-section {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  margin-bottom: 12px;
  /* overflow: visible so tooltips escape the section boundary */
}

.twin-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 10px;
  border-bottom: 1px solid #f1f5f9;
  background: #fafbfc;
}

.twin-section__title {
  font-size: 0.8125rem;
  font-weight: 700;
  color: #1e293b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0;
}

.twin-section__reg {
  font-size: 0.7rem;
  font-weight: 600;
  color: #6366f1;
  background: #eef2ff;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

/* ── Field rows ──────────────────────────────────────────────────────────── */
.twin-section__fields {
  padding: 4px 0;
}

.twin-field {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 16px;
  border-bottom: 1px solid #f8fafc;
  transition: background 0.1s;
}

.twin-field:last-child {
  border-bottom: none;
}

.twin-field:hover {
  background: #f8fafc;
}

.twin-field--full {
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.twin-field--risk {
  background: #fff8f8;
}

.twin-field--risk:hover {
  background: #fff1f1;
}

.twin-field__label {
  font-size: 0.8125rem;
  color: #64748b;
  flex-shrink: 0;
  min-width: 180px;
}

.twin-field--full .twin-field__label {
  min-width: unset;
  font-weight: 600;
  color: #475569;
  margin-bottom: 2px;
}

.twin-field__value {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 0.8125rem;
  color: #1e293b;
  text-align: right;
}

.twin-field--full .twin-field__value {
  text-align: left;
}

/* Value types */
.twin-val--yes {
  color: #15803d;
  font-weight: 600;
}

.twin-val--no {
  color: #94a3b8;
}

.twin-val--risk {
  color: #dc2626;
  font-weight: 700;
}

.twin-val--unknown {
  color: #cbd5e1;
}

.twin-val--na {
  color: #94a3b8;
  font-style: italic;
  font-size: 0.82em;
}

.twin-val--text {
  color: #1e293b;
}

/* Risk classification badge */
.twin-risk-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 700;
}

.twin-risk-badge--high {
  background: #fee2e2;
  color: #dc2626;
}

.twin-risk-badge--limited {
  background: #fef3c7;
  color: #b45309;
}

.twin-risk-badge--minimal {
  background: #dcfce7;
  color: #15803d;
}

.twin-risk-badge--unknown {
  background: #f1f5f9;
  color: #64748b;
}

/* List chips */
.twin-list-chip {
  display: inline-block;
  padding: 2px 7px;
  background: #f1f5f9;
  color: #475569;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
}

.twin-list-chip--sm {
  padding: 1px 5px;
  font-size: 0.7rem;
}

/* Issue badge — links to the findings section */
.twin-field__issue {
  display: inline-flex;
  align-items: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #dc2626;
  background: #fee2e2;
  padding: 1px 7px;
  border-radius: 10px;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.1s;
}

.twin-field__issue:hover {
  background: #fecaca;
}

/* ── Section actions (upload / edit / API stubs) ─────────────────────────── */
.twin-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px 16px 10px;
  border-top: 1px solid #f1f5f9;
  background: #fafbfc;
}

.twin-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  font-size: 0.75rem;
  font-weight: 500;
  color: #94a3b8;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  cursor: not-allowed;
}

.twin-action svg {
  opacity: 0.5;
}

.twin-action__soon {
  font-size: 0.65rem;
  font-weight: 700;
  color: #a0aec0;
  background: #f1f5f9;
  padding: 1px 5px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ── Extension footer ────────────────────────────────────────────────────── */
.twin-extension {
  border: 1.5px dashed #e2e8f0;
  border-radius: 10px;
  padding: 20px;
  margin-top: 16px;
  background: #fafbfc;
}

.twin-extension__title {
  font-size: 0.875rem;
  font-weight: 700;
  color: #374151;
  margin-bottom: 4px;
}

.twin-extension__sub {
  font-size: 0.8rem;
  color: #9ca3af;
  margin-bottom: 16px;
}

.twin-extension__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.twin-ext-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  cursor: not-allowed;
  text-align: left;
  width: 100%;
  transition: background 0.1s;
}

.twin-ext-btn__icon {
  flex-shrink: 0;
  color: #9ca3af;
}

.twin-ext-btn__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.twin-ext-btn__label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #9ca3af;
}

.twin-ext-btn__desc {
  font-size: 0.75rem;
  color: #cbd5e1;
}

.twin-ext-btn__badge {
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #a0aec0;
  background: #f1f5f9;
  padding: 2px 7px;
  border-radius: 5px;
}

/* ── Profile context block (inside finding cards) ────────────────────────── */
.twin-ctx {
  margin-top: 10px;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 7px;
}

.twin-ctx__label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
  margin-bottom: 6px;
}

.twin-ctx__row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 0.8rem;
}

.twin-ctx__key {
  color: #64748b;
  flex-shrink: 0;
  min-width: 140px;
}

.twin-ctx__val {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  color: #1e293b;
}

.twin-ctx__view-btn {
  margin-top: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #4f46e5;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: none;
}

.twin-ctx__view-btn:hover {
  text-decoration: underline;
}

/* ── Field hint / tooltip ────────────────────────────────────────────────── */
/* Inferred-vs-confirmed provenance markers (review screen) */
.twin-infer {
  display: inline-block;
  margin-left: 7px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  background: #eef2f7;
  color: #64748b;
  vertical-align: middle;
}
.twin-infer--verify {
  background: #fef3c7;
  color: #b45309;
}
.twin-field--inferred .twin-edit-input {
  border-style: dashed;
}
.twin-field--verify {
  background: #fffbeb;
  border-radius: 8px;
}
.twin-field--verify .twin-edit-input {
  border-color: #fbbf24;
  border-style: solid;
}

.twin-field__hint {
  display: inline-flex;
  align-items: center;
  margin-left: 5px;
  vertical-align: middle;
}

.twin-field__hint-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px;
  height: 13px;
  border: 1.5px solid #cbd5e1;
  border-radius: 50%;
  color: #94a3b8;
  font-size: 0.6rem;
  font-weight: 700;
  font-style: normal;
  line-height: 1;
  cursor: help;
  flex-shrink: 0;
  user-select: none;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}

.twin-field__hint-icon:hover,
.twin-field__hint-icon.is-active {
  border-color: #6366f1;
  color: #6366f1;
  background: #eef2ff;
}

/* Floating tooltip rendered at document level via JS */
#twin-tooltip {
  position: fixed;
  width: 240px;
  background: #1e293b;
  color: #e2e8f0;
  font-size: 0.72rem;
  font-weight: 400;
  line-height: 1.55;
  padding: 9px 11px;
  border-radius: 7px;
  pointer-events: none;
  z-index: 9999;
  box-shadow: 0 6px 20px rgba(0,0,0,0.22);
  white-space: normal;
  text-align: left;
  opacity: 0;
  transition: opacity 0.1s ease;
}

#twin-tooltip.is-visible {
  opacity: 1;
}

#twin-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  right: 12px;
  border: 5px solid transparent;
  border-top-color: #1e293b;
}

#twin-tooltip.flip-down::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: #1e293b;
}

/* ── Edit mode ───────────────────────────────────────────────────────────── */
.twin-edit-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  background: #fffbeb;
  border-bottom: 1px solid #fde68a;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.twin-edit-hint {
  font-size: 0.75rem;
  color: #92400e;
  margin: 0;
}

.twin-edit-btns {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.twin-edit-save {
  padding: 5px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
  background: #4f46e5;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.twin-edit-save:hover { background: #4338ca; }

.twin-edit-cancel {
  padding: 5px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #6b7280;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 5px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.twin-edit-cancel:hover { background: #e5e7eb; }

.twin-edit-input {
  font-size: 0.82rem;
  font-weight: 500;
  color: #0f172a;
  border: 1.5px solid #dbe2ee;
  border-radius: 9px;
  padding: 8px 12px;
  background: #fbfcfe;
  width: 100%;
  min-height: 38px;
  font-family: inherit;
  line-height: 1.3;
  box-shadow: 0 1px 1px rgba(15, 23, 42, 0.03);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  /* !important so no global form/select rule can re-enable the native control
     chrome (which would show a second arrow + an inner border = "double box"). */
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
}

.twin-edit-input::placeholder { color: #94a3b8; font-weight: 400; }

@media (hover: hover) and (pointer: fine) {
  /* background-color (not the `background` shorthand) so a select's custom
     chevron background-image/repeat/position/size are preserved — otherwise the
     shorthand resets background-repeat to `repeat` and the chevron tiles across
     the whole control (the "many arrows" bug). */
  .twin-edit-input:hover { border-color: #c2cde0; background-color: #fff; }
}

.twin-edit-input:focus {
  outline: none;
  background-color: #fff;
  border-color: #3869FA;
  box-shadow: 0 0 0 3px rgba(56, 105, 250, 0.15);
}

/* Native <select> chrome removed (kills the "double box") + custom chevron */
select.twin-edit-input {
  padding-right: 34px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 15px;
}
select.twin-edit-input:focus {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233869FA' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}
select.twin-edit-input::-ms-expand { display: none; }

/* Compact fields: keep the control comfortably sized in the right column */
.twin-field:not(.twin-field--full) .twin-edit-input {
  max-width: 240px;
  min-width: 150px;
}

.twin-edit-textarea {
  min-height: 64px;
  resize: vertical;
  max-width: 100%;
  line-height: 1.5;
}

/* Edit rows: vertically centre the label against the taller controls and
   give each row a little more breathing room. */
.twin-field--edit {
  align-items: center;
  padding: 10px 16px;
}
.twin-field--edit .twin-field__label {
  font-size: 0.84rem;
  color: #475569;
  font-weight: 500;
}
.twin-field--edit .twin-field__value {
  justify-content: flex-end;
}

/* Full-width fields: stack label + input vertically */
.twin-field--full.twin-field--edit {
  flex-direction: column;
  align-items: flex-start;
}
.twin-field--full.twin-field--edit .twin-field__label {
  margin-bottom: 6px;
}

.twin-field--full.twin-field--edit .twin-field__value {
  width: 100%;
}

/* Edit button in aside header */
.eu-aside-btn--edit:hover {
  color: #4f46e5;
  background: #eef2ff;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .twin-field__label {
    min-width: 120px;
    font-size: 0.75rem;
  }
  .eu-results-tab {
    padding: 8px 12px;
    font-size: 0.8rem;
  }
}
