/* ctx-lite – Basislayout um die Infineon-Komponenten herum.
   Farben: Infineon Ocean (#0A8276) als Primärfarbe, Engineering-Grau für Text. */
:root {
  --ifx-font-family: "Source Sans 3", Arial, sans-serif;
  --c-ocean: #0A8276;
  --c-ocean-dark: #08665C;
  --c-ocean-light: #E1F3F1;
  --c-text: #1D1D1D;
  --c-text-muted: #575352;
  --c-border: #E0E0E0;
  --c-bg: #F7F7F7;
  --c-surface: #FFFFFF;
  --c-danger: #CD002F;
  --c-warn: #E16B25;
  --c-user-bubble: #E1F3F1;
  --nav-h: 56px;
  --foot-h: 32px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--ifx-font-family);
  color: var(--c-text);
  background: var(--c-bg);
  font-size: 15px;
  line-height: 1.45;
}
a { color: var(--c-ocean); }
h1, h2, h3 { margin: 0 0 .5rem; font-weight: 600; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
pre { background: #F0F0F0; padding: .75rem; border-radius: 4px; overflow: auto; }
code { background: #F0F0F0; padding: .05rem .3rem; border-radius: 3px; font-size: .92em; }
pre code { background: none; padding: 0; }

.view {
  padding: calc(var(--nav-h) + 16px) 24px calc(var(--foot-h) + 16px);
  min-height: 100vh;
}
.foot {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--foot-h);
  display: flex; align-items: center; gap: .5rem; padding: 0 16px;
  font-size: .8rem; color: var(--c-text-muted);
  background: var(--c-surface); border-top: 1px solid var(--c-border);
}
.foot-status.ok::before, .foot-status.degraded::before, .foot-status.down::before {
  content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px;
}
.foot-status.ok::before { background: #2E8B57; }
.foot-status.degraded::before { background: var(--c-warn); }
.foot-status.down::before { background: var(--c-danger); }

.page-head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.spacer { flex: 1; }
.muted { color: var(--c-text-muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }
.error-box { color: var(--c-danger); padding: .5rem .75rem; border: 1px solid var(--c-danger); border-radius: 4px; background: #FFF3F5; }
.empty { padding: 2rem; text-align: center; color: var(--c-text-muted); }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }

/* ---------- Login ---------- */
.login-body { background: linear-gradient(160deg, #0A8276 0%, #1D1D1D 100%); min-height: 100vh; }
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1rem; }
.login-card {
  width: min(420px, 100%); background: var(--c-surface); border-radius: 8px; padding: 2rem;
  display: flex; flex-direction: column; gap: 1.1rem; box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
.login-brand { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .5rem; }
.login-mark { font-size: 2rem; font-weight: 700; letter-spacing: .08em; color: var(--c-ocean); }
.login-sub { color: var(--c-text-muted); }
.login-error { color: var(--c-danger); font-size: .9rem; }
.login-foot { color: rgba(255,255,255,.7); font-size: .8rem; margin-top: 1rem; }

/* ---------- Blocks ---------- */
.blocks-layout { display: grid; grid-template-columns: 260px 1fr; gap: 1.25rem; }
@media (max-width: 900px) { .blocks-layout { grid-template-columns: 1fr; } }
.filter-panel { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 6px; padding: 1rem; align-self: start; position: sticky; top: calc(var(--nav-h) + 16px); max-height: calc(100vh - var(--nav-h) - var(--foot-h) - 32px); overflow: auto; }
.filter-panel h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--c-text-muted); margin: .75rem 0 .4rem; }
.cat-list { display: flex; flex-direction: column; gap: 2px; }
.cat-btn {
  display: flex; justify-content: space-between; align-items: center; width: 100%; text-align: left;
  border: 0; background: none; padding: .35rem .5rem; border-radius: 4px; cursor: pointer; font: inherit; color: var(--c-text);
}
.cat-btn:hover { background: var(--c-bg); }
.cat-btn.active { background: var(--c-ocean-light); color: var(--c-ocean-dark); font-weight: 600; }
.cat-btn .n { font-size: .8rem; color: var(--c-text-muted); }
.block-list { display: flex; flex-direction: column; gap: .6rem; }
.block-card {
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 6px; padding: .8rem 1rem;
  cursor: pointer; transition: border-color .12s, box-shadow .12s;
}
.block-card:hover { border-color: var(--c-ocean); box-shadow: 0 2px 10px rgba(10,130,118,.12); }
.block-card .t { font-weight: 600; font-size: 1.02rem; margin-bottom: .2rem; }
.block-card .p { color: var(--c-text-muted); font-size: .9rem; white-space: pre-line; max-height: 4.2em; overflow: hidden; }
.block-meta { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: .45rem; font-size: .78rem; color: var(--c-text-muted); }
.tag { display: inline-block; padding: .05rem .45rem; border-radius: 999px; background: var(--c-bg); border: 1px solid var(--c-border); font-size: .75rem; }
.tag.cat { background: var(--c-ocean-light); border-color: transparent; color: var(--c-ocean-dark); font-weight: 600; }
.tag.scope { background: #F1EEE9; }
.tag.sens-credentials { background: #FDE8EC; color: var(--c-danger); }
.tag.sens-personal { background: #FFF1E6; color: var(--c-warn); }
.load-more { display: flex; justify-content: center; padding: 1rem; }

/* ---------- Detail (Modal) ---------- */
.detail-body { max-height: 65vh; overflow: auto; }
.detail-head { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .8rem; }
.detail-md { line-height: 1.55; }
.detail-md img { max-width: 100%; }
.detail-md table { border-collapse: collapse; }
.detail-md td, .detail-md th { border: 1px solid var(--c-border); padding: .25rem .5rem; }
.detail-md blockquote { border-left: 3px solid var(--c-ocean); margin: .5rem 0; padding: .2rem .8rem; color: var(--c-text-muted); }
.detail-buttons { display: flex; gap: .5rem; }

/* ---------- Graph ---------- */
.graph-layout { display: grid; grid-template-columns: 280px 1fr; gap: 1rem; height: calc(100vh - var(--nav-h) - var(--foot-h) - 32px); }
@media (max-width: 900px) { .graph-layout { grid-template-columns: 1fr; height: auto; } }
.graph-panel { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 6px; padding: 1rem; overflow: auto; display: flex; flex-direction: column; gap: .8rem; }
.graph-panel > * { flex-shrink: 0; }
.graph-panel h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--c-text-muted); margin: .25rem 0 0; }
.graph-canvas { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 6px; position: relative; overflow: hidden; min-height: 420px; }
.graph-canvas canvas { display: block; }
.graph-overlay { position: absolute; left: 12px; top: 10px; font-size: .8rem; color: var(--c-text-muted); background: rgba(255,255,255,.85); padding: .2rem .5rem; border-radius: 4px; pointer-events: none; }
.legend { display: flex; flex-direction: column; gap: .2rem; font-size: .82rem; }
.legend .li { display: flex; align-items: center; gap: .4rem; }
.legend .sw { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.search-results { display: flex; flex-direction: column; gap: 2px; max-height: 220px; overflow: auto; }
.search-results button { text-align: left; border: 0; background: none; padding: .3rem .4rem; border-radius: 4px; cursor: pointer; font: inherit; }
.search-results button:hover { background: var(--c-bg); }
.focus-box { background: var(--c-ocean-light); border-radius: 4px; padding: .5rem .6rem; font-size: .9rem; }
.seg { display: flex; gap: 0; border: 1px solid var(--c-border); border-radius: 4px; overflow: hidden; }
.seg button { flex: 1; border: 0; background: var(--c-surface); padding: .4rem .5rem; cursor: pointer; font: inherit; }
.seg button.active { background: var(--c-ocean); color: #fff; }
select.native { font: inherit; padding: .35rem .5rem; border: 1px solid var(--c-border); border-radius: 4px; background: #fff; }
label.lbl { font-size: .85rem; color: var(--c-text-muted); display: flex; flex-direction: column; gap: .25rem; }

/* ---------- Chat ---------- */
.chat-layout { display: grid; grid-template-columns: 280px 1fr; gap: 1rem; height: calc(100vh - var(--nav-h) - var(--foot-h) - 32px); }
@media (max-width: 900px) { .chat-layout { grid-template-columns: 1fr; height: auto; } }
.chat-sessions { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 6px; padding: .75rem; overflow: auto; display: flex; flex-direction: column; gap: .4rem; }
.sess-btn {
  text-align: left; border: 1px solid transparent; background: none; padding: .45rem .6rem; border-radius: 4px; cursor: pointer; font: inherit; color: var(--c-text);
  display: flex; flex-direction: column; gap: .1rem;
}
.sess-btn:hover { background: var(--c-bg); }
.sess-btn.active { background: var(--c-ocean-light); border-color: var(--c-ocean); }
.sess-btn .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sess-btn .m { font-size: .75rem; color: var(--c-text-muted); }
.chat-main { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 6px; display: flex; flex-direction: column; min-height: 480px; }
.chat-thread { flex: 1; overflow: auto; padding: 1rem; display: flex; flex-direction: column; gap: .75rem; }
.msg { max-width: 82%; padding: .6rem .85rem; border-radius: 10px; }
.msg.user { align-self: flex-end; background: var(--c-user-bubble); border-bottom-right-radius: 3px; white-space: pre-wrap; }
.msg.assistant { align-self: flex-start; background: var(--c-bg); border-bottom-left-radius: 3px; }
.msg.assistant .detail-md > :first-child { margin-top: 0; }
.msg.assistant .detail-md > :last-child { margin-bottom: 0; }
.msg-meta { font-size: .72rem; color: var(--c-text-muted); margin-top: .35rem; display: flex; gap: .5rem; flex-wrap: wrap; }
.tool-chip { display: inline-flex; align-items: center; gap: .3rem; font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; background: #EFEFEF; border: 1px solid var(--c-border); }
.tool-chip.ok { border-color: #9BD3C9; background: var(--c-ocean-light); }
.tool-chip.err { border-color: #F3B7C4; background: #FDE8EC; }
.tool-chip button { border: 0; background: none; padding: 0; cursor: pointer; font: inherit; color: var(--c-ocean-dark); text-decoration: underline; }
.typing { color: var(--c-text-muted); font-size: .85rem; }
.chat-compose { border-top: 1px solid var(--c-border); padding: .75rem; display: flex; gap: .6rem; align-items: flex-end; }
.chat-compose textarea {
  flex: 1; font: inherit; resize: vertical; min-height: 44px; max-height: 200px; padding: .55rem .7rem;
  border: 1px solid var(--c-border); border-radius: 4px;
}
.chat-compose textarea:focus { outline: 2px solid var(--c-ocean); outline-offset: 0; border-color: transparent; }
.chat-bar { display: flex; align-items: center; gap: .6rem; padding: .5rem .75rem; border-bottom: 1px solid var(--c-border); font-size: .85rem; color: var(--c-text-muted); flex-wrap: wrap; }
.blocks-inline { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .3rem; }
.blocks-inline button { font: inherit; font-size: .75rem; border: 1px solid var(--c-border); background: #fff; border-radius: 999px; padding: .05rem .5rem; cursor: pointer; }
.blocks-inline button:hover { border-color: var(--c-ocean); }

/* ---------- Markdown-Typografie (Antworten, Block-Details) ---------- */
.detail-md h1 { font-size: 1.35rem; margin: 1rem 0 .5rem; color: var(--c-ocean-dark); }
.detail-md h2 { font-size: 1.15rem; margin: 1.1rem 0 .45rem; padding-bottom: .2rem; border-bottom: 1px solid var(--c-border); }
.detail-md h3 { font-size: 1.02rem; margin: .9rem 0 .3rem; }
.detail-md h4, .detail-md h5, .detail-md h6 { font-size: .95rem; margin: .7rem 0 .25rem; color: var(--c-text-muted); text-transform: uppercase; letter-spacing: .04em; }
.detail-md p { margin: .45rem 0; }
.detail-md ul, .detail-md ol { margin: .4rem 0 .6rem; padding-left: 1.5rem; }
.detail-md li { margin: .18rem 0; }
.detail-md li > p { margin: .15rem 0; }
.detail-md li > ul, .detail-md li > ol { margin: .15rem 0 .25rem; }
.detail-md table { display: block; width: max-content; max-width: 100%; overflow-x: auto; margin: .5rem 0 .8rem; font-size: .92rem; border: 1px solid var(--c-border); border-radius: 4px; }
.detail-md th { background: var(--c-ocean-light); color: var(--c-ocean-dark); text-align: left; font-weight: 600; }
.detail-md td, .detail-md th { vertical-align: top; }
.detail-md tbody tr:nth-child(even) td { background: #FAFAFA; }
.detail-md hr { border: 0; border-top: 1px solid var(--c-border); margin: 1rem 0; }
.detail-md pre { margin: .5rem 0 .8rem; font-size: .88rem; line-height: 1.4; border: 1px solid var(--c-border); }
.detail-md strong { font-weight: 600; }
.detail-md a.ctx-link {
  display: inline-block; background: #fff; border: 1px solid #9BD3C9; border-radius: 999px; padding: 0 .55rem;
  font-size: .82rem; text-decoration: none; color: var(--c-ocean-dark); margin: .1rem 0; line-height: 1.5;
}
.detail-md a.ctx-link::before { content: "▤ "; font-size: .75em; opacity: .7; }
.detail-md a.ctx-link:hover { border-color: var(--c-ocean); background: var(--c-ocean-light); }

/* ---------- Chat: Antwortblase, Zwischenschritte, Aktionen ---------- */
.msg.assistant { max-width: 100%; }
.msg.assistant .answer { font-size: .98rem; }
.step { margin-bottom: .55rem; padding-bottom: .5rem; border-bottom: 1px dashed var(--c-border); }
.step .step-chips { margin: 0; }
.step details { margin-top: .3rem; }
.step summary { cursor: pointer; font-size: .78rem; color: var(--c-text-muted); user-select: none; }
.step summary:hover { color: var(--c-ocean-dark); }
.step details .detail-md { font-size: .86rem; color: var(--c-text-muted); padding: .3rem .7rem; border-left: 2px solid var(--c-border); margin-top: .3rem; }
.msg-actions { display: flex; gap: .3rem; margin-top: .55rem; flex-wrap: wrap; align-items: center; }
.act-btn { font: inherit; font-size: .78rem; border: 1px solid var(--c-border); background: #fff; border-radius: 999px; padding: .1rem .65rem; cursor: pointer; color: var(--c-text); line-height: 1.6; }
.act-btn:hover { border-color: var(--c-ocean); color: var(--c-ocean-dark); }
.act-btn:disabled { opacity: .5; cursor: wait; }
.chat-bar .bar-title { font-weight: 600; color: var(--c-text); }
.chat-bar .bar-group { display: inline-flex; gap: .3rem; align-items: center; padding-left: .5rem; border-left: 1px solid var(--c-border); }
