/* ═══════════════════════════════════════════════
   CALCPRO — CALCULATOR-SPECIFIC STYLES
═══════════════════════════════════════════════ */


.sci-calc-wrapper {
  display: flex;
  gap: 16px;
  align-items: stretch;
  min-height: 560px;
}

.sci-calc-container {
  flex: 3;
  min-width: 0;
}

.calc-history-container {
  flex: 2;
  min-width: 0;
}

/* ── Calculator Card ── */
.sci-calc-wrapper .card {
  background: #0C1222;
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 20px 40px rgba(0,0,0,0.5);
  border-radius: 20px;
  overflow: hidden;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* ── Display ── */
.calc-display {
  background: linear-gradient(180deg, #111B2E 0%, #0C1222 100%);
  border-bottom: 1px solid rgba(255,255,255,0.04);
  padding: 20px 20px 16px;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-end;
  position: relative;
}

.calc-display::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(96,165,250,0.3), transparent);
}

.calc-expression {
  font-size: 13px;
  color: rgba(255,255,255,0.4);
  font-family: var(--font-mono);
  min-height: 18px;
  word-break: break-all;
  text-align: right;
  margin-bottom: 4px;
  letter-spacing: 0.3px;
}

.calc-main-display {
  font-size: 34px;
  font-weight: 600;
  color: #fff;
  font-family: var(--font-mono);
  letter-spacing: -1px;
  word-break: break-all;
  text-align: right;
  line-height: 1.15;
  max-width: 100%;
}

/* ── Button Grid ── */
.calc-grid {
  display: flex;
  padding: 8px;
  gap: 6px;
  flex: 1;
}

.calc-basic {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: 4px;
  flex: 1;
}

.calc-scientific {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: auto repeat(7, 1fr);
  gap: 3px;
  background: rgba(0,0,0,0.2);
  padding: 5px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.03);
  width: 170px;
  flex-shrink: 0;
}

/* ── Shared Button Styles ── */
.calc-btn {
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.04);
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  position: relative;
  overflow: hidden;
}

.calc-btn:hover {
  transform: translateY(-1px);
  z-index: 2;
}

.calc-btn:active {
  transform: scale(0.95);
  transition-duration: 0.06s;
}

