/* Prevent iOS/Chrome from auto-zooming text on focus */
html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: sans-serif;
  background: #fff;
}

/* Greeting bubble */
#greeting {
  position: fixed;
  bottom: 100px;
  right: 20px;
  background: #0077b6;
  color: #fff;
  padding: 10px 15px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.5s ease-out, transform 0.5s ease-out;
  cursor: pointer;
  pointer-events: none;
  max-width: 200px;
  text-align: center;
}
#greeting.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Box-sizing */
#chat-widget,
#chat-widget * {
  box-sizing: border-box;
}

/* Collapsed widget */
#chat-widget {
  position: fixed;
  bottom: 30px;
  right: 20px;
  width: 60px;
  height: 60px;
  z-index: 1000;
  transition: height 0.3s ease, bottom 0.3s ease;
}

/* Expanded widget */
#chat-widget.open {
  width: min(400px, 90vw);
  max-height: min(600px, 80dvh, 80svh);
  bottom: 30px;
  right: 20px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  border-radius: 8px;
  background: #f7f7f7;
  overflow: hidden;
}

/* On desktop, also animate width */
@media (min-width: 601px) {
  #chat-widget,
  #chat-widget.open {
    transition: width 0.3s ease, height 0.3s ease, bottom 0.3s ease;
  }
}

/* Launcher icon */
#chat-launcher {
  display: flex;
  justify-content: center;
  align-items: center;
  background: transparent;
  border: none;
  cursor: pointer;
}
#chat-icon {
  max-width: 80px;
  max-height: 80px;
  display: block;
}

/* Header */
#chat-header {
  display: flex;
  align-items: center;
  background: #0077b6;
  color: #fff;
  padding: 10px 16px;
  font-size: 16px;
}
#chat-header span {
  flex-grow: 1;
}

/* Close button */
#chat-close-btn {
  background: transparent;
  border: none;
  padding: 8px;
  margin-left: auto;
  color: rgba(255,255,255,0.7);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
  -webkit-appearance: none;
  transition: color 0.2s ease, background-color 0.2s ease;
}
#chat-close-btn:hover {
  color: #fff;
  background-color: rgba(255,255,255,0.2);
}

/* Chat body */
#chat-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
}

/* Messages */
#messages {
  flex: 1;
  padding: 10px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.2) transparent;
}
#messages::-webkit-scrollbar {
  width: 6px;
}
#messages::-webkit-scrollbar-thumb {
  background-color: rgba(0,0,0,0.2);
  border-radius: 3px;
}

/* Individual messages */
.message {
  display: inline-block;
  padding: 8px 12px;
  margin: 4px 0;
  border-radius: 12px;
  max-width: 80%;
  line-height: 1.4;
  word-wrap: break-word;
}
.message.user {
  align-self: flex-end;
  margin-left: auto;
  background: #0077b6;
  color: #fff;
  text-align: right;
}
.message.bot {
  align-self: flex-start;
  margin-right: auto;
  background: #e5e5ea;
  color: #000;
  text-align: left;
}

/* Typing indicator */
.typing {
  display: inline-flex;
  align-items: flex-end;
  gap: 4px;
  background: #e5e5ea;
  padding: 8px 12px;
  margin: 4px 0;
  border-radius: 12px;
  align-self: flex-start;
}
.typing .dot {
  width: 8px;
  height: 8px;
  background: #0077b6;
  border-radius: 50%;
  animation: bubble 1.2s infinite ease-in-out;
}
.typing .dot:nth-child(1) { animation-delay: 0s; }
.typing .dot:nth-child(2) { animation-delay: 0.2s; }
.typing .dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes bubble {
  0%, 80%, 100% { transform: translateY(0); }
  40%           { transform: translateY(-8px); }
}

/* Input bar + send button */
#chat-form {
  display: flex;
  border-top: 1px solid #ddd;
  background: #fff;
}
#chat-input {
  flex: 1;
  border: none;
  padding: 10px;
  font-size: 16px;
  outline: none;
}
#chat-form button {
  border: none;
  background: #0077b6;
  color: #fff;
  padding: 0 15px;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Mobile-specific: full-width bottom sheet + flush, finger-friendly touch targets */
@media (max-width: 600px) {
  #chat-widget.open {
    width: 100%;
    max-height: 60vh;
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: 12px 12px 0 0;
  }
  #chat-header {
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
  }

  #chat-form {
    padding: 0;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
  }

  /* bigger input for touch, but no extra bar padding */
  #chat-input {
    padding: 14px;
    font-size: 18px;
  }

  /*
    bigger arrow-button and force it to stretch full height:
  */
  #chat-form button {
    padding: 0 20px;
    font-size: 24px;
    align-self: stretch;
  }
}