/* ---------- Latinovation brand fonts (self-hosted, CSP-safe) ---------- */
@font-face {
  font-family: 'DM Sans';
  font-style: normal; font-weight: 400 600;
  font-display: swap;
  src: url('/static/fonts/dm-sans.woff2') format('woff2');
}
@font-face {
  font-family: 'Playfair Display';
  font-style: normal; font-weight: 600 700;
  font-display: swap;
  src: url('/static/fonts/playfair-display.woff2') format('woff2');
}

:root {
  /* Latinovation palette — deep purple base, orange presence */
  --bg: #160f33;
  --bg-raised: #221a4a;
  --bg-inset: #110b27;
  --border: #352a66;
  --border-soft: #2c2356;
  --text: #f3f0fb;
  --text-dim: #ada3d0;
  --ink: #1a1233;

  --accent: #e87722;        /* orange — primary interactive */
  --accent-dim: #b95e16;
  --ok: #5cc22f;            /* green — clean verdict */
  --amber: #ffd24a;         /* yellow — suspicious */
  --red: #ff6b78;           /* danger — malicious */

  --sev-critical: #ff6b78;
  --sev-high: #f08030;
  --sev-medium: #ffd24a;
  --sev-low: #5ba8de;
  --sev-info: #9a93b8;

  --serif: "Playfair Display", Georgia, "Times New Roman", serif;
  --sans: "DM Sans", -apple-system, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
  --radius: 14px;
  --space: clamp(1rem, 0.8rem + 1vw, 2rem);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 460px at 72% -12%, rgba(232, 119, 34, 0.13), transparent),
    radial-gradient(900px 500px at 8% 0%, rgba(68, 157, 215, 0.10), transparent),
    var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

main {
  width: min(880px, 92vw);
  margin: 0 auto;
  flex: 1;
}

/* ---------- header ---------- */
.topbar {
  position: relative;
  width: min(880px, 92vw);
  margin: 0 auto;
  padding: calc(var(--space) * 1.4) 0 var(--space);
}
.brand { display: flex; align-items: center; gap: 0.7rem; }
.brand-mark {
  width: 15px; height: 15px; border-radius: 4px;
  background: linear-gradient(135deg, var(--accent), #f5a04e);
  box-shadow: 0 0 18px rgba(232, 119, 34, 0.6), 0 0 4px rgba(232, 119, 34, 0.8);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.5; } }
.brand h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(1.6rem, 1.2rem + 1.5vw, 2.3rem);
  letter-spacing: -0.01em;
}
.tagline { color: var(--text-dim); margin: 0.45rem 0 0; max-width: 58ch; }

.header-actions { position: absolute; top: calc(var(--space) * 1.4); right: 0; display: flex; gap: 0.5rem; align-items: center; }
.lang-select {
  font: inherit; font-size: 0.85rem; font-weight: 600;
  background: var(--bg-inset); color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 9px;
  padding: 0.45rem 0.6rem; cursor: pointer;
}
.lang-select:hover { color: var(--text); border-color: var(--accent); }
.lang-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.login-lang { margin-top: 1.3rem; text-align: center; }

/* ---------- dropzone ---------- */
.dropzone {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
  padding: calc(var(--space) * 1.8) var(--space);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}
.dropzone:hover, .dropzone:focus-visible, .dropzone.dragover {
  border-color: var(--accent);
  background: #2a2056;
  outline: none;
}
.dropzone.dragover { transform: scale(1.01); }
.drop-icon { color: var(--accent); }
.drop-title { font-size: 1.18rem; font-weight: 600; margin: 0.8rem 0 0.2rem; }
.drop-hint { color: var(--text-dim); margin: 0; font-size: 0.9rem; }

