/* Công cụ tính giá bạc — CSS thuần, scoped .stc */
.stc {
  --stc-bg: #ffffff;
  --stc-bg-soft: #f8fafc;
  --stc-bg-result: linear-gradient(135deg, #f8fafc 0%, #eef2f7 100%);
  --stc-border: #e2e8f0;
  --stc-text: #0f172a;
  --stc-muted: #64748b;
  --stc-accent: #334155;
  --stc-accent-soft: #475569;
  --stc-buy: #dc2626;
  --stc-sell: #16a34a;
  --stc-radius: 12px;
  --stc-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
  --stc-gap: 1rem;
  box-sizing: border-box;
  color: var(--stc-text);
  font-family: "Be Vietnam Pro", "Segoe UI", system-ui, sans-serif;
  width: 100%;
}

.stc *,
.stc *::before,
.stc *::after {
  box-sizing: border-box;
}

.stc-wrap {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem;
}

.stc-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  align-items: start;
}

.stc-card {
  background: var(--stc-bg);
  border: 1px solid var(--stc-border);
  border-radius: var(--stc-radius);
  box-shadow: var(--stc-shadow);
  overflow: hidden;
}

.stc-card-head {
  padding: 1.25rem 1.25rem 0.75rem;
}

.stc-card-head h2,
.stc-card-head h3 {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.3;
  color: var(--stc-accent);
  font-weight: 700;
}

.stc-card-head p {
  margin: 0.4rem 0 0;
  color: var(--stc-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.stc-card-body {
  padding: 1rem 1.25rem 1.25rem;
}

.stc-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.stc-field label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--stc-accent);
}

.stc-field-hint {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  color: var(--stc-muted);
  line-height: 1.4;
}

.stc-select,
.stc-input {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--stc-border);
  border-radius: 8px;
  background: #fff;
  color: var(--stc-text);
  font-size: 0.95rem;
  appearance: none;
  -webkit-appearance: none;
}

.stc-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
}

.stc-select:focus,
.stc-input:focus {
  outline: 2px solid #94a3b8;
  outline-offset: 1px;
  border-color: #94a3b8;
}

.stc-weight-row {
  display: grid;
  grid-template-columns: 1fr minmax(6.5rem, 7.5rem);
  gap: 0;
}

.stc-weight-row .stc-input {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: 0;
}

.stc-weight-row .stc-select {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.stc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 2.85rem;
  margin-top: 1rem;
  padding: 0.7rem 1rem;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, #334155 0%, #1e293b 100%);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.stc-btn:hover {
  opacity: 0.95;
}

.stc-btn:active {
  transform: scale(0.99);
}

.stc-btn:focus-visible {
  outline: 2px solid #94a3b8;
  outline-offset: 2px;
}

.stc-error {
  display: none;
  margin-top: 0.75rem;
  padding: 0.7rem 0.85rem;
  border-radius: 8px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  font-size: 0.875rem;
}

.stc-error.is-visible {
  display: block;
}

.stc-result {
  margin-top: 1.25rem;
  padding: 1rem;
  border-radius: 10px;
  border: 1px solid var(--stc-border);
  background: var(--stc-bg-result);
}

.stc-result-title {
  margin: 0 0 0.85rem;
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  color: var(--stc-accent);
}

.stc-result-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.stc-result-item {
  background: #fff;
  border: 1px solid var(--stc-border);
  border-radius: 8px;
  padding: 0.9rem;
}

.stc-result-item .stc-label {
  font-size: 0.8rem;
  color: var(--stc-muted);
  margin-bottom: 0.25rem;
}

.stc-result-item .stc-value {
  font-size: clamp(1.1rem, 3.5vw, 1.5rem);
  font-weight: 700;
  line-height: 1.25;
  word-break: break-word;
}

.stc-result-item.is-buy .stc-value {
  color: var(--stc-buy);
}

.stc-result-item.is-sell .stc-value {
  color: var(--stc-sell);
}

.stc-result-item.is-muted .stc-value {
  color: var(--stc-muted);
  font-size: 1.15rem;
}

.stc-convert {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.stc-convert > div {
  text-align: center;
  padding: 0.35rem 0.25rem;
}

.stc-convert strong {
  display: block;
  font-size: 0.95rem;
  color: var(--stc-text);
}

.stc-convert span {
  font-size: 0.72rem;
  color: var(--stc-muted);
}

.stc-meta {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--stc-border);
  font-size: 0.78rem;
  color: var(--stc-muted);
  line-height: 1.55;
}

.stc-meta p {
  margin: 0 0 0.35rem;
}

.stc-side-list {
  display: grid;
  gap: 0.65rem;
  padding: 0 1.25rem 1.25rem;
}

.stc-side-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.9rem;
  color: var(--stc-text);
}

.stc-side-row span:last-child {
  font-weight: 600;
  text-align: right;
  color: var(--stc-accent);
}

.stc-tip {
  margin: 0 1.25rem 1.25rem;
  padding: 0.85rem;
  border-radius: 8px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  font-size: 0.82rem;
  color: var(--stc-muted);
  line-height: 1.5;
}

.stc-tip strong {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--stc-accent);
}

.stc-live {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.5rem;
  font-size: 0.78rem;
  color: #047857;
  font-weight: 600;
}

.stc-live i {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: #10b981;
  display: inline-block;
  animation: stc-pulse 1.4s ease-in-out infinite;
}

@keyframes stc-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.stc-section {
  padding: 2rem 0 2.5rem;
  background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
}

.stc-section-head {
  text-align: center;
  margin-bottom: 1.5rem;
  padding: 0 1rem;
}

.stc-section-head h2 {
  margin: 0;
  font-size: clamp(1.4rem, 4vw, 2rem);
  color: #1e3a8a;
  font-weight: 800;
}

.stc-section-head p {
  margin: 0.5rem auto 0;
  max-width: 36rem;
  color: var(--stc-muted);
  font-size: 0.95rem;
  line-height: 1.55;
}

@media (min-width: 640px) {
  .stc-fields {
    grid-template-columns: 1fr 1fr;
  }

  .stc-result-grid {
    grid-template-columns: 1fr 1fr;
  }

  .stc-convert {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .stc-result-item.is-convert {
    grid-column: 1 / -1;
  }
}

@media (min-width: 900px) {
  .stc-grid {
    grid-template-columns: minmax(0, 1.7fr) minmax(260px, 0.9fr);
  }

  .stc-wrap {
    padding: 0 1.25rem;
  }
}

@media (max-width: 420px) {
  .stc-card-head,
  .stc-card-body,
  .stc-side-list,
  .stc-tip {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .stc-weight-row {
    grid-template-columns: 1fr minmax(5.75rem, 6.5rem);
  }

  .stc-btn {
    font-size: 0.9rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stc-live i {
    animation: none;
  }

  .stc-btn {
    transition: none;
  }
}
