/* EDC Audicy lab — same "liquid glass" design system as the EDC Face Matching lab
   (face.edctech.vn/assets/css/style.css). Brand blue (#29AAE2) from the EDC logo. */

:root {
  --edc-blue:       #29AAE2;
  --edc-blue-dark:  #1C87BD;
  --edc-blue-light: #6FC6EE;

  --ink:      #16324A;
  --ink-soft: #4C6478;
  --ink-faint:#8098AC;

  --glass-bg:      rgba(255, 255, 255, 0.55);
  --glass-bg-soft: rgba(255, 255, 255, 0.38);
  --glass-border:  rgba(255, 255, 255, 0.6);
  --glass-shadow:  0 8px 32px rgba(22, 74, 116, 0.16);

  --ok-bg:   rgba(22, 163, 74, 0.14);
  --ok-fg:   #0f8a3f;
  --err-bg:  rgba(220, 38, 38, 0.12);
  --err-fg:  #c22222;
}

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

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  color: var(--ink);
  min-height: 100vh;
  padding: 40px 16px 64px;
  position: relative;
  overflow-x: hidden;
  background: linear-gradient(180deg, #eef8fd 0%, #f6fbfe 45%, #ffffff 100%);
  background-attachment: fixed;
}

/* Soft blurred colour blobs behind the glass cards */
body::before, body::after {
  content: "";
  position: fixed;
  border-radius: 50%;
  filter: blur(70px);
  z-index: -1;
  opacity: 0.55;
}
body::before {
  width: 480px; height: 480px;
  top: -160px; left: -140px;
  background: radial-gradient(circle, var(--edc-blue) 0%, transparent 70%);
}
body::after {
  width: 560px; height: 560px;
  bottom: -220px; right: -180px;
  background: radial-gradient(circle, var(--edc-blue-light) 0%, transparent 70%);
}

.container { max-width: 960px; margin: 0 auto; position: relative; }

/* ── Header / brand ─────────────────────────────────────────────────────── */
.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
.brand-logo { height: 34px; width: auto; display: block; }
.brand-title h1 { font-size: 1.35rem; font-weight: 700; color: var(--ink); letter-spacing: -0.01em; }

/* ── Tabs ────────────────────────────────────────────────────────────────── */
.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 20px;
  background: var(--glass-bg-soft);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  box-shadow: var(--glass-shadow);
  max-width: 100%;
  overflow-x: auto;
}
.tab {
  padding: 8px 18px;
  border-radius: 999px;
  font-size: .88rem;
  font-weight: 600;
  color: var(--ink-soft);
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.tab:hover  { color: var(--edc-blue-dark); background: rgba(41,170,226,0.08); }
.tab.active { color: #fff; background: linear-gradient(180deg, var(--edc-blue-light) 0%, var(--edc-blue) 60%, var(--edc-blue-dark) 100%); }

/* ── Glass card ──────────────────────────────────────────────────────────── */
.card {
  background: var(--glass-bg);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  box-shadow: var(--glass-shadow);
  padding: 24px;
  margin-bottom: 20px;
  position: relative;
}
/* Subtle top-edge specular highlight */
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 20px;
  padding: 1px;
  background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(255,255,255,0));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}
.card-title {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-soft);
  margin-bottom: 16px;
}
.result-card { margin-top: 20px; }

/* ── Form controls ───────────────────────────────────────────────────────── */
label { display: block; font-size: .85rem; color: var(--ink-soft); margin-bottom: 6px; }
label .req { color: var(--err-fg); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }
.form-field { display: flex; flex-direction: column; min-width: 0; }
.form-field.wide { grid-column: 1 / -1; }

select, textarea {
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid rgba(41,170,226,0.3);
  background: rgba(255,255,255,0.7);
  font: inherit; font-size: .9rem; color: var(--ink);
  min-width: 0;
}
textarea { resize: vertical; min-height: 130px; line-height: 1.55; }
select:focus, textarea:focus { outline: none; border-color: var(--edc-blue); box-shadow: 0 0 0 3px rgba(41,170,226,0.18); }
select:disabled { opacity: .6; }

/* ── Upload / drop zone ─────────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed rgba(41,170,226,0.35);
  background: var(--glass-bg-soft);
  border-radius: 16px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s, transform .15s;
  position: relative;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.drop-zone:hover     { border-color: var(--edc-blue); background: rgba(41,170,226,0.08); }
.drop-zone.drag-over { border-color: var(--edc-blue); background: rgba(41,170,226,0.14); transform: scale(1.01); }
.drop-zone.has-file  { border-style: solid; border-color: var(--edc-blue); }
.drop-zone input[type=file] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
.drop-zone .icon  { font-size: 2rem; }
.drop-zone .label { font-size: .85rem; color: var(--ink-faint); overflow-wrap: anywhere; }
.drop-zone.has-file .label { color: var(--ink); font-weight: 600; }
.drop-zone .badge {
  font-size: .75rem;
  background: rgba(41,170,226,0.15);
  color: var(--edc-blue-dark);
  padding: 2px 10px;
  border-radius: 20px;
  font-weight: 600;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: linear-gradient(180deg, var(--edc-blue-light) 0%, var(--edc-blue) 55%, var(--edc-blue-dark) 100%);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 13px 30px;
  font-size: .95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(41,170,226,0.4), inset 0 1px 0 rgba(255,255,255,0.5);
  transition: transform .15s, box-shadow .15s, opacity .15s;
}
.btn:hover:not(:disabled)  { transform: translateY(-1px); box-shadow: 0 10px 26px rgba(41,170,226,0.48), inset 0 1px 0 rgba(255,255,255,0.5); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn .spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: none;
}
.btn.loading .spinner  { display: block; }
.btn.loading .btn-text { opacity: .8; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Micro đang thu: nút chuyển sang đỏ và có chấm nhấp nháy */
.btn.recording {
  background: linear-gradient(180deg, #ef6b6b 0%, #dc2626 55%, #b91c1c 100%);
  box-shadow: 0 6px 20px rgba(220,38,38,0.35), inset 0 1px 0 rgba(255,255,255,0.5);
}
.btn .rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #fff; display: none; animation: pulse 1.2s ease-in-out infinite; }
.btn.recording .rec-dot { display: block; }
@keyframes pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .btn .rec-dot, .btn .spinner { animation-duration: 3s; } }

