/* ═══════════════════════════════════════════════════════════════════════════
   styles.css — Salary & Tax Calculator
   Mobile-first, modern, clean design.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Reset & Base ─────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Colors */
  --clr-bg:         #f4f5f7;
  --clr-surface:    #ffffff;
  --clr-border:     #e2e4e9;
  --clr-text:       #1a1d23;
  --clr-text-muted: #5f6578;
  --clr-primary:    #4f46e5;          /* Indigo */
  --clr-primary-hover: #4338ca;
  --clr-primary-light: #eef2ff;
  --clr-green:      #16a34a;
  --clr-green-bg:   #f0fdf4;
  --clr-red:        #dc2626;
  --clr-red-bg:     #fef2f2;
  --clr-amber:      #d97706;

  /* Federal / SS / Medicare / State chart colors */
  --clr-federal:    #6366f1;
  --clr-ss:         #f59e0b;
  --clr-medicare:   #ef4444;
  --clr-state:      #8b5cf6;
  --clr-net:        #22c55e;

  /* Typography */
  --ff-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --ff-mono: 'SF Mono', 'Fira Code', 'Fira Mono', monospace;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.1);
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--ff-sans);
  color: var(--clr-text);
  background: var(--clr-bg);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── Layout ───────────────────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.main {
  flex: 1;
  padding-top: var(--space-xl);
  padding-bottom: var(--space-2xl);
}

/* ─── Screen-reader only ───────────────────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

/* ─── Header ───────────────────────────────────────────────────────────────── */
.header {
  background: var(--clr-primary);
  color: #fff;
  padding: var(--space-xl) 0;
  text-align: center;
}

.header-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.header-sub {
  margin-top: var(--space-xs);
  font-size: 0.9rem;
  opacity: 0.85;
}

/* ─── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  box-shadow: var(--shadow-sm);
}

.card + .card {
  margin-top: var(--space-lg);
}

.card-heading {
  font-size: 1rem;
  font-weight: 600;
  color: var(--clr-text);
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--clr-border);
}

/* ─── Input Card ───────────────────────────────────────────────────────────── */
.input-card {
  margin-bottom: var(--space-xl);
}

/* Input row — salary + state + button on one line */
.input-row {
  display: flex;
  gap: var(--space-md);
  align-items: flex-end;
  margin-bottom: var(--space-lg);
}

.input-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.input-field:first-child {
  flex: 1.5;
}

.input-field:nth-child(2) {
  flex: 1;
}

.input-field--btn {
  flex: 0 0 auto;
}

.input-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--clr-text-muted);
}

.input-wrap {
  position: relative;
}

.input-prefix {
  position: absolute;
  left: var(--space-md);
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--clr-text-muted);
  pointer-events: none;
}

.input-wrap input {
  width: 100%;
  padding: 0.85rem 1rem 0.85rem 2rem;
  font-size: 1.15rem;
  font-weight: 600;
  font-family: var(--ff-sans);
  border: 2px solid var(--clr-border);
  border-radius: var(--radius-md);
  color: var(--clr-text);
  transition: border-color 0.2s, box-shadow 0.2s;
  background: var(--clr-surface);
}

.input-wrap input:focus {
  outline: none;
  border-color: var(--clr-primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.15);
}

.input-wrap input.input-error {
  border-color: var(--clr-red);
  animation: shake 0.35s ease-in-out;
}

