/* styles.css - Giao diện Hán Ngữ Thông AI Chinese Speaking & Grammar Tutor */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Noto+Serif+SC:wght@500;700;900&display=swap');

:root {
  --primary: #e11d48;
  --primary-dark: #be123c;
  --primary-light: #ffe4e6;
  --gold: #d97706;
  --gold-light: #fef3c7;
  --emerald: #059669;
  --emerald-light: #d1fae5;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-focus: #f43f5e;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 6px 16px -2px rgba(0,0,0,0.08);
  --shadow-lg: 0 15px 35px -5px rgba(225,29,72,0.12);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-han: 'Noto Serif SC', 'Songti SC', 'SimSun', serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-ui);
  background: var(--bg-main);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.han-text {
  font-family: var(--font-han);
}

/* Header & Navigation Bar */
.app-header {
  background: linear-gradient(135deg, #881337 0%, #be123c 50%, #e11d48 100%);
  color: #ffffff;
  padding: 16px 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(190, 18, 60, 0.25);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo-icon {
  width: 44px;
  height: 44px;
  background: #ffffff;
  color: var(--primary);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-family: var(--font-han);
  font-weight: 900;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

.brand-text h1 {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-text p {
  font-size: 12px;
  opacity: 0.9;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.persona-select, .speed-select {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #ffffff;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: all 0.2s;
}

.persona-select option, .speed-select option {
  background: #ffffff;
  color: var(--text-main);
}

.persona-select:hover, .speed-select:hover {
  background: rgba(255, 255, 255, 0.25);
}

.btn-header-icon {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #ffffff;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-header-icon:hover {
  background: #ffffff;
  color: var(--primary);
}

/* Tabs Bar */
.nav-tabs-bar {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 76px;
  z-index: 90;
  box-shadow: 0 2px 6px rgba(0,0,0,0.03);
}

.nav-tabs-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  overflow-x: auto;
}

.nav-tab-btn {
  padding: 14px 20px;
  border: none;
  background: none;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: all 0.2s;
}

.nav-tab-btn:hover {
  color: var(--primary);
  background: rgba(225, 29, 72, 0.03);
}

.nav-tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: rgba(225, 29, 72, 0.05);
}

/* Main Container */
.main-wrapper {
  max-width: 1200px;
  width: 100%;
  margin: 20px auto 40px auto;
  padding: 0 16px;
  flex: 1;
}

.tab-pane {
  display: none;
  animation: fadeIn 0.25s ease-out;
}

.tab-pane.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Cards & Layout */
.card-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 22px;
  margin-bottom: 20px;
  transition: box-shadow 0.2s;
}

.card-box:hover {
  box-shadow: var(--shadow-md);
}

.card-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

.card-title-row h2, .card-title-row h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Chat Container */
.chat-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  min-height: 600px;
}

@media (max-width: 860px) {
  .chat-layout {
    grid-template-columns: 1fr;
  }
}

/* Scenario Sidebar */
.scenario-sidebar {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.scenario-btn {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fafaf9;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.scenario-btn:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.scenario-btn.active {
  border-color: var(--primary);
  background: #fff1f2;
  box-shadow: 0 2px 8px rgba(225, 29, 72, 0.12);
}

.scenario-btn-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-main);
}

.scenario-btn.active .scenario-btn-title {
  color: var(--primary);
}

.scenario-btn-desc {
  font-size: 11.5px;
  color: var(--text-muted);
}

/* Chat Main Window */
.chat-window {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.chat-messages-area {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  max-height: 520px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: #fbfbfc;
}

.message-item {
  display: flex;
  gap: 12px;
  max-width: 85%;
  animation: messageSlideIn 0.2s ease-out;
}

@keyframes messageSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.message-item.user {
  margin-left: auto;
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.message-item.user .msg-avatar {
  background: #0284c7;
}

.msg-bubble {
  padding: 14px 18px;
  border-radius: 16px;
  background: #ffffff;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  position: relative;
}

.message-item.user .msg-bubble {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
}

.msg-han {
  font-family: var(--font-han);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.5;
  margin-bottom: 4px;
}

.msg-pinyin {
  font-size: 13.5px;
  color: #b91c1c;
  font-weight: 600;
  margin-bottom: 6px;
}

.message-item.user .msg-pinyin {
  color: #e0f2fe;
}

.msg-vi {
  font-size: 13px;
  color: var(--text-muted);
  border-top: 1px dashed var(--border);
  padding-top: 6px;
  margin-top: 6px;
}

.message-item.user .msg-vi {
  color: #f0f9ff;
  border-top-color: rgba(255,255,255,0.3);
}

.msg-coaching {
  font-size: 12px;
  background: #fef3c7;
  color: #92400e;
  padding: 6px 10px;
  border-radius: 6px;
  margin-top: 8px;
  border-left: 3px solid var(--gold);
}

.msg-play-btn {
  background: rgba(225, 29, 72, 0.08);
  border: 1px solid rgba(225, 29, 72, 0.2);
  color: var(--primary);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-top: 6px;
  transition: all 0.2s;
}

.msg-play-btn:hover {
  background: var(--primary);
  color: #ffffff;
  transform: scale(1.08);
}

/* Chat Input Bar */
.chat-input-bar {
  padding: 14px 18px;
  background: #ffffff;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-text-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 14.5px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
}

.chat-text-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.12);
}

.btn-mic-pulse {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e11d48, #be123c);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 14px rgba(225, 29, 72, 0.35);
  transition: all 0.2s;
  flex-shrink: 0;
  position: relative;
}

.btn-mic-pulse:hover {
  transform: scale(1.06);
}

.btn-mic-pulse.recording {
  background: #dc2626;
  animation: pulseRecording 1.4s infinite;
}

@keyframes pulseRecording {
  0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.6); }
  70% { box-shadow: 0 0 0 16px rgba(220, 38, 38, 0); }
  100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

