/* ============================================================
   thai_errors.css — Thai-Speaker Error Engine styles
   ============================================================ */

/* ── "NEW" nav badge variant ──────────────────────────── */
.nav-badge-new {
  background: linear-gradient(135deg, #F59E0B, #EF4444) !important;
  font-size: .62rem !important;
  letter-spacing: .5px;
  padding: 2px 8px !important;
  animation: te-nav-pulse 2.4s ease-in-out infinite;
}
@keyframes te-nav-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.5); }
  50% { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); }
}

/* ── Hero ─────────────────────────────────────────────────── */
.te-hero {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 24px;
  margin-bottom: 16px;
  background: linear-gradient(135deg, rgba(37,99,235,.08), rgba(124,58,237,.08));
  border-left: 4px solid var(--accent);
}
.te-hero-icon {
  font-size: 3rem;
  flex-shrink: 0;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,.15));
}
.te-hero-text h2 {
  margin: 0 0 6px;
  font-size: 1.4rem;
  background: var(--brand-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.te-hero-text p {
  margin: 0;
  color: var(--text2);
  font-size: .95rem;
}
.te-hero-text strong {
  color: var(--accent);
}

/* ── Tester card ─────────────────────────────────────────── */
.te-tester {
  padding: 24px;
  margin-bottom: 16px;
}
.te-tester-head {
  margin-bottom: 14px;
}
.te-tester-head h3 {
  margin: 0 0 4px;
  font-size: 1.1rem;
}
.te-tester-head small {
  color: var(--text2);
  font-size: .85rem;
}
.te-textarea {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: inherit;
  font-size: 1rem;
  resize: vertical;
  min-height: 80px;
  transition: border-color .2s;
}
.te-textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.te-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
  flex-wrap: wrap;
}
.te-btn-analyze, .te-btn-mic {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: 0;
  border-radius: 999px;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s;
  font-size: .95rem;
}
.te-btn-analyze {
  background: var(--brand-grad);
  color: #fff;
  box-shadow: 0 4px 12px rgba(37,99,235,.3);
}
.te-btn-analyze:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(37,99,235,.4);
}
.te-btn-analyze:disabled {
  opacity: .6;
  cursor: not-allowed;
}
.te-btn-mic {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.te-btn-mic:hover {
  background: var(--bg3);
}
.te-btn-mic.recording {
  background: #EF4444;
  color: #fff;
  animation: te-pulse 1s infinite;
}
@keyframes te-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,.5); }
  50% { box-shadow: 0 0 0 8px rgba(239,68,68,0); }
}
.te-count {
  margin-left: auto;
  font-size: .8rem;
  color: var(--text3);
}
.te-key-hint {
  margin-top: 12px;
  padding: 10px 14px;
  background: rgba(245,158,11,.1);
  border-left: 3px solid var(--warning);
  border-radius: var(--radius-sm);
  font-size: .85rem;
  color: var(--text2);
}
.te-spin {
  display: inline-block;
  animation: te-spin 1s linear infinite;
}
@keyframes te-spin {
  to { transform: rotate(360deg); }
}

