/* ===== AI Chat Widget — Shopee Accounting Tools ===== */
#cw-toggle {
  position: fixed;
  bottom: 22px;
  right: 22px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue, #1565c0) 0%, var(--blue-dark, #0d47a1) 100%);
  color: #fff;
  border: none;
  box-shadow: 0 4px 16px rgba(13, 71, 161, .35);
  font-size: 24px;
  cursor: pointer;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .15s ease;
}
#cw-toggle:hover { transform: scale(1.06); }

#cw-panel {
  position: fixed;
  bottom: 90px;
  right: 22px;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 480px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(20, 40, 80, .22);
  border: 1px solid var(--gray-border, #dde3ea);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  font-family: 'Sarabun', 'Segoe UI', sans-serif;
}
#cw-panel.open { display: flex; }

#cw-header {
  background: linear-gradient(135deg, var(--blue, #1565c0) 0%, var(--blue-dark, #0d47a1) 100%);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
#cw-header .cw-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
#cw-header .cw-sub { font-size: 11px; opacity: .85; font-weight: 400; margin-top: 2px; }
#cw-close {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}

#cw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: var(--gray-bg, #f4f6f9);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cw-bubble {
  max-width: 85%;
  padding: 9px 13px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.cw-bubble.assistant {
  background: #fff;
  border: 1px solid var(--gray-border, #dde3ea);
  align-self: flex-start;
  color: var(--text-main, #1a1a2e);
}
.cw-bubble.user {
  background: var(--blue, #1565c0);
  color: #fff;
  align-self: flex-end;
}
.cw-bubble.loading { color: var(--text-sub, #5c6b7a); font-style: italic; }
.cw-bubble.notice {
  align-self: center;
  background: #fff7e0;
  border: 1px solid #f0d896;
  color: #6b5410;
  font-size: 12px;
  text-align: center;
}

#cw-inputbar {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--gray-border, #dde3ea);
  background: #fff;
}
#cw-input {
  flex: 1;
  border: 1px solid var(--gray-border, #dde3ea);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13.5px;
  font-family: inherit;
  resize: none;
  max-height: 80px;
}
#cw-input:focus { outline: 2px solid var(--blue-light, #e3f2fd); border-color: var(--blue, #1565c0); }
#cw-send {
  background: var(--amber, #f9a825);
  color: #4a3500;
  border: none;
  border-radius: 10px;
  padding: 0 16px;
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
}
#cw-send:disabled { opacity: .5; cursor: not-allowed; }

@media (max-width: 480px) {
  #cw-panel { width: calc(100vw - 24px); right: 12px; bottom: 82px; }
  #cw-toggle { right: 14px; bottom: 14px; }
}