.btn-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--text-main);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.btn-send:hover {
  background: var(--primary);
}

/* Pronunciation Tab */
.pronounce-card {
  background: linear-gradient(145deg, #ffffff, #fafafa);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  text-align: center;
  position: relative;
}

.pronounce-han {
  font-family: var(--font-han);
  font-size: 34px;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 8px;
}

.pronounce-pinyin {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 6px;
}

.pronounce-ipa {
  font-size: 14px;
  color: var(--text-muted);
  font-family: monospace;
  margin-bottom: 12px;
}

.pronounce-vi {
  font-size: 15px;
  color: #475569;
  background: #f1f5f9;
  display: inline-block;
  padding: 4px 16px;
  border-radius: var(--radius-full);
  margin-bottom: 20px;
}

.pronounce-controls {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.btn-action {
  padding: 10px 22px;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}

.btn-primary-action {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(225, 29, 72, 0.25);
}

.btn-primary-action:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
}

.btn-secondary-action {
  background: #ffffff;
  border: 1px solid var(--border);
  color: var(--text-main);
}

.btn-secondary-action:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* Assessment Results */
.assessment-box {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-top: 20px;
}

.score-badge-huge {
  font-size: 48px;
  font-weight: 900;
  color: var(--primary);
  line-height: 1;
}

.syllables-flex {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 18px 0;
}

.syllable-card {
  padding: 12px 14px;
  border-radius: 12px;
  text-align: center;
  min-width: 90px;
  border: 2px solid var(--border);
  background: #fafaf9;
}

.syllable-card.perfect {
  border-color: #22c55e;
  background: #f0fdf4;
}

.syllable-card.warning {
  border-color: #f59e0b;
  background: #fffbeb;
}

.syllable-card.wrong {
  border-color: #ef4444;
  background: #fef2f2;
}

.syl-char {
  font-family: var(--font-han);
  font-size: 22px;
  font-weight: 700;
}

.syl-target {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
}

.syl-spoken {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* 4 Tones Diagram */
.tone-diagram-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.tone-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  transition: transform 0.2s;
}

.tone-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
}

.tone-num-pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 8px;
}

.tone-card.t1 .tone-num-pill { background: #dbeafe; color: #1e40af; }
.tone-card.t2 .tone-num-pill { background: #dcfce7; color: #15803d; }
.tone-card.t3 .tone-num-pill { background: #fef3c7; color: #92400e; }
.tone-card.t4 .tone-num-pill { background: #fee2e2; color: #b91c1c; }

/* Exercise Solver Tab */
.solver-input-box {
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  resize: vertical;
  min-height: 110px;
  transition: border-color 0.2s;
}

.solver-input-box:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.12);
}

.solution-output-area {
  background: #fafaf9;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-top: 20px;
  line-height: 1.8;
  font-size: 15px;
}

.solution-output-area h3 {
  color: var(--primary);
  margin: 14px 0 8px 0;
  font-size: 17px;
}

.solution-output-area strong {
  color: #1e293b;
}

/* Modal Window */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay.open {
  display: flex;
}

.modal-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 100%;
  padding: 28px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
  animation: modalScale 0.2s ease-out;
}

@keyframes modalScale {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13.5px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-main);
}

.form-group input, .form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  outline: none;
}

.form-group input:focus {
  border-color: var(--primary);
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 24px;
  font-size: 13px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: #ffffff;
  margin-top: auto;
}
