/* ═══════════════════════════════════════════════════
   Redesign v3
   ═══════════════════════════════════════════════════ */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --violet-950: #1a0b2e;
  --violet-900: #2D1B4E;
  --violet-800: #3d1f5c;
  --violet-700: #512b78;
  --violet-600: #6b3fa0;
  --violet-500: #8255b8;
  --violet-400: #9e7bcc;
  --violet-300: #bca3dd;>
  --violet-200: #d9caee;
  --violet-100: #eee6f6;
  --violet-50:  #f8f5fb;

  --color-primary: #3B2566;
  --color-primary-hover: #2D1B4E;
  --color-primary-subtle: #f8f5fb;

  --color-success: #16794a;
  --color-success-bg: #ecfdf3;
  --color-success-border: #a6f4c5;

  --color-warning: #a16207;
  --color-warning-bg: #fefce8;
  --color-warning-border: #fde047;

  --color-danger: #be123c;
  --color-danger-bg: #fff1f2;
  --color-danger-border: #fecdd3;

  --gray-900: #18181b;
  --gray-800: #27272a;
  --gray-700: #3f3f46;
  --gray-600: #52525b;
  --gray-500: #71717a;
  --gray-400: #a1a1aa;
  --gray-300: #d4d4d8;
  --gray-200: #e4e4e7;
  --gray-100: #f0f0f2;
  --gray-50:  #f8f8fa;

  --bg-page: #f5f4f8;
  --bg-surface: #ffffff;
  --bg-surface-alt: var(--gray-50);
  --bg-header: var(--violet-900);

  --text-primary: var(--gray-900);
  --text-secondary: var(--gray-600);
  --text-muted: var(--gray-500);
  --text-on-dark: #ffffff;
  --text-on-dark-muted: var(--violet-300);

  --border-default: var(--gray-200);
  --border-light: var(--gray-100);

  --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.07);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.12);
  --shadow-focus: 0 0 0 3px rgba(59,37,102,0.15);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 999px;

  --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --transition-fast: 120ms ease;
  --transition-base: 200ms ease;
  --transition-smooth: 350ms var(--ease-out);
}

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* ─── HEADER ─── */
header {
  background: var(--bg-header);
  padding: 0 2rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

header::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--violet-600), var(--violet-400) 50%, transparent);
  opacity: 0.6;
}

.brand { display: flex; align-items: center; gap: 12px; height: 100%; }

.brand-mark {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.brand-mark svg { width: 16px; height: 16px; fill: white; }

header h1 {
  font-size: 0.9rem; font-weight: 600;
  color: var(--text-on-dark); margin: 0;
}

header h1 span { color: var(--text-on-dark-muted); font-weight: 400; }

.settings-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-on-dark-muted);
  padding: 7px 16px; border-radius: var(--radius-sm);
  font-size: 0.8rem; font-family: var(--font-sans); font-weight: 500;
  cursor: pointer; display: flex; align-items: center; gap: 8px;
  transition: all var(--transition-base);
}

.settings-btn:hover {
  background: rgba(255,255,255,0.12);
  color: var(--text-on-dark);
}

.settings-btn i { font-size: 0.75rem; }

/* ─── LAYOUT ─── */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 2rem 4rem;
}

/* ─── TABS ─── */
.tab-nav {
  display: flex; gap: 2px;
  background: var(--gray-100);
  border-radius: var(--radius-md);
  padding: 4px; margin-bottom: 2rem; width: fit-content;
}

.tab-btn {
  padding: 9px 22px; border: none; background: transparent;
  border-radius: calc(var(--radius-md) - 2px);
  font-family: var(--font-sans); font-size: 0.85rem; font-weight: 500;
  color: var(--text-muted); cursor: pointer;
  transition: all var(--transition-base);
  display: flex; align-items: center; gap: 8px; white-space: nowrap;
  appearance: none; -webkit-appearance: none; outline: none;
}

.tab-btn:hover { color: var(--text-primary); }