/* ── Number Buttons ── */
.calc-basic .calc-btn {
  background: #1A2236;
  color: #E2E8F0;
}
.calc-basic .calc-btn:hover { background: #243050; }

.calc-btn.btn-num { background: #151D2E; }
.calc-btn.btn-num:hover { background: #1E2A42; }

/* ── Operator Buttons ── */
.calc-btn.btn-op {
  background: linear-gradient(145deg, #2563EB, #4338CA);
  color: #fff;
  border-color: transparent;
  font-weight: 700;
  font-size: 16px;
  box-shadow: 0 2px 8px rgba(37,99,235,0.25);
}
.calc-btn.btn-op:hover {
  background: linear-gradient(145deg, #3B82F6, #5B5BD6);
  box-shadow: 0 4px 14px rgba(37,99,235,0.35);
}

/* ── Equals Button ── */
.calc-btn.btn-equals {
  background: linear-gradient(145deg, #34D399, #10B981);
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  border-color: transparent;
  box-shadow: 0 2px 6px rgba(52,211,153,0.15);
}
.calc-btn.btn-equals:hover {
  background: linear-gradient(145deg, #6EE7B7, #34D399);
  box-shadow: 0 4px 12px rgba(52,211,153,0.25);
}

/* ── Clear Button ── */
.calc-btn.btn-clear {
  background: linear-gradient(145deg, #F87171, #EF4444);
  color: #fff;
  font-weight: 700;
  border-color: transparent;
  box-shadow: 0 2px 6px rgba(248,113,113,0.15);
}
.calc-btn.btn-clear:hover {
  background: linear-gradient(145deg, #FCA5A5, #F87171);
  box-shadow: 0 4px 12px rgba(248,113,113,0.25);
}

.calc-btn.btn-zero { grid-column: span 2; }

/* ── Scientific Buttons ── */
.calc-scientific .calc-btn {
  background: #0D1526;
  color: #8899B0;
  font-size: 12px;
  font-weight: 600;
  min-height: 30px;
  border-radius: 6px;
  letter-spacing: 0.2px;
}
.calc-scientific .calc-btn:hover {
  background: #1A2744;
  color: #CBD5E1;
}

.calc-scientific .calc-btn.btn-inv {
  background: rgba(37,99,235,0.08);
  color: #60A5FA;
  border-color: rgba(37,99,235,0.12);
}
.calc-scientific .calc-btn.btn-inv:hover {
  background: rgba(37,99,235,0.18);
}

.calc-btn sup { font-size: 9px; margin-left: 1px; }
.calc-btn sub { font-size: 9px; }

/* ── DEG/RAD Toggle ── */
.deg-rad-toggle {
  grid-column: span 3;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(0,0,0,0.3);
  padding: 6px;
  border-radius: 8px;
  margin-bottom: 1px;
}

.deg-rad-toggle label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: #556680;
  cursor: pointer;
  transition: color 0.2s;
}

.deg-rad-toggle input[type="radio"] { accent-color: #38BDF8; width: 12px; height: 12px; }

.deg-rad-toggle label.active {
  color: #38BDF8;
}

/* ── History Panel ── */
.calc-history-container .card {
  height: 100%;
  min-height: 400px;
  display: flex;
  flex-direction: column;
}

.calc-history-container .card-header { border-bottom: 1px solid rgba(255,255,255,0.06); }
.calc-history-container .card-header h2 { color: #F8FAFC; }
.calc-history-container .btn-ghost { color: #94A3B8; }
.calc-history-container .btn-ghost:hover { background: rgba(255,255,255,0.05); color: #fff; }

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
  max-height: 520px;
}
.history-list::-webkit-scrollbar { width: 5px; }
.history-list::-webkit-scrollbar-track { background: transparent; }
.history-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 10px; }
.history-list::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

.history-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 140px;
  color: rgba(255,255,255,0.25);
  font-size: 13px;
  gap: 10px;
}
.history-empty svg { width: 32px; height: 32px; opacity: 0.4; }

.history-item {
  padding: 10px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  cursor: pointer;
  transition: all 0.15s;
}
.history-item:hover { 
  background: rgba(255,255,255,0.03); 
}
.history-item:last-child { border-bottom: none; }

.history-expr {
  font-size: 12px;
  color: rgba(255,255,255,0.4);
  font-family: var(--font-mono);
  margin-bottom: 2px;
  word-break: break-all;
}
.history-result {
  font-size: 15px;
  font-weight: 600;
  color: #E2E8F0;
  font-family: var(--font-mono);
  letter-spacing: -0.3px;
}

/* ── LOAN CALCULATOR ── */

.loan-tabs-section {
  margin-bottom: 0;
}

.loan-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 12px;
}

.loan-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

.loan-inputs {}
.loan-results {}

/* Loan term row */
.loan-term-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.loan-term-row .form-control {
  width: 72px;
  flex-shrink: 0;
}

.loan-term-row span {
  font-size: 13px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

/* Results section */
.loan-results-box {
  background: rgba(10, 15, 30, 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--r-xl);
  padding: 24px;
  color: #fff;
}

.loan-results-box h3 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: rgba(255,255,255,0.5);
  margin-bottom: 16px;
}

.loan-result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.loan-result-item:last-child { border-bottom: none; }

.loan-result-label {
  font-size: 13.5px;
  color: rgba(255,255,255,0.6);
}

.loan-result-value {
  font-size: 18px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: #fff;
  letter-spacing: -0.5px;
}

.loan-result-value.highlight {
  color: #60A5FA;
  font-size: 22px;
}

/* Pie chart */
.pie-wrapper {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.pie-canvas-wrap { flex-shrink: 0; }

.pie-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pie-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: rgba(255,255,255,0.7);
}

.pie-dot {
  width: 12px; height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* Amortization table */
.amort-table-wrap {
  overflow-x: auto;
  margin-top: 4px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
}

.amort-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.amort-table th {
  background: rgba(10, 15, 30, 0.8);
  color: rgba(255,255,255,0.7);
  padding: 10px 12px;
  text-align: right;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  position: sticky;
  top: 0;
}

.amort-table th:first-child { text-align: center; }

.amort-table td {
  padding: 9px 12px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.amort-table td:first-child {
  text-align: center;
  color: var(--text-tertiary);
  font-family: var(--font-sans);
}

.amort-table tr:last-child td { border-bottom: none; }
.amort-table tr:hover td { background: var(--surface-2); }

.amort-year-row td {
  background: rgba(37,99,235,0.1);
  color: #60A5FA;
  font-weight: 700;
  font-family: var(--font-sans);
  font-size: 12px;
  text-align: center;
  letter-spacing: 0.5px;
}

.amort-scroll-box {
  max-height: 420px;
  overflow-y: auto;
}

/* ── TAX CALCULATOR ── */
.tax-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
  margin-bottom: 28px;
}

.tax-result-display {
  background: rgba(34,197,94,0.08);
  border: 1.5px solid rgba(34,197,94,0.15);
  border-radius: var(--r-xl);
  padding: 24px;
}

.tax-result-display h3 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--green);
  margin-bottom: 8px;
}

.tax-result-display .big-val {
  font-size: 36px;
  font-weight: 700;
  color: var(--green);
  font-family: var(--font-mono);
  letter-spacing: -1px;
  margin-bottom: 16px;
}

.tax-breakdown {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tax-breakdown-row {
  display: flex;
  justify-content: space-between;
  font-size: 13.5px;
}

.tax-breakdown-row .label { color: var(--text-secondary); }
.tax-breakdown-row .value { font-weight: 600; color: var(--text-primary); font-family: var(--font-mono); }

/* State Tax Grid */
.state-grid-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.state-grid-header h2 {
  font-size: 16px;
  font-weight: 700;
}

.state-search {
  position: relative;
  width: 200px;
}

.state-search input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 36px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  font-size: 13px;
  background: var(--surface);
  color: var(--text-primary);
}

.state-search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.state-search svg {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  width: 15px; height: 15px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.states-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
}

.state-chip {
  background: rgba(15, 23, 42, 0.5);
  border: 1.5px solid rgba(255,255,255,0.06);
  border-radius: var(--r-md);
  padding: 8px 6px;
  text-align: center;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
}

.state-chip:hover {
  border-color: var(--accent);
  background: var(--accent-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.state-chip.no-tax {
  border-color: rgba(34,197,94,0.2);
  background: rgba(34,197,94,0.06);
}

.state-chip.no-tax .state-rate { color: var(--green); }

.state-chip.selected {
  border-color: var(--accent);
  background: var(--accent-light);
}

.state-abbr {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  display: block;
}

.state-rate {
  font-size: 11.5px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  display: block;
  margin-top: 2px;
}

/* ── SALARY CALCULATOR ── */
.salary-layout {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 24px;
  align-items: start;
}

.salary-result-table th:last-child,
.salary-result-table td:last-child {
  background: rgba(37,99,235,0.06);
}

/* ══════════════════════════════
   RESPONSIVE — CALCULATORS
══════════════════════════════ */

/* Tablet */
@media (max-width: 1000px) {
  .sci-calc-wrapper { flex-direction: column; min-height: auto; }
  .sci-calc-container { flex: none; width: 100%; }
  .calc-history-container { flex: none; width: 100%; }
  .loan-layout { grid-template-columns: 1fr; }
  .tax-layout { grid-template-columns: 1fr; }
  .salary-layout { grid-template-columns: 1fr; }
}

/* Mobile */
@media (max-width: 650px) {
  .sci-calc-container { width: 100%; min-width: unset; }
  
  .calc-grid {
    flex-direction: column-reverse;
    padding: 6px;
    gap: 6px;
  }
  
  .calc-scientific {
    width: 100%;
    grid-template-columns: repeat(6, 1fr);
    gap: 2px;
    padding: 4px;
  }
  .deg-rad-toggle { grid-column: span 6; }
  
  .calc-basic {
    grid-template-columns: repeat(4, 1fr);
    gap: 3px;
  }
  
  .calc-btn { height: 38px; font-size: 14px; border-radius: 7px; }
  .calc-btn.btn-equals { font-size: 18px; }
  .calc-scientific .calc-btn { height: 30px; font-size: 11px; }
  .calc-main-display { font-size: 28px; }
  .calc-display { padding: 16px 14px 12px; min-height: 70px; }

  .state-search { width: 160px; }
  .states-grid { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; }
  .pie-wrapper { flex-direction: column; }
  .loan-result-value.highlight { font-size: 18px; }
}

@media (max-width: 420px) {
  .calc-scientific { grid-template-columns: repeat(5, 1fr); }
  .deg-rad-toggle { grid-column: span 5; }
  .calc-btn { height: 36px; font-size: 13px; }
  .calc-scientific .calc-btn { height: 28px; font-size: 10.5px; }
  .calc-main-display { font-size: 24px; }
  .states-grid { grid-template-columns: repeat(auto-fill, minmax(66px, 1fr)); }
  .state-grid-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .state-search { width: 100%; }
}
