/* Reality18 Helpdesk — chat UI
   Barvy lze upravit v :root pod brand
*/
:root {
  --brand-primary: #173366;
  --brand-accent: #c41e3a;
  --bg: #f7f8fb;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #1a1f36;
  --text-soft: #6b7280;
  --bot-bg: #eef2f7;
  --user-bg: #173366;
  --user-text: #ffffff;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 40px;
  height: 40px;
  background: var(--brand-primary);
  color: white;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 14px;
  letter-spacing: -0.5px;
}

.brand-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 12px;
  color: var(--text-soft);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-soft);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-ghost:hover {
  background: var(--bot-bg);
  color: var(--text);
}

/* ---------- chat area ---------- */
.chat {
  flex: 1;
  overflow-y: auto;
  padding: 24px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
}

.welcome {
  text-align: center;
  padding: 30px 12px;
  margin: auto 0;
}

.welcome h1 {
  font-size: 24px;
  margin-bottom: 8px;
  color: var(--brand-primary);
}

.welcome p {
  color: var(--text-soft);
  margin-bottom: 28px;
}

.examples {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 460px;
  margin: 0 auto;
}

.example-title {
  font-size: 13px;
  color: var(--text-soft);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.example {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  text-align: left;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
}

.example:hover {
  border-color: var(--brand-primary);
  background: #f0f4fb;
}

/* ---------- messages ---------- */
.msg {
  display: flex;
  flex-direction: column;
  max-width: 92%;
}

.msg.user {
  align-self: flex-end;
  align-items: flex-end;
}

.msg.bot {
  align-self: flex-start;
  align-items: flex-start;
}

.bubble {
  padding: 12px 16px;
  border-radius: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.msg.user .bubble {
  background: var(--user-bg);
  color: var(--user-text);
  border-bottom-right-radius: 4px;
}

.msg.bot .bubble {
  background: var(--bot-bg);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.msg .bubble strong { font-weight: 700; }
.msg .bubble em { font-style: italic; }
.msg .bubble code {
  background: rgba(0,0,0,0.06);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: "SF Mono", Monaco, monospace;
  font-size: 0.9em;
}
.msg.bot .bubble ul, .msg.bot .bubble ol { margin: 8px 0 8px 22px; }
.msg.bot .bubble li { margin: 2px 0; }
.msg.bot .bubble p + p { margin-top: 10px; }
.msg.bot .bubble a { color: var(--brand-primary); text-decoration: underline; }

.sources {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.source {
  font-size: 12px;
  color: var(--text-soft);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  text-decoration: none;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.source-icon {
  display: inline-block;
  margin-right: 6px;
}

/* loading dots */
.thinking {
  display: flex;
  gap: 4px;
  padding: 14px 16px;
}
.thinking span {
  width: 8px;
  height: 8px;
  background: var(--text-soft);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}
.thinking span:nth-child(2) { animation-delay: 0.15s; }
.thinking span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* error */
.msg.error .bubble {
  background: #fff1f1;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

/* ---------- composer ---------- */
.composer {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 12px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
}

#q {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  outline: none;
  max-height: 200px;
  transition: border-color 0.15s;
}

#q:focus {
  border-color: var(--brand-primary);
  background: var(--surface);
}

.btn-send {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: none;
  background: var(--brand-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}

.btn-send:hover:not(:disabled) {
  background: #0f244a;
}

.btn-send:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

/* ---------- footer ---------- */
.foot {
  text-align: center;
  padding: 8px;
  font-size: 11px;
  color: var(--text-soft);
  background: var(--surface);
  border-top: 1px solid var(--border);
}

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  .topbar { padding: 10px 14px; }
  .brand-title { font-size: 14px; }
  .brand-subtitle { font-size: 11px; }
  .welcome h1 { font-size: 20px; }
  .chat { padding: 16px 12px; }
  .composer { padding: 10px 12px; }
}
