.chat-panel {
  position: fixed;
  bottom: 100px;
  right: 30px;
  width: 370px;
  max-height: 520px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

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

.chat-panel-header {
  background: #0B2341;
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.chat-panel-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-panel-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.chat-panel-avatar svg {
  stroke: #fff;
}

.chat-panel-avatar img {
  width: 30px;
  height: 30px;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

.chat-panel-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.chat-panel-status {
  font-size: 12px;
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.chat-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #bbb;
  display: inline-block;
}

.chat-panel-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-panel-close:hover {
  background: rgba(255,255,255,0.15);
}

.chat-panel-close svg {
  stroke: #fff;
}

.chat-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  min-height: 260px;
  max-height: 320px;
  background: #f7f8fa;
}

.chat-welcome-msg {
  background: #e8f0fe;
  border-radius: 12px;
  padding: 16px;
  font-size: 14px;
  color: #333;
  line-height: 1.5;
  text-align: center;
  margin-top: 30px;
}

.chat-welcome-msg p {
  margin: 0;
}

.chat-msg {
  margin-bottom: 12px;
  max-width: 82%;
  animation: chatMsgIn 0.2s ease;
}

@keyframes chatMsgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-msg-visitor {
  margin-left: auto;
}

.chat-msg-agent {
  margin-right: auto;
}

.chat-msg-text {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
}

.chat-msg-visitor .chat-msg-text {
  background: #0B2341;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-msg-agent .chat-msg-text {
  background: #fff;
  color: #333;
  border: 1px solid #e5e7eb;
  border-bottom-left-radius: 4px;
}

.chat-msg-meta {
  font-size: 11px;
  color: #999;
  margin-top: 4px;
  padding: 0 4px;
}

.chat-msg-visitor .chat-msg-meta {
  text-align: right;
}

.chat-typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 20px;
  background: #f7f8fa;
}

.chat-typing-indicator span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #bbb;
  animation: chatTyping 1.2s infinite;
}

.chat-typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatTyping {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
  30% { opacity: 1; transform: scale(1); }
}

.chat-panel-start {
  padding: 16px;
  border-top: 1px solid #eee;
  display: flex;
  gap: 8px;
  background: #fff;
}

.chat-panel-start input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

.chat-panel-start input:focus {
  border-color: #0B2341;
}

.chat-panel-start button {
  padding: 10px 18px;
  background: #0B2341;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
  font-family: inherit;
}

.chat-panel-start button:hover {
  background: #163a5e;
}

.chat-panel-input {
  padding: 12px 16px;
  border-top: 1px solid #eee;
  display: flex;
  gap: 8px;
  align-items: center;
  background: #fff;
}

.chat-panel-input input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

.chat-panel-input input:focus {
  border-color: #0B2341;
}

.chat-panel-input button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #0B2341;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}

.chat-panel-input button:hover {
  background: #163a5e;
}

.chat-panel-input button svg {
  stroke: #fff;
}

.chat-btn-logo {
  width: 28px;
  height: 28px;
}

.chat-button-active {
  background: #163a5e !important;
}

@media (max-width: 480px) {
  .chat-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-height: 100vh;
    border-radius: 16px 16px 0 0;
  }

  .chat-panel-body {
    max-height: calc(100vh - 200px);
  }
}
