/* 对话页样式 — zfmf_agent 联调 H5 */
/* 模块：static */
/* 能力：农业助手聊天界面布局与主题 */

:root {
  --bg: #f4f7f2;
  --panel: #ffffff;
  --border: #dce6d8;
  --text: #1f2d1a;
  --muted: #6b7a66;
  --primary: #2d6a4f;
  --primary-dark: #1b4332;
  --accent: #95d5b2;
  --user-bg: #d8f3dc;
  --bot-bg: #ffffff;
  --thinking-bg: #f0f4ef;
  --tool-bg: #eef6ff;
  --danger: #c1121f;
  --shadow: 0 8px 30px rgba(45, 106, 79, 0.08);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at top right, rgba(149, 213, 178, 0.35), transparent 28%),
    linear-gradient(180deg, #edf5ea 0%, var(--bg) 40%);
  color: var(--text);
}

.app {
  max-width: 920px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 16px;
}

.header {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.brand h1 {
  margin: 0;
  font-size: 1.25rem;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

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

.controls select {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  background: #fff;
  color: var(--text);
}

.status-pill {
  font-size: 0.8rem;
  padding: 6px 10px;
  border-radius: 999px;
  background: #e8f5e9;
  color: var(--primary-dark);
}

.status-pill.error {
  background: #fde8e8;
  color: var(--danger);
}

.status-pill.busy {
  background: #fff4d6;
  color: #9a6b00;
}

.chat-panel {
  flex: 1;
  margin-top: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 68vh;
  overflow: hidden;
}

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

.empty {
  margin: auto;
  text-align: center;
  color: var(--muted);
  max-width: 420px;
  line-height: 1.6;
}

.msg {
  max-width: 86%;
  padding: 12px 14px;
  border-radius: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.user {
  align-self: flex-end;
  background: var(--user-bg);
  border: 1px solid #b7e4c7;
}

.msg-images {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.msg-images img {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.msg-text + .msg-images {
  margin-top: 8px;
}

.msg.assistant {
  align-self: flex-start;
  background: var(--bot-bg);
  border: 1px solid var(--border);
}

.msg.thinking {
  align-self: flex-start;
  background: var(--thinking-bg);
  border: 1px dashed #c6d4c0;
  color: var(--muted);
  font-size: 0.92rem;
}

.msg.tool {
  align-self: flex-start;
  background: var(--tool-bg);
  border: 1px solid #c9ddf5;
  font-size: 0.88rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.msg.error {
  align-self: center;
  background: #fde8e8;
  border: 1px solid #f5c2c7;
  color: var(--danger);
}

.composer {
  border-top: 1px solid var(--border);
  padding: 14px;
  background: #fafcf9;
}

.composer-main {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.composer textarea {
  width: 100%;
  resize: none;
  min-height: 52px;
  max-height: 160px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  outline: none;
}

.composer-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  align-items: center;
}

.upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px dashed var(--border);
  background: #fff;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
}

.upload-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.image-preview {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.image-preview.hidden {
  display: none;
}

.image-preview .thumb {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.image-preview .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-preview .thumb button {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.composer button#send {
  border: none;
  border-radius: 12px;
  padding: 0 18px;
  background: var(--primary);
  color: #fff;
  font: inherit;
  cursor: pointer;
  min-width: 88px;
  height: 40px;
}

.composer textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45, 106, 79, 0.12);
}

.composer button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.composer button:not(:disabled):hover {
  background: var(--primary-dark);
}

.footer {
  margin-top: 10px;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
}

@media (max-width: 640px) {
  .app {
    padding: 10px;
  }

  .msg {
    max-width: 100%;
  }
}
