/* ====== IoT studijní průvodce – styly ====== */
:root {
  --bg: #0f1419;
  --bg-soft: #161c24;
  --card: #1b232e;
  --card-hover: #212c39;
  --border: #2a3543;
  --text: #e6edf3;
  --text-dim: #9aa7b4;
  --accent: #4aa3ff;
  --accent-soft: #1d3a5c;
  --good: #3fb950;
  --good-soft: #18351f;
  --shadow: 0 4px 18px rgba(0,0,0,.35);

  --src-prezentace: #4aa3ff;
  --src-ucebnice:   #b07cff;
  --src-doplnek:    #2bb6a8;
  --src-internet:   #f0883e;
  --src-interni:    #8b98a5;
}
:root[data-theme="light"] {
  --bg: #f4f6f9;
  --bg-soft: #ffffff;
  --card: #ffffff;
  --card-hover: #f7fafc;
  --border: #dce3eb;
  --text: #1a2330;
  --text-dim: #5a6878;
  --accent: #1769d6;
  --accent-soft: #e3effb;
  --good: #1a8c34;
  --good-soft: #e4f6e8;
  --shadow: 0 4px 18px rgba(20,40,70,.10);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---- Header ---- */
header.app {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.head-inner {
  max-width: 1100px; margin: 0 auto; padding: 14px 18px;
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
}
.head-inner h1 { font-size: 1.15rem; margin: 0; display: flex; align-items: center; gap: 8px; }
.head-inner h1 .logo { font-size: 1.4rem; }
.spacer { flex: 1 1 auto; }
.icon-btn {
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  border-radius: 9px; padding: 7px 11px; cursor: pointer; font-size: .9rem;
}
.icon-btn:hover { background: var(--card-hover); }

/* ---- Tabs ---- */
.tabs { display: flex; gap: 6px; max-width: 1100px; margin: 0 auto; padding: 0 18px 12px; flex-wrap: wrap; }
.tab {
  background: var(--card); border: 1px solid var(--border); color: var(--text-dim);
  padding: 8px 16px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: .92rem;
}
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---- Controls ---- */
.controls { max-width: 1100px; margin: 0 auto; padding: 4px 18px 0; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.search {
  flex: 1 1 240px; min-width: 180px;
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 10px 14px; font-size: .95rem;
}
.search:focus { outline: 2px solid var(--accent); }
.seg { display: flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { background: var(--card); border: 0; color: var(--text-dim); padding: 9px 13px; cursor: pointer; font-size: .85rem; }
.seg button.active { background: var(--accent-soft); color: var(--text); }
.mini-btn { background: var(--card); border: 1px solid var(--border); color: var(--text-dim); border-radius: 10px; padding: 9px 12px; cursor: pointer; font-size: .85rem; }
.mini-btn:hover { color: var(--text); }

/* ---- Progress ---- */
.progress-wrap { max-width: 1100px; margin: 12px auto 0; padding: 0 18px; }
.progress-bar { height: 8px; background: var(--border); border-radius: 999px; overflow: hidden; }
.progress-bar > span { display: block; height: 100%; width: 0; background: linear-gradient(90deg,var(--good),#2bb6a8); transition: width .35s ease; }
.progress-label { font-size: .8rem; color: var(--text-dim); margin-top: 6px; }

/* ---- Legend ---- */
.legend { max-width: 1100px; margin: 14px auto 0; padding: 0 18px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: .78rem; color: var(--text-dim); }
.legend .lg-title { font-weight: 600; }

/* ---- Chips ---- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  border: 1px solid currentColor; background: transparent; white-space: nowrap;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.prezentace { color: var(--src-prezentace); }
.chip.ucebnice   { color: var(--src-ucebnice); }
.chip.doplnek    { color: var(--src-doplnek); }
.chip.internet   { color: var(--src-internet); }
.chip.interni    { color: var(--src-interni); }
.chip a { color: inherit; text-decoration: none; }
.chip a:hover { text-decoration: underline; }

/* ---- Main / cards ---- */
main { max-width: 1100px; margin: 18px auto 80px; padding: 0 18px; }
.block-head { margin: 26px 0 10px; font-size: 1.02rem; color: var(--accent); font-weight: 700; letter-spacing: .2px; }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  margin-bottom: 12px; box-shadow: var(--shadow); overflow: hidden; scroll-margin-top: 130px;
}
.card.done { border-color: var(--good); }
.card-head {
  display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; cursor: pointer; user-select: none;
}
.card-head:hover { background: var(--card-hover); }
.card-check { flex: 0 0 auto; margin-top: 2px; }
.card-check input { width: 20px; height: 20px; cursor: pointer; accent-color: var(--good); }
.card-id { flex: 0 0 auto; font-size: .72rem; font-weight: 700; color: var(--text-dim); background: var(--bg-soft); border: 1px solid var(--border); padding: 2px 8px; border-radius: 7px; margin-top: 1px; }
.card-title { flex: 1 1 auto; font-weight: 650; }
.card.done .card-title { color: var(--text-dim); }
.card-arrow { flex: 0 0 auto; color: var(--text-dim); transition: transform .2s; margin-top: 2px; }
.card.open .card-arrow { transform: rotate(90deg); }

.card-body { display: none; padding: 0 16px 16px; border-top: 1px solid var(--border); }
.card.open .card-body { display: block; }

.tldr { background: var(--accent-soft); border-left: 4px solid var(--accent); border-radius: 8px; padding: 11px 14px; margin: 14px 0 6px; }
.tldr .tldr-lab { font-size: .72rem; text-transform: uppercase; letter-spacing: .6px; color: var(--accent); font-weight: 700; }

.sekce { margin-top: 16px; }
.sekce > h4 { margin: 0 0 6px; font-size: .95rem; color: var(--text); border-bottom: 1px dashed var(--border); padding-bottom: 4px; }
.point { margin: 10px 0; }
.point .src-row { margin-top: 5px; display: flex; flex-wrap: wrap; gap: 6px; }
.point p { margin: 0 0 6px; }
.point ul, .point ol { margin: 6px 0; padding-left: 22px; }
.point li { margin: 3px 0; }
.point code { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; font-size: .88em; }
.point table { border-collapse: collapse; margin: 8px 0; width: 100%; font-size: .9rem; }
.point th, .point td { border: 1px solid var(--border); padding: 6px 9px; text-align: left; }
.point th { background: var(--bg-soft); }

.empty { text-align: center; color: var(--text-dim); padding: 60px 20px; }

footer { max-width: 1100px; margin: 0 auto 40px; padding: 0 18px; color: var(--text-dim); font-size: .8rem; text-align: center; }

/* ====== AI konverzace – sekce pod kartou ====== */
.ai-zone { margin-top: 20px; border-top: 1px dashed var(--border); padding-top: 12px; }
.ai-zone-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ai-zone-title { font-weight: 700; font-size: .9rem; color: var(--accent); }
.ai-new-btn {
  background: var(--accent); color: #fff; border: 0; border-radius: 8px;
  padding: 6px 12px; cursor: pointer; font-weight: 600; font-size: .82rem; margin-left: auto;
}
.ai-new-btn:hover { filter: brightness(1.08); }
.conv-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.conv-hint { color: var(--text-dim); font-size: .82rem; padding: 4px 2px; }
.conv-hint.conv-err { color: var(--src-internet); }
.conv-item {
  display: flex; align-items: center; gap: 9px; cursor: pointer;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 9px; padding: 8px 11px;
}
.conv-item:hover { background: var(--card-hover); border-color: var(--accent); }
.conv-ic { flex: 0 0 auto; }
.conv-name { flex: 1 1 auto; font-size: .88rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-date { flex: 0 0 auto; font-size: .72rem; color: var(--text-dim); white-space: nowrap; }
@media (max-width: 480px) {
  .conv-item { flex-wrap: wrap; }
  .conv-name { flex: 1 1 100%; }
}

/* ====== Chat panel ====== */
.ai-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 90;
  opacity: 0; transition: opacity .25s; backdrop-filter: blur(2px);
}
.ai-overlay.open { opacity: 1; }
.ai-panel {
  position: fixed; top: 0; right: 0; height: 100dvh; width: min(460px, 94vw);
  background: var(--bg-soft); border-left: 1px solid var(--border);
  box-shadow: -8px 0 30px rgba(0,0,0,.4); z-index: 100;
  display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .25s ease;
}
.ai-panel.open { transform: translateX(0); }

.ai-head { padding: 12px 14px; border-bottom: 1px solid var(--border); background: var(--card); }
.ai-head-top { display: flex; align-items: flex-start; gap: 10px; }
.ai-title { flex: 1 1 auto; font-weight: 700; font-size: .98rem; line-height: 1.3; }
.ai-x { flex: 0 0 auto; background: transparent; border: 0; color: var(--text-dim); font-size: 1.15rem; cursor: pointer; }
.ai-x:hover { color: var(--text); }
.ai-head-row { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.ai-model { flex: 1 1 auto; background: var(--bg-soft); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; font-size: .8rem; }
.ai-mini { background: var(--card); color: var(--text-dim); border: 1px solid var(--border); border-radius: 8px; padding: 6px 9px; cursor: pointer; font-size: .76rem; }
.ai-mini:hover { color: var(--text); }
.ai-mini.ai-danger:hover { color: #fff; background: #c0392b; border-color: #c0392b; }

.ai-msgs { flex: 1 1 auto; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.ai-empty { color: var(--text-dim); font-size: .85rem; text-align: center; margin: auto; max-width: 320px; line-height: 1.5; }

.ai-msg { max-width: 92%; }
.ai-msg.user { align-self: flex-end; }
.ai-msg.assistant { align-self: flex-start; }
.ai-msg-who { font-size: .68rem; text-transform: uppercase; letter-spacing: .5px; color: var(--text-dim); margin-bottom: 3px; display: flex; align-items: center; gap: 6px; }
.ai-msg.user .ai-msg-who { justify-content: flex-end; }
.ai-msg-tools { display: inline-flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.ai-msg:hover .ai-msg-tools { opacity: 1; }
.ai-tool { background: transparent; border: 0; cursor: pointer; font-size: .72rem; padding: 0 2px; opacity: .8; }
.ai-tool:hover { opacity: 1; }
.ai-msg-body { padding: 9px 12px; border-radius: 12px; font-size: .9rem; }
.ai-msg.user .ai-msg-body { background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.ai-msg.assistant .ai-msg-body { background: var(--card); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.ai-msg-body p { margin: 0 0 8px; } .ai-msg-body p:last-child { margin-bottom: 0; }
.ai-msg-body ul { margin: 6px 0; padding-left: 20px; }
.ai-msg-body code { background: rgba(127,127,127,.18); padding: 1px 5px; border-radius: 4px; font-size: .86em; }
.ai-msg-body pre { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px; overflow-x: auto; }
.ai-msg-body pre code { background: none; padding: 0; }

.ai-edit { width: 100%; min-height: 90px; background: var(--bg); color: var(--text); border: 1px solid var(--accent); border-radius: 8px; padding: 8px; font: inherit; font-size: .88rem; }
.ai-edit-bar { display: flex; gap: 6px; margin: 6px 0; }
.ai-save { background: var(--good); color: #fff; border-color: var(--good); }

.ai-typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.ai-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-dim); animation: aiblink 1.2s infinite both; }
.ai-typing i:nth-child(2) { animation-delay: .2s; } .ai-typing i:nth-child(3) { animation-delay: .4s; }
@keyframes aiblink { 0%,80%,100% { opacity: .2; } 40% { opacity: 1; } }

.ai-compose { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); background: var(--card); align-items: flex-end; }
.ai-compose textarea { flex: 1 1 auto; resize: none; background: var(--bg-soft); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font: inherit; font-size: .9rem; max-height: 160px; }
.ai-compose textarea:focus { outline: 2px solid var(--accent); }
.ai-send { flex: 0 0 auto; width: 42px; height: 42px; border-radius: 10px; background: var(--accent); color: #fff; border: 0; font-size: 1.1rem; cursor: pointer; }
.ai-send:disabled { opacity: .5; cursor: default; }

@media (max-width: 600px) {
  .head-inner h1 { font-size: 1rem; }
  .card-head { padding: 12px 12px; }
  .point table { font-size: .82rem; }
  .ai-new-btn { margin-left: 0; }
  .ai-panel { width: 100vw; }
}
