:root {
  --bg: #0b1220;
  --panel: rgba(255, 255, 255, 0.06);
  --panel-2: rgba(255, 255, 255, 0.09);
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.65);
  --border: rgba(255, 255, 255, 0.1);
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  --me: #2f6bff;
  --ai: rgba(255, 255, 255, 0.08);
  --danger: #ff4d4f;
  --radius: 16px;
}

* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family: Arial, sans-serif;
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  background:
    radial-gradient(
      1200px 600px at 20% 10%,
      rgba(47, 107, 255, 0.25),
      transparent 60%
    ),
    radial-gradient(
      900px 500px at 80% 20%,
      rgba(0, 214, 170, 0.18),
      transparent 60%
    ),
    radial-gradient(
      1000px 600px at 50% 90%,
      rgba(255, 94, 87, 0.1),
      transparent 60%
    ),
    var(--bg);
  padding: 28px 14px;
}

.app {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
}

@media (max-width: 860px) {
  .app {
    grid-template-columns: 1fr;
  }
  .side {
    display: none;
  }
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.side {
  padding: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(
    135deg,
    rgba(47, 107, 255, 0.9),
    rgba(0, 214, 170, 0.75)
  );
  box-shadow: 0 10px 25px rgba(47, 107, 255, 0.25);
}
.brand h1 {
  font-size: 16px;
  margin: 0;
  letter-spacing: 0.4px;
}
.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.tips {
  padding: 14px;
  border-radius: 14px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
  line-height: 1.45;
  font-size: 13px;
}
.tips b {
  color: var(--text);
}

.chat {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 56px);
  min-height: 520px;
}

.topbar {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.title .name {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.3px;
}
.title .sub {
  font-size: 12px;
  color: var(--muted);
}

.actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: 0.15s ease;
  font-size: 12px;
  user-select: none;
}
.btn:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.09);
}
.btn.danger {
  border-color: rgba(255, 77, 79, 0.35);
  color: rgba(255, 180, 180, 0.95);
}
.btn.danger:hover {
  background: rgba(255, 77, 79, 0.12);
}

.messages {
  padding: 18px 14px;
  overflow: auto;
  flex: 1;
  scroll-behavior: smooth;
}

.row {
  display: flex;
  margin: 10px 0;
  gap: 10px;
}
.row.me {
  justify-content: flex-end;
}
.row.ai {
  justify-content: flex-start;
}

.bubble {
  max-width: min(700px, 92%);
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  line-height: 1.45;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}

.row.me .bubble {
  background: linear-gradient(
    135deg,
    rgba(47, 107, 255, 0.95),
    rgba(47, 107, 255, 0.7)
  );
  border-color: rgba(47, 107, 255, 0.35);
  box-shadow: 0 10px 24px rgba(47, 107, 255, 0.18);
}

.row.ai .bubble {
  background: var(--ai);
}

.meta {
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
  padding: 0 6px;
}
.row.me .meta {
  text-align: right;
}

.composer {
  border-top: 1px solid var(--border);
  padding: 12px;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: rgba(0, 0, 0, 0.1);
}

textarea {
  flex: 1;
  resize: none;
  height: 44px;
  max-height: 140px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 12px 12px;
  outline: none;
  font-size: 14px;
  line-height: 1.35;
}
textarea::placeholder {
  color: rgba(255, 255, 255, 0.45);
}
textarea:focus {
  border-color: rgba(47, 107, 255, 0.55);
  box-shadow: 0 0 0 4px rgba(47, 107, 255, 0.14);
}

.send {
  border: none;
  background: linear-gradient(
    135deg,
    rgba(47, 107, 255, 0.95),
    rgba(0, 214, 170, 0.85)
  );
  color: white;
  padding: 12px 14px;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.2px;
  min-width: 92px;
  transition: 0.15s ease;
}
.send:hover {
  transform: translateY(-1px);
  filter: brightness(1.02);
}
.send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.status {
  padding: 10px 14px 0;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(0, 214, 170, 0.9);
  box-shadow: 0 0 0 6px rgba(0, 214, 170, 0.12);
}
.dot.busy {
  background: rgba(47, 107, 255, 0.9);
  box-shadow: 0 0 0 6px rgba(47, 107, 255, 0.12);
  animation: pulse 1.2s infinite;
}
@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.9;
  }
  50% {
    transform: scale(1.35);
    opacity: 0.5;
  }
}

.error {
  color: rgba(255, 180, 180, 0.95);
}

/* --- PHẦN AUTHENTICATION --- */
.auth-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(11, 18, 32, 0.85); /* Tối màu nền */
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000; /* Hiển thị đè lên tất cả */
  transition: opacity 0.3s ease;
}

.auth-card {
  padding: 30px 24px;
  width: min(90%, 360px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-input {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 12px 14px;
  outline: none;
  font-size: 14px;
  transition: 0.2s ease;
}

.auth-input:focus {
  border-color: rgba(47, 107, 255, 0.55);
  background: rgba(255, 255, 255, 0.09);
}

.hidden {
  display: none !important;
}
