/* ================================================================
   AI Chat Widget — frontend styles
   Design tokens: #00862C, Jost, border-radius 20px, #E7E8E4
   ================================================================ */

#acw-widget {
  --acw-primary:    #00862C;
  --acw-primary-dk: #006622;
  --acw-gray:       #E7E8E4;
  --acw-gray-txt:   #676a68;
  --acw-radius:     20px;
  --acw-shadow:     0 8px 40px rgba(0, 0, 0, 0.18);

  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 99999;
  font-family: 'Jost', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #1a1a1a;
}

/* ── Trigger button ─────────────────────────────────────────────── */
.acw-trigger {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--acw-primary);
  border: none;
  box-shadow: var(--acw-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s;
  outline: none;
}

.acw-trigger:hover {
  background: var(--acw-primary-dk);
  transform: scale(1.07);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.24);
}

.acw-trigger:focus-visible {
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--acw-primary);
}

.acw-trigger__icon--close { display: none; }

.acw-widget--open .acw-trigger__icon--chat  { display: none; }
.acw-widget--open .acw-trigger__icon--close { display: block; }

/* ── Panel ──────────────────────────────────────────────────────── */
.acw-panel {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 370px;
  height: 540px;
  background: #ffffff;
  border-radius: var(--acw-radius);
  box-shadow: var(--acw-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;

  opacity: 0;
  pointer-events: none;
  transform: translateY(12px) scale(0.97);
  transform-origin: bottom right;
  transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.acw-widget--open .acw-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* ── Header ─────────────────────────────────────────────────────── */
.acw-header {
  background: var(--acw-primary);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.acw-header__info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.acw-header__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.acw-header__title {
  display: block;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
}

.acw-header__status {
  display: block;
  color: rgba(255, 255, 255, 0.75);
  font-size: 11px;
  margin-top: 1px;
}

.acw-header__close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.15s;
  outline: none;
}

.acw-header__close:hover     { background: rgba(255, 255, 255, 0.15); }
.acw-header__close:focus-visible { box-shadow: 0 0 0 2px rgba(255,255,255,0.6); }

/* ── Messages ───────────────────────────────────────────────────── */
.acw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.acw-messages::-webkit-scrollbar       { width: 4px; }
.acw-messages::-webkit-scrollbar-thumb { background: var(--acw-gray); border-radius: 2px; }

/* ── Message bubbles ────────────────────────────────────────────── */
.acw-msg {
  max-width: 88%;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
}

.acw-msg p             { margin: 0; }
.acw-msg p + p         { margin-top: 6px; }

.acw-msg--user {
  align-self: flex-end;
  background: var(--acw-primary);
  color: #fff;
  border-radius: 18px 18px 4px 18px;
}

.acw-msg--assistant {
  align-self: flex-start;
  background: var(--acw-gray);
  color: #1a1a1a;
  border-radius: 18px 18px 18px 4px;
}

/* ── Navigation link pills ──────────────────────────────────────── */
.acw-nav-links { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }

.acw-nav-link {
  display: inline-block;
  background: var(--acw-primary);
  color: #fff;
  padding: 7px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: opacity 0.15s, background 0.15s;
  align-self: flex-start;
}

.acw-nav-link:hover { background: var(--acw-primary-dk); }

/* ── Plant mini-cards ───────────────────────────────────────────── */
.acw-plant-cards { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }

.acw-plant-card {
  background: #fff;
  border: 1px solid var(--acw-gray);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.acw-plant-card__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--acw-primary);
  text-decoration: none;
  line-height: 1.3;
}

.acw-plant-card__title:hover { text-decoration: underline; }
.acw-plant-card__price { font-size: 13px; font-weight: 500; color: #1a1a1a; margin: 0; }

/* ── Typing indicator ───────────────────────────────────────────── */
.acw-typing { display: flex; align-items: center; gap: 5px; padding: 8px 16px; flex-shrink: 0; }
.acw-typing--hidden { display: none; }

.acw-typing span {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--acw-primary);
  opacity: 0.4;
  animation: acwBounce 1.3s ease-in-out infinite;
}
.acw-typing span:nth-child(2) { animation-delay: 0.2s; }
.acw-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes acwBounce {
  0%,80%,100% { transform: translateY(0);    opacity: 0.4; }
  40%          { transform: translateY(-7px); opacity: 1;   }
}

/* ── Input area ─────────────────────────────────────────────────── */
.acw-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px 14px;
  border-top: 1px solid var(--acw-gray);
  flex-shrink: 0;
}

.acw-input {
  flex: 1;
  border: 1px solid var(--acw-gray);
  border-radius: var(--acw-radius);
  padding: 9px 14px;
  font-family: inherit;
  font-size: 14px;
  resize: none;
  outline: none;
  max-height: 100px;
  overflow-y: auto;
  line-height: 1.5;
  color: #1a1a1a;
  background: #fff;
  transition: border-color 0.15s;
}

.acw-input:focus    { border-color: var(--acw-primary); }
.acw-input:disabled { background: #f5f5f5; color: #999; }
.acw-input::placeholder { color: #aaa; }

.acw-send {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--acw-primary);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
  outline: none;
}

.acw-send:hover    { background: var(--acw-primary-dk); transform: scale(1.05); }
.acw-send:disabled { opacity: 0.4; cursor: default; transform: none; }
.acw-send:focus-visible { box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--acw-primary); }

/* ── Limit notice ───────────────────────────────────────────────── */
.acw-limit-notice { text-align: center; font-size: 12px; color: var(--acw-gray-txt); padding: 0 12px 10px; display: none; flex-shrink: 0; }
.acw-limit-notice--visible { display: block; }

/* ── Mobile ─────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #acw-widget { bottom: 16px; right: 16px; }

  .acw-panel {
    position: fixed;
    bottom: 0; right: 0; left: 0;
    width: 100%;
    height: 85vh;
    max-height: 85vh;
    border-radius: var(--acw-radius) var(--acw-radius) 0 0;
  }
}
