/* ── Live Chat Widget ── */
.chat-widget {
  position: relative;
  margin-left: 1.5rem;
}

.chat-toggle {
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: .35rem .75rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 3px;
  cursor: pointer;
  font-size: .72rem;
  font-weight: 500;
  font-family: inherit;
  transition: all .15s;
  white-space: nowrap;
}

.chat-toggle:hover {
  border-color: var(--muted);
  color: var(--text);
}

.chat-toggle .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

.chat-window {
  display: none;
  position: absolute;
  top: calc(100% + .5rem);
  left: 0;
  width: 340px;
  max-height: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  flex-direction: column;
  overflow: hidden;
  z-index: 200;
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
}

.chat-window.open {
  display: flex;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .7rem .9rem;
  border-bottom: 1px solid var(--border);
  font-size: .78rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
}

.chat-header .online-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  margin-right: .35rem;
}

.chat-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0 .2rem;
  line-height: 1;
}

.chat-close:hover { color: var(--text); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: .75rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  min-height: 200px;
  max-height: 280px;
}

.chat-msg {
  max-width: 85%;
  padding: .5rem .7rem;
  border-radius: 6px;
  font-size: .78rem;
  line-height: 1.45;
  word-break: break-word;
}

.chat-msg.incoming {
  align-self: flex-start;
  background: var(--surface2);
  color: var(--text);
  border-bottom-left-radius: 2px;
}

.chat-msg.outgoing {
  align-self: flex-end;
  background: var(--text);
  color: var(--bg);
  border-bottom-right-radius: 2px;
}

.chat-msg .meta {
  font-size: .62rem;
  color: var(--muted2);
  margin-bottom: .15rem;
}

.chat-msg.outgoing .meta {
  color: rgba(0,0,0,.4);
}

.chat-input-area {
  display: flex;
  border-top: 1px solid var(--border);
  padding: .5rem;
  gap: .4rem;
}

.chat-input-area input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: .45rem .6rem;
  border-radius: 3px;
  font-size: .78rem;
  font-family: inherit;
  outline: none;
}

.chat-input-area input:focus {
  border-color: var(--muted);
}

.chat-input-area input::placeholder {
  color: var(--muted2);
}

.chat-input-area button {
  background: var(--text);
  color: var(--bg);
  border: none;
  padding: .45rem .75rem;
  border-radius: 3px;
  cursor: pointer;
  font-size: .78rem;
  font-weight: 600;
  font-family: inherit;
  white-space: nowrap;
}

.chat-input-area button:hover {
  background: var(--accent2);
}

.chat-input-area button:disabled {
  opacity: .4;
  cursor: not-allowed;
}

.chat-typing {
  font-size: .65rem;
  color: var(--muted2);
  padding: 0 .75rem .5rem;
  display: none;
}

.chat-typing.active {
  display: block;
}

@media (max-width: 480px) {
  .chat-window {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 60vh;
    border-radius: var(--radius) var(--radius) 0 0;
  }
  .chat-messages { max-height: 40vh; }
}