/* =====================================================================
   ASR Web App — style.css
   ===================================================================== */

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

:root {
  --bg:        #0f1117;
  --surface:   #1a1d27;
  --surface2:  #222636;
  --border:    #2e3248;
  --accent:    #6c7cff;
  --accent-h:  #8a97ff;
  --danger:    #ff5c6c;
  --success:   #3dd68c;
  --text:      #e2e4f0;
  --text-dim:  #7b80a0;
  --radius:    12px;
  --shadow:    0 4px 24px rgba(0,0,0,.45);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-size: 15px;
  min-height: 100vh;
  display: flex;
  align-items: stretch;
}

/* ── Layout ─────────────────────────────────────────────────────────── */
.container {
  display: flex;
  width: 100%;
  min-height: 100vh;
  gap: 0;
}

.panel {
  padding: 36px 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel-left {
  width: 380px;
  min-width: 320px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-right {
  flex: 1;
  background: var(--bg);
  overflow-y: auto;
}

h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: .02em;
  margin-bottom: 4px;
}

/* ── Upload Area ────────────────────────────────────────────────────── */
.upload-area {
  background: var(--surface2);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px 20px;
  cursor: pointer;
  text-align: center;
  transition: border-color .2s, background .2s;
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.upload-area:hover,
.upload-area.drag-over {
  border-color: var(--accent);
  background: #1e2138;
}

.upload-placeholder svg {
  color: var(--text-dim);
  margin-bottom: 10px;
}

.upload-placeholder p {
  color: var(--text-dim);
  font-size: .9rem;
  margin-bottom: 4px;
}

.upload-placeholder span {
  font-size: .78rem;
  color: #555c80;
}

.file-info {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent-h);
  font-size: .9rem;
  word-break: break-all;
}

.file-info svg { flex-shrink: 0; color: var(--accent); }

/* ── Record ─────────────────────────────────────────────────────────── */
.record-area {
  display: flex;
  align-items: center;
  gap: 14px;
}

.record-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .85rem;
  color: var(--danger);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  animation: blink 1s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ── Audio Preview ──────────────────────────────────────────────────── */
.audio-preview {
  width: 100%;
  height: 40px;
  filter: invert(1) hue-rotate(180deg) brightness(.85);
  border-radius: 8px;
}

/* ── Language Select ────────────────────────────────────────────────── */
.language-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.language-group label {
  font-size: .85rem;
  color: var(--text-dim);
}

select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: .9rem;
  padding: 10px 14px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='[w3.org](http://www.w3.org/2000/svg)' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237b80a0' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
  transition: border-color .2s;
}

select:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── Buttons ────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .2s, opacity .2s, transform .1s;
  padding: 11px 18px;
}

.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
  padding: 13px;
  font-size: 1rem;
  border-radius: var(--radius);
  margin-top: 4px;
}

.btn-primary:hover:not(:disabled) { background: var(--accent-h); }

.btn-primary:disabled {
  opacity: .4;
  cursor: not-allowed;
}

.btn-record {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.btn-record:hover { border-color: var(--accent); color: var(--accent); }

.btn-record.recording {
  background: rgba(255,92,108,.15);
  border-color: var(--danger);
  color: var(--danger);
}

/* ── Result Area ────────────────────────────────────────────────────── */
.result-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  height: 100%;
  min-height: 300px;
  color: var(--text-dim);
  text-align: center;
}

.result-placeholder svg { opacity: .3; }

.result-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Cards ──────────────────────────────────────────────────────────── */
.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.result-row {
  display: flex;
  gap: 16px;
}

.result-card.half { flex: 1; }

.card-label {
  font-size: .78rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 8px;
}

.card-value {
  font-size: 1rem;
  color: var(--text);
  font-weight: 500;
  line-height: 1.6;
  word-break: break-word;
}

.text-main {
  font-size: 1.15rem;
  line-height: 1.7;
}

.raw-text {
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: .82rem;
  color: var(--text-dim);
  word-break: break-all;
}

/* ── Emotion Colors ─────────────────────────────────────────────────── */
.emotion-happy    { color: #f9c74f; }
.emotion-sad      { color: #74b9ff; }
.emotion-angry    { color: var(--danger); }
.emotion-neutral  { color: var(--text); }
.emotion-fearful  { color: #a29bfe; }
.emotion-disgusted{ color: #55efc4; }
.emotion-surprised{ color: #fd79a8; }

/* ── Tags ───────────────────────────────────────────────────────────── */
.tag-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}

.tag {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 500;
}

.tag-event {
  background: rgba(108,124,255,.15);
  color: var(--accent-h);
  border: 1px solid rgba(108,124,255,.3);
}

.tag-unknown {
  background: rgba(255,92,108,.1);
  color: #ff8a94;
  border: 1px solid rgba(255,92,108,.25);
}

.tag-empty { color: var(--text-dim); }

/* ── Loading ────────────────────────────────────────────────────────── */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 200px;
  color: var(--text-dim);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Error ──────────────────────────────────────────────────────────── */
.error-msg {
  background: rgba(255,92,108,.1);
  border: 1px solid rgba(255,92,108,.3);
  border-radius: var(--radius);
  padding: 16px 20px;
  color: #ff8a94;
  font-size: .9rem;
  line-height: 1.6;
}

/* ── Utility ────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .container {
    flex-direction: column;
  }

  .panel-left {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .panel-right {
    min-height: 400px;
  }

  .result-row {
    flex-direction: column;
  }
}
