/* Khoa Dev AI Lab — shared stylesheet for all demos */
:root {
  --bg: #070b15;
  --bg-glow: #0d1730;
  --panel: #0d1425;
  --panel-2: #111a30;
  --line: #1f2c4a;
  --line-2: #2a3a60;
  --text: #e9eefb;
  --muted: #8b9dc0;
  --muted-2: #63749b;
  --accent: #5ce1e6;
  --accent-2: #8b7cff;
  --good: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 14px;
  --font: 'Segoe UI', 'Inter', system-ui, -apple-system, Roboto, 'Helvetica Neue', sans-serif;
  --mono: 'Cascadia Mono', 'JetBrains Mono', Consolas, 'SF Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(139, 124, 255, 0.14), transparent 60%),
    radial-gradient(800px 500px at 5% 110%, rgba(92, 225, 230, 0.1), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 22px;
  height: 60px;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 16, 30, 0.75);
  backdrop-filter: blur(8px);
  flex: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.brand .logo {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid;
  place-items: center;
  color: #06101f;
  font-size: 13px;
  font-weight: 900;
}

.brand .sub {
  color: var(--muted);
  font-weight: 500;
  font-size: 13px;
}

.demo-title {
  font-size: 15px;
  font-weight: 650;
  margin-left: 6px;
  padding-left: 18px;
  border-left: 1px solid var(--line);
  white-space: nowrap;
}

.demo-title small {
  display: block;
  font-weight: 450;
  color: var(--muted);
  font-size: 12px;
}

.top-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.model-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  background: rgba(17, 26, 48, 0.6);
  white-space: nowrap;
}

.model-badge b { color: var(--accent); font-weight: 600; }

.pulse-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.5);
  animation: pulse 1.6s infinite;
}
.pulse-dot.ready { background: var(--good); animation: none; }
.pulse-dot.error { background: var(--bad); animation: none; }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.5); }
  70% { box-shadow: 0 0 0 8px rgba(251, 191, 36, 0); }
  100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0); }
}

/* ---------- workspace ---------- */
.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 16px;
  padding: 16px 22px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.workspace.wide-right { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
.workspace.wide-left  { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
.workspace.single     { grid-template-columns: minmax(0, 1fr); max-width: 1180px; margin: 0 auto; width: 100%; }

.panel {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  flex: none;
}

.panel-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--muted);
}

.panel-head .hint { margin-left: auto; font-size: 12px; color: var(--muted-2); }

.panel-body {
  flex: 1;
  min-height: 0;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
}

/* ---------- controls ---------- */
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.tight { gap: 6px; }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }

.btn {
  appearance: none;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
}

.btn:hover { border-color: var(--accent); background: #16213c; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, rgba(92, 225, 230, 0.9), rgba(139, 124, 255, 0.9));
  border: none;
  color: #06101f;
}
.btn-primary:hover { background: linear-gradient(135deg, #6cebf0, #998aff); }

.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }

.chip {
  border: 1px solid var(--line-2);
  background: rgba(17, 26, 48, 0.65);
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12.5px;
  font-weight: 550;
  cursor: pointer;
  transition: all 0.15s;
}

.chip:hover { color: var(--text); border-color: var(--line-2); }
.chip.active {
  color: #06101f;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  font-weight: 650;
}

label.field { font-size: 12.5px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
label.field b { color: var(--accent); font-family: var(--mono); font-weight: 600; }

input[type='range'] { accent-color: var(--accent); }

select, input[type='text'] {
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 10px;
  font: inherit;
  font-size: 13px;
}

/* ---------- dropzone & canvas ---------- */
.dropzone {
  border: 1.5px dashed var(--line-2);
  border-radius: 12px;
  padding: 18px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  cursor: pointer;
  transition: all 0.15s;
  background: rgba(17, 26, 48, 0.3);
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); color: var(--text); background: rgba(92, 225, 230, 0.05); }
.dropzone b { color: var(--accent); }

.thumbstrip { display: flex; gap: 8px; }
.thumbstrip .thumb {
  width: 74px; height: 52px;
  border-radius: 8px;
  border: 1.5px solid var(--line-2);
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  background: #000;
  flex: none;
  transition: border-color 0.15s, transform 0.1s;
}
.thumbstrip .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0.85; }
.thumbstrip .thumb:hover { transform: translateY(-2px); }
.thumbstrip .thumb.active { border-color: var(--accent); }
.thumbstrip .thumb.active img { opacity: 1; }

.canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  border-radius: 12px;
  background:
    linear-gradient(45deg, #0a0f1d 25%, transparent 25%, transparent 75%, #0a0f1d 75%),
    linear-gradient(45deg, #0a0f1d 25%, #0c1222 25%, #0c1222 75%, #0a0f1d 75%);
  background-size: 22px 22px;
  background-position: 0 0, 11px 11px;
  border: 1px solid var(--line);
  overflow: hidden;
  display: grid;
  place-items: center;
}

.canvas-wrap canvas { max-width: 100%; max-height: 100%; min-width: 0; min-height: 0; display: block; }
.canvas-wrap video { max-width: 100%; max-height: 100%; min-width: 0; min-height: 0; }

.canvas-wrap .placeholder {
  color: var(--muted-2);
  font-size: 14px;
  text-align: center;
  padding: 30px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.placeholder .big { font-size: 34px; }
.placeholder .dim { font-size: 12.5px; color: var(--muted-2); }

/* ---------- stats & results ---------- */
.statgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
  flex: none;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(17, 26, 48, 0.5);
  padding: 9px 12px;
}

.stat .k { font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted-2); }
.stat .v { font-family: var(--mono); font-size: 17px; font-weight: 600; color: var(--accent); margin-top: 2px; }
.stat .v.small { font-size: 13px; }
.stat .v.good { color: var(--good); }

.result-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  min-height: 0;
}

.result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(17, 26, 48, 0.45);
  padding: 9px 12px;
  font-size: 13.5px;
}

.result-item .idx {
  font-family: var(--mono);
  color: var(--muted-2);
  font-size: 11.5px;
  min-width: 24px;
}

.result-item .txt { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.result-item .score { font-family: var(--mono); font-size: 12px; color: var(--good); }
.result-item .swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }

.meter { height: 7px; border-radius: 999px; background: #101a30; overflow: hidden; border: 1px solid var(--line); }
.meter > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); width: 0%; transition: width 0.2s; }

/* ---------- status bar ---------- */
.statusbar {
  flex: none;
  height: 42px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 22px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  background: rgba(10, 16, 30, 0.8);
}

.statusbar .sep { width: 1px; height: 18px; background: var(--line); }
.statusbar b { color: var(--accent); font-weight: 600; }
.statusbar .grow { flex: 1; }

.progress-inline { display: flex; align-items: center; gap: 10px; min-width: 240px; }
.progress-inline .meter { flex: 1; }

/* ---------- misc ---------- */
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.small { font-size: 12px; }
.hidden { display: none !important; }

.note {
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  background: rgba(92, 225, 230, 0.06);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 12.5px;
  color: var(--muted);
}

.transcript {
  flex: 1;
  min-height: 130px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(10, 16, 30, 0.6);
  padding: 14px 16px;
  font-size: 16px;
  line-height: 1.65;
  overflow: auto;
  white-space: pre-wrap;
  color: var(--text);
}

.transcript[data-empty='1'] {
  display: grid;
  place-items: center;
  color: var(--muted-2);
  font-size: 14px;
}

/* ---------- chat ---------- */
.chat-log {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px;
}

.msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg .who {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--muted-2);
  margin-bottom: 4px;
  font-family: var(--mono);
}

.msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(92, 225, 230, 0.16), rgba(139, 124, 255, 0.2));
  border: 1px solid rgba(139, 124, 255, 0.42);
  border-bottom-right-radius: 4px;
}

.msg.assistant {
  align-self: flex-start;
  background: rgba(17, 26, 48, 0.72);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}

.msg.system {
  align-self: center;
  max-width: 92%;
  background: transparent;
  border: 1px dashed var(--line-2);
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
  padding: 7px 14px;
}

.chat-input {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.chat-input textarea {
  flex: 1;
  resize: none;
  min-height: 46px;
  max-height: 130px;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  color: var(--text);
  border-radius: 12px;
  padding: 11px 14px;
  font: inherit;
  font-size: 14px;
  line-height: 1.45;
}

.chat-input textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.typing::after {
  content: '▌';
  color: var(--accent);
  animation: blink 0.9s steps(1) infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* ---------- big reading display (7-segment demo) ---------- */
.reading-box {
  border: 1px solid var(--line-2);
  background: linear-gradient(135deg, rgba(92, 225, 230, 0.08), rgba(139, 124, 255, 0.1));
  border-radius: 12px;
  padding: 12px 16px;
  flex: none;
}

.reading-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--muted-2);
}

.reading {
  font-family: var(--mono);
  font-size: 40px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 3px;
  margin-top: 2px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

/* ---------- big count display (counter demo) ---------- */
.count-box {
  border: 1px solid var(--line-2);
  background: linear-gradient(135deg, rgba(92, 225, 230, 0.08), rgba(139, 124, 255, 0.1));
  border-radius: 12px;
  padding: 12px 16px;
  flex: none;
}

.count-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--muted-2);
}

.count-value {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-top: 2px;
}

.count-value span {
  font-family: var(--mono);
  font-size: 46px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
}

.count-value small {
  color: var(--muted);
  font-size: 14px;
}

/* ---------- document checker ---------- */
.verdict-box {
  display: flex;
  align-items: center;
  gap: 14px;
  border-radius: 12px;
  padding: 12px 16px;
  border: 1px solid var(--line-2);
  background: rgba(17, 26, 48, 0.5);
  flex: none;
}

