/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  font-weight: 600;
  transition: all var(--transition);
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--gray-200); }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-outline:hover { background: var(--primary-light); }

.btn-sm { padding: 6px 14px; font-size: 0.875rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-md);
}

/* Cards */
.card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-link {
  display: block;
  cursor: pointer;
}

.card-link:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* Calculator Card */
.calc-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all var(--transition);
}

.calc-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--primary);
}

.calc-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.calc-card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.calc-card-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
  flex: 1;
}

.calc-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* Category Badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
}

.badge-loan { background: #EFF6FF; color: var(--cat-loan); }
.badge-investment { background: #ECFDF5; color: var(--cat-investment); }
.badge-real-estate { background: #FFFBEB; color: var(--cat-real-estate); }
.badge-auto { background: #FEF2F2; color: var(--cat-auto); }
.badge-business { background: #F5F3FF; color: var(--cat-business); }
.badge-tax { background: #FDF4FF; color: var(--cat-tax); }

[data-theme="dark"] .badge-loan { background: #1e3a5f; }
[data-theme="dark"] .badge-investment { background: #064e3b; }
[data-theme="dark"] .badge-real-estate { background: #451a03; }
[data-theme="dark"] .badge-auto { background: #450a0a; }
[data-theme="dark"] .badge-business { background: #2e1065; }
[data-theme="dark"] .badge-tax { background: #4a044e; }

/* Form inputs */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.9375rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgb(37 99 235 / 0.15);
}

.form-input.error {
  border-color: var(--error);
}

.form-input:focus.error {
  box-shadow: 0 0 0 3px rgb(239 68 68 / 0.15);
}

.input-group {
  display: flex;
  align-items: stretch;
}

.input-group .input-prefix,
.input-group .input-suffix {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-secondary);
  border: 1.5px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
}

.input-group .input-prefix {
  border-right: none;
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.input-group .input-suffix {
  border-left: none;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.input-group .form-input {
  border-radius: 0;
  flex: 1;
  min-width: 0;
}

.input-group .form-input:first-child {
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.input-group .form-input:last-child {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.form-select {
  width: 100%;
  padding: 10px 36px 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.9375rem;
  appearance: none;
  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='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition);
}

.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgb(37 99 235 / 0.15);
}

.form-error {
  font-size: 0.8125rem;
  color: var(--error);
  display: none;
}

.form-error.visible {
  display: block;
}

.form-hint {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

/* Toggle / Mode Selector */
.toggle-group {
  display: flex;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 4px;
  gap: 4px;
}

.toggle-btn {
  flex: 1;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition);
  text-align: center;
}

.toggle-btn.active {
  background: var(--bg-primary);
  color: var(--primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* Tooltip */
.tooltip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--gray-300);
  color: var(--gray-700);
  font-size: 0.7rem;
  font-weight: 700;
  cursor: help;
  position: relative;
  flex-shrink: 0;
}

.tooltip-icon::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--gray-900);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 400;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  max-width: 220px;
  white-space: normal;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition);
  z-index: 100;
  line-height: 1.4;
}

.tooltip-icon:hover::after {
  opacity: 1;
}

/* Result Box */
.result-box {
  background: var(--primary-light);
  border: 1px solid var(--primary);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
}

.result-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 8px;
}

.result-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  font-family: var(--font-mono);
  line-height: 1.2;
}

.result-sub {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 6px;
}

/* Summary Table */
.summary-table {
  width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
}

.summary-table tr {
  border-bottom: 1px solid var(--border);
}

.summary-table tr:last-child {
  border-bottom: none;
}

.summary-table td {
  padding: 12px 16px;
  font-size: 0.9375rem;
}

.summary-table td:first-child {
  color: var(--text-secondary);
}

.summary-table td:last-child {
  font-weight: 600;
  text-align: right;
  font-family: var(--font-mono);
}

.summary-table tr.highlight td {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
  font-size: 1rem;
}

/* Data Table */
.data-table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.data-table {
  width: 100%;
  font-size: 0.875rem;
}

.data-table thead tr {
  background: var(--bg-secondary);
}

.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  color: var(--text-primary);
  font-family: var(--font-mono);
  white-space: nowrap;
}

.data-table tbody tr:hover {
  background: var(--bg-secondary);
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  flex-wrap: wrap;
}

.breadcrumb a:hover {
  color: var(--primary);
}

.breadcrumb-sep {
  color: var(--gray-400);
}

.breadcrumb-current {
  color: var(--text-primary);
  font-weight: 500;
}

/* Favorite button */
.fav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  color: var(--gray-400);
  transition: all var(--transition);
  flex-shrink: 0;
}

.fav-btn:hover { color: var(--error); background: #fef2f2; }
.fav-btn.active { color: var(--error); }

/* Tags */
.tag {
  display: inline-block;
  padding: 4px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.tag:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

/* Action bar */
.action-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Section header */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.section-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-top: 6px;
}

/* Alert / info box */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  line-height: 1.5;
}

.alert-info { background: #EFF6FF; color: #1D4ED8; border: 1px solid #BFDBFE; }
.alert-success { background: #ECFDF5; color: #065F46; border: 1px solid #A7F3D0; }
.alert-warning { background: #FFFBEB; color: #92400E; border: 1px solid #FDE68A; }
.alert-error { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }

[data-theme="dark"] .alert-info { background: #1e3a5f; color: #93C5FD; border-color: #1e40af; }
[data-theme="dark"] .alert-success { background: #064e3b; color: #6EE7B7; border-color: #065f46; }
[data-theme="dark"] .alert-warning { background: #451a03; color: #FCD34D; border-color: #78350f; }
[data-theme="dark"] .alert-error { background: #450a0a; color: #FCA5A5; border-color: #7f1d1d; }

/* Slider */
.range-slider {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--gray-200);
  border-radius: var(--radius-full);
  outline: none;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}

.range-slider::-webkit-slider-thumb:hover {
  box-shadow: 0 0 0 6px rgb(37 99 235 / 0.15);
}

/* Chart container */
.chart-container {
  position: relative;
  height: 260px;
  width: 100%;
}

/* Loading skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: var(--radius-md);
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Animate result */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.result-animate {
  animation: fadeInUp 0.3s ease forwards;
}

/* Print hide */
@media print {
  .no-print { display: none !important; }
  .print-only { display: block !important; }
}
