/* =============================================================================
   CodeJudge AI — style.css
   Premium dark dashboard · glassmorphism · animated score rings
   Impact tiers: HIGH=red/coral, MEDIUM=amber, LOW=green
============================================================================= */

:root {
  --bg: #0a0e1a;
  --bg-2: #0f1424;
  --panel: rgba(22, 28, 46, 0.72);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #e8ecf5;
  --muted: #8b93a7;
  --accent: #6ea8fe;
  --accent-2: #a78bfa;
  --high: #ff6b6b;
  --medium: #ffb454;
  --low: #51d88a;
  --good: #51d88a;
  --bad: #ff6b6b;
  --radius: 18px;
  --shadow: 0 18px 50px -20px rgba(0, 0, 0, 0.7);
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --display: 'Space Grotesk', 'Inter', sans-serif;
}

[hidden] { display: none !important; }

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

html, body { height: 100%; }

body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(110, 168, 254, 0.12), transparent 60%),
    radial-gradient(900px 500px at -10% 20%, rgba(167, 139, 250, 0.10), transparent 55%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Top bar ─────────────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px clamp(16px, 5vw, 56px);
  border-bottom: 1px solid var(--panel-border);
  backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 10;
  background: rgba(10, 14, 26, 0.6);
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo-mark {
  font-size: 26px; color: var(--accent);
  filter: drop-shadow(0 0 12px rgba(110, 168, 254, 0.6));
  animation: pulse 3s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
.brand h1 { font-family: var(--display); font-size: 1.3rem; font-weight: 700; letter-spacing: -0.01em; }
.brand .accent { background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tagline { font-size: 0.78rem; color: var(--muted); }
.pill {
  font-size: 0.74rem; padding: 6px 12px; border-radius: 999px;
  background: rgba(255,255,255,0.06); border: 1px solid var(--panel-border); color: var(--muted);
}
.pill.ok { color: var(--good); border-color: rgba(81,216,138,0.3); }
.pill.bad { color: var(--bad); border-color: rgba(255,107,107,0.3); }

/* ── Layout ──────────────────────────────────────────────────────────────── */
main {
  max-width: 1180px; margin: 0 auto; padding: 32px clamp(16px, 5vw, 40px) 80px;
  display: flex; flex-direction: column; gap: 26px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

h2 { font-family: var(--display); font-size: 1.15rem; font-weight: 600; letter-spacing: -0.01em; }
.muted { color: var(--muted); font-size: 0.88rem; }
.opt { color: var(--muted); font-style: normal; font-weight: 400; font-size: 0.78rem; }

/* ── Form ────────────────────────────────────────────────────────────────── */
.form-card h2 { margin-bottom: 4px; }
.form-card .muted { margin-bottom: 18px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field-label { font-size: 0.82rem; font-weight: 600; color: #c4cadd; }
.checkbox-field { flex-direction: row; align-items: center; gap: 10px; }
input[type="text"], input[type="url"], input[type="number"], textarea {
  background: rgba(10, 14, 26, 0.7);
  border: 1px solid var(--panel-border);
  border-radius: 12px; padding: 12px 14px; color: var(--text);
  font: inherit; font-size: 0.92rem; transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(110,168,254,0.15); }
textarea { resize: vertical; min-height: 70px; font-family: var(--font); }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }
.form-actions { display: flex; gap: 12px; margin-top: 6px; }
.btn {
  font: inherit; font-weight: 600; font-size: 0.92rem;
  padding: 12px 22px; border-radius: 12px; border: 1px solid transparent; cursor: pointer;
  transition: transform .12s, background .15s, border-color .15s;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(90deg, var(--accent), var(--accent-2)); color: #0a0e1a; }
.btn.primary:hover { box-shadow: 0 0 24px rgba(110,168,254,0.45); }
.btn.primary:disabled { opacity: 0.6; cursor: progress; }
.btn.ghost { background: transparent; border-color: var(--panel-border); color: var(--muted); }
.btn.ghost:hover { color: var(--text); border-color: rgba(255,255,255,0.2); }
.error-line { color: var(--bad); font-size: 0.86rem; margin-top: 10px; }

/* ── Loading ─────────────────────────────────────────────────────────────── */
.loading-card { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.loader {
  width: 46px; height: 46px; border-radius: 50%;
  border: 4px solid rgba(255,255,255,0.08);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Score hero ──────────────────────────────────────────────────────────── */
.score-hero { display: flex; align-items: center; gap: 36px; flex-wrap: wrap; }
.ring-wrap { position: relative; width: 160px; height: 160px; flex-shrink: 0; }
.ring { width: 160px; height: 160px; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(255,255,255,0.07); stroke-width: 10; }
.ring-fg {
  fill: none; stroke: url(#grad); stroke-width: 10; stroke-linecap: round;
  stroke-dasharray: 326.7; stroke-dashoffset: 326.7;
  transition: stroke-dashoffset 1.1s cubic-bezier(.2,.8,.2,1);
  stroke: var(--accent);
}
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-score { font-family: var(--display); font-size: 2.6rem; font-weight: 700; line-height: 1; }
.ring-max { color: var(--muted); font-size: 0.9rem; }
.hero-meta { flex: 1; min-width: 240px; }
.hero-meta h2 { font-size: 1.25rem; margin-bottom: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
  font-size: 0.74rem; padding: 5px 11px; border-radius: 999px;
  background: rgba(255,255,255,0.05); border: 1px solid var(--panel-border); color: #c4cadd;
}
.calibration-banner {
  margin-top: 14px; padding: 12px 16px; border-radius: 12px;
  font-size: 0.88rem; border: 1px solid;
}
.calibration-banner.converged { background: rgba(81,216,138,0.08); border-color: rgba(81,216,138,0.3); color: var(--good); }
.calibration-banner.notconverged { background: rgba(255,180,84,0.08); border-color: rgba(255,180,84,0.3); color: var(--medium); }

/* ── Pillar grid ─────────────────────────────────────────────────────────── */
.pillar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 18px; }
.pillar-card {
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
  backdrop-filter: blur(14px); display: flex; flex-direction: column; gap: 12px;
  position: relative; overflow: hidden;
}
.pillar-card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--tier-color, var(--accent));
}
.pillar-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.pillar-title { display: flex; align-items: center; gap: 10px; }
.pillar-icon { font-size: 1.3rem; }
.pillar-name { font-weight: 600; font-size: 0.96rem; }
.pillar-impact { font-size: 0.68rem; padding: 3px 8px; border-radius: 999px; font-weight: 600; letter-spacing: .02em; }
.impact-HIGH { background: rgba(255,107,107,0.12); color: var(--high); }
.impact-MEDIUM { background: rgba(255,180,84,0.12); color: var(--medium); }
.impact-LOW { background: rgba(81,216,138,0.12); color: var(--low); }
.pillar-score-mini { text-align: right; }
.pillar-score-mini .num { font-family: var(--display); font-size: 1.7rem; font-weight: 700; line-height: 1; }
.pillar-score-mini .w { font-size: 0.72rem; color: var(--muted); }

.mini-bar { height: 6px; border-radius: 999px; background: rgba(255,255,255,0.06); overflow: hidden; }
.mini-bar > span { display: block; height: 100%; border-radius: 999px; background: var(--tier-color, var(--accent)); width: 0; transition: width 1s cubic-bezier(.2,.8,.2,1); }

.pillar-reason { font-size: 0.84rem; color: #c4cadd; font-style: italic; border-left: 2px solid var(--panel-border); padding-left: 10px; }
.pillar-list { font-size: 0.82rem; display: flex; flex-direction: column; gap: 4px; }
.pillar-list li { list-style: none; }
.pillar-list .lbl { color: var(--muted); font-weight: 600; margin: 6px 0 2px; font-size: 0.74rem; text-transform: uppercase; letter-spacing: .04em; }
.pillar-list .ok { color: var(--good); }
.pillar-list .warn { color: var(--medium); }
.pillar-list .bad { color: var(--bad); }
.degraded-tag { font-size: 0.68rem; color: var(--medium); border: 1px dashed rgba(255,180,84,0.4); border-radius: 8px; padding: 4px 8px; align-self: flex-start; }

/* ── Report ──────────────────────────────────────────────────────────────── */
.report-card h2 { margin-bottom: 14px; }
.report-body { font-size: 0.9rem; line-height: 1.6; }
.report-body h2, .report-body h3 { font-family: var(--display); margin-top: 18px; margin-bottom: 6px; }
.report-body h3 { font-size: 1rem; }
.report-body table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 0.84rem; }
.report-body th, .report-body td { padding: 8px 10px; border-bottom: 1px solid var(--panel-border); text-align: left; }
.report-body th { color: var(--muted); font-weight: 600; }
.report-body code { background: rgba(255,255,255,0.06); padding: 1px 5px; border-radius: 5px; font-size: 0.85em; }
.report-body ul { padding-left: 20px; }
.report-body blockquote { border-left: 3px solid var(--accent); padding-left: 12px; color: #c4cadd; margin: 8px 0; }

/* ── Footer ──────────────────────────────────────────────────────────────── */
.footer { text-align: center; padding: 30px; color: var(--muted); font-size: 0.8rem; border-top: 1px solid var(--panel-border); }
.footer strong { color: var(--accent); }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .grid2 { grid-template-columns: 1fr; }
  .score-hero { gap: 20px; }
  .ring-wrap { width: 130px; height: 130px; }
  .ring { width: 130px; height: 130px; }
  .ring-score { font-size: 2.1rem; }
}
