/* AgentHub: dua menu (Chat Agent dan Search DB).
   Palet: hijau-teal tua (sidebar), kertas abu-kehijauan (latar), teal (aksi), amber (aksen kecil). */

:root {
  --teal-900: #0f2f33;
  --teal-800: #163d41;
  --teal-700: #1a6862;
  --teal-600: #1f7a74;
  --teal-100: #dcebe8;
  --paper: #f2f4f0;
  --surface: #ffffff;
  --ink: #1a2a2c;
  --muted: #5a6c6e;
  --line: #d9dfda;
  --danger: #b3392f;
  --danger-bg: #fbeceb;
  --radius: 8px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
}

a { color: var(--teal-700); }
a:hover { color: var(--teal-900); }

h1, h2 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.6rem; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; font-weight: 650; }

code {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.9em;
}

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

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

:focus-visible {
  outline: 2px solid var(--teal-600);
  outline-offset: 2px;
}

/* ---------- Shell ---------- */

.shell {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--teal-900);
  color: #d7e6e4;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-weight: 650;
  font-size: 1.1rem;
  text-decoration: none;
  padding: 0 8px;
}
.brand:hover { color: #fff; }

.brand-mark {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 3px solid #7fd1c6;
  position: relative;
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: #e6a24a;
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  color: #c4d8d5;
  text-decoration: none;
  padding: 9px 12px;
  border-radius: 6px;
  border-left: 3px solid transparent;
}
.nav a:hover { background: var(--teal-800); color: #fff; }
.nav a.is-current {
  background: var(--teal-800);
  color: #fff;
  border-left-color: #e6a24a;
  font-weight: 600;
}

.sidebar-foot {
  margin: auto 8px 0;
  font-size: 0.8rem;
  color: #9db8b4;
}

.main {
  padding: 28px 36px 36px;
  min-width: 0;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.page-head p { margin: 4px 0 0; }

/* ---------- Buttons, chips, forms ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 16px;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.3;
}
.btn:hover { background: #eef1ed; color: var(--ink); }
.btn-primary { background: var(--teal-600); border-color: var(--teal-600); color: #fff; }
.btn-primary:hover { background: var(--teal-700); border-color: var(--teal-700); color: #fff; }
.btn-small { padding: 5px 11px; font-size: 0.88rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chip {
  display: inline-block;
  font-size: 0.82rem;
  padding: 2px 9px;
  border-radius: 4px;
  background: #f5ead9;
  color: #7a4a0b;
}

input[type="text"], textarea {
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid #bcc7c2;
  border-radius: 6px;
  padding: 8px 10px;
  width: 100%;
}
textarea { resize: vertical; }
input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--teal-600);
  outline-offset: 0;
  border-color: var(--teal-600);
}

.form-error {
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid #efc4c0;
  border-radius: 6px;
  padding: 8px 12px;
  margin: 0 0 16px;
}
.form-error[hidden], .empty[hidden], .panel[hidden], .muted[hidden] { display: none; }

.empty { color: var(--muted); padding: 18px 4px; margin: 0; }

/* ---------- Search DB ---------- */

.search-form { display: flex; gap: 10px; max-width: 640px; margin-bottom: 20px; }
.search-form input { flex: 1; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  max-width: 860px;
}
.panel h2 { margin-bottom: 8px; }

.rows { list-style: none; margin: 0; padding: 0; }
.rows li + li { border-top: 1px solid var(--line); }
.row { display: flex; justify-content: space-between; gap: 16px; padding: 12px 6px; }
.row-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

/* ---------- Chat Agent ---------- */

.chat {
  display: flex;
  flex-direction: column;
  max-width: 860px;
  height: calc(100vh - 64px);
  min-height: 480px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.chat-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}
.chat-head h1 { font-size: 1.15rem; }
.chat-head p { margin: 0; }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.chat-empty {
  margin: auto;
  max-width: 420px;
  text-align: center;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-empty p { margin: 0; }

.msg { display: flex; flex-direction: column; max-width: 80%; gap: 4px; }
.msg-user { align-self: flex-end; align-items: flex-end; }
.msg-agent { align-self: flex-start; align-items: flex-start; }

.bubble {
  padding: 10px 14px;
  border-radius: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg-user .bubble { background: var(--teal-100); border-bottom-right-radius: 3px; }
.msg-agent .bubble { background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 3px; }
.msg-agent.is-pending .bubble { color: var(--muted); border-style: dashed; }
.sources { padding: 0 4px; }

.composer {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
}
.composer textarea { flex: 1; resize: none; max-height: 180px; }

#chat-error { margin: 0 20px 12px; }
.chat-note { margin: 0 20px 12px; }

/* ---------- Contoh curl ---------- */

.curl { max-width: 860px; margin: 18px 0 0; }
.chat .curl { margin: 0; padding: 0 20px 14px; max-width: none; }
.curl summary { cursor: pointer; color: var(--teal-700); font-weight: 600; }
.api-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 8px; }

pre.code {
  margin: 8px 0;
  padding: 14px 16px;
  background: var(--teal-900);
  color: #d7e6e4;
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 0.88rem;
  line-height: 1.55;
}
pre.code code { font-size: inherit; }

/* ---------- Responsive ---------- */

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 16px;
  }
  .nav { flex-direction: row; gap: 4px; }
  .nav a { border-left: 0; border-bottom: 3px solid transparent; border-radius: 6px 6px 0 0; padding: 6px 10px; }
  .nav a.is-current { border-bottom-color: #e6a24a; }
  .sidebar-foot { display: none; }
  .main { padding: 18px 16px 28px; }
  .chat { height: calc(100vh - 120px); }
  .msg { max-width: 92%; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