/* ---------- scanning ---------- */
.scanning { margin-top: var(--space); text-align: center; color: var(--text-dim); }
.scan-bar {
  height: 6px; border-radius: 3px; overflow: hidden;
  background: var(--bg-inset); border: 1px solid var(--border);
}
.scan-pulse {
  height: 100%; width: 35%;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: sweep 1.1s linear infinite;
}
@keyframes sweep { from { transform: translateX(-100%); } to { transform: translateX(380%); } }

/* ---------- error ---------- */
.error-box {
  margin-top: var(--space);
  border: 1px solid var(--red);
  background: #2c1330;
  color: #ffd0d6;
  border-radius: var(--radius);
  padding: 0.9rem 1.2rem;
  font-family: var(--mono);
  font-size: 0.92rem;
}

/* ---------- verdict ---------- */
.results { margin-top: var(--space); }
.verdict {
  display: flex; flex-wrap: wrap; gap: var(--space);
  justify-content: space-between; align-items: center;
  border-radius: var(--radius);
  padding: var(--space);
  border: 1px solid var(--border);
  background: var(--bg-raised);
}
.verdict.clean   { border-color: #3a7a1f; box-shadow: inset 4px 0 0 var(--ok); }
.verdict.suspicious { border-color: #8a6a2f; box-shadow: inset 4px 0 0 var(--amber); }
.verdict.malicious  { border-color: #7c2f4a; box-shadow: inset 4px 0 0 var(--red); }
.verdict-left { display: flex; gap: 0.9rem; align-items: center; }
.verdict-icon { font-size: 2rem; line-height: 1; }
.verdict h2 { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 1.45rem; }
.verdict.clean h2 { color: var(--ok); }
.verdict.suspicious h2 { color: var(--amber); }
.verdict.malicious h2 { color: var(--red); }
.verdict p { margin: 0.2rem 0 0; color: var(--text-dim); font-size: 0.92rem; }

.file-meta {
  display: grid; grid-template-columns: auto auto; gap: 0.1rem 1rem;
  margin: 0; font-size: 0.82rem;
}
.file-meta dt { color: var(--text-dim); }
.file-meta dd { margin: 0; font-family: var(--mono); }

/* ---------- findings ---------- */
.section-label {
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--text-dim); margin: calc(var(--space) * 1.2) 0 0.6rem;
}
.count-chip {
  background: var(--bg-inset); border: 1px solid var(--border);
  padding: 0.05rem 0.55rem; border-radius: 99px; margin-left: 0.4rem;
}
.findings { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; }
.finding {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-raised);
  padding: 0.85rem 1rem;
  display: grid; gap: 0.35rem;
}
.finding-head { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.sev {
  font-family: var(--mono); font-size: 0.68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 0.15rem 0.5rem; border-radius: 5px; color: var(--ink);
}
.sev-critical { background: var(--sev-critical); }
.sev-high     { background: var(--sev-high); }
.sev-medium   { background: var(--sev-medium); }
.sev-low      { background: var(--sev-low); }
.sev-info     { background: var(--sev-info); }
.finding-title { font-weight: 600; }
.finding-loc { color: var(--text-dim); font-size: 0.78rem; font-family: var(--mono); margin-left: auto; }
.finding-detail { color: var(--text-dim); font-size: 0.92rem; }
.finding-evidence {
  font-family: var(--mono); font-size: 0.8rem;
  background: var(--bg-inset); border: 1px solid var(--border);
  border-radius: 7px; padding: 0.5rem 0.7rem;
  white-space: pre-wrap; word-break: break-word;
  color: #d7cff0; max-height: 7.5rem; overflow: auto;
}
.no-findings {
  color: var(--text-dim); border: 1px dashed var(--border);
  border-radius: 10px; padding: 0.9rem 1rem; font-size: 0.92rem;
}

/* ---------- convert CTA / markdown ---------- */
.convert-cta {
  margin-top: var(--space);
  border: 1px solid #8a5a2a; background: #2a1d10;
  border-radius: var(--radius); padding: var(--space);
}
.convert-cta p { margin: 0 0 0.8rem; color: #f0d9b8; font-size: 0.95rem; }

.markdown-wrap { margin-top: var(--space); }
.md-header { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.md-actions { display: flex; gap: 0.5rem; }
.markdown-output {
  font-family: var(--mono); font-size: 0.84rem; line-height: 1.6;
  background: var(--bg-inset); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--space);
  white-space: pre-wrap; word-break: break-word;
  max-height: 26rem; overflow: auto; margin: 0;
}

/* ---------- buttons ---------- */
.btn {
  font: inherit; font-size: 0.9rem; font-weight: 600;
  border-radius: 9px; padding: 0.55rem 1.1rem;
  cursor: pointer; border: 1px solid transparent;
  transition: filter 0.15s, transform 0.1s;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); color: #241200; }
.btn-amber { background: var(--amber); color: #2a1c04; }
.btn-ghost {
  background: transparent; color: var(--text-dim);
  border-color: var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--accent); }
.reset { margin-top: var(--space); }

.footer {
  text-align: center; color: var(--text-dim);
  font-size: 0.78rem; padding: var(--space) 0;
}

.hidden { display: none !important; }

/* ---------- settings panel ---------- */
.settings-backdrop {
  position: fixed; inset: 0; background: #0a0720cc;
  display: flex; align-items: center; justify-content: center;
  padding: var(--space); z-index: 50;
}
.settings-card {
  width: min(520px, 94vw);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: calc(var(--space) * 1.2);
  box-shadow: 0 24px 70px #0009;
  max-height: 90vh; overflow: auto;
}
.settings-card h2 {
  font-family: var(--serif); font-weight: 600; font-size: 1.35rem; margin: 0 0 0.2rem;
}
.settings-card .muted { color: var(--text-dim); font-size: 0.9rem; margin: 0 0 1.2rem; }
.field { display: grid; gap: 0.4rem; margin-bottom: 1rem; }
.field label {
  font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-dim);
}
.field input, .field select {
  font: inherit;
  background: var(--bg-inset); border: 1px solid var(--border);
  border-radius: 9px; padding: 0.6rem 0.8rem; color: var(--text);
}
.field input:focus-visible, .field select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.field .hint { font-size: 0.8rem; color: var(--text-dim); text-transform: none; letter-spacing: 0; }
.key-status {
  font-family: var(--mono); font-size: 0.82rem;
  padding: 0.4rem 0.7rem; border-radius: 7px;
  background: var(--bg-inset); border: 1px solid var(--border);
}
.key-status.set { color: var(--ok); border-color: #3a7a1f; }
.key-status.unset { color: var(--amber); border-color: #8a6a2f; }
.settings-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1.2rem; flex-wrap: wrap; }
.settings-msg { font-size: 0.88rem; margin: 0.6rem 0 0; min-height: 1.2em; }
.settings-msg.ok { color: var(--ok); }
.settings-msg.err { color: var(--red); }

/* ---------- login ---------- */
.login-body {
  display: flex; align-items: center; justify-content: center;
  padding: var(--space);
}
.login-card {
  width: min(420px, 92vw);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: calc(var(--space) * 1.4);
  box-shadow: 0 24px 60px #0009;
}
.login-card .tagline { margin: 0.6rem 0 1.4rem; }
.login-form { display: grid; gap: 0.5rem; }
.login-label {
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--text-dim);
}
.login-input {
  font: inherit;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0.7rem 0.9rem;
  color: var(--text);
}
.login-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.login-submit { margin-top: 0.6rem; justify-self: stretch; }
.login-error {
  margin: 1rem 0 0; color: #ffd0d6; font-size: 0.9rem; font-family: var(--mono);
}

@media (max-width: 600px) {
  .verdict { flex-direction: column; align-items: flex-start; }
  .finding-loc { margin-left: 0; }
  .header-actions { position: static; margin-top: 0.8rem; }
}
