/* ============================================================
   AI Content Forensics — dark navy dashboard
   ============================================================ */
:root {
  --bg-deep: #000000;
  --bg: #0a0a0a;
  --bg-card: #111111;
  --bg-card-hover: #1a1a1a;
  --border: #2a2a2a;
  --border-soft: #222222;
  --text: #e6edf7;
  --text-dim: #94a3b8;
  --text-faint: #5d6b85;
  --accent: #4f8cff;
  --accent-dim: rgba(79, 140, 255, 0.14);
  --green: #22d37e;
  --green-dim: rgba(34, 211, 126, 0.5);
  --yellow: #f5b93c;
  --orange: #f97316;
  --red: #ef4444;
  --mono: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --radius: 12px;
}

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

html { scroll-behavior: smooth; }

body {
  background:
    radial-gradient(1200px 500px at 80% -10%, rgba(59, 130, 246, 0.06), transparent 60%),
    radial-gradient(900px 400px at -10% 110%, rgba(34, 211, 126, 0.04), transparent 60%),
    var(--bg-deep);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100vh;
  font-size: 14.5px;
  line-height: 1.55;
}

::selection { background: rgba(79, 140, 255, 0.35); }

.mono { font-family: var(--mono); }

/* ===== Shell ===== */
.app-shell { display: flex; min-height: 100vh; }

/* ===== Sidebar ===== */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.88);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.4rem 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 0.7rem; padding: 0 0.4rem 1.4rem; border-bottom: 1px solid var(--border); }
.brand-icon {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: grid; place-items: center;
  color: var(--accent); font-size: 1.15rem; font-weight: 700;
  box-shadow: none;
}
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-weight: 700; font-size: 0.95rem; letter-spacing: -0.2px; }
.brand-sub { font-size: 0.68rem; color: var(--text-faint); font-family: var(--mono); }

.nav { margin-top: 1.2rem; display: flex; flex-direction: column; gap: 0.25rem; }
.nav-link {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.6rem 0.75rem; border-radius: 8px;
  color: var(--text-dim); text-decoration: none;
  font-size: 0.9rem; font-weight: 500;
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s;
}
.nav-link:hover { background: var(--bg-card); color: var(--text); }
.nav-link.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: rgba(79, 140, 255, 0.3);
}
.nav-link i { opacity: 0.7; }
.nav-link.active i { opacity: 1; }
.nav-link:hover i { opacity: 0.95; }

.sidebar-foot { margin-top: auto; padding: 0.8rem 0.4rem; }
.env-pill {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-family: var(--mono); font-size: 0.7rem;
  color: var(--green); background: var(--green-dim);
  padding: 0.3rem 0.6rem; border-radius: 99px;
  border: 1px solid rgba(34, 211, 126, 0.35);
}
.env-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.eng-note { margin-top: 0.7rem; font-size: 0.72rem; color: var(--text-faint); line-height: 1.5; }

/* ===== Main ===== */
.main {
  flex: 1;
  padding: 1.8rem 2.4rem 3rem;
  max-width: 1080px;
  margin: 0 auto;
  width: 100%;
}
.panel { display: none; }
.panel.active { display: block; animation: fadeUp 0.3s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.4rem; }
.panel-head h1 { font-size: 1.45rem; font-weight: 800; letter-spacing: -0.4px; }
.sub { color: var(--text-dim); font-size: 0.86rem; margin-top: 0.25rem; }

.stats-strip { display: flex; gap: 0.5rem; }
.stat-box {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; padding: 0.5rem 0.9rem; text-align: center; min-width: 72px;
}
.stat-box span { display: block; font-family: var(--mono); font-size: 1.05rem; font-weight: 600; color: var(--text); }
.stat-box label { font-size: 0.65rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.06em; }