.tab-btn.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.tab-btn i { font-size: 0.78rem; opacity: 0.5; }
.tab-btn.active i { opacity: 1; color: var(--color-primary); }

.tab-panel { display: none; animation: panelIn 350ms var(--ease-out); }
.tab-panel.active { display: block; }

@keyframes panelIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── SECTION HEADER ─── */
.section-header { margin-bottom: 1.25rem; }

.section-header h2 {
  font-size: 1.35rem; font-weight: 700;
  letter-spacing: -0.025em; color: var(--text-primary);
  margin: 0 0 4px;
}

.section-header p { font-size: 0.88rem; color: var(--text-muted); line-height: 1.5; }

.section-header code {
  font-family: var(--font-mono); font-size: 0.78rem;
  background: var(--gray-100); padding: 2px 8px;
  border-radius: 6px; color: var(--text-secondary);
}

.muted { font-size: 0.85rem; color: var(--text-muted); }

/* ─── TEXTAREA ─── */
.input-area { position: relative; margin-bottom: 1rem; }

textarea {
  width: 100%; min-height: 130px; padding: 16px 18px;
  border: 1.5px solid var(--border-default);
  border-radius: var(--radius-md);
  font-family: var(--font-mono); font-size: 0.85rem; line-height: 1.7;
  color: var(--text-primary); background: var(--bg-surface);
  resize: vertical;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

textarea::placeholder { color: var(--gray-400); font-family: var(--font-sans); }

textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: var(--shadow-focus);
}

.char-count {
  position: absolute; bottom: 12px; right: 14px;
  font-size: 0.72rem; color: var(--gray-400);
  font-family: var(--font-mono); pointer-events: none;
}

/* ─── BUTTONS ─── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 24px;
  background: var(--color-primary); color: white; border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans); font-size: 0.85rem; font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-base);
  box-shadow: 0 1px 3px rgba(59,37,102,0.25);
}

.btn:hover {
  background: var(--color-primary-hover);
  box-shadow: 0 3px 10px rgba(59,37,102,0.3);
  transform: translateY(-1px);
}

.btn:active { transform: translateY(0); }
.btn i { font-size: 0.8rem; }

.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

.btn.loading { pointer-events: none; opacity: 0.7; }
.btn.loading i { animation: spin 0.8s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

.btn-ghost {
  padding: 10px 20px; background: transparent;
  border: 1.5px solid var(--border-default);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans); font-size: 0.82rem; font-weight: 500;
  color: var(--text-secondary); cursor: pointer;
  transition: all var(--transition-base);
}

.btn-ghost:hover { border-color: var(--gray-400); color: var(--text-primary); }

.btn-primary { background: var(--color-primary); color: white; border: none; }

/* ─── RESULTS LAYOUT ─── */
.results-area {
  margin-top: 1.75rem;
  display: flex; flex-direction: column; gap: 14px;
}

.results-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* ─── CARDS ─── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between;
}

.card-header h3 {
  font-size: 0.72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted);
  display: flex; align-items: center; gap: 8px; margin: 0;
}

.card-header h3 i { font-size: 0.7rem; opacity: 0.5; }

.card-body { padding: 20px; }

.copy-btn {
  background: none; border: 1px solid var(--border-default);
  border-radius: var(--radius-sm); padding: 5px 12px;
  font-size: 0.72rem; font-family: var(--font-sans); font-weight: 500;
  color: var(--text-muted); cursor: pointer;
  transition: all var(--transition-fast);
  display: flex; align-items: center; gap: 5px;
}

.copy-btn:hover {
  border-color: var(--gray-400);
  color: var(--text-secondary); background: var(--gray-50);
}

/* ─── VERDICT CARD ─── */
.verdict-card .verdict-inner {
  display: flex; align-items: center;
  gap: 20px; padding: 24px;
}