.action-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

/* ── Result ──────────────────────────────────────────────────────────────── */
.fields-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.field-item {
  background: rgba(255,255,255,0.55);
  border: 1px solid rgba(41,170,226,0.12);
  border-radius: 12px;
  padding: 12px 14px;
}
.field-key { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); margin-bottom: 4px; }
.field-val { font-size: .95rem; color: var(--ink); overflow-wrap: anywhere; }

.status-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 14px; border-radius: 20px; font-size: .8rem; font-weight: 700;
  margin-bottom: 16px;
}
.status-badge.ok   { background: var(--ok-bg);  color: var(--ok-fg); }
.status-badge.err  { background: var(--err-bg); color: var(--err-fg); }
.status-badge.info { background: rgba(41,170,226,0.15); color: var(--edc-blue-dark); }
.status-badge.inline { margin-bottom: 0; }

.result-text {
  background: rgba(255,255,255,0.55);
  border: 1px solid rgba(41,170,226,0.12);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 1.05rem;
  line-height: 1.6;
  margin-bottom: 14px;
  overflow-wrap: anywhere;
}

.raw-toggle {
  display: block;
  font-size: .8rem; color: var(--edc-blue-dark); cursor: pointer;
  background: none; border: none; padding: 0; margin-top: 16px;
  font-family: inherit;
  text-decoration: underline;
}
pre.raw {
  display: none;
  background: rgba(22,50,74,0.92);
  border: 1px solid rgba(41,170,226,0.25);
  border-radius: 12px; padding: 14px;
  font-family: Consolas, 'Cascadia Mono', monospace;
  font-size: .78rem; color: #cfe9f7;
  overflow-x: auto; margin-top: 8px;
  max-height: 400px;
}
pre.raw.show { display: block; }

.error-box {
  background: var(--err-bg); border: 1px solid rgba(220,38,38,0.25);
  border-radius: 14px; padding: 14px;
  color: var(--err-fg); font-size: .9rem;
  margin-bottom: 20px;
  overflow-wrap: anywhere;
}

.muted { color: var(--ink-faint); font-size: .88rem; }
.hint  { color: var(--ink-faint); font-size: .8rem; margin-top: 10px; }

.pill {
  display: inline-block;
  font-size: .72rem; font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.pill.on   { background: var(--ok-bg); color: var(--ok-fg); }
.pill.off  { background: var(--err-bg); color: var(--err-fg); }
.pill.warn { background: rgba(217,119,6,0.14); color: #b45309; }
.pill.info { background: rgba(41,170,226,0.15); color: var(--edc-blue-dark); }

/* ── Danh sách câu (stream + file audio) ─────────────────────────────────── */
.partial-line {
  min-height: 1.6em;
  margin-bottom: 12px;
  color: var(--ink-faint);
  font-style: italic;
  overflow-wrap: anywhere;
}
.segment-list { display: grid; gap: 10px; }
.segment {
  background: rgba(255,255,255,0.55);
  border: 1px solid rgba(41,170,226,0.12);
  border-radius: 12px;
  padding: 12px 14px;
  min-width: 0;
}
.segment-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; font-size: .75rem; color: var(--ink-faint); }
.segment-time { font-variant-numeric: tabular-nums; }
.segment-text { font-size: .98rem; line-height: 1.55; overflow-wrap: anywhere; }
.segment-translation { margin-top: 6px; padding-top: 6px; border-top: 1px dashed rgba(41,170,226,0.2); color: var(--edc-blue-dark); line-height: 1.55; overflow-wrap: anywhere; }
.segment-translation:empty { display: none; }

/* ── Trang trạng thái ────────────────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.stat-tile {
  background: rgba(255,255,255,0.55);
  border: 1px solid rgba(41,170,226,0.14);
  border-radius: 14px;
  padding: 12px 14px;
}
.stat-label  { font-size: .78rem; color: var(--ink-soft); font-weight: 600; }
.stat-value  { font-size: 1.6rem; font-weight: 700; margin: 2px 0; font-variant-numeric: tabular-nums; }
.stat-detail { font-size: .75rem; color: var(--ink-faint); line-height: 1.5; }
.provider-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* ── Thanh tiến độ ───────────────────────────────────────────────────────── */
.progress-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: .88rem; margin-bottom: 8px; }
.progress-percent { font-weight: 700; color: var(--edc-blue-dark); font-variant-numeric: tabular-nums; }
.progress { height: 8px; border-radius: 999px; background: rgba(41,170,226,0.15); overflow: hidden; }
.progress-bar { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--edc-blue-light), var(--edc-blue)); transition: width .3s; }
/* Chưa biết còn bao lâu: một đoạn ngắn chạy qua lại */
.progress.indeterminate .progress-bar { width: 35%; transition: none; animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(290%); } }
@media (prefers-reduced-motion: reduce) { .progress.indeterminate .progress-bar { animation-duration: 6s; } }

.segment-error { margin-top: 6px; font-size: .82rem; color: var(--err-fg); }
.segment-error:empty { display: none; }