/* ── Result ───────────────────────────────────────────────── */
.te-result-wrap {
  margin-top: 18px;
  padding: 16px;
  background: var(--surface2);
  border-radius: var(--radius);
}
.te-result-score {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
}
.te-score-num {
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1;
}
.te-score-label {
  font-size: .9rem;
  color: var(--text2);
}
.te-score-good { background: rgba(34,197,94,.12); }
.te-score-good .te-score-num { color: #22C55E; }
.te-score-mid { background: rgba(245,158,11,.12); }
.te-score-mid .te-score-num { color: #F59E0B; }
.te-score-low { background: rgba(239,68,68,.12); }
.te-score-low .te-score-num { color: #EF4444; }

.te-result-corrected {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 12px;
}
.te-result-label {
  font-size: .8rem;
  color: var(--text2);
  margin-bottom: 6px;
  font-weight: 600;
}
.te-result-text {
  font-size: 1.05rem;
  color: var(--text);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.te-result-summary {
  padding: 10px 14px;
  background: rgba(37,99,235,.08);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  font-size: .9rem;
  color: var(--text);
}

.te-issues-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.te-issue {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.te-issue-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.te-issue-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: .75rem;
  font-weight: 700;
}
.te-issue-cat {
  font-size: .75rem;
  padding: 3px 10px;
  background: var(--surface2);
  border-radius: 999px;
  color: var(--text2);
  font-weight: 600;
}
.te-issue-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: .95rem;
  flex-wrap: wrap;
}
.te-err-icon {
  flex-shrink: 0;
}
.te-err-wrong {
  color: #EF4444;
  text-decoration: line-through;
  text-decoration-color: rgba(239,68,68,.5);
}
.te-err-right {
  color: #22C55E;
  font-weight: 600;
}
.te-issue-explain {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: .88rem;
  color: var(--text2);
  line-height: 1.55;
}

.te-perfect {
  text-align: center;
  padding: 24px 16px;
}
.te-perfect-icon {
  font-size: 3rem;
  margin-bottom: 8px;
}
.te-perfect h4 {
  margin: 0 0 4px;
  color: #22C55E;
}
.te-perfect p {
  margin: 0;
  color: var(--text2);
}

.te-msg {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface2);
  font-size: .9rem;
}
.te-msg-warn {
  background: rgba(245,158,11,.1);
  border-left: 3px solid var(--warning);
}
.te-msg-error {
  background: rgba(239,68,68,.1);
  border-left: 3px solid var(--danger);
}
.te-link {
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

/* ── History ─────────────────────────────────────────────── */
.te-history {
  padding: 20px 24px;
  margin-bottom: 16px;
}
.te-history h3 {
  margin: 0 0 12px;
  font-size: 1rem;
}
.te-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.te-history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s;
}
.te-history-item:hover {
  background: var(--bg3);
}
.te-history-text {
  flex: 1;
  font-size: .9rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.te-history-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}
.te-score {
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .75rem;
}
.te-issues-count {
  font-size: .75rem;
  color: var(--text2);
}

/* ── Library (curated 25) ─────────────────────────────────── */
.te-library {
  padding: 24px;
}
.te-library h3 {
  margin: 0 0 4px;
  font-size: 1.1rem;
}
.te-library small {
  color: var(--text2);
  font-size: .85rem;
}
.te-categories {
  display: flex;
  gap: 8px;
  margin: 16px 0 18px;
  flex-wrap: wrap;
  overflow-x: auto;
  padding-bottom: 4px;
}
.te-cat {
  padding: 6px 14px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text2);
  border-radius: 999px;
  font-family: inherit;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.te-cat:hover {
  background: var(--bg3);
}
.te-cat.active {
  background: var(--brand-grad);
  color: #fff;
  border-color: transparent;
}

.te-error-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}
.te-err-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  position: relative;
  transition: transform .2s, box-shadow .2s;
}
.te-err-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0,0,0,.12);
}
.te-err-cat {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: .7rem;
  padding: 3px 10px;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  font-weight: 700;
}
.te-err-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 8px 0;
  font-size: .92rem;
  padding-right: 70px;
}
.te-err-row.te-err-wrong {
  padding-right: 70px;
}
.te-err-explain {
  margin-top: 10px;
  padding: 10px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: .82rem;
  color: var(--text2);
  line-height: 1.55;
}

/* ── Mobile ───────────────────────────────────────────────── */
@media (max-width: 640px) {
  .te-hero {
    flex-direction: column;
    text-align: center;
    gap: 12px;
  }
  .te-hero-text h2 {
    font-size: 1.2rem;
  }
  .te-actions {
    gap: 6px;
  }
  .te-btn-analyze, .te-btn-mic {
    padding: 8px 14px;
    font-size: .88rem;
  }
  .te-count {
    margin-left: 0;
    width: 100%;
    text-align: right;
  }
  .te-error-list {
    grid-template-columns: 1fr;
  }
  .te-err-cat {
    position: static;
    display: inline-block;
    margin-bottom: 6px;
  }
  .te-err-row, .te-err-row.te-err-wrong {
    padding-right: 0;
  }
}
