:root {
  --farmwise-font-family: Helvetica;
  --farmwise-bg: #f6fbfd;
  --farmwise-surface: #ffffff;
  --farmwise-surface-soft: #edf5f8;
  --farmwise-panel: #ffffff;
  --farmwise-border: #c7dce8;
  --farmwise-border-strong: #80b0d8;
  --farmwise-text: #10213a;
  --farmwise-muted: #516a85;
  --farmwise-primary: #184f88;
  --farmwise-primary-hover: #2c6aa0;
  --farmwise-secondary: #21a596;
  --farmwise-green: #3fba86;
  --farmwise-green-strong: #21a596;
  --farmwise-green-soft: #eef8f3;
  --farmwise-harvest: #f59e0b;
  --farmwise-danger: #b0123f;
  --farmwise-shadow: 0 12px 30px rgba(16, 33, 58, 0.09);
  --greenchat-spinner-surface: #ffffff;
  --greenchat-spinner-green: #29da4f;
  --greenchat-spinner-blue: steelblue;
  color-scheme: light;
}

html[data-theme="dark"] {
  --farmwise-bg: #0d1724;
  --farmwise-surface: #142235;
  --farmwise-surface-soft: #1b2c42;
  --farmwise-panel: #111f30;
  --farmwise-border: #31465e;
  --farmwise-border-strong: #5f86aa;
  --farmwise-text: #ecf4fb;
  --farmwise-muted: #a9bbca;
  --farmwise-primary: #74b7f0;
  --farmwise-primary-hover: #5f9fd6;
  --farmwise-secondary: #54d7c6;
  --farmwise-green: #67d7a0;
  --farmwise-green-strong: #54d7c6;
  --farmwise-green-soft: #17392f;
  --farmwise-harvest: #f7ba4f;
  --farmwise-danger: #ff7d9e;
  --farmwise-shadow: 0 16px 34px rgba(0, 0, 0, 0.36);
  --greenchat-spinner-surface: #18222c;
  --greenchat-spinner-green: #31d66a;
  --greenchat-spinner-blue: #6ca6d9;
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  font-family: var(--farmwise-font-family);
}

html {
  width: 100%;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--farmwise-font-family);
  font-stretch: normal;
  background: var(--farmwise-bg);
  color: var(--farmwise-text);
  width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

/* Full-width container with padding */
.container {
  position: relative;
  width: min(calc(100vw - 24px), calc(100% - 24px));
  height: calc(100dvh - 10px);
  max-height: calc(100dvh - 10px);
  margin: 5px auto;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--farmwise-border);
  border-radius: 8px;
  box-shadow: var(--farmwise-shadow);
  padding: 18px 22px 20px 22px;
  overflow: hidden;
}

html[data-theme="dark"] .container {
  background: rgba(17, 31, 48, 0.97);
}

h1 {
  color: var(--farmwise-primary);
  font-family: var(--farmwise-font-family);
  font-weight: 700;
}

h2,
h3,
h4,
h5,
h6,
strong,
b {
  font-family: var(--farmwise-font-family);
  font-weight: 700;
}

button,
input,
select,
textarea,
option {
  font-family: var(--farmwise-font-family);
}

svg,
svg text,
svg tspan,
.message,
.chart-source-list,
.osm-location-label,
.osm-map-badge {
  font-family: var(--farmwise-font-family);
}

.chat-box {
    max-height: 390px;
    overflow-y: auto;
    border-radius: 8px;
    padding: .5rem;
    background: var(--farmwise-surface);
	border: 1px solid var(--farmwise-border);
}

html[data-theme="dark"] .chat-box {
  background: #0f1a29;
}

.message {
  margin-bottom: 12px;
  padding: 15px 14px;
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(49, 72, 45, 0.07);
  transition: 0.3s;
  line-height: 1.5;
}

.message.user {
  background: #edf5f8;
  color: var(--farmwise-text);
  align-self: flex-end;
  text-align: left;
  margin-left: auto;
  max-width: 60%;
  border-width: 0.5px;
  border-style: solid;
  border-color: rgba(24, 79, 136, 0.34);
  transition: 0.3s;
}

.message.bot {
  background: var(--farmwise-surface);
  color: var(--farmwise-text);
  align-self: flex-start;
  text-align: left;
  max-width: 70%;
  border-width: 0.5px;
  border-style: solid;
  border-color: rgba(33, 165, 150, 0.40);
  transition: 0.3s;
  animation: message-fade-in 0.2s ease-out;
}

.message.bot.bot-pending {
  display: inline-flex;
  align-items: center;
  width: max-content;
  min-width: 0;
  max-width: min(70%, 260px);
  padding: 11px 14px;
  border-radius: 14px 14px 14px 6px;
  background: linear-gradient(180deg, var(--farmwise-surface), var(--farmwise-surface-soft));
  color: var(--farmwise-muted);
}

.bot-typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 24px;
}

.bot-typing-label {
  color: var(--farmwise-muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.bot-typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.bot-typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--farmwise-primary);
  opacity: 0.35;
  animation: bot-typing-bounce 1.15s ease-in-out infinite;
}

