/* Luyện nói AI role-play — kế thừa biến màu đỏ/trắng từ styles.css. */

.rp-body { background: linear-gradient(180deg, var(--cream) 0%, #fff 60%); min-height: 100vh; }
.btn.btn-sm { padding: 8px 16px; font-size: 13.5px; }

.rp-main { max-width: 980px; margin: 0 auto; padding: 0 20px; }

/* Screen switching */
.rp-screen { display: none; padding: 28px 0 60px; }
.rp-screen.active { display: block; }
/* Phòng chat chiếm trọn chiều cao để composer dính đáy */
#screenChat.active {
  display: flex; flex-direction: column;
  height: calc(100vh - 70px); padding: 0;
}

/* ---------- Màn 1: hero + lưới ngữ cảnh ---------- */
.rp-hero { text-align: center; max-width: 680px; margin: 18px auto 30px; }
.rp-hero h1 { font-size: clamp(26px, 4vw, 40px); margin: 14px 0 12px; }
.rp-hero h1 .hl { color: var(--brand); }
.rp-sub { font-size: 16px; color: #4a414f; }
.rp-sub b { color: var(--brand-700); }

.rp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 820px) { .rp-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .rp-grid { grid-template-columns: 1fr; } }

.rp-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 20px; box-shadow: var(--shadow-sm); cursor: pointer;
  transition: transform .18s ease, box-shadow .2s ease, border-color .2s; text-align: left;
}
.rp-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: #f4d9dd; }
.rp-card .rp-card-emoji { font-size: 38px; line-height: 1; }
.rp-card h3 { font-size: 19px; margin: 12px 0 2px; }
.rp-card .rp-card-zh { color: var(--brand); font-weight: 700; font-size: 15px; }
.rp-card .rp-card-desc { color: var(--muted); font-size: 14px; margin-top: 8px; }
.rp-card .rp-card-roles {
  margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line);
  font-size: 13px; color: #54495a; font-weight: 600;
}
.rp-card .rp-card-roles .vs { color: var(--brand); margin: 0 7px; }

/* ---------- Màn 2: chọn nhân vật ---------- */
.rp-back {
  background: #fff; border: 1px solid var(--line); color: var(--brand);
  border-radius: 999px; padding: 9px 18px; font-weight: 700; font-size: 14px;
  box-shadow: var(--shadow-sm); margin-bottom: 18px; transition: all .15s;
}
.rp-back:hover { border-color: var(--brand); background: var(--brand-50); }
.rp-rolehead { text-align: center; margin: 6px auto 26px; max-width: 600px; }
.rp-emoji { font-size: 54px; line-height: 1; }
.rp-rolehead h2 { font-size: 28px; margin: 10px 0 4px; }
.rp-rolehint { font-weight: 700; color: var(--brand-700); margin-top: 16px; }

.rp-roles { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; max-width: 640px; margin: 0 auto; }
@media (max-width: 520px) { .rp-roles { grid-template-columns: 1fr; } }
.rp-role-card {
  background: #fff; border: 2px solid var(--line); border-radius: var(--radius-lg);
  padding: 26px 22px; text-align: center; cursor: pointer;
  transition: transform .18s ease, box-shadow .2s, border-color .2s;
}
.rp-role-card:hover { transform: translateY(-4px); border-color: var(--brand); box-shadow: var(--shadow); }
.rp-role-card .rp-role-zh { font-size: 30px; font-weight: 800; color: var(--brand); }
.rp-role-card .rp-role-name { font-size: 16px; font-weight: 700; margin-top: 8px; }
.rp-role-card .rp-role-pick {
  display: inline-block; margin-top: 14px; font-size: 13px; font-weight: 700;
  color: var(--brand); background: var(--brand-50); padding: 6px 14px; border-radius: 999px;
}

