/* Chat panel — log, input, messages (static site; no Gradio overrides). */

:root {
  --chat-input-height: 44px;
}

#chat.chat-panel {
  position: sticky;
  top: var(--nav-height);
  height: 100%;
  max-height: calc(100vh - var(--nav-height));
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: transparent;
  padding-left: var(--col-pad-x);
  padding-right: var(--col-pad-x);
}

.chat-console {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: 56px;
}

.chat-body {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.chat-log-frame {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-top: 14px;
}

.chat-log-toolbar {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 4;
  transform: translateY(calc(-100% + 1px));
  pointer-events: none;
}

.chat-clear-trigger {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  height: 24px;
  padding: 6px 8px;
  gap: 4px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: #c5d0e3;
  background: transparent;
  border: 1px solid var(--border-bright);
  border-radius: 12px 12px 0 0;
  box-shadow: var(--surface-highlight), var(--surface-glow);
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.chat-clear-trigger:hover {
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
  background: transparent;
  box-shadow: var(--surface-highlight), var(--glow-cyan-soft);
}

.chat-log {
  position: relative;
  flex: 1 1 0;
  min-height: 200px;
  margin: 0;
  padding: 12px 10px 12px;
  border: 1px solid var(--border-panel);
  border-radius: 12px 0 12px 12px;
  background: var(--surface-glass-bg);
  backdrop-filter: var(--surface-glass-blur);
  -webkit-backdrop-filter: var(--surface-glass-blur);
  box-shadow:
    var(--shadow-card),
    var(--surface-highlight),
    inset 0 0 80px rgba(0, 200, 255, 0.025);
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.chat-log::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 1;
  background: var(--surface-gloss);
}

.msg {
  font-size: var(--font-size-chat);
  line-height: var(--line-height-chat);
  max-width: var(--chat-message-max-width);
  padding: 6px 0;
  white-space: pre-line;
}

.msg-user {
  align-self: flex-end;
  text-align: right;
  color: var(--color-chat-user);
  font-weight: 500;
}

.msg-bot {
  align-self: flex-start;
  color: var(--color-chat-assistant);
  font-weight: 400;
}

.msg-bot .reply-body {
  display: block;
  white-space: pre-line;
}

.msg-bot .typing-indicator::after {
  content: "…";
}

.msg-bot.is-loading {
  opacity: 0.65;
}

.chat-input-row {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 12px;
  align-items: stretch;
}

.chat-input-row input {
  width: 100%;
  height: var(--chat-input-height);
  padding: 10px 16px;
  background: linear-gradient(180deg, rgba(10, 20, 40, 0.9) 0%, rgba(6, 14, 30, 0.85) 100%);
  border: 1px solid var(--border-panel);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.25;
  box-shadow: var(--surface-highlight), inset 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.chat-input-row input::placeholder {
  color: var(--color-input-placeholder);
  opacity: 1;
}

.chat-input-row input:focus {
  outline: none;
  border-color: var(--accent-cyan);
  box-shadow:
    var(--surface-highlight),
    0 0 0 2px rgba(46, 231, 247, 0.14),
    0 0 48px rgba(46, 231, 247, 0.1);
}

.chat-input-row input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.chat-input-row button {
  height: var(--chat-input-height);
  min-width: 72px;
  padding: 0 20px;
  background: linear-gradient(135deg, var(--accent-cyan) 0%, var(--accent-blue) 42%, var(--accent-violet) 100%);
  border: none;
  border-radius: 10px;
  font-weight: 600;
  font-size: var(--font-size-card-text);
  color: var(--bg-base);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  box-shadow:
    var(--surface-highlight),
    0 4px 24px rgba(0, 200, 255, 0.28),
    0 0 56px rgba(46, 231, 247, 0.12);
  transition: opacity 0.15s, transform 0.15s, box-shadow 0.15s;
}

.chat-input-row button:hover:not(:disabled) {
  opacity: 0.96;
  transform: translateY(-1px);
  box-shadow:
    var(--surface-highlight),
    0 6px 32px rgba(0, 200, 255, 0.32),
    0 0 72px rgba(46, 231, 247, 0.18);
}

.chat-input-row button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

@media (max-width: 1024px) {
  #chat.chat-panel {
    grid-area: chat;
    position: relative;
    top: 0;
    height: auto;
    max-height: none;
    min-height: min(72vh, 640px);
    border-top: 1px solid var(--border-bright);
    box-shadow: 0 -1px 48px rgba(46, 231, 247, 0.06);
  }

  .chat-console {
    padding-bottom: 28px;
  }
}
