:root {
  --background: #ffffff;
  --foreground: #172b4d;
  --primary: #0052cc;
  --primary-strong: #0747a6;
  --secondary: #f4f5f7;
  --accent: #ebecef;
  --border: #dfe1e6;
  --ring: #4c9aff;
  --danger: #de350b;
  --danger-surface: #ffebe6;
  --danger-border: #ffbdad;
  --muted: #5e6c84;
  --sidebar: #fafbfc;
  --shadow-panel: 0 24px 80px rgba(9, 30, 66, 0.18);
  --shadow-soft: 0 10px 30px rgba(9, 30, 66, 0.1);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Proxima Nova", ui-sans-serif, system-ui, sans-serif;
  background:
    radial-gradient(circle at top right, rgba(76, 154, 255, 0.08), transparent 24%),
    linear-gradient(180deg, #f7f9fc 0%, #ffffff 35%, #f6f8fb 100%);
  color: var(--foreground);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.chat-icon {
  display: block;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.hidden {
  display: none !important;
}

.chat-page {
  min-height: 100vh;
  padding: 0;
}

.chat-widget {
  position: relative;
  display: flex;
  width: 100%;
  min-height: 100vh;
  height: 100vh;
  flex-direction: column;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: none;
}

.chat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px 14px;
  border-bottom: 1px solid rgba(223, 225, 230, 0.75);
  background: linear-gradient(180deg, rgba(250, 251, 252, 0.96) 0%, rgba(255, 255, 255, 0.96) 100%);
}

.chat-header-copy {
  min-width: 0;
}

.chat-header-label {
  margin: 0;
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.chat-header-title {
  margin: 6px 0 0;
  font-size: 20px;
  line-height: 1.2;
}

.chat-header-subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.chat-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--border);
}

.chat-status-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 24px;
  border-bottom: 1px solid rgba(223, 225, 230, 0.6);
  background: rgba(244, 245, 247, 0.52);
}

.chat-status-bar .chat-status-dot {
  width: 10px;
  height: 10px;
  background: var(--ring);
}

.chat-status-text {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.chat-status-text[data-phase="reconnecting"] {
  color: #9f5f00;
}

.chat-status-text[data-phase="reconnecting"]::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 999px;
  background: #f5a623;
  box-shadow: 0 0 0 0 rgba(245, 166, 35, 0.35);
  animation: chat-pulse 1.6s infinite;
  vertical-align: middle;
}

.chat-auth,
.chat-conversation {
  display: flex;
  flex: 1;
  min-height: 0;
}

.chat-auth {
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  background: linear-gradient(180deg, rgba(250, 251, 252, 0.9) 0%, rgba(255, 255, 255, 0.94) 100%);
}

.chat-auth-card {
  width: 100%;
  max-width: 540px;
  padding: 20px;
  border: 1px solid rgba(223, 225, 230, 0.8);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-soft);
}

.chat-auth-copy h3 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
}

.chat-auth-copy p,
.chat-auth-message {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.chat-auth-copy-centered {
  text-align: center;
}

.chat-auth-card label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.chat-auth-card input,
.chat-composer textarea {
  width: 100%;
  border: 1px solid rgba(223, 225, 230, 0.85);
  border-radius: 18px;
  background: var(--background);
  color: var(--foreground);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.chat-auth-card input {
  height: 46px;
  margin-top: 8px;
  padding: 0 15px;
  background: rgba(250, 251, 252, 0.75);
}

.chat-auth-phone-label {
  margin-top: 18px;
}

.chat-phone-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  border: 1px solid rgba(223, 225, 230, 0.85);
  border-radius: 12px;
  padding: 2px 14px;
  margin: 8px 0 0;
  transition: all 0.3s;
  box-sizing: border-box;
  background: rgba(250, 251, 252, 0.75);
}

.chat-phone-wrapper.focused {
  background: var(--background);
  border-color: var(--ring);
  box-shadow: 0 0 0 4px rgba(76, 154, 255, 0.18);
}

.chat-phone-wrapper.error {
  border-color: rgba(222, 53, 11, 0.55);
  box-shadow: 0 0 0 4px rgba(222, 53, 11, 0.12);
}

.chat-selected-country {
  display: flex;
  width: auto;
  height: auto;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 10px 14px 10px 0;
  user-select: none;
  border: 0;
  border-right: 1px solid rgba(223, 225, 230, 0.9);
  border-radius: 0;
  margin: 0 14px 0 0;
  background: transparent;
  color: var(--foreground);
  font-family: sans-serif;
  font-size: 16px;
  font-weight: 500;
}

.chat-country-caret {
  color: var(--muted);
  font-size: 10px;
}

.chat-phone-wrapper #phoneInput {
  flex: 1;
  height: auto;
  min-width: 0;
  width: 100%;
  margin: 0;
  padding: 12px 0;
  border: none;
  border-radius: 0;
  outline: none;
  box-shadow: none;
  box-sizing: border-box;
  background: transparent;
  color: var(--foreground);
  caret-color: var(--primary);
  font-size: 16px;
}