.bot-typing-dots span:nth-child(2) {
  animation-delay: 0.16s;
}

.bot-typing-dots span:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes bot-typing-bounce {
  0%, 70%, 100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  35% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

html[data-theme="dark"] .message.user {
  background: #1b334d;
  border-color: rgba(116, 183, 240, 0.42);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.24);
}

html[data-theme="dark"] .message.bot {
  background: #142235;
  border-color: rgba(84, 215, 198, 0.38);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.24);
}

html[data-theme="dark"] .message.bot.bot-pending {
  background: linear-gradient(180deg, #142235, #1a2d46);
}

.chart-source-list {
  margin-top: 4px;
  font-size: 11px;
  line-height: 1.35;
  color: var(--farmwise-muted);
}

.chart-source-list a {
  color: var(--farmwise-primary);
  text-decoration: none;
  font-weight: 600;
}

.chart-source-list a:hover {
  text-decoration: underline;
}

@keyframes message-fade-in {
  from {
    opacity: 0;
    transform: translateY(3px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.input-area {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  background: var(--farmwise-surface);
  color: var(--farmwise-text);
}

#loader{
  padding: 0;
  color: var(--farmwise-primary);
}

.loader {
  --loader-color: #ffffff;
  --loader-ring-width: 1rem;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 6rem;
  margin-top: 3rem;
  margin-bottom: 3rem;
}

.loader:before,
.loader:after {
  content: '';
  position: absolute;
  border-radius: 50%;
  animation: pulsOut 1.8s ease-in-out infinite;
  filter: drop-shadow(0 0 1rem rgba(255, 255, 255, 0.75));
}

.loader:before {
  width: 100%;
  padding-bottom: 100%;
  box-shadow: inset 0 0 0 var(--loader-ring-width) var(--loader-color);
  animation-name: pulsIn;
}

.loader:after {
  width: calc(100% - 2rem);
  padding-bottom: calc(100% - 2rem);
  box-shadow: 0 0 0 0 var(--loader-color);
}

@keyframes pulsIn {
  0% {
    box-shadow: inset 0 0 0 var(--loader-ring-width) var(--loader-color);
    opacity: 1;
  }
  50%, 100% {
    box-shadow: inset 0 0 0 0 var(--loader-color);
    opacity: 0;
  }
}

@keyframes pulsOut {
  0%, 50% {
    box-shadow: 0 0 0 0 var(--loader-color);
    opacity: 0;
  }
  100% {
    box-shadow: 0 0 0 var(--loader-ring-width) var(--loader-color);
    opacity: 1;
  }
}

input[type="text"] {
  flex: 1;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--farmwise-border-strong);
  border-radius: 6px;
  font-size: 16px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  background: var(--farmwise-surface);
  color: var(--farmwise-text);
}

html[data-theme="dark"] input[type="text"] {
  background: var(--farmwise-panel);
  color: var(--farmwise-text);
}

input[type="text"]:focus {
  border-color: var(--farmwise-primary);
  box-shadow: 0 0 0 3px rgba(24, 79, 136, 0.14);
  outline: none;
}

input[type="range"] {
  accent-color: var(--farmwise-primary);
  height: 16px;
}

#send-btn{
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  padding: 0;
  background: var(--farmwise-primary);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.86;
  transition: opacity 0.12s ease, background-color 0.12s ease;
}

#send-btn:hover {
  opacity: 1;
  background: var(--farmwise-primary-hover);
}

#send-btn:disabled {
  cursor: wait;
  opacity: 1;
}

#send-btn .send-icon {
  width: 13px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transform: translateX(1px);
}

#send-btn .send-icon svg {
  width: 13px;
  height: 16px;
  fill: currentColor;
  display: block;
}

#send-btn .button-loader {
  --loader-color: #ffffff;
  --loader-ring-width: 0.22rem;
  width: 20px;
  max-width: 20px;
  height: 20px;
  margin: 0;
  flex: 0 0 auto;
}

#send-btn .button-loader:before,
#send-btn .button-loader:after {
  filter: none;
}

#send-btn .button-loader:before {
  box-shadow: inset 0 0 0 var(--loader-ring-width) var(--loader-color);
}

#send-btn .button-loader:after {
  width: calc(100% - 0.5rem);
  padding-bottom: calc(100% - 0.5rem);
}

#send-btn.loading .send-icon {
  display: none;
}

#reset-btn {
  padding: 8px 16px;
  background: #fff4f7;
  border: 1px solid rgba(176, 18, 63, 0.30);
  color: var(--farmwise-danger);
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  opacity: 0.9;
  transition: 0.2s;
}

#reset-btn:hover {
  opacity: 1;
  background: #fde8ee;
  border-color: rgba(176, 18, 63, 0.50);
}

select {
  border: 1px solid var(--farmwise-border);
  border-radius: 6px;
  background: #ffffff;
  color: var(--farmwise-text);
  padding: 5px 8px;
}
