/* ===== Reset & base ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --red: #e0182d;
  --red-2: #ff3b50;
  --red-dark: #a50f1f;
  --bg: #000000;
  --card: #141414;
  --card-2: #1c1c1c;
  --line: #2a2a2a;
  --text: #ffffff;
  --muted: #9a9a9a;
  --gold: #f5c451;
  --green: #2ecc71;
  --blue: #3b82f6;
}

html, body { overflow-x: hidden; overscroll-behavior: none; background: #000; }
[hidden] { display: none !important; }   /* ép ẩn, đè display:flex của .welcome/.chat */

body {
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  display: flex; justify-content: center; min-height: 100vh;
}
.phone {
  width: 100%; max-width: 430px; height: 100vh; overflow: hidden;
  background: radial-gradient(120% 50% at 50% 0%, #2a0c10 0%, var(--bg) 55%);
  position: relative; display: flex; flex-direction: column;
  box-shadow: 0 0 40px rgba(0,0,0,.6);
}
.ic { width: 16px; height: 16px; fill: currentColor; }

/* ===== Header ===== */
.chat-header {
  flex-shrink: 0; display: flex; align-items: center; gap: 10px;
  padding: 8px 14px 12px; border-bottom: 1px solid var(--line);
}
.back-btn, .history-btn {
  background: none; border: none; color: #e3e3e3; cursor: pointer;
  display: inline-flex; align-items: center;
}
.back-btn svg { width: 24px; height: 24px; }
.logo { display: flex; align-items: center; gap: 8px; flex: 1; }
.logo-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px; letter-spacing: .5px;
}
.logo-mark-img { width: 34px; height: 34px; border-radius: 9px; object-fit: cover; display: block; flex-shrink: 0; }
.logo-text { display: flex; flex-direction: column; line-height: 1.15; }
.logo-name { font-size: 16px; font-weight: 800; display: flex; align-items: center; gap: 5px; }
.ai-tag {
  font-size: 9px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, var(--red), var(--red-2));
  padding: 2px 6px; border-radius: 5px;
}
.logo-sub { font-size: 9px; color: var(--muted); }
.history-btn { font-size: 12px; gap: 4px; }
.history-btn svg { width: 16px; height: 16px; }

/* ===== Welcome ===== */
.welcome {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  padding: 10px 20px 16px; text-align: center;
  display: flex; flex-direction: column; align-items: center;
}
.robot-wrap { position: relative; width: 200px; height: 200px; margin: 6px 0 4px; }
.robot-ring {
  position: absolute; inset: 8px; border-radius: 50%;
  border: 2px solid rgba(224,24,45,.7);
  box-shadow: 0 0 30px rgba(224,24,45,.5), inset 0 0 30px rgba(224,24,45,.3);
}
.robot-img {
  position: absolute; inset: 22px; width: calc(100% - 44px); height: calc(100% - 44px);
  object-fit: contain; border-radius: 50%;
}
.welcome-title { font-size: 22px; font-weight: 800; margin-top: 8px; line-height: 1.3; }
.welcome-title .accent { color: var(--red-2); }
.welcome-desc { font-size: 13px; color: var(--muted); margin-top: 10px; line-height: 1.5; max-width: 320px; }

