/* v2 styles */
* { box-sizing: border-box; }
body { font-family: Inter, system-ui, -apple-system, Arial, sans-serif; background: #f3f5f7; margin: 0; color: #1f2937; }
.app { max-width: 1000px; margin: 32px auto; padding: 20px; }
header h1 { margin: 0 0 6px 0; font-size: 1.4rem; }
header .hint { margin: 0 0 18px 0; color: #6b7280; font-size: .95rem; }
.compare-form { background: #fff; border-radius: 10px; padding: 18px; box-shadow: 0 6px 18px rgba(15,23,42,0.08); }
.controls { display:flex; justify-content:space-between; align-items:center; gap:12px; margin-bottom:12px; }
.controls .small { font-size: .85rem; color: #374151; }
.legend { display:flex; gap:8px; align-items:center; }
.legend label { display:flex; align-items:center; gap:6px; font-size:.85rem; color:#374151; }
.sub-links { margin-top:10px; display:flex; gap:12px; justify-content:flex-end; }
.sub-links a { color:#2563eb; text-decoration:underline; font-size:.75rem; }
.textareas { display:flex; gap:12px; }
.textareas textarea { width:50%; min-height:160px; padding:10px; border:1px solid #e5e7eb; border-radius:6px; resize:vertical; font-family: monospace; font-size:.9rem; }
.actions { display:flex; gap:8px; justify-content:flex-end; margin-top:12px; }
.actions button { padding:8px 14px; border-radius:6px; border:none; background:#0ea5a4; color: white; cursor:pointer; }
.actions button[type="reset"] { background:#ef4444; }
.actions button#compare-samples { background:#3b82f6; }
.results { margin-top:18px; }
.result-table { width:100%; border-collapse:collapse; margin-top:22px; table-layout: fixed; }
.result-table th, .result-table td { padding:8px; border-bottom:1px solid #eef2f7; vertical-align: top; }
.result-table th { background:#f8fafc; text-align:left; }
.result-table td { word-wrap:break-word; }
.result-table td.key { width: 22%; font-weight:600; }
.result-table td.left, .result-table td.right { width: 34%; }
.result-table td.match { width: 10%; text-transform:capitalize; font-weight:600; }
/* coloring rows */
.legend-row-exact td { background:#e6fffa; }
.legend-row-exists td { background:#fff7ed; }
.legend-row-left-only td { background:#fff1f2; }
.legend-row-right-only td { background:#eef2ff; }
.legend-row-pii td { outline: none; }

/* result table improvements */
.result-table td.pii { position:relative; }
.result-table td.pii:before { content:"PII"; position:absolute; top:50%; left:50%; transform:translate(-50%,-50%); background:#ffd9a6; color:#92400e; padding:2px 6px; border-radius:4px; font-size:.8rem; white-space:nowrap; }
.result-table td.pii.exact { background:#e6fffa; }
.result-table td.pii.exists { background:#fff7ed; }
.result-table td.pii.left-only { background:#fff1f2; }
.result-table td.pii.right-only { background:#eef2ff; }

/* Legend swatches - darker, more accessible */
.legend-swatch.exact { background:#a7f3eb; border:1px solid #065f46 }
.legend-swatch.exists { background:#fff4d6; border:1px solid #92400e }
.legend-swatch.left-only { background:#fecaca; border:1px solid #7f1d1d }
.legend-swatch.right-only { background:#bae6fd; border:1px solid #075985 }

/* extra space before each table */
.result-table { width:100%; border-collapse:collapse; margin-top:22px; table-layout: fixed; }

/* PII flag on offending rows - tooltip centered under flag */
.pii-flag { display:inline-block; margin-left:8px; background:#ffedd5; color:#92400e; padding:2px 6px; border-radius:4px; font-size:.75rem; cursor:help; position:relative; }
.pii-flag::after { content: attr(data-reason); position:absolute; left:50%; top: calc(100% + 8px); transform: translateX(-50%) translateY(6px); background:#111827; color:#fff; padding:8px 10px; border-radius:6px; white-space:normal; max-width:360px; z-index:9999; box-shadow: 0 8px 24px rgba(0,0,0,0.2); opacity:0; pointer-events:none; transition:opacity .12s ease, transform .12s ease; }
.pii-flag:hover::after { opacity:1; transform: translateX(-50%) translateY(0); pointer-events:auto; }

/* table heading and PII warning (heading kept simple) */
.table-heading { font-weight:600; margin-top:12px; margin-bottom:6px; }
.pii-warning { display:inline-block; margin-left:12px; background:#ffedd5; color:#9a3412; padding:4px 8px; border-radius:6px; font-weight:700; }

/* PII badge */
.pii-badge { display:inline-block; padding:2px 6px; background:#ffd9a6; color:#92400e; border-radius:4px; font-size:.8rem; margin-left:6px; }

/* info icon and tooltip */
.info-icon { display:inline-block; margin-left:8px; width:18px; height:18px; line-height:18px; text-align:center; border-radius:50%; background:#e5e7eb; color:#0f172a; font-weight:700; cursor:help; position:relative; }
.info-icon:focus { outline:2px solid #2563eb; }
.info-icon::after { content: attr(data-tooltip); position:absolute; left:50%; transform:translateX(-50%) translateY(8px); top:100%; background:#111827; color:#fff; padding:8px 10px; border-radius:6px; white-space:normal; width:260px; max-width:320px; z-index:9999; box-shadow:0 8px 20px rgba(0,0,0,0.2); opacity:0; pointer-events:none; transition:opacity .12s ease, transform .12s ease; font-size:0.9rem; }
.info-icon:hover::after, .info-icon:focus::after { opacity:1; transform:translateX(-50%) translateY(0); pointer-events:auto; }

/* muted links */
.muted-link { color:#6b7280; margin-left:8px; font-size:.95rem; text-decoration:underline; }

/* Modal styles */
.modal { position:fixed; left:0; top:0; right:0; bottom:0; background:rgba(2,6,23,0.5); display:none; align-items:center; justify-content:center; z-index:2000; }
.modal[aria-hidden="false"] { display:flex; }
.modal-content { background:#fff; border-radius:8px; padding:16px; width:640px; max-width:92%; box-shadow:0 12px 40px rgba(2,6,23,0.2); }
.modal-content header { display:flex; justify-content:space-between; align-items:center; }
.modal-content header h2{ margin:0; font-size:1.1rem; }
.modal-close{ background:transparent; border:none; font-size:1.2rem; cursor:pointer; }
.modal-body { margin-top:12px; }
.modal-subtitle { color:#6b7280; margin-top:6px; margin-bottom:6px; font-size:0.85rem; }

/* Align Save link with action buttons and match sub-links style */
.actions .muted-link { margin-right:8px; display:inline-flex; align-items:center; color:#6b7280; text-decoration:underline; font-size:.95rem; }

.save-actions { margin-top:8px; display:flex; gap:8px; justify-content:flex-end; }
.save-actions button { padding:8px 12px; border-radius:6px; border:none; background:#0ea5a4; color:#fff; }
.save-actions button#save-cancel { background:#ef4444; }
/* place label/input and buttons on same row */
.save-row { display:flex; gap:12px; align-items:center; }
.save-row label { flex: 1 1 60%; }
.save-row input#save-name { width: 100%; }
.saved-list { margin-top:12px; }
.saved-item { display:flex; justify-content:space-between; align-items:center; padding:8px 0; border-bottom:1px solid #eef2f7; }
.saved-item .meta { color:#374151; }
.saved-item .meta .name { font-weight:600; }
.saved-item .meta .date { font-size:0.85rem; font-style:italic; color:#6b7280; margin-top:4px; }
.saved-item .controls { display:flex; gap:8px; }
.saved-item .controls button { background:#fff; border:1px solid #e5e7eb; padding:6px 8px; border-radius:6px; cursor:pointer; }

/* extra space before each table */
.result-table { width:100%; border-collapse:collapse; margin-top:22px; table-layout: fixed; }

/* footer consent styling */
.footer .consent { text-align: right; margin-top: 8px; }
.footer .consent label { color: #6b7280; font-size: 0.85rem; display: inline-flex; align-items: center; gap: 6px; }
.footer .consent input[type="checkbox"] { transform: scale(0.95); }