/* State select */
select {
  width: 100%;
  padding: 0.85rem 2.2rem 0.85rem 1rem;
  font-size: 0.95rem;
  font-weight: 500;
  font-family: var(--ff-sans);
  border: 2px solid var(--clr-border);
  border-radius: var(--radius-md);
  color: var(--clr-text);
  background: var(--clr-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%235f6578' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 0.85rem center;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}

select:focus {
  outline: none;
  border-color: var(--clr-primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.15);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX(6px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}

/* ─── Primary Button ───────────────────────────────────────────────────────── */
.btn-primary {
  padding: 0.85rem 2rem;
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--ff-sans);
  color: #fff;
  background: var(--clr-primary);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  white-space: nowrap;
}

.btn-primary:hover {
  background: var(--clr-primary-hover);
  box-shadow: var(--shadow-md);
}

.btn-primary:active {
  transform: scale(0.97);
}

.btn-primary:focus-visible {
  outline: 2px solid var(--clr-primary);
  outline-offset: 2px;
}

/* ─── Frequency Buttons ────────────────────────────────────────────────────── */
.freq-group {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.freq-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--clr-text-muted);
}

.freq-buttons {
  display: flex;
  gap: var(--space-xs);
  background: var(--clr-bg);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.freq-btn {
  padding: 0.45rem 0.9rem;
  font-size: 0.8rem;
  font-weight: 500;
  font-family: var(--ff-sans);
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--clr-text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.freq-btn:hover {
  color: var(--clr-text);
  background: rgba(255,255,255,0.6);
}

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

.freq-btn:focus-visible {
  outline: 2px solid var(--clr-primary);
  outline-offset: 1px;
}

/* ─── Empty State ──────────────────────────────────────────────────────────── */
.empty-card {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--clr-text-muted);
}

.empty-icon {
  margin-bottom: var(--space-md);
  color: var(--clr-border);
}

.empty-text {
  font-size: 0.95rem;
  max-width: 400px;
  margin: 0 auto;
  line-height: 1.6;
}

/* ─── State Badge Row ──────────────────────────────────────────────────────── */
.state-badge-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.state-badge {
  display: inline-block;
  padding: 0.3rem 0.8rem;
  background: var(--clr-primary);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 999px;
  letter-spacing: 0.02em;
}

.state-tax-note {
  font-size: 0.82rem;
  color: var(--clr-text-muted);
  font-weight: 500;
}

.state-tax-note.no-tax {
  color: var(--clr-green);
  font-weight: 600;
}

/* ─── Summary Grid ─────────────────────────────────────────────────────────── */
.summary-grid {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
  margin-bottom: var(--space-lg);
}

.summary-item {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  padding: var(--space-lg) var(--space-xl);
  text-align: center;
  flex: 1;
  min-width: 140px;
}

.summary-item.arrow {
  flex: 0;
  min-width: auto;
  background: transparent;
  border: none;
  padding: 0 var(--space-xs);
  box-shadow: none;
}

.arrow-icon {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--clr-text-muted);
}

.summary-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--clr-text-muted);
  margin-bottom: var(--space-xs);
}

.summary-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.summary-item.gross .summary-value { color: var(--clr-text); }
.summary-item.taxes .summary-value { color: var(--clr-red); }
.summary-item.net   .summary-value { color: var(--clr-green); }

.summary-item.taxes {
  background: var(--clr-red-bg);
  border-color: #fecaca;
}

.summary-item.net {
  background: var(--clr-green-bg);
  border-color: #bbf7d0;
}

/* ─── Rates Row ────────────────────────────────────────────────────────────── */
.rates-row {
  display: flex;
  justify-content: center;
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.rate-badge {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--clr-primary-light);
  border-radius: 999px;
  font-size: 0.82rem;
}

.rate-label {
  font-weight: 500;
  color: var(--clr-text-muted);
}

.rate-value {
  font-weight: 700;
  color: var(--clr-primary);
}

/* ─── Detail Grid (Chart + Table) ──────────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: var(--space-lg);
  margin-bottom: var(--space-lg);
}

/* ─── Donut Chart ──────────────────────────────────────────────────────────── */
.donut {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-lg);
  position: relative;
}

.donut-hole {
  width: 120px;
  height: 120px;
  background: var(--clr-surface);
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.donut-label {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--clr-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.donut-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--clr-green);
}