/* ===== Cards ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.3rem;
  margin-bottom: 1.2rem;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

/* ===== Input ===== */
.textarea-wrap { position: relative; }
.textarea-wrap::before {
  content: 'input.txt';
  position: absolute; top: -0.7rem; left: 1rem;
  background: var(--bg-card); padding: 0 0.45rem;
  font-family: var(--mono); font-size: 0.68rem; color: var(--text-faint);
  border: 1px solid var(--border); border-radius: 5px;
  z-index: 1;
}
textarea {
  width: 100%;
  min-height: 240px;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 1rem 1.1rem;
  font-family: var(--mono);
  font-size: 0.88rem;
  line-height: 1.7;
  resize: vertical;
  caret-color: var(--accent);
  transition: border-color 0.2s, box-shadow 0.2s;
}
textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.15); }
textarea::placeholder { color: var(--text-faint); }

.toolbar { display: flex; align-items: center; gap: 0.55rem; margin-top: 0.9rem; flex-wrap: wrap; }
.txt-info { color: var(--text-faint); font-size: 0.75rem; margin-right: auto; margin-top: 0.2rem; }
.flex-spacer { flex: 1; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--border);
  background: var(--bg-deep);
  color: var(--text-dim);
  border-radius: 8px;
  padding: 0.5rem 0.95rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.05s;
  font-family: inherit;
}
.btn i { font-size: 0.9em; opacity: 0.75; }
.btn.primary i { opacity: 0.95; }
.btn:hover { background: var(--bg-card-hover); color: var(--text); border-color: var(--border-soft); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(135deg, #3b7cff, #2f66e0);
  border-color: transparent;
  color: #fff;
  padding: 0.55rem 1.3rem;
  box-shadow: 0 4px 16px rgba(79, 140, 255, 0.3);
}
.btn.primary:hover { filter: brightness(1.1); background: linear-gradient(135deg, #3b7cff, #2f66e0); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-icon { margin-right: 0.35rem; }

.sample-row { margin-top: 0.8rem; font-size: 0.78rem; color: var(--text-faint); }
.sample-row a { color: var(--accent); text-decoration: none; }
.sample-row a:hover { text-decoration: underline; }

/* ===== Hasil ===== */
.result-card { border-color: var(--border-soft); }
.result-head { display: flex; gap: 2.2rem; align-items: center; flex-wrap: wrap; }

.score-block { display: flex; align-items: center; gap: 1.4rem; flex-shrink: 0; }
.score-ring {
  width: 128px; height: 128px; border-radius: 50%;
  background: conic-gradient(var(--accent) 0deg, rgba(79, 140, 255, 0.12) 0deg);
  display: grid; place-items: center;
  position: relative;
  transition: background 0.8s ease;
}
.score-ring::before {
  content: ''; position: absolute; inset: 9px;
  background: var(--bg-card); border-radius: 50%;
  box-shadow: inset 0 0 12px rgba(0,0,0,0.4);
}
.score-ring-inner { position: relative; text-align: center; z-index: 1; }
.score-num { display: block; font-size: 1.8rem; font-weight: 600; color: var(--text); }
.score-lbl { font-size: 0.62rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.08em; }

.confidence-block { min-width: 170px; }
.conf-label { display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--text-dim); margin-bottom: 0.4rem; text-transform: uppercase; letter-spacing: 0.05em; }
.conf-track { height: 7px; background: var(--bg-deep); border-radius: 99px; overflow: hidden; }
.conf-fill { height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width 1s ease; }
.conf-note { display: block; font-size: 0.72rem; color: var(--text-faint); margin-top: 0.4rem; }

.verdict-block { flex: 1; min-width: 240px; }
.verdict-tag {
  display: inline-block;
  font-family: var(--mono); font-weight: 600; font-size: 0.85rem;
  padding: 0.3rem 0.8rem; border-radius: 7px; letter-spacing: 0.02em;
}
.verdict-desc { margin-top: 0.6rem; color: var(--text-dim); font-size: 0.86rem; line-height: 1.6; }
.verdict-meta { margin-top: 0.7rem; font-size: 0.68rem; color: var(--text-faint); }

/* ===== Breakdown ===== */
.breakdown { margin-top: 1.6rem; }
.bd-title { font-size: 0.78rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 0.8rem; }
.bd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem 1.6rem; }
@media (max-width: 720px) { .bd-grid { grid-template-columns: 1fr; } }
.bd-item {
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0.75rem 0.95rem;
}
.bd-item-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.5rem; }
.bd-label { font-size: 0.78rem; color: var(--text-dim); font-weight: 500; }
.bd-val { font-family: var(--mono); font-size: 0.9rem; font-weight: 600; }
.bd-track { height: 6px; background: var(--bg-card); border-radius: 99px; overflow: hidden; }
.bd-fill { height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width 1s ease 0.15s; }
.bd-note { display: block; margin-top: 0.45rem; font-size: 0.7rem; color: var(--text-faint); }

