/* tool-page.css — Trang công cụ chi tiết */

/* Form layout */
.tool-form {
  display: grid;
  gap: 1.25rem;
}

/* Input group */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}
.input-group label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--navy);
}
.input-group .input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.input-group input[type="number"],
.input-group input[type="text"],
.input-group select {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  font-size: 0.9375rem;
  color: var(--navy);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: #fff;
}
.input-group input:focus,
.input-group select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-100);
}
.input-unit {
  position: absolute;
  right: 0.75rem;
  font-size: 0.8125rem;
  color: #94a3b8;
  pointer-events: none;
}

/* Range slider */
.input-group input[type="range"] {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: #e2e8f0;
  outline: none;
  -webkit-appearance: none;
  margin-top: 0.25rem;
}
.input-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--brand);
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: #94a3b8;
  margin-top: 0.125rem;
}

/* Result card */
.result-card {
  background: linear-gradient(135deg, var(--navy) 0%, #1a4494 100%);
  border-radius: 1rem;
  padding: 1.5rem;
  color: #fff;
}
.result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.result-item:last-child {
  border-bottom: none;
}
.result-label {
  font-size: 0.875rem;
  color: rgba(255,255,255,0.75);
}
.result-value {
  font-size: 1.125rem;
  font-weight: 700;
}
.result-value.primary {
  font-size: 1.5rem;
  color: #40d8a0;
}

/* Recap row (1 dòng 1 thông số chuẩn hóa đơn tài chính) */
.recap-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.5rem;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.15s ease;
  gap: 0.75rem;
}
.recap-row:hover {
  background-color: #eff6ff;
}
.recap-row .recap-label {
  font-size: 0.8125rem;
  color: #64748b;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.recap-row .recap-val {
  font-size: 0.8125rem;
  color: var(--navy);
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}

/* Formula box */
.formula-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
  font-size: 0.875rem;
  color: #475569;
  line-height: 1.7;
}
.formula-box strong {
  color: var(--navy);
}

/* Related tools */
.related-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}
.related-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--navy);
  transition: all 0.15s;
  text-decoration: none;
}
.related-link:hover {
  border-color: var(--brand-200);
  color: var(--brand);
  transform: translateY(-1px);
}

/* Responsive */
@media (min-width: 768px) {
  .tool-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 2rem;
    align-items: start;
  }
}
@media (min-width: 1024px) {
  .tool-layout {
    grid-template-columns: 1fr 420px;
  }
}

/* ──────────────────────────────────────────
   New Feature Styles
   ────────────────────────────────────────── */

/* 1. Formatted number input */
.input-formatted {
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}
.input-formatted::-webkit-outer-spin-button,
.input-formatted::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* 2. Select dropdown */
.input-group select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.875rem center;
  background-size: 1rem 1rem;
  padding-right: 2.25rem;
  cursor: pointer;
}

/* 3. Radio group */
.radio-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.radio-option {
  position: relative;
  display: inline-flex;
  cursor: pointer;
  user-select: none;
}
.radio-option input[type="radio"],
.radio-option input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.radio-option span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 9999px;
  background-color: #fff;
  color: #334155;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s ease;
}
.radio-option:hover span {
  border-color: var(--brand-200);
}
.radio-option input:checked + span {
  background-color: var(--brand);
  border-color: var(--brand);
  color: #ffffff;
}

/* 4. Checkbox toggle */
.checkbox-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  cursor: pointer;
  user-select: none;
}
.checkbox-wrapper input[type="checkbox"],
.checkbox-wrapper input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  background-color: #cbd5e1;
  border-radius: 9999px;
  transition: background-color 0.2s ease;
  flex-shrink: 0;
}
.toggle-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background-color: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease;
}
.toggle-switch.active,
input:checked + .toggle-switch,
.checkbox-wrapper input:checked + .toggle-switch {
  background-color: var(--brand);
}
.toggle-switch.active::after,
input:checked + .toggle-switch::after,
.checkbox-wrapper input:checked + .toggle-switch::after {
  transform: translateX(20px);
}