.chat-phone-wrapper #phoneInput:focus {
  border-color: transparent;
  box-shadow: none;
}

.chat-country-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  max-height: 250px;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid rgba(223, 225, 230, 0.9);
  border-radius: 20px;
  z-index: 10000;
  box-shadow: 0 16px 34px rgba(9, 30, 66, 0.16);
  margin-top: 5px;
  box-sizing: border-box;
}

.chat-country-dropdown::-webkit-scrollbar {
  width: 6px;
}

.chat-country-dropdown::-webkit-scrollbar-track {
  background: transparent;
}

.chat-country-dropdown::-webkit-scrollbar-thumb {
  background: #c1c7d0;
  border-radius: 3px;
}

.chat-country-search-shell {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 12px 15px;
  border-bottom: 1px solid rgba(223, 225, 230, 0.75);
  background: #ffffff;
}

.chat-country-search-shell input {
  width: 100%;
  height: auto;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(223, 225, 230, 0.85);
  border-radius: 10px;
  background: rgba(250, 251, 252, 0.9);
  color: var(--foreground);
  font-family: sans-serif;
  font-size: 15px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.2s, background-color 0.2s;
}

.chat-country-search-shell input:focus {
  border-color: var(--ring);
  background-color: #ffffff;
  color: var(--foreground);
}

.chat-prefix-option {
  display: flex;
  width: 100%;
  height: auto;
  align-items: center;
  gap: 15px;
  padding: 12px 20px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--foreground);
  cursor: pointer;
  font-family: sans-serif;
  font-size: 16px;
  text-align: left;
  transition: background 0.2s;
}

.chat-prefix-option:hover,
.chat-selected-country:hover {
  background: rgba(9, 30, 66, 0.06);
}

.chat-prefix-option .opt-flag {
  display: flex;
  align-items: center;
  font-size: 20px;
}

.chat-prefix-option .opt-name {
  flex: 1;
  font-weight: 500;
}

.chat-prefix-option .opt-val {
  color: #a0aec0;
  font-weight: 500;
}

.chat-auth-card label.hidden {
  display: none;
}

.chat-auth-card input:focus,
.chat-composer textarea:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 4px rgba(76, 154, 255, 0.18);
}

.chat-input-invalid {
  border-color: rgba(222, 53, 11, 0.55) !important;
  box-shadow: 0 0 0 4px rgba(222, 53, 11, 0.12) !important;
}

.chat-auth-card > button,
.chat-composer button {
  border: 0;
  color: #fff;
  font-weight: 700;
}

.chat-auth-card > button {
  width: 100%;
  height: 46px;
  margin-top: 18px;
  border-radius: 16px;
  background: var(--primary);
}

.chat-auth-card .chat-auth-link {
  height: auto;
  margin-top: 12px;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
}

.chat-auth-card > button:hover,
.chat-composer button:hover {
  background: var(--primary-strong);
}

.chat-auth-card .chat-auth-link:hover {
  background: transparent;
  color: var(--primary-strong);
}

.chat-otp-container {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 20px 0 4px;
}