.verdict-box.ok { border-color: rgba(74, 222, 128, 0.5); background: rgba(74, 222, 128, 0.08); }
.verdict-box.warn { border-color: rgba(251, 191, 36, 0.5); background: rgba(251, 191, 36, 0.08); }
.verdict-box.bad { border-color: rgba(248, 113, 113, 0.55); background: rgba(248, 113, 113, 0.1); }

.verdict-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 800;
  background: var(--panel-2);
  flex: none;
}

.verdict-box.ok .verdict-icon { color: #06101f; background: var(--good); }
.verdict-box.warn .verdict-icon { color: #06101f; background: var(--warn); }
.verdict-box.bad .verdict-icon { color: #fff; background: var(--bad); }
.verdict-title { font-size: 18px; font-weight: 800; letter-spacing: 0.5px; }
.verdict-box.ok .verdict-title { color: var(--good); }
.verdict-box.warn .verdict-title { color: var(--warn); }
.verdict-box.bad .verdict-title { color: var(--bad); }

.check-icon {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
  flex: none;
}

.check-icon.pass { background: rgba(74, 222, 128, 0.15); color: var(--good); border: 1px solid rgba(74, 222, 128, 0.4); }
.check-icon.warn { background: rgba(251, 191, 36, 0.15); color: var(--warn); border: 1px solid rgba(251, 191, 36, 0.4); }
.check-icon.fail { background: rgba(248, 113, 113, 0.15); color: var(--bad); border: 1px solid rgba(248, 113, 113, 0.45); }

/* ---------- visual search results grid ---------- */
.match-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 10px;
  overflow: auto;
  min-height: 0;
  align-content: start;
}

.match-tile {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(17, 26, 48, 0.45);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}

.match-tile:hover { border-color: var(--accent); transform: translateY(-2px); }
.match-tile img { width: 100%; height: 92px; object-fit: cover; display: block; }

.match-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px 4px;
  font-size: 11.5px;
}

.match-rank { font-family: var(--mono); color: var(--muted-2); }

.match-dup {
  background: rgba(251, 191, 36, 0.18);
  border: 1px solid rgba(251, 191, 36, 0.5);
  color: var(--warn);
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 10.5px;
}

.match-pct {
  margin-left: auto;
  font-family: var(--mono);
  color: var(--accent);
  font-weight: 600;
}

/* gallery strip (visual search) — thu nhỏ hơn thumbstrip thường */
.thumbstrip.gallery-row .thumb { width: 88px; height: 62px; }
.thumbstrip#gallery-strip .thumb { width: 88px; height: 62px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--muted); }
.legend .item { display: flex; align-items: center; gap: 6px; }
.legend .dot { width: 9px; height: 9px; border-radius: 50%; }

.tag {
  font-family: var(--mono);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(139, 124, 255, 0.14);
  border: 1px solid rgba(139, 124, 255, 0.35);
  color: #b9aeff;
}

/* spinner */
.spinner {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 3px solid rgba(92, 225, 230, 0.2);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #22304f; border-radius: 8px; border: 2px solid var(--panel); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- contact (statusbar) ---------- */
.statusbar .contact { color: var(--muted); white-space: nowrap; }
.statusbar .contact a { color: var(--accent); text-decoration: none; }
.statusbar .contact a:hover { text-decoration: underline; }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  html { height: auto; }
  body { overflow: auto; height: auto; min-height: 100vh; }
  .workspace,
  .workspace.wide-left,
  .workspace.wide-right {
    display: flex;
    flex-direction: column;
    padding: 12px;
    gap: 12px;
  }
  .workspace.single { max-width: none; }
  .panel { min-height: 0; }
  .panel-body { overflow: visible; }
  .canvas-wrap { min-height: 280px; max-height: 62vh; }
  .topbar {
    height: auto;
    flex-wrap: wrap;
    padding: 10px 14px;
    gap: 8px 12px;
  }
  .demo-title {
    border-left: none;
    padding-left: 0;
    margin-left: 0;
    width: 100%;
    white-space: normal;
    order: 3;
  }
  .demo-title small { font-size: 11.5px; }
  .top-right { margin-left: auto; }
  .model-badge { font-size: 11px; padding: 6px 10px; }
  .statusbar {
    height: auto;
    min-height: 40px;
    flex-wrap: wrap;
    padding: 7px 14px;
    gap: 6px 10px;
  }
  .statusbar .grow { display: none; }
  .statusbar .progress-inline { min-width: 0; flex: 1 1 200px; }
  .statgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .match-grid { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); }
  .result-item { flex-wrap: wrap; row-gap: 4px; }
  .count-value span, .reading { font-size: 34px; }
  .msg { max-width: 94%; }
  .transcript { font-size: 15px; }
}

@media (max-width: 560px) {
  .brand .sub { display: none; }
  .demo-title small { display: none; }
  .demo-title { font-size: 14px; }
  .thumbstrip .thumb { width: 62px; height: 46px; }
  .statusbar { font-size: 11px; }
  .statusbar .contact { white-space: normal; }
  .count-value span, .reading { font-size: 30px; }
  .btn { padding: 8px 12px; font-size: 12.5px; }
  .match-tile img { height: 78px; }
}