/* 5. Breakdown table */
.breakdown-section {
  margin-top: 1.5rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  overflow: hidden;
  background: #ffffff;
}
.breakdown-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1rem;
  background-color: #f8fafc;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--navy);
  user-select: none;
  transition: background-color 0.15s ease;
}
.breakdown-toggle:hover {
  background-color: #f1f5f9;
}
.breakdown-toggle .chevron,
.breakdown-toggle .chevron-icon,
.breakdown-toggle svg {
  transition: transform 0.2s ease;
}
.breakdown-toggle.open .chevron,
.breakdown-toggle.open .chevron-icon,
.breakdown-toggle.open svg,
.breakdown-section.is-open .breakdown-toggle .chevron,
.breakdown-section.is-open .breakdown-toggle .chevron-icon,
.breakdown-section.is-open .breakdown-toggle svg {
  transform: rotate(180deg);
}
.breakdown-table-wrapper {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 400px;
}
.breakdown-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  text-align: left;
}
.breakdown-table th {
  position: sticky;
  top: 0;
  z-index: 10;
  background-color: #f8fafc;
  font-size: 0.875rem;
  font-weight: 600;
  text-align: left;
  color: var(--navy);
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}
.breakdown-table td {
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
  white-space: nowrap;
}
.breakdown-table tr:hover td {
  background-color: var(--brand-50);
}
.breakdown-table td.currency,
.breakdown-table th.currency {
  text-align: right;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.breakdown-summary,
.breakdown-table tr.breakdown-summary {
  font-size: 0.875rem;
  font-weight: 700;
  background-color: #f8fafc;
  border-top: 2px solid #e2e8f0;
}
.breakdown-summary td {
  font-weight: 700;
  color: var(--navy);
}

/* 6. Input validation */
.input-error,
.input-group.has-error input,
.input-group.has-error select {
  border-color: #f87171 !important;
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.25) !important;
}
.input-error-msg {
  font-size: 0.75rem;
  color: #ef4444;
  margin-top: 0.25rem;
}

/* 7. Result animation */
.result-value {
  transition: transform 0.2s ease, opacity 0.2s ease, color 0.2s ease;
}
.result-value.updating {
  opacity: 0.6;
  transform: scale(0.97);
}

/* 8. Chart card */
.chart-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 1rem;
  padding: 1rem 1.25rem;
  position: relative;
}
.chart-card canvas {
  max-height: 280px;
}
@media (max-width: 640px) {
  .chart-card canvas {
    max-height: 220px;
  }
}

/* 9. Print styles */
@media print {
  header, footer, .breakdown-toggle, nav[aria-label="Breadcrumb"],
  .mt-12.text-center, #related-section, .radio-group, input[type="range"],
  .range-labels, button { display: none !important; }
  body { background: #fff !important; }
  .tool-layout { display: block !important; }
  .result-card {
    background: #fff !important;
    color: #000 !important;
    border: 2px solid #10316B;
    break-inside: avoid;
  }
  .result-label { color: #333 !important; }
  .result-value { color: #10316B !important; }
  .result-value.primary { color: #0B60B0 !important; }
  .breakdown-table-wrapper { display: block !important; max-height: none !important; overflow: visible !important; }
  .breakdown-table { font-size: 0.75rem; }
  .chart-card { break-inside: avoid; border: 1px solid #ccc; }
}

/* 10. Keyboard focus ring */
.input-group input:focus-visible,
.input-group select:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  box-shadow: none;
}
.radio-option input:focus-visible + span {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* 11. Number counting animation */
@keyframes resultPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); }
}
.result-value.pulse {
  animation: resultPulse 0.25s ease;
}

/* 12. Input flash animation on recap click */
@keyframes fieldFlashHighlight {
  0% {
    box-shadow: 0 0 0 4px rgba(11, 96, 176, 0.45);
    border-color: var(--brand);
    background-color: #eff6ff;
  }
  100% {
    box-shadow: none;
    background-color: #fff;
  }
}
.field-highlight {
  animation: fieldFlashHighlight 1.5s ease-out;
}

/* ══════════ DARK MODE STYLES FOR TOOL PAGE ══════════ */
html.dark .recap-card {
  background-color: #1e293b;
  border-color: #334155;
}
html.dark .recap-row {
  border-bottom-color: #334155;
}
html.dark .recap-row:hover {
  background-color: #334155;
}
html.dark .recap-key {
  color: #94a3b8;
}
html.dark .recap-val {
  color: #f8fafc;
}
html.dark .input-wrapper input,
html.dark .input-wrapper select {
  background-color: #1e293b;
  border-color: #334155;
  color: #f8fafc;
}
html.dark .input-unit {
  color: #94a3b8;
}
html.dark .radio-option span {
  background-color: #1e293b;
  border-color: #334155;
  color: #cbd5e1;
}
html.dark .radio-option input:checked + span {
  background-color: var(--brand);
  border-color: var(--brand);
  color: #ffffff;
}
html.dark .chart-card {
  background-color: #1e293b;
  border-color: #334155;
}
html.dark .breakdown-card {
  background-color: #1e293b;
  border-color: #334155;
}
html.dark .breakdown-table th {
  background-color: #0f172a;
  color: #94a3b8;
  border-bottom-color: #334155;
}
html.dark .breakdown-table td {
  border-bottom-color: #334155;
  color: #e2e8f0;
}


