/* =========================================================
   PRI AI Assistant — frontend styles (matches reference)
   ========================================================= */
:root {
  --bg: #f2efe6;
  --panel: #ffffff;
  --green: #1f7a3d;
  --green-dark: #175f30;
  --green-soft: #e6f2e8;
  --green-hero1: #eaf3e2;
  --green-hero2: #dceccf;
  --text: #2b2b2b;
  --muted: #6b7280;
  --line: #e4e0d5;
  --sidebar: #ffffff;
  --chip-border: #cfe0cf;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(0, 0, 0, .05);
}

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

html, body { height: 100%; }

body {
  font-family: "Poppins", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.layout { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* ================= TOP HEADER ================= */
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 20px;
  background: var(--bg);
  flex-shrink: 0;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 260px; }
.emblem { width: 42px; height: 58px; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-l1, .brand-l2 { font-size: 11px; color: #4b4b4b; }
.brand-l3 { font-size: 14px; font-weight: 700; color: #1c1c1c; }
.brand-l4 { font-size: 13px; font-weight: 600; color: var(--green); }

.disclaimer {
  flex: 1;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: #f4f6ec;
  border: 1px solid #e5e8d8;
  border-radius: 12px;
  padding: 10px 16px;
  max-height: 70px;
  overflow: hidden;
}
.disc-icon { color: var(--green); font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.disclaimer p { font-size: 11.5px; color: #4a4a4a; line-height: 1.45; }
.disclaimer b { color: #333; }

.lang-switch { display: flex; gap: 8px; flex-shrink: 0; }
.lang-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: #333;
  transition: all .15s;
}
.lang-btn.active { background: var(--green); border-color: var(--green); color: #fff; }

/* ================= BODY ================= */
.body { display: flex; flex: 1; overflow: hidden; gap: 0; }

/* ================= SIDEBAR ================= */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  color: #333;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s;
}
.nav-item .nav-ic { font-size: 17px; width: 22px; text-align: center; }
.nav-item:hover { background: #f4f7f2; }
.nav-item.active { background: var(--green-soft); color: var(--green-dark); font-weight: 600; }

.promo-card {
  margin-top: 22px;
  border-radius: 14px;
  overflow: hidden;
}
.promo-img { width: 100%; display: block; }

.mitra {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 8px;
  border-top: 1px solid var(--line);
  position: relative;
}
.mitra-av { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.mitra-text { display: flex; flex-direction: column; line-height: 1.25; }
.mitra-name { font-size: 14px; font-weight: 700; color: #222; }
.mitra-sub { font-size: 12px; color: var(--muted); }
.mitra-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #22c55e; position: absolute; left: 40px; bottom: 16px;
  border: 2px solid #fff;
}

/* ================= MAIN ================= */
.main {
  flex: 1;
  overflow-y: auto;
  padding: 16px 22px 96px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.main.video-library-mode > section:not(#training-videos) {
  display: none;
}

.training-videos {
  display: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

.main.video-library-mode .training-videos {
  display: block;
}

.training-videos-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.training-videos-sub {
  margin: 6px 0 0 31px;
  color: var(--muted);
  font-size: 12px;
}

.training-videos-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.training-videos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.training-video-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcfa;
  box-shadow: var(--shadow);
}

.training-video-card video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #193d27;
}

.training-video-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  color: var(--green-dark);
  font-size: 12px;
}

.training-video-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.training-video-info strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.training-video-remove {
  align-self: center;
  flex-shrink: 0;
  padding: 5px 12px;
  border: 1px solid #e2b4b4;
  border-radius: 8px;
  background: #fff;
  color: #b3261e;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.training-video-remove:hover {
  background: #fbeaea;
  border-color: #d99;
}

.training-video-meta span {
  color: var(--muted);
  white-space: nowrap;
}

.training-videos-empty {
  grid-column: 1 / -1;
  padding: 44px 20px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  color: var(--muted);
  text-align: center;
}

/* Hero */
.hero {
  display: flex;
  align-items: stretch;
  background: linear-gradient(120deg, var(--green-hero1) 0%, var(--green-hero2) 100%);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 200px;
}
.hero-left { padding: 26px 28px; display: flex; flex-direction: column; justify-content: center; flex: 1; }
.hero-hi { font-size: 20px; color: #333; margin-bottom: 6px; }
.hero-title { font-size: 26px; font-weight: 700; color: var(--green-dark); line-height: 1.25; margin-bottom: 12px; max-width: 620px; }
.hero-desc { font-size: 13.5px; color: #4a4a4a; max-width: 560px; }
.hero-img { width: 46%; max-width: 640px; object-fit: cover; object-position: left center; }

/* Selectors */
.selectors {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 22px;
  display: flex;
  align-items: flex-start;
  gap: 20px;
  box-shadow: var(--shadow);
}
.sel-col { flex: 1; min-width: 0; }
.sel-divider { width: 1px; align-self: stretch; background: var(--line); }
.sel-head { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; color: #222; margin-bottom: 12px; }
.sel-ic { font-size: 16px; }
.sel-opt { color: var(--muted); font-weight: 500; font-size: 13px; }
.sel-help { font-size: 11.5px; color: #8a8f98; margin-top: 8px; }

.select-wrap { position: relative; }
.select-wrap::after {
  content: "\25BE";
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  color: #6b7280; pointer-events: none; font-size: 12px;
}
.select-wrap select {
  width: 100%;
  appearance: none;
  border: 1px solid #d8dbe0;
  border-radius: 10px;
  padding: 11px 34px 11px 14px;
  font-size: 13.5px;
  font-family: inherit;
  color: #333;
  background: #fff;
  cursor: pointer;
}
.select-wrap select:focus { outline: none; border-color: var(--green); }

.recent-wrap { display: flex; gap: 8px; align-items: center; }
.recent-wrap input {
  flex: 1;
  border: 1px solid #d8dbe0;
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 13.5px;
  font-family: inherit;
  background: #f7f8f9;
  color: #333;
}
.recent-wrap input:focus { outline: none; border-color: var(--green); background: #fff; }
.recent-edit {
  width: 42px; height: 42px;
  border: 1px solid #d8dbe0; border-radius: 10px;
  background: #fff; cursor: pointer; font-size: 16px; color: #555;
  flex-shrink: 0;
}
.recent-edit:hover { border-color: var(--green); color: var(--green); }

/* Answer card */
.answer-card {
  position: relative;
  background: var(--panel);
  border: 1px solid #dfe6dc;
  border-radius: var(--radius);
  padding: 20px 22px;
  display: flex;
  gap: 16px;
  box-shadow: var(--shadow);
}
.ans-avatar { width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0; object-fit: cover; }
.ans-body { flex: 1; min-width: 0; }
.ans-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.ans-title { font-size: 15px; font-weight: 700; color: var(--green-dark); margin-bottom: 8px; flex: 1; }
.listen-btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid #d8dbe0; background: #fff; border-radius: 10px;
  padding: 8px 14px; font-size: 13px; color: var(--green-dark);
  cursor: pointer; font-family: inherit; flex-shrink: 0; font-weight: 500;
}
.listen-btn:hover { background: var(--green-soft); }
.listen-btn.speaking { background: var(--green); color: #fff; border-color: var(--green); }

.ans-content { font-size: 13.5px; color: #3a3a3a; }
.ans-content p { margin: 0 0 12px; line-height: 1.62; }
.ans-content h3 { font-size: 16px; font-weight: 700; color: var(--green-dark); margin: 18px 0 8px; }
.ans-content h4 { font-size: 14.5px; font-weight: 700; color: #1c1c1c; margin: 16px 0 6px; }
.ans-content h2 { font-size: 17px; font-weight: 700; color: var(--green-dark); margin: 18px 0 10px; }
.ans-content ul, .ans-content ol { margin: 0 0 14px; padding-left: 22px; display: flex; flex-direction: column; gap: 7px; }
.ans-content li { line-height: 1.55; padding-left: 3px; }
.ans-content strong { color: #1c1c1c; }
.ans-content .context-intro { margin-bottom: 14px; }
.ans-content .answer { margin: 4px 0; }
.ans-content .source { margin-top: 16px; padding-top: 10px; border-top: 1px solid var(--line); color: #6b7280; font-size: 12.5px; }
.ans-content > :first-child { margin-top: 0; }
.ans-content > :last-child { margin-bottom: 0; }
.ans-placeholder {
  color: #9aa0a6; font-size: 13.5px; font-style: italic;
  padding: 14px 0; min-height: 40px;
}
.ans-steps-label { margin: 10px 0 4px; }
.ans-steps { padding-left: 22px; display: flex; flex-direction: column; gap: 4px; }
.ans-steps li { padding-left: 4px; }
.ans-note { margin-top: 10px; color: #555; }
.ans-content b { color: #222; }

.ans-actions { display: flex; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.act-btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid #d8dbe0; background: #fff; border-radius: 10px;
  padding: 9px 16px; font-size: 13px; color: #444; cursor: pointer;
  font-family: inherit; transition: all .15s;
}
.act-btn:hover { border-color: var(--green); color: var(--green-dark); background: var(--green-soft); }
.act-btn.active-up { border-color: var(--green); background: var(--green-soft); color: var(--green-dark); }
.act-btn.active-down { border-color: #d97a7a; background: #fbeaea; color: #b3423e; }

.ans-illus { width: 190px; align-self: center; object-fit: contain; flex-shrink: 0; }

.ans-loader {
  position: absolute; inset: 0; background: rgba(255,255,255,.7);
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius); z-index: 5;
}
.spinner {
  width: 38px; height: 38px; border: 4px solid #d7e6d7;
  border-top-color: var(--green); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Suggestions */
.suggestions {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
}
.sug-head { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; color: #333; margin-bottom: 14px; }
.sug-ic { font-size: 16px; }
.sug-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.chip {
  border: 1px solid var(--chip-border);
  background: #fff;
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 13px;
  color: #2f5d3a;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  line-height: 1.42;
  min-height: 44px;
  display: flex;
  align-items: center;
  transition: all .15s;
}
.chip:hover { background: var(--green-soft); border-color: var(--green); }
.chip-more { justify-content: center; text-align: center; color: #444; gap: 6px; }

/* Composer */
.composer {
  position: fixed;
  bottom: 0;
  left: 240px;
  right: 0;
  display: flex;
  gap: 12px;
  padding: 14px 22px;
  background: var(--bg);
  border-top: 1px solid var(--line);
  align-items: center;
}
.composer-input {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid #d8dbe0;
  border-radius: 12px;
  padding: 12px 16px;
}
.comp-ic { font-size: 16px; color: #8a8f98; }
.composer-input input {
  flex: 1; border: none; outline: none; font-size: 14px;
  font-family: inherit; background: transparent; color: #333;
}
.mic-btn {
  position: relative;
  border: none; background: transparent; cursor: pointer;
  font-size: 17px; line-height: 1; width: 36px; height: 36px; border-radius: 50%;
  color: #555; flex-shrink: 0; display: inline-flex;
  align-items: center; justify-content: center;
  transition: background .15s, color .15s, transform .12s;
}
.mic-btn:hover { background: #eef3ee; color: var(--green-dark); }
.mic-btn:active { transform: scale(.9); }
.mic-btn.listening {
  color: #fff; background: #d93b3b;
  animation: micbounce .9s ease-in-out infinite;
}
/* Expanding sound-wave rings while listening */
.mic-btn.listening::before,
.mic-btn.listening::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid rgba(217, 59, 59, .55);
  animation: micring 1.5s cubic-bezier(.2, .6, .3, 1) infinite;
  pointer-events: none;
}
.mic-btn.listening::after { animation-delay: .75s; }
@keyframes micring {
  0%   { transform: scale(1);   opacity: .7; }
  100% { transform: scale(2.4); opacity: 0; }
}
@keyframes micbounce {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.12); }
}
.send-btn {
  border: none; background: var(--green); color: #fff; cursor: pointer;
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  font-size: 15px; line-height: 1; display: inline-flex;
  align-items: center; justify-content: center; transition: background .15s;
}
.send-btn:hover { background: var(--green-dark); }
.comp-lang, .comp-about {  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid #d8dbe0; background: #fff; border-radius: 12px;
  padding: 12px 18px; font-size: 13.5px; color: #333; cursor: pointer;
  font-family: inherit; font-weight: 500; white-space: nowrap;
}
.comp-lang:hover, .comp-about:hover { border-color: var(--green); color: var(--green-dark); }
.comp-about span:first-child { color: var(--green); font-weight: 700; }

/* Stop generation button */
.comp-stop {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid #e0b4b4; background: #fff; color: #b3423e;
  border-radius: 12px; padding: 12px 18px; font-size: 13.5px;
  cursor: pointer; font-family: inherit; font-weight: 600; white-space: nowrap;
}
.comp-stop:hover { background: #fbeaea; border-color: #d97a7a; }
.stop-ic { width: 11px; height: 11px; background: #b3423e; border-radius: 2px; display: inline-block; }
.ans-stopped { color: #b3423e; font-style: italic; }

/* Toast */
.toast {
  position: fixed; bottom: 88px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #222; color: #fff; padding: 10px 20px; border-radius: 10px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.hidden { display: none !important; }

/* Thinking / streaming status */
.thinking { display: flex; align-items: center; gap: 12px; padding: 10px 2px; color: var(--green-dark); }
.think-text { font-size: 14px; font-weight: 500; }
.think-dots { display: inline-flex; gap: 5px; }
.think-dots i {
  width: 8px; height: 8px; border-radius: 50%; background: var(--green);
  display: inline-block; animation: bounce 1s infinite ease-in-out;
}
.think-dots i:nth-child(2) { animation-delay: .15s; }
.think-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce {
  0%, 80%, 100% { transform: scale(.5); opacity: .4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Info modal (Schemes / How to Use) */
.modal {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(20, 30, 20, .45);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal-card {
  background: #fff; border-radius: 16px;
  max-width: 640px; width: 100%; max-height: 82vh; overflow-y: auto;
  padding: 26px 28px; position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
.modal-close {
  position: absolute; top: 14px; right: 16px;
  border: none; background: none; font-size: 26px; line-height: 1;
  color: #888; cursor: pointer;
}
.modal-close:hover { color: #333; }
.modal-title {
  font-size: 20px; font-weight: 700; color: var(--green-dark);
  margin-bottom: 16px; padding-right: 30px;
}
.modal-body { font-size: 14px; color: #3a3a3a; }
.modal-list { padding-left: 20px; display: flex; flex-direction: column; gap: 10px; }
.modal-list li { line-height: 1.55; }
.modal-list b { color: #1c1c1c; }
.modal-note {
  margin-top: 16px; padding: 10px 14px; border-radius: 10px;
  background: var(--green-soft); color: var(--green-dark); font-size: 13px;
}

@media (max-width: 1100px) {
  .sug-grid { grid-template-columns: repeat(2, 1fr); }
  .hero-img { width: 40%; }
}
@media (max-width: 820px) {
  .sidebar { display: none; }
  .composer { left: 0; }
  .disclaimer { display: none; }
  .selectors { flex-direction: column; }
  .sel-divider { display: none; }
  .sug-grid { grid-template-columns: 1fr; }
}
