/* ===== NiuNiu2027 Homepage Styles ===== */
/* 护眼暖绿色主题 + 木制边框 */

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

html, body {
  font-family: 'Noto Serif SC', SimSun, '宋体', serif;
}

body {
  background: linear-gradient(135deg, #c8e6c0 0%, #d4edbc 25%, #cce8cf 50%, #d8f0d0 75%, #c5e3bd 100%);
  background-attachment: fixed;
  min-height: 100vh;
  padding: 0;
}

#app {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 20px 20px;
}

/* ===== Header ===== */
#site-header {
  text-align: center;
  margin-bottom: 18px;
  width: 100%;
}

#site-name {
  font-size: 32px;
  font-weight: 700;
  color: #2d5016;
  text-shadow: 1px 1px 3px rgba(255,255,255,0.7);
  letter-spacing: 2px;
  margin-bottom: 6px;
}

#model-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.65);
  border: 1px solid rgba(45,80,22,0.2);
  border-radius: 16px;
  padding: 3px 14px;
  font-size: 13px;
  color: #3a6b1e;
  backdrop-filter: blur(6px);
}

.model-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4caf50;
  display: inline-block;
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

/* ===== Wooden Frame ===== */
/* 木框随内容自动拉长，不限制高度，不内部滚动 */
#wooden-frame {
  width: 100%;
  min-height: 400px;
  background: #ffffff;
  border: 14px solid;
  border-image: linear-gradient(
    145deg,
    #8B6914 0%,
    #C4993B 8%,
    #A67C2E 15%,
    #D4A843 22%,
    #B8893A 30%,
    #C9963C 38%,
    #A07228 45%,
    #D4A843 52%,
    #B38535 60%,
    #C4993B 68%,
    #9A6C24 75%,
    #D4A843 82%,
    #B8893A 90%,
    #8B6914 100%
  ) 14;
  border-radius: 4px;
  box-shadow:
    0 0 0 2px #6B4F10,
    0 0 0 4px #8B6914,
    inset 0 0 20px rgba(139,105,20,0.08),
    0 8px 32px rgba(0,0,0,0.15),
    0 2px 8px rgba(0,0,0,0.1);
  position: relative;
  display: flex;
  flex-direction: column;
}

/* Wood grain texture overlay */
#wooden-frame::before {
  content: '';
  position: absolute;
  top: -14px; left: -14px; right: -14px; bottom: -14px;
  pointer-events: none;
  z-index: 0;
}

/* ===== Chat Container ===== */
/* 不内部滚动，内容自然展开撑高木框 */
#chat-container {
  padding: 28px 36px;
  position: relative;
  z-index: 1;
}

/* ===== Welcome Message ===== */
#welcome-message {
  text-align: center;
  padding: 60px 20px;
  color: #666;
}

.welcome-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

#welcome-message p {
  font-size: 16px;
  line-height: 1.8;
  margin-bottom: 4px;
  color: #888;
}

/* ===== Messages ===== */
.message-wrapper {
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
}

/* User message - right aligned, blue, smaller */
.message-wrapper.user {
  align-items: flex-end;
}

.message-wrapper.user .message-content {
  background: #e8f0fe;
  color: #1a5bb5;
  font-size: 14px;
  padding: 10px 16px;
  border-radius: 14px 14px 4px 14px;
  max-width: 70%;
  line-height: 1.6;
  display: inline-block;
}

/* AI message - left aligned / centered, black, larger */
.message-wrapper.assistant {
  align-items: flex-start;
}

.message-wrapper.assistant .message-content {
  width: 100%;
  padding: 8px 0;
  line-height: 2;
  color: #000000;
  font-size: 18px;
  /* These will be overridden by settings from backend */
}

/* AI answer paragraph styling - article-like */
.message-wrapper.assistant .message-content p,
.message-wrapper.assistant .message-content .paragraph {
  margin-bottom: 18px;
  text-indent: 2em;
  line-height: 2;
}

.message-wrapper.assistant .message-content .paragraph:last-child {
  margin-bottom: 0;
}

/* ===== Loading Area ===== */
#loading-area {
  text-align: center;
  padding: 30px 20px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 4px solid #e0e0e0;
  border-top-color: #4caf50;
  border-radius: 50%;
  margin: 0 auto 14px;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#status-text {
  font-size: 14px;
  color: #666;
  animation: fade-pulse 1.5s ease-in-out infinite;
}

@keyframes fade-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ===== Source Status ===== */
#source-status {
  padding: 12px 0;
  margin-top: 12px;
  border-top: 1px solid #eee;
}

