:root {
  --bg:#ffffff;         /* n?n tr?ng */
  --card:#f9f9f9;       /* khung hoi xám nh?t */
  --fg:#111111;         /* ch? den */
  --muted:#666666;      /* ch? m? */
  --primary:#4f46e5;    /* màu nút chính */
  --border:#cccccc;     /* màu vi?n nh?t */
}

* { box-sizing: border-box; }
body { margin:0; font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif; background: var(--bg); color: var(--fg); }

.container { max-width: 900px; margin: 0 auto; padding: 16px; }

.header { border-bottom: 1px solid var(--border); background: #ffffffee; position: sticky; top:0; backdrop-filter: blur(8px); }
.header .container { display:flex; align-items:center; justify-content: space-between; }
.brand { font-weight: 700; letter-spacing: .3px; }

/* footer b? luôn, không c?n n?a */

.btn { border: 1px solid var(--border); padding: 10px 14px; border-radius: 10px; cursor: pointer; background: transparent; color: var(--fg); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: white; }
.btn-outline { background: transparent; }

.login-body { display: grid; place-items: center; height: 100svh; }
.login-card { width: 360px; max-width: 92vw; background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 24px; }
.login-card h1 { margin: 0 0 16px; }
.login-card .alert { background: #ffe5e5; border: 1px solid #e55; padding: 8px 10px; border-radius: 8px; margin-bottom: 12px; }
.login-card form { display: grid; gap: 8px; }
.login-card input { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; color: var(--fg); }
.login-card label { color: var(--muted); font-size: 14px; }

.chat-wrapper { display: grid; gap: 12px; }
.chat-header { display: flex; align-items: center; justify-content: space-between; }
.chat-history {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 16px;
  padding: 12px;
  height: 60vh;
  overflow-y: auto;      /* ch? cho cu?n d?c */
  overflow-x: hidden;    /* t?t cu?n ngang */
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bubble {
  max-width: 80%;
  padding: 10px 12px;
  border-radius: 12px;
  line-height: 1.4;
  white-space: pre-wrap;       /* gi? xu?ng dòng ngu?i dùng nh?p */
  word-break: normal;          /* không c?t gi?a t? */
  overflow-wrap: break-word;   /* ch? ng?t khi t? quá dài */
}

.bubble.user {
  align-self: flex-end;
  background: #e0f7fa;
}

.bubble.bot {
  align-self: flex-start;
  background: #f1f1f1;
}

.chat-input{
  margin-top: 10px;
}

.input-wrap{
  position: relative;
}

/* Textarea t? giãn, ch?a ch? cho nút g?i bên trong */
.input-wrap textarea{
  width: 100%;
  min-height: 45px;          /* chi?u cao ban d?u */
  max-height: 40vh;          /* h?n ch? t?i da */
  resize: none;
  overflow: auto;            /* hi?n scroll d?c khi vu?t max-height */
  border: 1px solid #ccc;
  border-radius: 12px;
  padding: 12px 56px 12px 12px; /* RIGHT PADDING d? tránh dè nút */
  line-height: 1.4;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: normal;
  overflow-wrap: break-word;
  background: #fff;
  color: #111;
}

/* Nút g?i n?m trong khung, luôn c? d?nh kích thu?c */
.send-btn{
  position: absolute;
  right: 8px;
  bottom: 8px;               /* bám dáy khung khi textarea cao lên */
  width: 39px;
  height: 39px;
  border: none;
  border-radius: 999px;
  background: #6366f1;
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.send-btn:hover{ filter: brightness(1.05); }
.send-btn:active{ transform: translateY(1px); }
.send-btn .icon{ width: 20px; height: 20px; fill: #fff; display: block; }

.small { font-size: 12px; color: var(--muted); }