.verdict-icon-wrap {
  width: 56px; height: 56px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.verdict-icon-wrap svg { width: 26px; height: 26px; }

.verdict-icon-wrap.v-block { background: var(--color-danger-bg); }
.verdict-icon-wrap.v-block svg { stroke: var(--color-danger); }

.verdict-icon-wrap.v-allow { background: var(--color-success-bg); }
.verdict-icon-wrap.v-allow svg { stroke: var(--color-success); }

.verdict-icon-wrap.v-mask { background: var(--color-warning-bg); }
.verdict-icon-wrap.v-mask svg { stroke: var(--color-warning); }

.verdict-icon-wrap.v-default { background: var(--gray-100); }
.verdict-icon-wrap.v-default svg { stroke: var(--gray-500); }

.verdict-body { flex: 1; }

.verdict-title {
  font-size: 1.05rem; font-weight: 600;
  color: var(--text-primary); margin-bottom: 2px;
}

.verdict-desc {
  font-size: 0.85rem; color: var(--text-secondary);
  line-height: 1.45; margin-bottom: 8px;
}

.score-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 14px; border-radius: var(--radius-full);
  font-size: 0.8rem; font-weight: 600;
}

.score-pill .pill-dot {
  width: 8px; height: 8px; border-radius: 50%;
}