.source-status-item {
  font-size: 12px;
  padding: 3px 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.source-status-item.success {
  color: #2e7d32;
}

.source-status-item.failed {
  color: #c62828;
}

.source-status-item .status-icon {
  font-size: 14px;
}

/* ===== Input Section ===== */
#input-section {
  width: 100%;
  margin-top: 14px;
}

#keywords-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

#keywords-row label {
  font-size: 13px;
  color: #5a7a3a;
  white-space: nowrap;
  font-weight: 600;
}

#keywords-input {
  flex: 1;
  padding: 8px 14px;
  border: 2px solid #b8d4a0;
  border-radius: 8px;
  font-size: 13px;
  background: rgba(255,255,255,0.85);
  outline: none;
  transition: border-color 0.2s;
  font-family: 'Noto Serif SC', SimSun, '宋体', serif;
}

#keywords-input:focus {
  border-color: #6aad3a;
  background: #fff;
}

#question-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

#question-input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid #b8d4a0;
  border-radius: 12px;
  font-size: 16px;
  resize: none;
  background: rgba(255,255,255,0.9);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  line-height: 1.5;
  font-family: 'Noto Serif SC', SimSun, '宋体', serif;
  min-height: 52px;
}

#question-input:focus {
  border-color: #6aad3a;
  box-shadow: 0 0 0 3px rgba(106,173,58,0.15);
  background: #fff;
}

#send-btn {
  width: 52px;
  height: 52px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #4caf50, #388e3c);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, box-shadow 0.15s, background 0.2s;
  box-shadow: 0 2px 8px rgba(76,175,80,0.3);
  flex-shrink: 0;
}

#send-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(76,175,80,0.4);
  background: linear-gradient(135deg, #56c05a, #43a047);
}

#send-btn:active {
  transform: translateY(0);
}

#send-btn:disabled {
  background: #a5d6a7;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ===== Admin Link ===== */
#admin-link-row {
  text-align: center;
  margin-top: 12px;
  padding-bottom: 12px;
}

#admin-link {
  color: #7a9a5a;
  font-size: 13px;
  text-decoration: none;
  opacity: 0.7;
  transition: opacity 0.2s;
}

#admin-link:hover {
  opacity: 1;
  text-decoration: underline;
}

/* ===== 27" Monitor Optimization ===== */
@media (min-width: 1800px) {
  #app {
    max-width: 1400px;
    padding: 32px 30px 24px;
  }

  #wooden-frame {
    border-width: 18px;
  }

  #site-name {
    font-size: 38px;
  }

  #chat-container {
    padding: 36px 48px;
  }

  #question-input {
    font-size: 17px;
    padding: 14px 18px;
    min-height: 58px;
  }

  #send-btn {
    width: 58px;
    height: 58px;
  }

  .message-wrapper.assistant .message-content {
    font-size: 18px;
  }
}

/* ===== Large Desktop (2K+) ===== */
@media (min-width: 2400px) {
  #app {
    max-width: 1600px;
  }

  #wooden-frame {
    border-width: 20px;
  }

  #site-name {
    font-size: 42px;
  }
}

/* ===== Regular Desktop ===== */
@media (max-width: 1200px) {
  #app {
    max-width: 960px;
  }
}

/* ===== Tablet ===== */
@media (max-width: 768px) {
  #app {
    padding: 16px 12px 12px;
  }

  #site-name {
    font-size: 24px;
  }

  #wooden-frame {
    border-width: 10px;
  }

  #chat-container {
    padding: 18px 16px;
  }

  .message-wrapper.assistant .message-content {
    font-size: 16px;
  }

  .message-wrapper.user .message-content {
    font-size: 13px;
    max-width: 85%;
  }

  #question-input {
    font-size: 15px;
  }

  #keywords-row {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
  }
}

/* ===== Mobile ===== */
@media (max-width: 480px) {
  #app {
    padding: 10px 8px 8px;
  }

  #site-name {
    font-size: 20px;
  }

  #wooden-frame {
    border-width: 8px;
  }

  #chat-container {
    padding: 14px 12px;
  }

  .message-wrapper.assistant .message-content {
    font-size: 15px;
    line-height: 1.8;
  }

  .message-wrapper.assistant .message-content p,
  .message-wrapper.assistant .message-content .paragraph {
    text-indent: 0;
  }

  .message-wrapper.user .message-content {
    font-size: 13px;
    max-width: 90%;
  }

  #send-btn {
    width: 46px;
    height: 46px;
  }

  #question-input {
    font-size: 14px;
    padding: 10px 12px;
  }
}