/* ===== Sentences highlight ===== */
.sentences-block { margin-top: 1.6rem; }
.sent-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.7rem; flex-wrap: wrap; gap: 0.5rem; }
.sent-head > span:first-child { font-size: 0.78rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; }
.sent-legend { font-size: 0.72rem; color: var(--text-faint); }
.sent-legend .lg { margin-left: 0.8rem; }
.lg.ai-mark { color: var(--yellow); }
.lg.mixed-mark { color: var(--orange); }
.lg.human-mark { color: var(--green); }

.sentences {
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.15rem;
  font-size: 0.88rem;
  line-height: 1.9;
  font-family: var(--sans);
}
.sent {
  display: inline;
  padding: 0.12rem 0.2rem;
  border-radius: 4px;
  cursor: default;
  transition: background 0.15s;
  border-bottom: 1px dashed transparent;
}
.sent:hover { background: rgba(255, 255, 255, 0.05); }
.sent.ai { background: rgba(245, 185, 60, 0.16); border-bottom-color: rgba(245, 185, 60, 0.5); }
.sent.mixed { background: rgba(249, 115, 22, 0.13); border-bottom-color: rgba(249, 115, 22, 0.45); }
.sent.human { color: var(--text-dim); }
.sent-sep { opacity: 0.35; color: var(--text-faint); }

.sent-tip {
  margin-top: 0.6rem; font-size: 0.72rem; color: var(--text-faint);
  display: flex; gap: 0.9rem; flex-wrap: wrap;
}
.sent-tip .tip-chip { font-family: var(--mono); }