.score-pill.sp-danger  { background: var(--color-danger-bg);  color: #881337; }
.score-pill.sp-danger .pill-dot  { background: var(--color-danger); }

.score-pill.sp-warning { background: var(--color-warning-bg); color: #854d0e; }
.score-pill.sp-warning .pill-dot { background: var(--color-warning); }

.score-pill.sp-success { background: var(--color-success-bg); color: #14532d; }
.score-pill.sp-success .pill-dot { background: var(--color-success); }

.score-pill.sp-neutral { background: var(--gray-100); color: var(--gray-600); }
.score-pill.sp-neutral .pill-dot { background: var(--gray-400); }

/* Hidden data elements — app.js writes to these, verdict reads from them */
#decisionBadge, #riskScore, #riskDescription, #scoreRing { display: none; }

/* ─── PRE ─── */
pre {
  font-family: var(--font-mono); font-size: 0.85rem;
  line-height: 1.7; white-space: pre-wrap; word-break: break-word;
  color: var(--text-primary); background: transparent;
  padding: 0; border: none;
}

/* ─── EMPTY STATE ─── */
.empty-state-container { margin-top: 1.75rem; }

.empty-state { text-align: center; padding: 3.5rem 1rem; }

.empty-state .empty-icon {
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--violet-50); border: 1px solid var(--violet-100);
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
}

.empty-state .empty-icon i { font-size: 1.3rem; color: var(--violet-400); }

.empty-state p { font-size: 0.92rem; color: var(--text-muted); font-weight: 500; }

.empty-state .empty-hint {
  font-size: 0.82rem; font-weight: 400; opacity: 0.65; margin-top: 4px;
}

/* ─── ENTITY ROWS ─── */
.entity-list { display: flex; flex-direction: column; }

.entity-row {
  display: flex; align-items: center;
  padding: 11px 0; gap: 12px;
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition-fast);
}

.entity-row:last-child { border-bottom: none; }

.entity-type-col { width: 120px; flex-shrink: 0; }

.entity-badge {
  display: inline-flex; padding: 3px 10px;
  border-radius: 6px; font-size: 0.73rem;
  font-weight: 600; font-family: var(--font-sans);
  border: 1px solid;
}

.entity-badge.eb-BANK_CARD, .entity-badge.eb-IBAN { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.entity-badge.eb-EMAIL     { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }
.entity-badge.eb-I-PER, .entity-badge.eb-PERSON { background: #ede9fe; color: #5b21b6; border-color: #c4b5fd; }
.entity-badge.eb-I-LOC, .entity-badge.eb-LOCATION { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.entity-badge.eb-MED_PATIENT { background: #fce7f3; color: #9d174d; border-color: #f9a8d4; }
.entity-badge.eb-PHONE     { background: #e0f2fe; color: #075985; border-color: #7dd3fc; }
.entity-badge.eb-DATE      { background: #f0f9ff; color: #0c4a6e; border-color: #bae6fd; }
.entity-badge.eb-default   { background: var(--violet-50); color: var(--violet-700); border-color: var(--violet-200); }

.entity-value-col {
  flex: 1; font-family: var(--font-mono); font-size: 0.82rem;
  color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.entity-conf-col {
  width: 50px; text-align: right; font-size: 0.78rem;
  color: var(--text-muted); font-family: var(--font-mono); flex-shrink: 0;
}

.entity-source-col { width: 50px; text-align: right; flex-shrink: 0; }

.source-tag {
  display: inline-flex; padding: 2px 8px; border-radius: 4px;
  font-size: 0.68rem; font-weight: 500; font-family: var(--font-sans);
}

.source-tag.src-rules { background: #f0f9ff; color: #0c4a6e; }
.source-tag.src-ml    { background: var(--gray-100); color: var(--gray-600); }

.entity-count { font-size: 0.78rem; color: var(--text-muted); }

/* ─── LLM GUARD ─── */
.llm-guard-card {
  margin-top: 16px; padding: 16px 18px;
  border-radius: var(--radius-md);
  background: var(--violet-50); border: 1px solid var(--violet-100);
}

.llm-guard-card h4 {
  font-size: 0.72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--violet-600); margin-bottom: 6px;
  display: flex; align-items: center; gap: 8px;
}

.llm-guard-card h4 i { font-size: 0.7rem; }
.llm-guard-card p { font-size: 0.82rem; color: var(--text-secondary); margin-bottom: 2px; }
.llm-guard-card ul { list-style: none; padding: 0; margin: 4px 0 0; }
.llm-guard-card ul li { font-size: 0.8rem; color: var(--text-secondary); padding: 2px 0; }

/* ─── DATASET TABLE ─── */
table {
  width: 100%; font-size: 0.82rem; border-collapse: collapse; margin-top: 4px;
}

th, td {
  padding: 10px 12px; border-bottom: 1px solid var(--border-light); text-align: left;
}

th {
  background: var(--bg-surface-alt); font-weight: 600; font-size: 0.72rem;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted);
}

td { font-family: var(--font-mono); font-size: 0.8rem; color: var(--text-primary); }

tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--transition-fast); }
tbody tr:hover { background: var(--gray-50); }

.badge {
  padding: 4px 12px; border-radius: var(--radius-full);
  font-weight: 600; font-size: 0.73rem;
  display: inline-flex; align-items: center; gap: 5px;
}

.badge-allow { background: var(--color-success-bg); color: var(--color-success); border: 1px solid var(--color-success-border); }
.badge-mask  { background: var(--color-warning-bg); color: var(--color-warning); border: 1px solid var(--color-warning-border); }
.badge-block { background: var(--color-danger-bg);  color: var(--color-danger);  border: 1px solid var(--color-danger-border); }

/* ─── UPLOAD ─── */
.upload-zone {
  border: 2px dashed var(--gray-300); border-radius: var(--radius-lg);
  padding: 2.5rem 2rem; text-align: center; cursor: pointer;
  transition: all var(--transition-base);
  background: var(--bg-surface); position: relative; overflow: hidden;
}

.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--color-primary); background: var(--color-primary-subtle);
}

.upload-zone input[type="file"] {
  position: absolute !important; inset: 0 !important;
  width: 100% !important; height: 100% !important;
  opacity: 0 !important; cursor: pointer !important; z-index: 2;
}

.upload-zone .upload-icon {
  width: 56px; height: 56px; border-radius: var(--radius-md);
  background: var(--violet-50); border: 1px solid var(--violet-100);
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 14px; transition: all var(--transition-base);
}

.upload-zone:hover .upload-icon { background: var(--violet-100); border-color: var(--violet-200); }

.upload-zone .upload-icon i {
  font-size: 1.3rem; color: var(--violet-400);
  transition: color var(--transition-base);
}

.upload-zone:hover .upload-icon i { color: var(--color-primary); }

.upload-zone .upload-text {
  font-size: 0.92rem; font-weight: 500; color: var(--text-primary); margin-bottom: 4px;
}

.upload-zone .upload-text em {
  color: var(--color-primary); font-style: normal;
  text-decoration: underline; text-underline-offset: 2px;
}

.upload-zone .upload-hint { font-size: 0.8rem; color: var(--text-muted); }

.upload-zone.has-file {
  border-style: solid; border-color: var(--color-success);
  background: var(--color-success-bg);
}

.file-selected { display: flex; align-items: center; gap: 10px; justify-content: center; }
.file-selected i { color: var(--color-success); font-size: 1.2rem; }
.file-selected .file-name { font-family: var(--font-mono); font-size: 0.82rem; font-weight: 500; }
.file-selected .file-size { color: var(--text-muted); font-size: 0.78rem; }

.file-selected .file-remove {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; padding: 4px; font-size: 0.8rem; border-radius: 4px;
  transition: all var(--transition-fast);
}

.file-selected .file-remove:hover { color: var(--color-danger); background: rgba(190,18,60,0.06); }

.upload-actions { margin-top: 1.25rem; display: flex; align-items: center; gap: 14px; }

.separator, hr.separator { display: none; }

/* ─── MODAL ─── */
.modal {
  display: none; position: fixed; inset: 0;
  background: rgba(15,15,18,0.45); backdrop-filter: blur(6px);
  z-index: 200; align-items: center; justify-content: center;
}

.modal.active { display: flex; }

.modal-content {
  background: var(--bg-surface); border-radius: var(--radius-xl);
  width: 90%; max-width: 560px; max-height: 80vh;
  overflow-y: auto; box-shadow: var(--shadow-lg);
  animation: modalUp 350ms var(--ease-out); position: relative;
}

@keyframes modalUp {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-content > h3 { padding: 24px 24px 0; font-size: 1.05rem; font-weight: 700; margin: 0; }
.modal-content > h3 i { color: var(--color-primary); margin-right: 8px; }
.modal-content > p.muted { padding: 6px 24px 18px; border-bottom: 1px solid var(--border-light); margin: 0; }

.close-btn {
  position: absolute; top: 18px; right: 20px;
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 1.4rem;
  padding: 4px 8px; border-radius: var(--radius-sm);
  transition: all var(--transition-fast); line-height: 1;
}

.close-btn:hover { color: var(--text-primary); background: var(--gray-100); }

.weights-table { width: 100%; border-collapse: collapse; margin: 16px 0; }
.weights-table th, .weights-table td { border: none; border-bottom: 1px solid var(--border-light); padding: 10px 16px; text-align: left; }
.weights-table th { background: var(--bg-surface-alt); font-weight: 600; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }

.weights-table input[type="number"] {
  width: 80px; padding: 7px 10px;
  border: 1.5px solid var(--border-default); border-radius: var(--radius-sm);
  font-family: var(--font-mono); font-size: 0.82rem; text-align: center;
  transition: border-color var(--transition-base);
}

.weights-table input[type="number"]:focus { outline: none; border-color: var(--color-primary); box-shadow: var(--shadow-focus); }

#weightsTableContainer { padding: 0 24px; }

.modal-footer {
  display: flex; justify-content: flex-end; align-items: center;
  gap: 10px; padding: 18px 24px; border-top: 1px solid var(--border-light);
}

.modal-footer .status-message { margin-right: auto; }

/* ─── ENTITY TAGS (legacy compat) ─── */
.entity-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: var(--radius-full);
  font-size: 0.73rem; font-weight: 500; font-family: var(--font-mono);
  border: 1px solid; margin: 2px;
}

/* ─── RESPONSIVE ─── */
@media (max-width: 768px) {
  .results-columns { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  header { padding: 0 1rem; }
  main { padding: 1.25rem 1rem 3rem; }
  .tab-nav { width: 100%; }
  .tab-btn { flex: 1; justify-content: center; padding: 9px 12px; font-size: 0.8rem; }
  .upload-zone { padding: 2rem 1.25rem; }
  .verdict-card .verdict-inner { flex-direction: column; align-items: flex-start; }
  .entity-row { flex-wrap: wrap; }
}
