/* components.css — UI Components */
.card {
  background: var(--card);
  border-radius: 16px;
  padding: 28px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}
.card h2 { font-size: 1.25rem; font-weight: 700; margin-bottom: 20px; display: flex; align-items: center; gap: 8px; }
.card h2 .icon { font-size: 1.4rem; }

.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 0.875rem; font-weight: 600; margin-bottom: 8px; color: var(--text); }

.input-wrap { position: relative; }
.input-wrap input, .input-wrap select {
  width: 100%; padding: 12px 60px 12px 14px;
  font-size: 1rem; font-weight: 500;
  border: 2px solid var(--border); border-radius: 10px;
  background: var(--card); color: var(--text); font-family: inherit;
  transition: all 0.2s; outline: none;
}
.input-wrap input:focus, .input-wrap select:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-light); }
.input-wrap .suffix {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: 0.875rem; font-weight: 600; pointer-events: none;
}
.input-wrap .prefix {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: 0.875rem; font-weight: 600; pointer-events: none;
}
.input-wrap.has-prefix input { padding-left: 40px; }

.hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }

input[type="range"] {
  -webkit-appearance: none; width: 100%; height: 6px; border-radius: 3px;
  background: var(--border); outline: none; margin-top: 12px; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%;
  background: var(--primary); cursor: pointer;
  box-shadow: 0 2px 6px rgba(37,99,235,0.4); transition: transform 0.15s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }
input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%; background: var(--primary); cursor: pointer; border: none;
}

/* Advanced panel */
.advanced-toggle {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 0.875rem;
  margin-bottom: 12px; transition: all 0.2s;
}
.advanced-toggle:hover { background: var(--primary-light); }
.advanced-toggle .arrow { transition: transform 0.3s; }
.advanced-toggle.open .arrow { transform: rotate(180deg); }
.advanced-panel { max-height: 0; overflow: hidden; transition: max-height 0.4s ease; }
.advanced-panel.open { max-height: 1200px; }

/* Results */
.result-main {
  background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
  color: white; padding: 24px; border-radius: 14px; text-align: center; margin-bottom: 20px;
}
.result-main .label { font-size: 0.875rem; opacity: 0.9; margin-bottom: 6px; }
.result-main .value { font-size: clamp(1.75rem, 5vw, 2.5rem); font-weight: 800; letter-spacing: -0.02em; }
.result-main .sub-value { font-size: 0.75rem; opacity: 0.7; margin-top: 4px; }

.piti-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.piti-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--bg); border-radius: 8px; font-size: 0.8rem; }
.piti-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.piti-label { color: var(--text-muted); flex: 1; }
.piti-value { font-weight: 700; }

.result-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.result-item { background: var(--bg); padding: 16px; border-radius: 10px; border: 1px solid var(--border); }
.result-item .label { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; margin-bottom: 4px; }
.result-item .value { font-size: 1.125rem; font-weight: 700; color: var(--text); }

.savings-box { background: #d1fae5; border: 1px solid #6ee7b7; border-radius: 10px; padding: 16px; margin-bottom: 20px; }
.savings-title { font-weight: 700; font-size: 0.9rem; margin-bottom: 8px; color: #065f46; }
.savings-row { display: flex; justify-content: space-between; font-size: 0.85rem; margin-bottom: 4px; }

/* Chart */
.chart-wrap { position: relative; height: 220px; margin-bottom: 20px; display: flex; justify-content: center; align-items: center; }
.legend { display: flex; justify-content: center; gap: 24px; font-size: 0.875rem; margin-top: 12px; }
.legend-item { display: flex; align-items: center; gap: 8px; }
.legend-dot { width: 12px; height: 12px; border-radius: 3px; }

/* Table */
.table-header { display: flex; justify-content: space-between; align-items: center; margin-top: 24px; margin-bottom: 16px; flex-wrap: wrap; gap: 8px; }
.table-header h3 { font-size: 1.05rem; font-weight: 700; }
.table-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.toggle-btn {
  background: var(--primary-light); color: var(--primary-dark); border: none;
  padding: 8px 14px; border-radius: 8px; font-weight: 600; font-size: 0.875rem;
  cursor: pointer; font-family: inherit; transition: all 0.2s;
}
.toggle-btn:hover { background: #bfdbfe; }
.toggle-btn.active { background: var(--primary); color: white; }

.table-wrap { max-height: 0; overflow: hidden; transition: max-height 0.4s ease; }
.table-wrap.open { max-height: 500px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
thead { position: sticky; top: 0; background: var(--bg); z-index: 1; }
th, td { padding: 10px 8px; text-align: right; border-bottom: 1px solid var(--border); }
th:first-child, td:first-child { text-align: left; }
th { font-weight: 600; color: var(--text-muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }
tbody tr:hover { background: var(--bg); }

/* Ad slot */
.ad-slot {
  margin: 24px 0; min-height: 90px; background: #f1f5f9;
  border: 1px dashed #cbd5e1; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #94a3b8; font-size: 0.75rem; font-weight: 500;
}

/* Content sections */
.content-section {
  margin-top: 40px; background: var(--card); border-radius: 16px; padding: 32px;
  box-shadow: var(--shadow); border: 1px solid var(--border);
}
.content-section h2 { font-size: 1.5rem; margin-bottom: 16px; }
.content-section h3 { font-size: 1.125rem; margin: 24px 0 12px; color: var(--primary-dark); }
.content-section p { margin-bottom: 12px; color: #334155; }
.content-section ul { margin: 12px 0 12px 24px; color: #334155; }
.content-section li { margin-bottom: 8px; }

/* Comparison */
.comparison-section { margin-top: 40px; background: var(--card); border-radius: 16px; padding: 32px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.comparison-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin-bottom: 16px; }
.scenario-card { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 20px; }
.scenario-card h4 { font-size: 1rem; margin-bottom: 12px; }
.scenario-card .form-group { margin-bottom: 12px; }
.scenario-card .result-mini { display: flex; justify-content: space-between; font-size: 0.85rem; padding: 4px 0; border-bottom: 1px solid var(--border); }
.btn-primary {
  background: var(--primary); color: white; border: none;
  padding: 12px 24px; border-radius: 10px; font-weight: 600; font-size: 0.9rem;
  cursor: pointer; font-family: inherit; transition: all 0.2s;
}
.btn-primary:hover { background: var(--primary-dark); }

/* Affordability */
.affordability-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.affordability-result { text-align: center; padding: 24px; background: var(--bg); border-radius: 14px; border: 1px solid var(--border); }
.afford-value { font-size: 2rem; font-weight: 800; color: var(--primary); }
.afford-label { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 8px; }
.afford-detail { font-size: 0.8rem; color: var(--text-muted); }

footer { text-align: center; padding: 32px 20px; color: var(--text-muted); font-size: 0.875rem; border-top: 1px solid var(--border); background: var(--card); }

/* Dark mode toggle */
.dark-toggle {
  position: fixed; top: 16px; right: 16px; z-index: 100;
  background: var(--card); border: 1px solid var(--border);
  width: 44px; height: 44px; border-radius: 50%;
  cursor: pointer; font-size: 1.2rem; display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow); transition: all 0.2s;
}
.dark-toggle:hover { transform: scale(1.1); }