* {
  box-sizing: border-box;
}

:root {
  --primary: #2E6DA4;
  --primary-dark: #1A5276;
  --primary-light: #EBF3FB;
  --text-dark: #1A1A2E;
  --text-gray: #555555;
  --white: #FFFFFF;
  --shadow: rgba(46, 109, 164, 0.15);
}

/* WordPress / theme overrides: IDs + !important keep widget viewport-fixed */
#chatLauncher {
  position: fixed !important;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  background: #2e6da4;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 28px;
  z-index: 999999 !important;
  box-shadow: 0 4px 16px rgba(46, 109, 164, 0.4);
  border: none;
  padding: 0;
  margin: 0;
}

#chatWidget {
  position: fixed !important;
  bottom: 100px;
  right: 24px;
  width: 380px;
  height: 560px;
  z-index: 999999 !important;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(46, 109, 164, 0.2);
  display: flex;
  flex-direction: column;
  background: white;
  overflow: hidden;
}

#chatLauncher,
#chatWidget,
#chatWidget .chat-header,
#chatWidget .chat-body,
#chatWidget .chat-form,
#chatWidget .header-left,
#chatWidget .header-actions,
#chatWidget .bubble,
#chatWidget .quick-replies,
#chatWidget .quick-reply-btn,
#chatWidget .typing,
#chatWidget #chatBody,
#chatWidget #chatForm,
#chatWidget #userInput,
#chatWidget #sendBtn,
#chatWidget #languageToggle,
#chatWidget #closeChatBtn,
#chatWidget .lang-toggle,
#chatWidget .close-chat-btn,
#chatWidget .lang-segment,
#chatWidget .logo-icon,
#chatWidget .launcher-icon {
  z-index: 999999;
}

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", Arial, sans-serif;
  background: #f7fbff;
  color: var(--text-dark);
  min-height: 100vh;
}

.chat-widget {
  background: var(--white);
  border: 1px solid rgba(46, 109, 164, 0.12);
  animation: widget-in 180ms ease-out;
}

@keyframes widget-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.chat-launcher {
  animation: pulse 2s infinite;
}

.chat-launcher:hover {
  background: var(--primary-dark);
}

.chat-launcher.open {
  animation: none;
}

.launcher-icon,
.logo-icon {
  line-height: 1;
}

.launcher-icon {
  font-size: inherit;
  line-height: 1;
  transform: translateY(1px);
}

@keyframes pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(46, 109, 164, 0.55);
  }
  70% {
    transform: scale(1.02);
    box-shadow: 0 0 0 12px rgba(46, 109, 164, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(46, 109, 164, 0);
  }
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 13px 12px;
  background: linear-gradient(145deg, var(--primary) 0%, #2c6294 100%);
  color: var(--white);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.chat-header h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.chat-header p {
  margin: 3px 0 0;
  font-size: 11px;
  opacity: 0.95;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lang-toggle {
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 999px;
  padding: 3px;
  background: transparent;
  color: var(--white);
  cursor: pointer;
  display: flex;
  gap: 3px;
}

.lang-toggle:hover {
  border-color: rgba(255, 255, 255, 0.75);
}

.lang-segment {
  min-width: 34px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  padding: 5px 8px;
  color: rgba(255, 255, 255, 0.5);
}

.lang-segment.active {
  background: var(--white);
  color: var(--primary);
}

.close-chat-btn {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: transparent;
  color: var(--white);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.close-chat-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px 14px;
  background: var(--white);
  scrollbar-width: thin;
  scrollbar-color: rgba(46, 109, 164, 0.35) transparent;
}

.chat-body::-webkit-scrollbar {
  width: 8px;
}

.chat-body::-webkit-scrollbar-thumb {
  background: rgba(46, 109, 164, 0.35);
  border-radius: 999px;
}

.bubble {
  max-width: 80%;
  margin-bottom: 11px;
  padding: 10px 13px;
  border-radius: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  font-size: 14px;
  box-shadow: 0 2px 12px rgba(46, 109, 164, 0.08);
}

.bubble.user {
  margin-left: auto;
  background: var(--primary);
  color: var(--white);
  border-radius: 12px 12px 2px 12px;
}

.bubble.bot {
  margin-right: auto;
  background: var(--primary-light);
  color: var(--text-dark);
  border-radius: 12px 12px 12px 2px;
}

.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quick-reply-btn {
  border: 1px solid var(--primary);
  background: transparent;
  color: var(--primary);
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 13px;
  font-weight: 600;
}

.quick-reply-btn:hover {
  background: var(--primary);
  color: var(--white);
}

.chat-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--primary-light);
  background: var(--white);
}

#userInput {
  flex: 1;
  border: 1px solid var(--primary-light);
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 14px;
  color: var(--text-dark);
  outline: none;
}

#userInput:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(46, 109, 164, 0.15);
}

#userInput::placeholder {
  color: var(--text-gray);
}

#sendBtn {
  background: var(--primary);
  color: var(--white);
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 600;
}

#sendBtn:hover {
  background: var(--primary-dark);
}

.typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.typing span {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--primary);
  animation: typing-bounce 1.2s infinite ease-in-out;
}

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

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

@keyframes typing-bounce {
  0%, 80%, 100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  40% {
    transform: translateY(-3px);
    opacity: 1;
  }
}

@media (max-width: 480px) {
  #chatWidget {
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100dvh !important;
    border-radius: 0 !important;
    box-shadow: none !important;
  }

  .chat-widget {
    border: none;
  }

  #chatLauncher {
    right: 16px !important;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .chat-header {
    padding-top: calc(12px + env(safe-area-inset-top));
  }

  .chat-form {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
}