.chat-auth-card .chat-otp-box {
  width: 45px;
  height: 55px;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(223, 225, 230, 0.9);
  border-radius: 12px;
  background: rgba(250, 251, 252, 0.9);
  color: var(--foreground);
  box-sizing: border-box;
  font-size: 24px;
  font-weight: 700;
  text-align: center;
  transition: all 0.3s;
}

.chat-auth-card .chat-otp-box:focus {
  border-color: var(--ring);
  background-color: #ffffff;
  box-shadow: 0 0 0 4px rgba(76, 154, 255, 0.18);
}

.chat-auth-card .chat-otp-box::-webkit-outer-spin-button,
.chat-auth-card .chat-otp-box::-webkit-inner-spin-button {
  appearance: none;
  margin: 0;
}

.chat-auth-card > button:disabled,
.chat-composer button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.chat-conversation {
  position: relative;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.8) 0%, rgba(255, 255, 255, 0.92) 100%);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.chat-empty {
  display: flex;
  min-height: 100%;
  align-items: center;
  justify-content: center;
}

.chat-empty-card {
  width: 100%;
  max-width: 280px;
  padding: 22px;
  border: 1px dashed rgba(223, 225, 230, 0.9);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.72);
  text-align: center;
  box-shadow: var(--shadow-soft);
}

.chat-empty-card p {
  margin: 0;
}

.chat-empty-card p:last-child {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.7;
}

.chat-message-row {
  display: flex;
  min-width: 0;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 14px;
}

.chat-message-row.chat-message-row-grouped {
  margin-top: -6px;
}

.chat-message-row.contact {
  justify-content: flex-end;
}

.chat-message-row.agent {
  justify-content: flex-start;
}

.chat-message-row.system {
  justify-content: center;
  margin: 18px 0;
}

.chat-message-bubble {
  position: relative;
  min-width: 0;
  max-width: 78%;
  padding: 12px 14px 10px;
  border-radius: 20px;
  overflow-wrap: anywhere;
  word-break: break-word;
  hyphens: auto;
}

.chat-message-bubble-with-image {
  position: relative;
  display: flex;
  width: 320px;
  max-width: 72%;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
  isolation: isolate;
}

.chat-message-bubble-with-image:not(.has-body) {
  background: transparent !important;
  line-height: 0;
}

.chat-message-bubble::after {
  content: "";
  display: block;
  clear: both;
}

.chat-message-bubble-with-image::after {
  display: none;
}

.chat-message-row.contact .chat-message-bubble {
  background: var(--primary);
  color: #fff;
}

.chat-message-row.contact:not(.chat-message-row-after-same) .chat-message-bubble,
.chat-message-row.contact.chat-message-row-before-same .chat-message-bubble {
  border-bottom-right-radius: 6px;
}

.chat-message-row.contact.chat-message-row-after-same .chat-message-bubble {
  border-top-right-radius: 6px;
}

.chat-message-row.agent .chat-message-bubble {
  background: var(--secondary);
  color: var(--foreground);
}

.chat-message-row.agent:not(.chat-message-row-after-same) .chat-message-bubble,
.chat-message-row.agent.chat-message-row-before-same .chat-message-bubble {
  border-bottom-left-radius: 6px;
}

.chat-message-row.agent.chat-message-row-after-same .chat-message-bubble {
  border-top-left-radius: 6px;
}

.chat-message-row.system .chat-message-bubble {
  background: rgba(244, 245, 247, 0.72);
  border: 1px solid rgba(223, 225, 230, 0.5);
  border-radius: 999px;
  padding: 6px 18px;
  color: var(--muted);
  max-width: 85%;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
}