/* ===== Detail accordion ===== */
.detail-acc { margin-top: 1.3rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.detail-acc summary { cursor: pointer; color: var(--text-dim); font-size: 0.82rem; font-weight: 600; user-select: none; }
.detail-acc summary:hover { color: var(--text); }
.detail-list { list-style: none; margin-top: 0.8rem; display: flex; flex-direction: column; gap: 0.45rem; }
.detail-list li {
  font-size: 0.8rem; color: var(--text-dim);
  padding: 0.45rem 0.7rem;
  background: var(--bg-deep); border: 1px solid var(--border);
  border-radius: 7px;
}
.detail-list b { color: var(--text); font-family: var(--mono); font-weight: 500; }
.detail-list i { color: var(--yellow); }

/* ===== History ===== */
.history-list { display: flex; flex-direction: column; gap: 0.75rem; min-height: 120px; }
.empty-note { color: var(--text-faint); font-size: 0.86rem; text-align: center; padding: 2.5rem 0; }
.hist-item {
  display: flex; align-items: center; gap: 1rem;
  background: var(--bg-deep); border: 1px solid var(--border);
  border-radius: 10px; padding: 0.85rem 1rem;
  cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.hist-item:hover { border-color: var(--accent); background: var(--bg-card-hover); }
.hist-score {
  font-family: var(--mono); font-size: 1.15rem; font-weight: 700;
  min-width: 58px; text-align: center;
  padding: 0.35rem 0.5rem; border-radius: 8px;
}
.hist-body { flex: 1; min-width: 0; }
.hist-preview { font-size: 0.84rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist-meta { font-size: 0.7rem; color: var(--text-faint); margin-top: 0.2rem; font-family: var(--mono); }
.hist-del {
  background: transparent; border: none; color: var(--text-faint);
  cursor: pointer; font-size: 1rem; padding: 0.3rem 0.5rem; border-radius: 6px;
}
.hist-del:hover { color: var(--red); background: rgba(239, 68, 68, 0.1); }

/* ===== Colors helper ===== */
.c-green { color: var(--green) !important; }
.c-yellow { color: var(--yellow) !important; }
.c-orange { color: var(--orange) !important; }
.c-red { color: var(--red) !important; }

.hidden { display: none !important; }

/* Scrollbar */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #3a3a3a; }

/* Toast */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  background: #161616;
  color: var(--text);
  border: 1px solid var(--border);
  border-left: 3px solid var(--green);
  padding: 0.8rem 1.1rem;
  border-radius: 10px;
  font-size: 0.85rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.25s, transform 0.25s;
  max-width: 340px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.warn { border-left-color: var(--yellow); }
.toast.error { border-left-color: var(--orange); }

@media (max-width: 860px) {
  .sidebar { width: 64px; padding: 1rem 0.6rem; }
  .brand-text, .nav-link span, .eng-note, .env-pill { display: none; }
  .nav-link { justify-content: center; }
  .main { padding: 1.2rem 1rem; }
}

/* ===== Mobile: bottom nav bar ===== */
@media (max-width: 600px) {
  .app-shell { display: block; }

  /* Sidebar jadi bottom navigation fixed */
  .sidebar {
    position: fixed;
    bottom: 0; left: 0; right: 0; top: auto;
    width: 100%; height: auto;
    flex-direction: row;
    align-items: center;
    padding: 0;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
    border-right: none;
    border-top: 1px solid var(--border);
    z-index: 100;
  }
  .brand, .sidebar-foot { display: none; }
  .nav {
    flex-direction: row;
    justify-content: space-around;
    margin: 0;
    width: 100%;
    padding: 0.45rem 0.5rem calc(0.45rem + env(safe-area-inset-bottom, 0px));
    gap: 0;
  }
  .nav-link {
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.62rem;
    padding: 0.45rem 0.6rem;
    min-width: 84px;
  }
  .nav-link i { font-size: 1.05rem; }
  .nav-link span { display: block; }

  /* Main content stack + ruang buat bottom nav */
  .main { padding: 1rem 0.9rem calc(76px + env(safe-area-inset-bottom, 0px)); }

  .panel-head { flex-direction: column; }
  .panel-head h1 { font-size: 1.2rem; }

  /* Stats strip wrap */
  .stats-strip { flex-wrap: wrap; }

  /* Textarea lebih pendek, font lebih besar biar gampang diketik */
  textarea { min-height: 170px; font-size: 0.96rem; }

  /* Toolbar: tombol full-width di baris sendiri */
  .toolbar { gap: 0.45rem; }
  .toolbar .btn { flex: 1; justify-content: center; padding: 0.55rem 0.4rem; }
  #detect-btn { flex-basis: 100%; margin-top: 0.2rem; padding: 0.7rem 1rem; }
  .txt-info { width: 100%; text-align: right; }

  /* Hasil: ring + confidence + verdict tumpuk */
  .result-head { flex-direction: column; gap: 1.2rem; align-items: stretch; }
  .score-block { justify-content: center; }
  .score-ring { width: 108px; height: 108px; }
  .confidence-block { min-width: 0; }
  .verdict-block { min-width: 0; }

  .bd-grid { grid-template-columns: 1fr; }

  /* Riwayat lebih padat */
  .hist-item { padding: 0.7rem 0.8rem; }
  .hist-score { min-width: 48px; font-size: 1rem; }

  .card { padding: 1rem; }

  /* Toast full-width di bawah tapi di atas nav */
  #toast-container {
    left: 12px; right: 12px; bottom: 84px;
    align-items: stretch;
  }
  .toast { max-width: none; }
}