* {
  box-sizing: border-box;
}

:root {
  --chat-panel-width: 380px;
  --chat-panel-wide-width: 520px;
}

/* Pushes the app content over when the chat panel is docked open, like a
   split-view side panel rather than an overlay. */
.app-body-content {
  min-width: 0;
  margin-right: 0;
  overflow-x: clip;
  transition: margin-right 0.25s ease-out;
}
.app-body-content.panel-open {
  margin-right: var(--chat-panel-width, 380px);
}
.app-body-content.panel-open.panel-wide {
  margin-right: var(--chat-panel-wide-width, 520px);
}
/* Below lg the chat overlays instead of docking so account pages, maps,
   and the v2 shell keep a usable content width. */
.app-body-content.panel-open .chat-dock-fixed {
  right: var(--chat-panel-width, 380px);
}
.app-body-content.panel-open.panel-wide .chat-dock-fixed {
  right: var(--chat-panel-wide-width, 520px);
}
@media (max-width: 1023px) {
  .app-body-content.panel-open,
  .app-body-content.panel-open.panel-wide {
    margin-right: 0;
  }
  .app-body-content.panel-open .chat-dock-fixed,
  .app-body-content.panel-open.panel-wide .chat-dock-fixed {
    right: 0;
  }
}

/* Only widget-specific overrides; do NOT change page body here */
.chat-widget {
  position: fixed;
  inset: 0 0 0 auto;
  height: 100vh;
  width: 0;
  z-index: 9999 !important;
  pointer-events: none;
}
.chat-widget > * {
  pointer-events: auto;
}
.chat-button {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0eab56 0%, #0eab56 100%);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 255, 136, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 24px;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  position: fixed;
  bottom: 20px;
  right: 20px;
}
.chat-button svg {
  width: 26px;
  height: 26px;
  display: block;
}
.chat-button:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 25px rgba(25, 135, 84, 0.4);
}
.chat-button.has-notification::after {
  content: "";
  position: absolute;
  top: -2px;
  right: -2px;
  width: 16px;
  height: 16px;
  background: #ff4757;
  border-radius: 50%;
  border: 2px solid white;
}
.chat-window {
  width: var(--chat-panel-width, 380px);
  max-width: 100vw;
  height: 100vh;
  background: white;
  border-radius: 0;
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.15);
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: slideInRight 0.25s ease-out;
  transition: width 0.25s ease;
  position: fixed;
  top: 0;
  bottom: 0;
  right: 0;
  z-index: 100000 !important;
}
.chat-window.wide {
  width: min(var(--chat-panel-wide-width, 520px), 100vw);
}
.chat-window.open {
  display: flex;
}
@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(24px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.chat-header {
  background: linear-gradient(135deg, #198754 0%, #0eab56 100%);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chat-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 10px;
}
.logo-placeholder {
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: white;
}
.logo-placeholder img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: 4px;
}
.header-buttons {
  display: flex;
  gap: 8px;
}
.header-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: background-color 0.2s;
}
.header-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}
.config-panel {
  background: #f8f9fa;
  padding: 15px;
  border-bottom: 1px solid #e9ecef;
  display: none;
}
.config-panel.open {
  display: block;
}
.config-item {
  margin-bottom: 10px;
}
.config-item:last-child {
  margin-bottom: 0;
}
.config-item label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #000;
  margin-bottom: 4px;
}
.config-item input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 12px;
}
.config-item input:focus {
  outline: none;
  border-color: #667eea;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
  background: #fafafa;
}
.message {
  margin-bottom: 12px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.message.user {
  flex-direction: row-reverse;
}
.message-content {
  max-width: 75%;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
}
.message.user .message-content {
  background: #0eab56;
  color: white;
  border-bottom-right-radius: 3px;
}
.message.assistant .message-content {
  background: white;
  color: #000;
  border: 1px solid #e9ecef;
  border-bottom-left-radius: 3px;
}
.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
}
.message.user .avatar {
  background: #0eab56;
  color: white;
}
.message.assistant .avatar {
  background: #e9ecef;
  color: #000;
}
.chat-input {
  padding: 15px;
  background: white;
  border-top: 1px solid #e9ecef;
  display: flex;
  gap: 8px;
}
.input-field {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 20px;
  font-size: 14px;
  outline: none;
}
.input-field:focus {
  border-color: #0eab56;
}
.send-btn {
  background: #0eab56;
  color: white;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background-color 0.2s;
}
.send-btn:hover:not(:disabled) {
  background: #0eab56;
}
.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.loading {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #000;
  font-size: 12px;
}
.spinner {
  width: 12px;
  height: 12px;
  border: 2px solid #e9ecef;
  border-left-color: #0eab56;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.error {
  background: #ffe6e6;
  color: #d63384;
  padding: 8px 10px;
  border-radius: 6px;
  margin-bottom: 10px;
  font-size: 12px;
}
@media (max-width: 1023px) {
  .chat-window,
  .chat-window.wide {
    width: 100vw;
    max-width: 100vw;
  }
}
.chat-footer,
.chat-footer strong {
  color: #000;
}