.chat-message-row.system .chat-message-body {
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.chat-message-body {
  display: inline;
  max-width: 100%;
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  hyphens: auto;
  line-height: 1.6;
  font-size: 14px;
}

.chat-message-body a {
  color: inherit;
  text-decoration: underline;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.chat-message-body a:hover {
  opacity: 0.82;
}

.chat-message-body:empty {
  display: none;
}

.chat-message-image {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  max-height: 520px;
  margin-bottom: 0;
  object-fit: contain;
}

.chat-message-image-button {
  position: relative;
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  overflow: hidden;
}

.chat-message-bubble-with-image .chat-message-body {
  display: block;
  padding: 8px 12px 4px;
}

.chat-message-bubble-with-image .chat-message-meta {
  float: none;
  align-self: flex-end;
  margin: 0;
  padding: 2px 12px 8px;
}

.chat-message-image-overlay {
  position: absolute;
  bottom: 24px;
  left: 12px;
  right: 12px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.chat-message-image-overlay .chat-message-meta {
  float: none;
  align-self: unset;
  margin: 0;
  padding: 2px 8px;
  min-height: 28px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  color: rgba(255, 255, 255, 0.92) !important;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 500;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.chat-message-image-overlay .chat-message-meta time {
  color: inherit;
  line-height: 1;
}

.chat-message-image-button:focus-visible {
  outline: 2px solid var(--ring, #2563eb);
  outline-offset: 3px;
}

.chat-message-image-button .chat-message-image {
  max-width: 100%;
  margin-bottom: 0;
}

.chat-message-bubble-with-image:not(.has-body) .chat-message-image-button,
.chat-message-bubble-with-image:not(.has-body) .chat-message-image {
  border-radius: 20px;
}

.chat-message-row.contact:not(.chat-message-row-after-same) .chat-message-bubble-with-image:not(.has-body) .chat-message-image-button,
.chat-message-row.contact:not(.chat-message-row-after-same) .chat-message-bubble-with-image:not(.has-body) .chat-message-image,
.chat-message-row.contact.chat-message-row-before-same .chat-message-bubble-with-image:not(.has-body) .chat-message-image-button,
.chat-message-row.contact.chat-message-row-before-same .chat-message-bubble-with-image:not(.has-body) .chat-message-image {
  border-bottom-right-radius: 2px;
}

.chat-message-row.contact.chat-message-row-after-same .chat-message-bubble-with-image:not(.has-body) .chat-message-image-button,
.chat-message-row.contact.chat-message-row-after-same .chat-message-bubble-with-image:not(.has-body) .chat-message-image {
  border-top-right-radius: 2px;
}

.chat-message-row.agent:not(.chat-message-row-after-same) .chat-message-bubble-with-image:not(.has-body) .chat-message-image-button,
.chat-message-row.agent:not(.chat-message-row-after-same) .chat-message-bubble-with-image:not(.has-body) .chat-message-image,
.chat-message-row.agent.chat-message-row-before-same .chat-message-bubble-with-image:not(.has-body) .chat-message-image-button,
.chat-message-row.agent.chat-message-row-before-same .chat-message-bubble-with-image:not(.has-body) .chat-message-image,
.chat-message-row.system:not(.chat-message-row-after-same) .chat-message-bubble-with-image:not(.has-body) .chat-message-image-button,
.chat-message-row.system:not(.chat-message-row-after-same) .chat-message-bubble-with-image:not(.has-body) .chat-message-image,
.chat-message-row.system.chat-message-row-before-same .chat-message-bubble-with-image:not(.has-body) .chat-message-image-button,
.chat-message-row.system.chat-message-row-before-same .chat-message-bubble-with-image:not(.has-body) .chat-message-image {
  border-bottom-left-radius: 2px;
}

.chat-message-row.agent.chat-message-row-after-same .chat-message-bubble-with-image:not(.has-body) .chat-message-image-button,
.chat-message-row.agent.chat-message-row-after-same .chat-message-bubble-with-image:not(.has-body) .chat-message-image,
.chat-message-row.system.chat-message-row-after-same .chat-message-bubble-with-image:not(.has-body) .chat-message-image-button,
.chat-message-row.system.chat-message-row-after-same .chat-message-bubble-with-image:not(.has-body) .chat-message-image {
  border-top-left-radius: 2px;
}

.chat-message-bubble-with-image.has-body .chat-message-image-button,
.chat-message-bubble-with-image.has-body .chat-message-image {
  border-radius: 20px 20px 0 0;
}

.chat-message-row.contact.chat-message-row-after-same .chat-message-bubble-with-image.has-body .chat-message-image-button,
.chat-message-row.contact.chat-message-row-after-same .chat-message-bubble-with-image.has-body .chat-message-image {
  border-top-right-radius: 2px;
}

.chat-message-row.agent.chat-message-row-after-same .chat-message-bubble-with-image.has-body .chat-message-image-button,
.chat-message-row.agent.chat-message-row-after-same .chat-message-bubble-with-image.has-body .chat-message-image,
.chat-message-row.system.chat-message-row-after-same .chat-message-bubble-with-image.has-body .chat-message-image-button,
.chat-message-row.system.chat-message-row-after-same .chat-message-bubble-with-image.has-body .chat-message-image {
  border-top-left-radius: 2px;
}

.chat-message-meta {
  float: right;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0.62em 0 0 8px;
  font-size: 11px;
  line-height: 1;
  color: rgba(255, 255, 255, 0.65);
}

.chat-image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(8px);
  cursor: pointer;
}

.chat-image-lightbox.hidden {
  display: none;
}

.chat-image-lightbox img {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  cursor: default;
  border-radius: 8px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.chat-image-lightbox-actions {
  position: absolute;
  right: 16px;
  top: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 1001;
}

.chat-image-lightbox-close,
.chat-image-lightbox-download {
  display: inline-flex;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  transition: background-color 0.2s ease, opacity 0.2s ease;
}

.chat-image-lightbox-close:hover,
.chat-image-lightbox-close:focus-visible,
.chat-image-lightbox-download:hover,
.chat-image-lightbox-download:focus-visible {
  background: rgba(255, 255, 255, 0.2);
  outline: none;
}

.chat-close-icon,
.chat-image-lightbox-download svg {
  width: 20px;
  height: 20px;
  color: #fff;
  flex-shrink: 0;
}

.chat-message-image-download {
  display: inline-flex;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  text-decoration: none;
}

.chat-message-image-overlay .chat-message-image-download {
  pointer-events: auto;
}

.chat-message-bubble-with-image.has-body .chat-message-image-download {
  position: absolute;
  bottom: 12px;
  left: 12px;
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.chat-message-bubble-with-image.has-body .chat-message-image-button:hover .chat-message-image-download,
.chat-message-bubble-with-image.has-body .chat-message-image-button:focus-within .chat-message-image-download {
  opacity: 1;
  pointer-events: auto;
}

.chat-message-image-download:hover {
  background: rgba(0, 0, 0, 0.65);
}

.chat-download-icon {
  width: 14px;
  height: 14px;
}

.chat-message-row.agent .chat-message-meta {
  color: rgba(94, 108, 132, 0.75);
}

.chat-message-row.system .chat-message-meta {
  display: none !important;
}

.chat-message-failed {
  display: inline-flex;
  width: 18px;
  height: 18px;
  margin-bottom: 10px;
  padding: 0;
  align-items: center;
  justify-content: center;
  flex: 0 0 18px;
  border: 0;
  border-radius: 999px;
  background: #ff3b30;
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.chat-message-failed:hover {
  transform: translateY(-1px);
}

.chat-message-failed:focus-visible {
  outline: 2px solid rgba(222, 53, 11, 0.35);
  outline-offset: 3px;
}

.chat-message-pending {
  position: relative;
  display: inline-flex;
  width: 13px;
  height: 13px;
  align-items: center;
  justify-content: center;
  flex: 0 0 13px;
  border-radius: 999px;
  border: 1.5px solid currentColor;
  opacity: 0.82;
}

.chat-message-pending::before,
.chat-message-pending::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1.5px;
  border-radius: 999px;
  background: currentColor;
  transform-origin: bottom center;
}

.chat-message-pending::before {
  height: 4px;
  transform: translate(-50%, -100%) rotate(0deg);
}

.chat-message-pending::after {
  height: 3.5px;
  transform: translate(-50%, -100%) rotate(90deg);
}

.chat-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0 24px 16px;
  width: fit-content;
  padding: 10px 14px;
  border-radius: 18px;
  border: 1px solid rgba(223, 225, 230, 0.75);
  background: rgba(255, 255, 255, 0.9);
  color: var(--muted);
  font-size: 12px;
}

.chat-typing-dots {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
}

.chat-typing-dots span {
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.35;
  animation: chat-typing-dot-bounce 1.2s ease-in-out infinite;
}

.chat-typing-dots span:nth-child(2) {
  animation-delay: 0.16s;
}

.chat-typing-dots span:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes chat-typing-dot-bounce {

  0%,
  60%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  30% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.chat-composer {
  padding: 14px 24px 18px;
  border-top: 1px solid rgba(223, 225, 230, 0.75);
  background: rgba(250, 251, 252, 0.92);
}

.chat-selected-image-toolbar {
  display: flex;
  height: 48px;
  flex: 0 0 48px;
  align-items: center;
  justify-content: flex-start;
  padding: 0 24px;
  border-bottom: 1px solid rgba(223, 225, 230, 0.75);
  background: rgba(250, 251, 252, 0.92);
}

.chat-selected-image-toolbar button {
  display: inline-flex;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: var(--secondary);
  color: var(--muted);
}

.chat-selected-image-toolbar button:hover,
.chat-selected-image-toolbar button:focus-visible {
  background: var(--accent);
  color: var(--foreground);
  outline: none;
}

.chat-has-pending-image .chat-selected-image-toolbar {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  z-index: 6;
  height: auto;
  flex-basis: auto;
  padding: 16px 18px;
  border-bottom: 0;
  background: transparent;
  pointer-events: none;
}

.chat-has-pending-image .chat-selected-image-toolbar button {
  width: 40px;
  height: 40px;
  background: rgba(15, 23, 42, 0.56);
  color: #fff;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.26);
  backdrop-filter: blur(14px) saturate(150%);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  pointer-events: auto;
}

.chat-has-pending-image .chat-selected-image-toolbar button:hover,
.chat-has-pending-image .chat-selected-image-toolbar button:focus-visible {
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
}

.chat-image-preview {
  display: flex;
  flex: 1;
  min-height: 0;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(250, 251, 252, 0.92);
}

.chat-has-pending-image .chat-messages,
.chat-has-pending-image .chat-typing {
  display: none;
}

.chat-has-pending-image .chat-image-preview {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: 0;
  background:
    radial-gradient(circle at 24% 18%, rgba(255, 255, 255, 0.15), transparent 28%),
    linear-gradient(135deg, #09111f 0%, #172033 45%, #0b1220 100%);
}

.chat-selected-image-backdrop {
  display: none;
}

.chat-has-pending-image .chat-selected-image-backdrop {
  position: absolute;
  inset: -28px;
  z-index: -2;
  display: block;
  width: calc(100% + 56px);
  height: calc(100% + 56px);
  object-fit: cover;
  filter: blur(28px) saturate(120%);
  opacity: 0.42;
  transform: scale(1.04);
}

.chat-has-pending-image .chat-image-preview::after {
  position: absolute;
  inset: 0;
  z-index: -1;
  content: "";
  background:
    linear-gradient(180deg, rgba(3, 7, 18, 0.32), transparent 28%, transparent 62%, rgba(3, 7, 18, 0.36)),
    rgba(3, 7, 18, 0.22);
}

.chat-selected-image-button {
  position: relative;
  display: inline-flex;
  max-width: 100%;
  max-height: min(62vh, 620px);
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 0;
  border-radius: 4px;
  background: #fff;
  padding: 4px;
  color: inherit;
}

.chat-has-pending-image .chat-selected-image-button {
  width: 100%;
  height: 100%;
  max-height: none;
  border-radius: 0;
  background: transparent;
  padding: 0;
}

.chat-selected-image-button:hover,
.chat-selected-image-button:focus-visible {
  background: #fff;
  outline: 2px solid rgba(76, 154, 255, 0.5);
  outline-offset: 2px;
}

.chat-has-pending-image .chat-selected-image-button:hover,
.chat-has-pending-image .chat-selected-image-button:focus-visible {
  background: transparent;
  outline-offset: -2px;
}

.chat-selected-image-button img {
  display: block;
  max-width: 100%;
  max-height: min(60vh, 600px);
  object-fit: contain;
}

.chat-has-pending-image .chat-selected-image-button img {
  width: 100%;
  height: 100%;
  max-height: none;
  border-radius: 0;
  object-fit: contain;
}

.chat-selected-image-size {
  display: none;
}

.chat-selected-image-name {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.chat-composer-shell {
  position: relative;
  border: 1px solid rgba(223, 225, 230, 0.8);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.95);
  padding: 10px 52px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.chat-composer-shell:focus-within {
  border-color: rgba(0, 82, 204, 0.35);
  box-shadow: 0 0 0 4px rgba(76, 154, 255, 0.12);
  background: #fff;
}

.chat-composer textarea {
  display: block;
  min-height: 28px;
  height: 28px;
  max-height: 96px;
  resize: none;
  overflow-y: hidden;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  line-height: 1.6;
  box-shadow: none;
}

.chat-composer textarea:focus {
  background: transparent;
  box-shadow: none;
}

.chat-composer-shell button {
  position: absolute;
  top: 50%;
  display: inline-flex;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  transform: translateY(-50%);
  border-radius: 999px;
  background: var(--primary);
}

.chat-attach-button {
  left: 8px;
  background: var(--secondary) !important;
  color: var(--muted) !important;
}

.chat-attach-button:hover {
  background: var(--accent) !important;
  color: var(--foreground) !important;
}

.chat-has-pending-image .chat-composer-shell {
  padding-left: 16px;
  border-color: rgba(255, 255, 255, 0.26);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.24);
}

.chat-has-pending-image .chat-attach-button {
  display: none;
}

.chat-has-pending-image .chat-composer {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 6;
  padding: 18px;
  border-top: 0;
  background: transparent;
  pointer-events: none;
}

.chat-has-pending-image .chat-composer-shell,
.chat-has-pending-image .chat-error {
  pointer-events: auto;
}

#sendButton {
  right: 8px;
}

.chat-error {
  margin: 12px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--danger-border);
  border-radius: 16px;
  background: var(--danger-surface);
  color: var(--danger);
  font-size: 13px;
}

@keyframes chat-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(245, 166, 35, 0.35);
  }

  70% {
    box-shadow: 0 0 0 8px rgba(245, 166, 35, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(245, 166, 35, 0);
  }
}

@media (max-width: 640px) {
  .chat-widget {
    min-height: 100svh;
    height: 100svh;
  }

  .chat-header,
  .chat-status-bar,
  .chat-auth,
  .chat-messages,
  .chat-composer {
    padding-left: 16px;
    padding-right: 16px;
  }

  .chat-otp-container {
    gap: 7px;
  }

  .chat-auth-card .chat-otp-box {
    width: 38px;
    height: 50px;
  }
}

.chat-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 20px;
}

.chat-loading-content {
  background: var(--background, #ffffff);
  border: 1px solid rgba(223, 225, 230, 0.8);
  padding: 32px 40px;
  border-radius: 22px;
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
  max-width: 90%;
  width: 340px;
  animation: chat-loading-fade-in 0.3s ease-out;
}

.chat-loading-spinner {
  width: 48px;
  height: 48px;
  border: 3.5px solid var(--secondary, #f4f5f7);
  border-radius: 50%;
  border-top-color: var(--primary, #0052cc);
  border-right-color: var(--primary, #0052cc);
  animation: chat-loading-spin 1s cubic-bezier(0.5, 0.1, 0.4, 0.9) infinite;
}

.chat-loading-text {
  margin: 0;
  color: var(--foreground, #172b4d);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.5;
}

@keyframes chat-loading-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes chat-loading-fade-in {
  from {
    opacity: 0;
    transform: scale(0.96);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.chat-header-notification-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(223, 225, 230, 0.85);
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  transition: all 0.2s ease;
  flex-shrink: 0;
  margin-top: 6px;
  padding: 0;
}

.chat-header-notification-toggle:hover {
  background: var(--secondary);
  color: var(--foreground);
}

.chat-header-notification-toggle.disabled {
  color: var(--danger);
  background: var(--danger-surface);
  border-color: var(--danger-border);
}

.chat-header-notification-toggle.unsupported {
  display: none !important;
}

.chat-message-avatar-container {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  box-shadow: 0 2px 6px rgba(9, 30, 66, 0.08);
  margin-bottom: 2px;
}

.chat-message-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-message-avatar-initials {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  user-select: none;
}

.chat-message-avatar-spacer {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}
