.chat-widget { position: fixed; right: 20px; bottom: 20px; z-index: 9999; }

.chat-toggle-btn {
  width: 58px; height: 58px; border-radius: 50%; border: 1px solid var(--border);
  background: linear-gradient(135deg, #7d24ef, #962cf7);
  color: #fff; font-size: 24px; cursor: pointer;
  box-shadow: 0 14px 40px rgba(47, 34, 67, 0.18);
  display: flex; align-items: center; justify-content: center;
}

.chat-panel {
  position: fixed; right: 20px; bottom: 90px; width: 340px; max-width: calc(100vw - 32px);
  height: 460px; max-height: calc(100vh - 120px);
  background: #fff; border: 1px solid var(--border); border-radius: 18px;
  box-shadow: 0 14px 40px rgba(47, 34, 67, 0.16);
  display: none; flex-direction: column; overflow: hidden;
}

.chat-panel[aria-hidden="false"] { display: flex; }

.chat-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; font-weight: 700; color: var(--text);
  border-bottom: 1px solid var(--border);
}

.chat-panel-close { background: transparent; border: 0; color: var(--text); font-size: 20px; cursor: pointer; line-height: 1; }

.chat-gate { padding: 16px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.chat-gate-text { color: var(--muted); margin: 0; font-size: .92rem; }
.chat-gate-error { color: var(--danger, #e34b5f); font-size: .85rem; min-height: 1em; }

.chat-gate .input {
  height: 44px; padding: 0 14px; border: 2px solid var(--border); border-radius: 10px;
  font-size: 14px; font-family: inherit; color: var(--text); outline: none;
}
.chat-gate .input:focus { border-color: var(--primary); }

.chat-gate-submit {
  height: 42px; border: 0; border-radius: 10px; font-size: 14px; font-weight: 700;
  color: #fff; background: linear-gradient(135deg, #7d24ef, #962cf7); cursor: pointer;
}
.chat-gate-submit:disabled { opacity: .6; cursor: not-allowed; }

.chat-thread { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { max-width: 80%; padding: 8px 12px; border-radius: 14px; font-size: .9rem; line-height: 1.4; word-wrap: break-word; white-space: pre-wrap; }
.chat-msg--user { align-self: flex-end; background: linear-gradient(135deg, #7d24ef, #962cf7); color: #fff; }
.chat-msg--agent { align-self: flex-start; background: var(--primary-soft, #f4ebff); color: var(--text); }
.chat-msg-time { display: block; font-size: .7rem; opacity: .65; margin-top: 2px; }

.chat-form { display: flex; align-items: flex-end; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--border); }
.chat-message-input {
  flex: 1; resize: none; max-height: 100px; overflow-y: auto; font-family: inherit;
  line-height: 1.4; padding: .6rem .7rem; border: 2px solid var(--border); border-radius: 10px;
  font-size: 14px; color: var(--text); outline: none;
}
.chat-message-input:focus { border-color: var(--primary); }

.chat-form-send {
  flex: none; height: 40px; padding: 0 16px; border: 0; border-radius: 10px;
  font-size: 14px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, #7d24ef, #962cf7); cursor: pointer;
}

.chat-attach-btn {
  flex: none; width: 40px; height: 40px; border-radius: 10px; border: 2px solid var(--border);
  background: var(--primary-soft, #f4ebff); color: var(--text); font-size: 16px; cursor: pointer;
}
.chat-attach-btn:disabled { opacity: .6; cursor: not-allowed; }

.chat-attachment {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; margin-top: 6px;
  border-radius: 10px; background: rgba(0, 0, 0, .06); text-decoration: none; color: inherit;
}
.chat-msg--user .chat-attachment { background: rgba(255, 255, 255, .18); }
.chat-attachment-icon { font-size: 18px; }
.chat-attachment-name { font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 170px; }
.chat-attachment-size { font-size: .7rem; opacity: .7; }
.chat-attachment-image { display: block; max-width: 100%; max-height: 180px; border-radius: 10px; margin-top: 6px; }

.chat-gate[hidden], .chat-thread[hidden], .chat-form[hidden] { display: none; }

@media (max-width: 520px) {
  .chat-panel { right: 16px; bottom: 86px; width: calc(100vw - 32px); }
}

.chat-recaptcha-modal {
  position: fixed; inset: 0; z-index: 10000;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.chat-recaptcha-modal[hidden] { display: none; }
.chat-recaptcha-backdrop { position: absolute; inset: 0; background: rgba(20, 8, 38, .45); backdrop-filter: blur(4px); }
.chat-recaptcha-card {
  position: relative; background: #fff; border-radius: 16px; padding: 20px;
  box-shadow: 0 24px 60px rgba(30, 10, 60, .35);
}