.quick-list { width: 100%; display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }
.quick-card {
  display: flex; align-items: center; gap: 12px; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px; text-align: left; color: var(--text);
}
.quick-card:active { transform: scale(.985); }
.qc-ic { width: 40px; height: 40px; border-radius: 11px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.qc-ic svg { width: 22px; height: 22px; }
.qc-ic.red { background: rgba(224,24,45,.15); color: var(--red-2); }
.qc-ic.gold { background: rgba(245,196,81,.15); color: var(--gold); }
.qc-ic.blue { background: rgba(59,130,246,.15); color: var(--blue); }
.qc-ic.green { background: rgba(46,204,113,.15); color: var(--green); }
.qc-text { flex: 1; display: flex; flex-direction: column; }
.qc-text b { font-size: 14px; }
.qc-text small { font-size: 11px; color: var(--muted); margin-top: 2px; }
.qc-chev { width: 18px; height: 18px; color: var(--muted); flex-shrink: 0; }

/* ===== Chat ===== */
.chat { flex: 1; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 14px; }
.day-divider { text-align: center; margin-bottom: 14px; }
.day-divider span { font-size: 11px; color: var(--muted); background: rgba(255,255,255,.05); padding: 4px 12px; border-radius: 10px; }
.messages { display: flex; flex-direction: column; gap: 14px; }

.msg { display: flex; gap: 8px; max-width: 85%; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg.bot { align-self: flex-start; }
.bot-ava {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  object-fit: cover; border: 1px solid var(--line); background: #1c1c1c;
}
.bubble {
  border-radius: 16px; padding: 11px 13px; font-size: 13.5px; line-height: 1.5;
  position: relative; word-wrap: break-word;
}
.msg.user .bubble {
  background: linear-gradient(135deg, var(--red), var(--red-dark)); color: #fff;
  border-bottom-right-radius: 5px;
}
.msg.bot .bubble {
  background: var(--card); border: 1px solid var(--line); color: #ededed;
  border-bottom-left-radius: 5px;
}
.bubble b, .bubble strong { color: var(--gold); }
.msg-time { font-size: 10px; color: var(--muted); margin-top: 6px; display: flex; align-items: center; gap: 3px; }
.msg.user .msg-time { justify-content: flex-end; }
.msg-time .tick { width: 13px; height: 13px; color: #ff9aa6; }

/* nút copy trong câu trả lời AI */
.msg-actions { display: flex; gap: 8px; margin-top: 8px; }
.copy-btn {
  display: inline-flex; align-items: center; gap: 4px; cursor: pointer;
  background: rgba(255,255,255,.05); border: 1px solid var(--line);
  color: var(--muted); border-radius: 8px; padding: 4px 9px; font-size: 11px;
}
.copy-btn svg { width: 13px; height: 13px; }
.copy-btn.copied { color: var(--green); border-color: rgba(46,204,113,.5); }

/* file đính kèm trong câu trả lời */
.file-card {
  display: flex; align-items: center; gap: 10px; margin-top: 10px;
  background: rgba(255,255,255,.04); border: 1px solid var(--line);
  border-radius: 12px; padding: 8px; cursor: pointer;
}
.file-thumb { width: 42px; height: 42px; border-radius: 8px; object-fit: cover; }
.file-info { flex: 1; }
.file-name { font-size: 12px; font-weight: 600; }
.file-meta { font-size: 10px; color: var(--muted); margin-top: 2px; }
.file-dl {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--red), var(--red-dark)); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.file-dl svg { width: 16px; height: 16px; }

/* hiệu ứng đang gõ */
.typing { display: inline-flex; gap: 4px; align-items: center; padding: 4px 2px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite both; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }

/* ===== Input bar ===== */
.input-bar {
  flex-shrink: 0; display: flex; align-items: center; gap: 8px;
  padding: 10px 14px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: #0c0c0c;
}
#msgInput {
  flex: 1; background: var(--card); border: 1px solid var(--line);
  border-radius: 22px; padding: 12px 44px 12px 16px; color: var(--text);
  font-size: 13px; outline: none;
}
#msgInput::placeholder { color: var(--muted); }
.attach-btn {
  background: none; border: none; color: var(--muted); cursor: pointer;
  margin-left: -42px; padding: 4px; display: flex; z-index: 2;
}
.attach-btn svg { width: 20px; height: 20px; }
.send-btn {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--red), var(--red-dark)); border: none;
  color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(224,24,45,.45);
}
.send-btn:active { transform: scale(.94); }
.send-btn svg { width: 22px; height: 22px; }
.send-btn:disabled { opacity: .5; cursor: default; }
