:root {
  --accent-blue: #0d6efd;
  --secondary-blue: #0a4fb3;
  --charcoal: #1b1b1b;
  --white: #ffffff;
  --light-gray: #f5f7fa;
  --medium-gray: #373d49;
  --success-green: #16a34a;
  --error-red: #dc2626;
  --body-bg: linear-gradient(180deg, #f5f7fa 0%, #ffffff 100%);
  --text-primary: #1b1b1b !important;
  --text-secondary: #6b7280;
  --surface: rgba(255, 255, 255, 0.95);
  --card-bg: #ffffff;
  --panel-bg: rgba(255, 255, 255, 0.95);
  --topbar-bg: #0a4fb3;
  --topbar-color: #ffffff;
  --navbar-bg: rgba(255, 255, 255, 0.95);
  --hero-bg: none !important;
  --hero-overlay-light:
    radial-gradient(
      circle at top left,
      rgba(13, 110, 253, 0.1),
      transparent 35%
    ),
    radial-gradient(
      circle at bottom right,
      rgba(10, 79, 179, 0.1),
      transparent 35%
    ),
    radial-gradient(
      circle at bottom right,
      rgba(10, 79, 179, 0.08),
      transparent 40%
    );
}

.public-chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  left: auto;
  top: auto;
  z-index: 99999;
  width: min(400px, calc(100vw - 1.5rem));
  max-width: 400px;
  height: 650px;
  display: grid;
  place-items: end;
  pointer-events: none;
}

.chat-toggle-btn {
  pointer-events: auto;
  width: 68px;
  height: 68px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(
    135deg,
    var(--accent-blue),
    var(--secondary-blue)
  );
  color: white;
  box-shadow: var(--public-chat-shadow);
  cursor: pointer;
  transition: box-shadow 0.25s ease;
  position: relative;
  transform: none;
}

.chat-toggle-btn:hover {
  box-shadow: 0 36px 72px rgba(255, 98, 19, 0.3);
}

.chat-icon {
  font-size: 1.35rem;
  line-height: 1;
}

.chat-badge,
.chat-dot {
  position: absolute;
  right: -4px;
  top: -4px;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #22c55e;
  border: 2px solid #fff;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.16);
}

.chat-badge {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  background: var(--accent-blue);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.chat-panel {
  position: fixed;
  bottom: 90px;
  right: 24px;
  left: auto;
  top: auto;
  width: 400px;
  max-width: calc(100vw - 1.5rem);
  height: 650px;
  border-radius: 30px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: var(--public-chat-panel);
  box-shadow: var(--public-chat-shadow);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(18px);
  transition:
    opacity 0.25s ease,
    visibility 0.25s ease,
    transform 0.25s ease;
  pointer-events: auto;
  z-index: 99998;
}

.chat-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.chat-panel-shell {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100%;
}

.chat-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--accent-blue);
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
  position: sticky;
  top: 0;
  z-index: 1;
}

.chat-header-title {
  font-size: 1rem;
  font-weight: 700;
  color: #f8fafc;
}

.chat-header-subtitle {
  font-size: 0.85rem;
  color: #cbd5e1;
}

.chat-close-btn {
  border: none;
  background: transparent;
  color: #e2e8f0;
  font-size: 1.1rem;
  cursor: pointer;
}

.chat-content {
  flex: 1;
  min-height: 0;
  padding: 1rem;
  display: grid;
  gap: 0.9rem;
  overflow-y: auto;
  background: white;
}

.chat-bubble {
  display: inline-grid;
  width: fit-content;
  min-width: 110px;
  max-width: 80%;
  justify-self: start;
  border-radius: 24px;
  padding: 0.95rem 1rem;
  box-shadow: 0 16px 42px rgba(15, 23, 42, 0.12);
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: break-word;
  white-space: normal;
}

.chat-bubble.bot {
  background: #ffffff;
  color: #1f242d;
  justify-self: start;
}

.chat-bubble.user {
  background: #1f242d;
  color: #ffffff;
  justify-self: end;
}

.chat-bubble-author {
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  color: var(--accent-blue);
}

.chat-bubble-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-bubble-meta {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: rgba(189, 194, 205, 0.6);
}

.chat-empty,
.chat-step {
  margin: auto;
  max-width: 100%;
  text-align: center;
  color: #64748b;
}

.chat-empty-title,
.chat-step .chat-bubble.bot {
  font-size: 1.05rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 6px;
}

.chat-empty-copy,
.chat-step p {
  font-size: 0.92rem;
  line-height: 1.5;
}

.chat-bubble.user {
  width: fit-content;
  justify-self: end;
}

.chat-bubble.bot {
  width: fit-content;
  justify-self: start;
}

.chat-actions {
  display: grid;
  gap: 0.75rem;
}

.chat-actions input,
#visitorChatInput {
  width: 100%;
  min-height: 46px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(255, 255, 255, 0.95);
  color: #111827;
  padding: 0.9rem 1rem;
  font-size: 0.95rem;
}

.chat-actions input:focus,
#visitorChatInput:focus {
  outline: none;
  border-color: rgba(220, 38, 38, 0.8);
  box-shadow: 0 0 0 0.14rem rgba(220, 38, 38, 0.16);
}

.chat-action-btn,
#visitorChatSend {
  width: 100%;
  min-height: 46px;
  border: none;
  border-radius: 16px;
  background: linear-gradient(
    135deg,
    var(--accent-blue),
    var(--secondary-blue)
  );
  color: white;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 0.2s ease,
    filter 0.2s ease;
}

.chat-action-btn:hover,
#visitorChatSend:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.chat-footer {
  padding: 0.9rem 1rem 1rem;
  font-size: 0.82rem;
  color: #cbd5e1;
  background: rgba(15, 23, 42, 0.95);
  position: sticky;
  bottom: 0;
}

.chat-composer {
  display: none;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  margin-top: 0.9rem;
}

.chat-composer input {
  width: 100%;
}

.chat-status {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
}

.chat-status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #22c55e;
}

.chat-status.info::before {
  background: #38bdf8;
}

.chat-status.success::before {
  background: #22c55e;
}

.chat-status.error::before {
  background: #ef4444;
}

@media (max-width: 599px) {
  body.chat-widget-open {
    overflow: hidden;
  }

  .public-chat-widget {
    inset: 0;
    width: 100vw;
    height: 100dvh;
    max-width: 100vw;
    bottom: 0;
    right: 0;
    left: 0;
    top: 0;
  }

  .chat-content {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
  }

  .chat-bubble {
    max-width: 90%;
    min-width: 100px;
  }

  .chat-toggle-btn {
    width: 60px;
    height: 60px;
    position: fixed;
    right: 16px;
    bottom: 16px;
  }

  .chat-panel {
    inset: 0;
    width: 100vw;
    height: 100dvh;
    max-width: 100vw;
    border-radius: 0;
    bottom: 0;
    right: 0;
    left: 0;
    top: 0;
  }

  .chat-content {
    padding-bottom: 1.25rem;
  }
}

@media (min-width: 600px) {
  .public-chat-widget,
  .chat-panel {
    max-height: min(750px, calc(100vh - 150px));
    height: 750px;
  }
}

@media (min-width: 1024px) {
  .public-chat-widget,
  .chat-panel {
    max-height: min(750px, calc(100vh - 150px));
    height: 750px;
  }
}
