/* ---------- Chat Widget ---------- */
.chat-widget {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 60;
  font-family: 'Inter', system-ui, sans-serif;
}

.chat-toggle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  border: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 20px rgba(37, 99, 235, .4);
  transition: transform .2s, box-shadow .2s;
  position: relative;
}
.chat-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 28px rgba(37, 99, 235, .5);
}
.chat-toggle svg {
  width: 28px;
  height: 28px;
}
.chat-toggle .chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  border: 2px solid #fff;
  display: none;
}
.chat-badge.active {
  display: grid;
}

.chat-window {
  position: absolute;
  bottom: 72px;
  left: 0;
  width: 380px;
  max-height: 520px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid #e2e6ea;
  box-shadow: 0 12px 48px rgba(0, 0, 0, .15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0) translateY(20px);
  transform-origin: bottom left;
  opacity: 0;
  transition: transform .3s ease, opacity .25s ease;
  pointer-events: none;
}
.chat-window.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--blue);
  color: #fff;
}
.chat-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .2);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.chat-header-avatar svg {
  width: 22px;
  height: 22px;
  fill: #fff;
}
.chat-header-info {
  flex: 1;
}
.chat-header-name {
  display: block;
  font-weight: 700;
  font-size: 15px;
}
.chat-header-status {
  font-size: 12px;
  opacity: .85;
}
.chat-header-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  transition: background .2s;
}
.chat-header-close:hover {
  background: rgba(255, 255, 255, .2);
}

.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 280px;
  background: #f8f9fb;
}

.chat-msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
}
.chat-msg-customer {
  align-self: flex-end;
  background: var(--blue);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg-admin {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #e2e6ea;
  border-bottom-left-radius: 4px;
}
.chat-msg-time {
  font-size: 10px;
  opacity: .6;
  margin-top: 4px;
  display: block;
}
.chat-msg-customer .chat-msg-time {
  text-align: right;
}

.chat-welcome {
  text-align: center;
  padding: 20px;
  color: #6b7280;
  font-size: 13px;
}
.chat-welcome strong {
  display: block;
  color: var(--text);
  font-size: 14px;
  margin-bottom: 4px;
}

.chat-footer {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #e2e6ea;
  background: #fff;
}
.chat-footer input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 24px;
  border: 1px solid #e2e6ea;
  font-size: 14px;
  outline: none;
  transition: border-color .2s;
}
.chat-footer input:focus {
  border-color: var(--blue);
}
.chat-send {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background .2s;
}
.chat-send:hover {
  background: #1d4ed8;
}
.chat-send svg {
  width: 18px;
  height: 18px;
}

.chat-typing {
  display: none;
  padding: 8px 14px;
  font-size: 13px;
  color: #6b7280;
}
.chat-typing.active {
  display: block;
}

@media (max-width: 480px) {
  .chat-window {
    width: calc(100vw - 32px);
    left: -8px;
    bottom: 72px;
    max-height: 70vh;
  }
}
