@import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100..900;1,100..900&display=swap');

:root {
  --bg-1: #fcf7ff;
  --bg-2: #e0e6ff;
  --card: #ffffff;
  --brand: #6c43f9;
  --accent: #ff8f70;
  --shadow: 0 0 10px rgba(44, 38, 59, 0.5);
  --border: rgba(0, 0, 0, 0.05);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Roboto", sans-serif;
}

body {
  min-height: 100svh;
  height: 100svh;
  background: radial-gradient(circle at top, var(--bg-1) 0%, var(--bg-2) 60%, #cde5ff 120%);
  display: flex;
  justify-content: center;
  align-items: stretch;
}

@supports not (height: 100svh) {
  body {
    min-height: 100vh;
    height: 100vh;
  }
}

.chat-wrapper {
  width: 100%;
  max-width: 480px;
  height: 95%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
  box-sizing: border-box;
}

.chatbot {
  width: min(100%, 420px);
  height: 100%;
  min-height: 0;
  background: var(--card);
  border-radius: 22px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  border: 0;
}

.chatbot header {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  background: #724ae8;
  color: #fff;
}

.chatbot header h2 {
  font-size: 1.3rem;
  font-weight: 600;
}

.close-btn {
  cursor: pointer;
  font-size: 1.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.15);
  transition: background 0.2s ease;
}

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

.chatbox {
  flex: 1;
  min-height: 0;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(108, 67, 249, 0.6) transparent;
}

.chatbox::-webkit-scrollbar {
  width: 6px;
}

.chatbox::-webkit-scrollbar-thumb {
  background: rgba(108, 67, 249, 0.4);
  border-radius: 999px;
}

.chat {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
}

.chat p {
  margin: 0;
  padding: 0.85rem 1rem;
  border-radius: 18px 18px 18px 0px;
  font-size: 0.95rem;
  line-height: 1.4;
  max-width: 80%;
  white-space: pre-wrap;
  word-break: break-word;
}

.incoming {
  justify-content: flex-start;
}

.incoming span {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  font-size: 1.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.incoming p {
  background: #f2f2f2;
  color: #1a1a1a;
}

.outgoing {
  justify-content: flex-end;
}

.outgoing p {
  background: linear-gradient(135deg, var(--brand), #9558ff);
  color: #fff;
  border-bottom-right-radius: 4px;
  border-bottom-left-radius: 18px;
}

.chat p.error {
  background: #ffe3e8;
  color: #b1232b;
}

.chat-input {
  padding: 0.85rem 1.25rem 1rem;
  display: flex;
  gap: 0.85rem;
  align-items: flex-end;
  border-top: 1px solid var(--border);
  background: #fff;
  position: sticky;
  bottom: 0;
}

.chat-input textarea {
  width: 100%;
  min-height: 60px;
  max-height: 160px;
  resize: none;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 16px;
  padding: 0.95rem 1rem;
  font-size: 0.95rem;
  line-height: 1.4;
  font-family: inherit;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

.chat-input textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(108, 67, 249, 0.18);
}

.send-btn {
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 16px;
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.send-btn:not(:disabled):active {
  transform: translateY(1px);
}

.chat-input textarea:placeholder-shown + .send-btn {
  opacity: 0.6;
}

.copyright {
  text-align: center;
  padding: 20px;
  margin-top: 10px;
  font-size: 0.9rem;
  color: #666;
  width: 100%;
  position: fixed;
  bottom: 0;
  z-index: 1000;
}

/* Larger layouts gain fixed height and center alignment */
@media (min-width: 640px) {
  body {
    padding-top: 2.5rem;
    align-items: center;
  }

  .chatbot {
    min-height: 70vh;
    max-height: 80vh;
  }
}

@media (min-width: 900px) {
  .chatbot {
    box-shadow: 0 35px 90px rgba(44, 38, 59, 0.18);
  }
