/* ============================================
   UK Take Home Pay — Shared Styles
   ============================================ */

/* --- Skip to Content (Accessibility) --- */
.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  z-index: 10000;
  padding: 12px 24px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  border-radius: 0 0 var(--radius) var(--radius);
  text-decoration: none;
  transition: top 0.2s;
}
.skip-link:focus {
  top: 0;
}

/* --- Focus Visible (Accessibility) --- */
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input:focus-visible, select:focus-visible {
  outline: none; /* handled by existing box-shadow */
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- Light Theme --- */
[data-theme="light"] {
  --bg-deep: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-alt: #f1f5f9;
  --bg-input: #e2e8f0;
  --border: #cbd5e1;
  --border-focus: #3b82f6;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --accent: #2563eb;
  --accent-glow: rgba(37, 99, 235, 0.12);
  --green: #059669;
  --green-glow: rgba(5, 150, 105, 0.1);
  --amber: #d97706;
  --red: #dc2626;
  --red-soft: rgba(220, 38, 38, 0.08);
}
[data-theme="light"] body { background: var(--bg-deep); }
[data-theme="light"] .noise-overlay { display: none; }
[data-theme="light"] .glow-orb { display: none; }

/* --- Theme Toggle Button --- */
.theme-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9998;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: transform 0.2s, background 0.2s;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}
.theme-toggle:hover {
  transform: scale(1.1);
  background: var(--bg-card-alt);
}
[data-theme="light"] .theme-toggle {
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
}
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="light"] .theme-toggle .icon-sun { display: block; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* --- Social Proof Bar --- */
.social-proof {
  display: flex;
  justify-content: center;
  gap: 32px;
  flex-wrap: wrap;
  padding: 16px 24px;
  margin: -16px auto 24px;
  font-size: 13px;
  color: var(--text-muted);
}
.social-proof-item {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.social-proof-item strong {
  color: var(--text-secondary);
  font-weight: 600;
}
.social-proof-icon {
  font-size: 16px;
  line-height: 1;
}

/* --- Share Results Modal --- */
.share-bar {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--bg-card-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  text-decoration: none;
}
.share-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.share-btn.copied {
  border-color: var(--green);
  color: var(--green);
}

/* --- Calculation History Panel --- */
.history-panel {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
.history-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 8px 0;
  background: none;
  border: none;
  width: 100%;
  color: var(--text-muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.history-toggle:hover { color: var(--text-secondary); }
.history-toggle .arrow {
  transition: transform 0.2s;
  font-size: 10px;
}
.history-toggle[aria-expanded="true"] .arrow {
  transform: rotate(180deg);
}
.history-list {
  display: none;
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  max-height: 240px;
  overflow-y: auto;
}
.history-list.open { display: block; }
.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  margin-bottom: 4px;
  background: var(--bg-card-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.2s;
}
.history-item:hover { border-color: var(--accent); }
.history-item-salary {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}
.history-item-net {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--green);
}
.history-clear {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 6px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
.history-clear:hover { color: var(--red); border-color: var(--red); }

/* --- Enhanced Mobile Styles --- */
@media (max-width: 768px) {
  .social-proof { gap: 16px; font-size: 12px; }
  .share-bar { justify-content: center; }
  .theme-toggle { bottom: 16px; right: 16px; width: 40px; height: 40px; font-size: 18px; }

  /* Larger touch targets */
  input[type="number"], input[type="text"], select {
    min-height: 48px;
    font-size: 16px !important; /* prevents zoom on iOS */
  }
  .period-btn { min-height: 44px; }
  .checkbox-group { min-height: 44px; }
}

/* --- Print Styles --- */
@media print {
  body {
    background: #fff !important;
    color: #000 !important;
    font-size: 12pt;
    line-height: 1.4;
  }

  .noise-overlay, .glow-orb, .glow-orb-1, .glow-orb-2,
  .theme-toggle, .skip-link, .social-proof,
  .share-bar, .history-panel, .badge,
  #email-capture, .ad-slot, .mobile-results-bar,
  footer h2, footer p:not(:first-child) { display: none !important; }

  .container { max-width: 100% !important; padding: 0 !important; }

  header { padding: 0 0 12pt !important; text-align: left !important; }
  h1 { font-size: 18pt !important; color: #000 !important; }

  .calc-grid { display: block !important; }
  .card {
    background: none !important;
    border: 1px solid #ccc !important;
    border-radius: 4pt !important;
    padding: 12pt !important;
    margin-bottom: 12pt !important;
    page-break-inside: avoid;
  }

  .results-panel { position: static !important; }
  .take-home-hero {
    background: #f5f5f5 !important;
    border: 2px solid #000 !important;
    padding: 16pt !important;
  }
  .take-home-label { color: #333 !important; }
  .take-home-amount { color: #000 !important; font-size: 24pt !important; }

  .breakdown-label { color: #333 !important; }
  .breakdown-value { color: #000 !important; }
  .val-green { color: #059669 !important; }
  .val-red { color: #dc2626 !important; }
  .val-amber { color: #d97706 !important; }

  .period-cell {
    background: #f5f5f5 !important;
    border: 1px solid #ccc !important;
  }
  .period-cell-label { color: #666 !important; }
  .period-cell-value { color: #000 !important; }

  .content-section { margin-bottom: 24pt !important; }
  .content-section h2 { color: #000 !important; font-size: 14pt !important; }
  .content-section p { color: #333 !important; }

  .tax-table th { background: #eee !important; color: #000 !important; }
  .tax-table td { color: #333 !important; border-color: #ccc !important; }

  footer {
    border-top: 1px solid #ccc !important;
    margin-top: 16pt !important;
    padding: 8pt 0 !important;
  }
  footer p { color: #666 !important; }

  a { color: #000 !important; text-decoration: underline !important; }
  a[href]:after { content: " (" attr(href) ")"; font-size: 9pt; color: #666; }
  a[href^="/"]:after { content: " (uktakehomepay.co.uk" attr(href) ")"; }
  a[href^="#"]:after { content: ""; }

  .tax-bar-fill { background: #666 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  /* Payslip header */
  header::after {
    content: "Generated by uktakehomepay.co.uk \2014  2025/26 Tax Year";
    display: block;
    font-size: 9pt;
    color: #999;
    margin-top: 4pt;
  }
}

/* --- Font loading optimization class --- */
.fonts-loading body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
