/* Collapsed button */
#chat-widget.collapsed {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: auto;
  height: 44px;
  background: var(--hero-gradient);
  color: #fff;
  border-radius: 24px;
  padding: 0 18px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  z-index: 9999;
}
#chat-widget.collapsed::after {
  content: "💬 Chat with us";
}

/* Hide internals when collapsed */
#chat-widget.collapsed .chat-header,
#chat-widget.collapsed .chat-box,
#chat-widget.collapsed .chat-input-area {
  display: none;
}

/* Expanded chat box */
#chat-widget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 360px;
  max-height: 540px;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  background: #fff;
  z-index: 9999;
}

/* Header */
.chat-header {
  background: var(--hero-gradient);
  color: #fff;
  padding: 12px 16px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
}
.chat-header::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
}
.chat-header button {
  background: none;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}

/* Message area */
.chat-box {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  background: var(--secondary-bg);
}

/* Input area */
.chat-input-area {
  display: flex;
  border-top: 1px solid #eee;
  background: #fff;
}
#chat-input {
  flex: 1;
  border: none;
  padding: 12px;
  font-size: 14px;
  outline: none;
}
#chat-send {
  background: var(--accent-digital);
  color: white;
  border: none;
  padding: 0 18px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}
#chat-send:hover {
  background: #1ea557;
}

/* Message cards */
.msg {
  margin: 6px 0;
  padding: 10px 12px;
  border-radius: 10px;
  max-width: 80%;
  line-height: 1.4;
  word-wrap: break-word;
  box-shadow: var(--shadow-sm);
}
.msg.visitor {
  background: var(--gradient-1);
  color: #fff;
  margin-left: auto;
}
.msg.telegram {
  background: #fff;
  color: var(--text-primary);
  margin-right: auto;
  border: 1px solid #eee;
}
.msg.welcome {
  background: #e6f8f2;
  color: #0c5460;
  border: 1px solid #ccefe0;
  margin: 8px auto;
  border-radius: 8px;
  text-align: center;
  font-size: 13px;
  padding: 10px;
  width: 90%;
}