/* Chart Legend */
.chart-legend {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.chart-legend li {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.82rem;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-label {
  flex: 1;
  color: var(--clr-text-muted);
}

.legend-value {
  font-weight: 600;
  font-family: var(--ff-mono);
  font-size: 0.8rem;
  color: var(--clr-text);
}

/* ─── Table ────────────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead th {
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--clr-text-muted);
  padding: var(--space-sm) var(--space-md);
  border-bottom: 2px solid var(--clr-border);
}

thead th.amount,
thead th.rate {
  text-align: right;
}

tbody td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--clr-border);
  vertical-align: middle;
}

tbody td.amount {
  text-align: right;
  font-family: var(--ff-mono);
  font-size: 0.82rem;
}

tbody td.rate {
  text-align: right;
  font-size: 0.82rem;
  color: var(--clr-text-muted);
}

.total-row td {
  border-top: 2px solid var(--clr-text);
  border-bottom: none;
  padding-top: var(--space-md);
}

.net-row td {
  color: var(--clr-green);
  border-bottom: none;
}

/* Color dots in table */
.color-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: var(--space-sm);
}

.color-dot.federal  { background: var(--clr-federal); }
.color-dot.state    { background: var(--clr-state); }
.color-dot.ss       { background: var(--clr-ss); }
.color-dot.medicare { background: var(--clr-medicare); }

/* ─── Per-Period Card ──────────────────────────────────────────────────────── */
.period-card {
  margin-top: var(--space-lg);
}

.period-grid {
  display: flex;
  gap: var(--space-lg);
  flex-wrap: wrap;
}

.period-item {
  flex: 1;
  min-width: 140px;
  text-align: center;
  padding: var(--space-md);
  border-radius: var(--radius-md);
  background: var(--clr-bg);
}

.period-item.highlight {
  background: var(--clr-green-bg);
}

.period-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--clr-text-muted);
  margin-bottom: var(--space-xs);
}

.period-value {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.period-item.highlight .period-value {
  color: var(--clr-green);
}

/* ─── Disclaimer ───────────────────────────────────────────────────────────── */
.disclaimer {
  margin-top: var(--space-xl);
  padding: var(--space-md) var(--space-lg);
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  line-height: 1.6;
  color: #92400e;
}

/* ─── Fade-in Animation ────────────────────────────────────────────────────── */
.fade-in {
  animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Footer ───────────────────────────────────────────────────────────────── */
.footer {
  text-align: center;
  padding: var(--space-lg) 0;
  font-size: 0.78rem;
  color: var(--clr-text-muted);
  border-top: 1px solid var(--clr-border);
  margin-top: auto;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════════════════════════════════════ */

/* Tablets & small laptops */
@media (max-width: 768px) {
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .summary-item {
    padding: var(--space-md);
  }

  .summary-value {
    font-size: 1.2rem;
  }

  .summary-item.arrow {
    display: none;
  }

  .summary-grid {
    gap: var(--space-sm);
  }

  .rates-row {
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
  }

  .input-row {
    flex-wrap: wrap;
  }

  .input-field:first-child {
    flex: 1 1 100%;
  }

  .input-field:nth-child(2) {
    flex: 1;
  }

  .input-field--btn {
    flex: 0 0 auto;
  }
}

/* Phones */
@media (max-width: 480px) {
  .container {
    padding: 0 var(--space-md);
  }

  .header {
    padding: var(--space-lg) 0;
  }

  .header-title {
    font-size: 1.35rem;
  }

  .card {
    padding: var(--space-lg);
  }

  .input-row {
    flex-direction: column;
  }

  .input-field:first-child,
  .input-field:nth-child(2) {
    flex: 1 1 100%;
  }

  .btn-primary {
    width: 100%;
  }

  .freq-group {
    flex-direction: column;
    align-items: flex-start;
  }

  .freq-buttons {
    width: 100%;
    justify-content: space-between;
  }

  .freq-btn {
    flex: 1;
    text-align: center;
    padding: 0.5rem 0.3rem;
    font-size: 0.75rem;
  }

  .summary-grid {
    flex-direction: column;
  }

  .summary-item {
    width: 100%;
  }

  .period-grid {
    flex-direction: column;
  }

  .donut {
    width: 160px;
    height: 160px;
  }

  .donut-hole {
    width: 96px;
    height: 96px;
  }

  .donut-value {
    font-size: 1.1rem;
  }
}