/* ---------- Màn 3: chat ---------- */
.rp-chat-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 20px; background: #fff; border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.rp-back-icon { margin: 0; padding: 7px 14px; font-size: 16px; }
.rp-chat-title { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 160px; }
.rp-chat-emoji { font-size: 30px; line-height: 1; }
.rp-ct-main { font-weight: 800; font-size: 16px; }
.rp-ct-sub { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.rp-chat-toggles { display: flex; gap: 8px; }
.rp-toggle {
  background: #fff; border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 7px 13px; font-weight: 700; font-size: 12.5px; transition: all .15s;
}
.rp-toggle.active { background: var(--brand-50); color: var(--brand-700); border-color: #f0c9cf; }
.rp-toggle[disabled] { opacity: .4; cursor: not-allowed; }

.rp-messages {
  flex: 1; overflow-y: auto; padding: 22px 20px;
  display: flex; flex-direction: column; gap: 14px;
  background: linear-gradient(180deg, #fff 0%, var(--cream) 100%);
}
.rp-msg { max-width: 80%; display: flex; flex-direction: column; }
.rp-msg.ai { align-self: flex-start; align-items: flex-start; }
.rp-msg.user { align-self: flex-end; align-items: flex-end; }
.rp-who { font-size: 11.5px; font-weight: 700; color: var(--muted); margin: 0 6px 4px; }
.rp-bubble {
  border-radius: 16px; padding: 12px 16px; box-shadow: var(--shadow-sm); position: relative;
}
.rp-msg.ai .rp-bubble { background: #fff; border: 1px solid var(--line); border-top-left-radius: 5px; }
.rp-msg.user .rp-bubble { background: var(--brand); color: #fff; border-top-right-radius: 5px; }
.rp-zh { font-size: 20px; font-weight: 700; line-height: 1.45; }
.rp-msg.user .rp-zh { font-weight: 600; }
.rp-pinyin { font-size: 13px; color: var(--brand-700); margin-top: 5px; }
.rp-vi { font-size: 13.5px; color: var(--muted); font-style: italic; margin-top: 2px; }
/* Ẩn gợi ý khi tắt toggle */
.rp-messages.hide-helper .rp-pinyin,
.rp-messages.hide-helper .rp-vi { display: none; }
.rp-replay {
  background: none; border: none; color: var(--brand); font-size: 15px;
  margin-top: 6px; padding: 0; opacity: .8;
}
.rp-replay:hover { opacity: 1; }

/* typing dots */
.rp-typing .rp-bubble { padding: 14px 18px; }
.rp-typing .dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--brand); margin: 0 2px; opacity: .3; animation: rp-blink 1.3s infinite both;
}
.rp-typing .dot:nth-child(2) { animation-delay: .2s; }
.rp-typing .dot:nth-child(3) { animation-delay: .4s; }
@keyframes rp-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.rp-composer {
  display: flex; align-items: flex-end; gap: 10px;
  padding: 14px 20px; background: #fff; border-top: 1px solid var(--line);
}
.rp-mic {
  flex: none; width: 46px; height: 46px; border-radius: 50%;
  border: 1px solid var(--line); background: #fff; font-size: 20px;
  display: grid; place-items: center; transition: all .15s; box-shadow: var(--shadow-sm);
}
.rp-mic:hover { border-color: var(--brand); background: var(--brand-50); }
.rp-mic.listening { background: var(--brand); border-color: var(--brand); animation: rp-pulse 1s infinite; }
@keyframes rp-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(200,16,46,.4); } 50% { box-shadow: 0 0 0 8px rgba(200,16,46,0); } }
.rp-composer textarea {
  flex: 1; resize: none; border: 1.5px solid var(--line); border-radius: 14px;
  padding: 12px 14px; font-size: 17px; font-family: var(--font); line-height: 1.4;
  max-height: 120px; transition: border-color .15s, box-shadow .15s;
}
.rp-composer textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-50); }
.rp-send { flex: none; }

/* ---------- Màn 4: nhận xét ---------- */
.rp-fb-head { text-align: center; margin: 10px auto 22px; }
.rp-fb-badge {
  display: inline-block; background: var(--ok-bg); color: var(--ok);
  font-weight: 800; font-size: 13px; padding: 6px 16px; border-radius: 999px; margin-bottom: 12px;
}
.rp-fb-head h2 { font-size: 26px; }
.rp-fb-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); padding: 26px 28px; max-width: 680px; margin: 0 auto;
}
.rp-fb-overall { font-size: 16.5px; color: var(--ink); margin-bottom: 18px; line-height: 1.6; }
.rp-fb-section { margin-bottom: 18px; }
.rp-fb-section h3 { font-size: 16px; margin-bottom: 8px; }
.rp-fb-section.good h3 { color: var(--ok); }
.rp-fb-section.improve h3 { color: var(--brand-700); }
.rp-fb-list { list-style: none; margin: 0; padding: 0; }
.rp-fb-list li { padding: 7px 0 7px 28px; position: relative; font-size: 15px; color: #463c4c; line-height: 1.5; }
.rp-fb-section.good li::before { content: "✓"; position: absolute; left: 4px; color: var(--ok); font-weight: 800; }
.rp-fb-section.improve li::before { content: "•"; position: absolute; left: 8px; color: var(--brand); font-weight: 800; font-size: 18px; }
.rp-fb-encourage {
  margin-top: 8px; padding: 14px 18px; background: var(--brand-50);
  border-radius: var(--radius); font-weight: 600; color: var(--brand-700); text-align: center;
}
.rp-fb-actions { display: flex; gap: 12px; justify-content: center; margin-top: 24px; flex-wrap: wrap; }

/* loading mini */
.rp-loading { text-align: center; padding: 36px 20px; color: var(--muted); }
.rp-loading .spinner { width: 38px; height: 38px; border: 4px solid var(--brand-50); border-top-color: var(--brand); border-radius: 50%; margin: 0 auto 14px; animation: spin .8s linear infinite; }
