/* =========================================================================
   BarrioRadar - Property Purchase Tax Calculator Widget V1 Stylesheet
   Self-Contained Responsive Widget CSS (Desktop, Sidebar 380-450px, Mobile 320px+)
   Zero External Fonts or Trackers
   ========================================================================= */

:root,
body[data-theme="light"] {
  --br-tax-bg: #ffffff;
  --br-tax-surface: #f8fafc;
  --br-tax-surface-alt: #f1f5f9;
  --br-tax-border: #e2e8f0;
  --br-tax-border-strong: #cbd5e1;
  --br-tax-text: #0f172a;
  --br-tax-text-secondary: #334155;
  --br-tax-text-muted: #64748b;
  --br-tax-accent: #2563eb;
  --br-tax-accent-rgb: 37, 99, 235;
  --br-tax-accent-soft: rgba(37, 99, 235, 0.1);
  --br-tax-accent-border: rgba(37, 99, 235, 0.28);
  --br-tax-bar-track: #e2e8f0;
  --br-tax-bar-solid: #2563eb;
  --br-tax-bar-ajd: #0d9488;
  --br-tax-bar-step-1: rgba(37, 99, 235, 0.26);
  --br-tax-bar-step-2: rgba(37, 99, 235, 0.42);
  --br-tax-bar-step-border: #2563eb;
  --br-tax-hero-bg: linear-gradient(135deg, rgba(37, 99, 235, 0.07) 0%, rgba(15, 23, 42, 0.02) 100%);
  --br-tax-warn-bg: #fffbeb;
  --br-tax-warn-border: #fde68a;
  --br-tax-warn-text: #92400e;
  --br-tax-err-bg: #fef2f2;
  --br-tax-err-border: #fecaca;
  --br-tax-err-text: #b91c1c;
  --br-tax-shadow: 0 4px 16px -4px rgba(15, 23, 42, 0.08), 0 2px 6px -2px rgba(15, 23, 42, 0.04);
  --br-tax-tooltip-bg: #0f172a;
  --br-tax-tooltip-text: #f8fafc;
}

body[data-theme="dark"] {
  --br-tax-bg: #0f172a;
  --br-tax-surface: #1e293b;
  --br-tax-surface-alt: #334155;
  --br-tax-border: #334155;
  --br-tax-border-strong: #475569;
  --br-tax-text: #f8fafc;
  --br-tax-text-secondary: #e2e8f0;
  --br-tax-text-muted: #94a3b8;
  --br-tax-accent: #3b82f6;
  --br-tax-accent-rgb: 59, 130, 246;
  --br-tax-accent-soft: rgba(59, 130, 246, 0.18);
  --br-tax-accent-border: rgba(59, 130, 246, 0.4);
  --br-tax-bar-track: #334155;
  --br-tax-bar-solid: #3b82f6;
  --br-tax-bar-ajd: #14b8a6;
  --br-tax-bar-step-1: rgba(59, 130, 246, 0.28);
  --br-tax-bar-step-2: rgba(59, 130, 246, 0.45);
  --br-tax-bar-step-border: #60a5fa;
  --br-tax-hero-bg: linear-gradient(135deg, rgba(59, 130, 246, 0.16) 0%, rgba(30, 41, 59, 0.6) 100%);
  --br-tax-warn-bg: rgba(120, 53, 15, 0.35);
  --br-tax-warn-border: rgba(251, 191, 36, 0.35);
  --br-tax-warn-text: #fde68a;
  --br-tax-err-bg: rgba(127, 29, 29, 0.35);
  --br-tax-err-border: rgba(248, 113, 113, 0.4);
  --br-tax-err-text: #fca5a5;
  --br-tax-shadow: 0 8px 24px -6px rgba(0, 0, 0, 0.45);
  --br-tax-tooltip-bg: #f8fafc;
  --br-tax-tooltip-text: #0f172a;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body.tax-v1-body {
  margin: 0;
  padding: 0;
  width: 100%;
  background: transparent;
  color: var(--br-tax-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.4;
}

.tax-v1-shell {
  width: 100%;
  background: var(--br-tax-bg);
  border: 1px solid var(--br-tax-border);
  border-radius: 14px;
  box-shadow: var(--br-tax-shadow);
  overflow: hidden;
  transition: background-color 0.2s ease, border-color 0.2s ease;
  container-type: inline-size;
  container-name: tax-widget;
}

.tax-v1-active {
  display: flex;
  flex-direction: column;
}

/* =========================================================================
   Header: Calculator Title + Configured Region
   ========================================================================= */

.tax-v1-header {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--br-tax-border);
  background: var(--br-tax-surface);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tax-v1-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.tax-v1-kicker {
  font-size: 0.6875rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--br-tax-accent);
}

.tax-v1-regime-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 700;
  background: var(--br-tax-surface-alt);
  color: var(--br-tax-text-secondary);
  border: 1px solid var(--br-tax-border);
}

.tax-v1-heading {
  margin: 0;
  font-size: 1.025rem;
  font-weight: 800;
  letter-spacing: -0.015em;
  color: var(--br-tax-text);
  line-height: 1.25;
}

.tax-v1-region-row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 1px;
  color: var(--br-tax-text-secondary);
  font-size: 0.84rem;
  font-weight: 700;
}

.tax-v1-region-icon {
  color: var(--br-tax-accent);
  flex-shrink: 0;
}

/* =========================================================================
   Controls: Purchase Price Input + Property Type Selector
   ========================================================================= */

.tax-v1-controls {
  padding: 14px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  border-bottom: 1px solid var(--br-tax-border);
}

.tax-v1-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.tax-v1-label {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--br-tax-text-secondary);
}

.tax-v1-price-input-wrap {
  display: flex;
  align-items: center;
  background: var(--br-tax-bg);
  border: 1.5px solid var(--br-tax-border-strong);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.tax-v1-price-input-wrap:focus-within {
  border-color: var(--br-tax-accent);
  box-shadow: 0 0 0 3px var(--br-tax-accent-soft);
}

.tax-v1-price-input-wrap.has-error {
  border-color: #ef4444;
}

.tax-v1-currency-prefix {
  padding: 8px 10px;
  background: var(--br-tax-surface);
  border-right: 1px solid var(--br-tax-border);
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--br-tax-text-muted);
  user-select: none;
}

.tax-v1-price-input {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 8px 11px;
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--br-tax-text);
  font-variant-numeric: tabular-nums;
  outline: none;
}

.tax-v1-price-input::placeholder {
  color: var(--br-tax-text-muted);
  font-weight: 500;
  opacity: 0.75;
}

.tax-v1-clear-btn {
  border: 0;
  background: transparent;
  color: var(--br-tax-text-muted);
  font-size: 1.1rem;
  line-height: 1;
  padding: 6px 10px;
  cursor: pointer;
}

.tax-v1-clear-btn:hover {
  color: var(--br-tax-text);
}

.tax-v1-field-error {
  margin: 2px 0 0;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--br-tax-err-text);
}

.tax-v1-type-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: var(--br-tax-surface);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--br-tax-border);
}

.tax-v1-type-btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 7px;
  padding: 6px 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--br-tax-text-secondary);
  transition: all 0.15s ease;
}

.tax-v1-type-btn:hover {
  color: var(--br-tax-text);
}

.tax-v1-type-btn.is-active {
  background: var(--br-tax-bg);
  color: var(--br-tax-accent);
  border-color: var(--br-tax-accent-border);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.tax-v1-type-sub {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--br-tax-surface-alt);
  color: var(--br-tax-text-muted);
}

.tax-v1-type-btn.is-active .tax-v1-type-sub {
  background: var(--br-tax-accent-soft);
  color: var(--br-tax-accent);
}

.tax-v1-type-static {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 11px;
  border-radius: 9px;
  background: var(--br-tax-surface);
  border: 1px solid var(--br-tax-border);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--br-tax-text);
}

.tax-v1-type-static-tax {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--br-tax-accent-soft);
  color: var(--br-tax-accent);
}

/* =========================================================================
   Compact Single-Region Interactive Tax Bar
   ========================================================================= */

.tax-v1-bar-section {
  padding: 11px 16px 12px;
  border-bottom: 1px solid var(--br-tax-border);
  background: var(--br-tax-bg);
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.tax-v1-bar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.tax-v1-bar-title {
  font-size: 0.73rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--br-tax-text-muted);
}

.tax-v1-bar-summary {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--br-tax-text-secondary);
  font-variant-numeric: tabular-nums;
}

.tax-v1-bar-track-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tax-v1-bar-track {
  position: relative;
  height: 26px;
  width: 100%;
  background: var(--br-tax-bar-track);
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid var(--br-tax-border);
}

.tax-v1-bar-seg {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  border: 0;
  padding: 0 4px;
  transition: width 0.22s ease, left 0.22s ease, filter 0.15s ease;
  font-variant-numeric: tabular-nums;
}

.tax-v1-bar-seg:hover,
.tax-v1-bar-seg:focus-visible {
  filter: brightness(1.08);
  outline: 2px solid var(--br-tax-text);
  outline-offset: -2px;
  z-index: 4;
}

.tax-v1-bar-seg--solid {
  background: var(--br-tax-accent);
  color: #ffffff;
  z-index: 2;
}

.tax-v1-bar-seg--ajd {
  background: var(--br-tax-bar-ajd);
  color: #ffffff;
  border-left: 1.5px solid rgba(255, 255, 255, 0.7);
  z-index: 2;
}

.tax-v1-bar-seg--higher {
  background: repeating-linear-gradient(
    -45deg,
    var(--br-tax-bar-step-1),
    var(--br-tax-bar-step-1) 5px,
    var(--br-tax-bar-step-2) 5px,
    var(--br-tax-bar-step-2) 10px
  );
  color: var(--br-tax-text);
  border-left: 1.5px dashed var(--br-tax-bar-step-border);
  border-right: 1px solid var(--br-tax-bar-step-border);
  z-index: 1;
}

.tax-v1-bar-seg--reached {
  background: transparent;
  border-right: 1.5px dashed rgba(255, 255, 255, 0.75);
  color: transparent;
  z-index: 3;
}

.tax-v1-bar-axis {
  display: flex;
  justify-content: space-between;
  font-size: 0.64rem;
  font-weight: 600;
  color: var(--br-tax-text-muted);
  font-variant-numeric: tabular-nums;
}

.tax-v1-bar-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tax-v1-chip-btn {
  appearance: none;
  border: 1px solid var(--br-tax-border);
  background: var(--br-tax-surface);
  color: var(--br-tax-text-secondary);
  border-radius: 6px;
  padding: 3px 7px;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.tax-v1-chip-btn:hover,
.tax-v1-chip-btn:focus-visible {
  border-color: var(--br-tax-accent);
  background: var(--br-tax-accent-soft);
  color: var(--br-tax-text);
  outline: none;
}

.tax-v1-chip-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tax-v1-chip-dot--solid {
  background: var(--br-tax-accent);
}

.tax-v1-chip-dot--ajd {
  background: var(--br-tax-bar-ajd);
}

.tax-v1-chip-dot--higher {
  background: transparent;
  border: 1.5px dashed var(--br-tax-accent);
}

/* =========================================================================
   Results Section (Empty State / Calculated Hero & Breakdown / Unsupported)
   ========================================================================= */

.tax-v1-results-wrap {
  padding: 14px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tax-v1-empty-state {
  padding: 16px 14px;
  border-radius: 11px;
  border: 1px dashed var(--br-tax-border-strong);
  background: var(--br-tax-surface);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.tax-v1-empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--br-tax-accent-soft);
  color: var(--br-tax-accent);
  font-size: 0.72rem;
  font-weight: 800;
  margin-bottom: 2px;
}

.tax-v1-empty-title {
  margin: 0;
  font-size: 0.86rem;
  font-weight: 800;
  color: var(--br-tax-text);
}

.tax-v1-empty-desc {
  margin: 0;
  font-size: 0.76rem;
  color: var(--br-tax-text-muted);
  max-width: 310px;
}

.tax-v1-unsupported-state {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--br-tax-warn-border);
  background: var(--br-tax-warn-bg);
  color: var(--br-tax-warn-text);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tax-v1-unsupported-title {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 800;
}

.tax-v1-unsupported-desc {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.4;
}

.tax-v1-calculated-view {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tax-v1-hero-card {
  padding: 12px 14px;
  border-radius: 11px;
  background: var(--br-tax-hero-bg);
  border: 1px solid var(--br-tax-accent-border);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.tax-v1-hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.tax-v1-hero-label {
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--br-tax-text-secondary);
}

.tax-v1-eff-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  background: var(--br-tax-accent);
  color: #ffffff;
  font-variant-numeric: tabular-nums;
}

.tax-v1-hero-amount {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--br-tax-text);
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.tax-v1-hero-sub {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--br-tax-text-muted);
}

.tax-v1-breakdown-card {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--br-tax-surface);
  border: 1px solid var(--br-tax-border);
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.tax-v1-breakdown-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tax-v1-comp-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.8rem;
}

.tax-v1-comp-left {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  color: var(--br-tax-text-secondary);
  font-weight: 600;
}

.tax-v1-comp-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--br-tax-surface-alt);
  color: var(--br-tax-text-muted);
  font-variant-numeric: tabular-nums;
}

.tax-v1-comp-val {
  font-weight: 700;
  color: var(--br-tax-text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tax-v1-divider {
  height: 1px;
  background: var(--br-tax-border);
  margin: 2px 0;
}

.tax-v1-summary-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--br-tax-text-secondary);
}

.tax-v1-summary-label {
  font-weight: 600;
}

.tax-v1-summary-val {
  font-weight: 700;
  color: var(--br-tax-text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tax-v1-summary-row--total {
  font-size: 0.84rem;
  color: var(--br-tax-text);
}

.tax-v1-summary-row--total .tax-v1-summary-label,
.tax-v1-summary-row--total .tax-v1-summary-val {
  font-weight: 800;
}

/* =========================================================================
   Disclaimer & Footer Attribution
   ========================================================================= */

.tax-v1-disclaimer {
  margin: 0;
  padding: 0 16px 11px;
  font-size: 0.69rem;
  line-height: 1.38;
  color: var(--br-tax-text-muted);
}

.tax-v1-footer {
  padding: 9px 16px;
  border-top: 1px solid var(--br-tax-border);
  background: var(--br-tax-surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.tax-v1-brand-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--br-tax-text-secondary);
  text-decoration: none;
}

.tax-v1-brand-link:hover {
  color: var(--br-tax-accent);
}

.tax-v1-brand-icon {
  display: block;
  flex-shrink: 0;
}

.tax-v1-calc-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--br-tax-accent);
  text-decoration: none;
  margin-left: auto;
}

.tax-v1-calc-link:hover {
  text-decoration: underline;
}

/* =========================================================================
   Inactive / Paused View
   ========================================================================= */

.tax-v1-inactive {
  padding: 28px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.tax-v1-inactive-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--br-tax-surface-alt);
  color: var(--br-tax-text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

.tax-v1-inactive-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--br-tax-text);
}

.tax-v1-inactive-desc {
  margin: 0;
  font-size: 0.8rem;
  color: var(--br-tax-text-muted);
  max-width: 300px;
}

/* =========================================================================
   Popover Tooltip for Interactive Tax Bar
   ========================================================================= */

.tax-v1-tooltip {
  position: fixed;
  z-index: 9999;
  max-width: min(310px, calc(100vw - 24px));
  padding: 10px 12px;
  border-radius: 9px;
  background: var(--br-tax-tooltip-bg);
  color: var(--br-tax-tooltip-text);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.35);
  font-size: 0.74rem;
  line-height: 1.38;
  pointer-events: none;
}

.tax-v1-tt-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.tax-v1-tt-title {
  font-weight: 800;
  font-size: 0.78rem;
}

.tax-v1-tt-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.25);
  color: inherit;
}

.tax-v1-tt-range {
  font-weight: 700;
  opacity: 0.9;
  margin-bottom: 3px;
}

.tax-v1-tt-exp {
  opacity: 0.88;
}

.tax-v1-tt-note {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid rgba(148, 163, 184, 0.25);
  font-weight: 700;
}

/* Narrow mobile adjustments */
@container tax-widget (max-width: 350px) {
  .tax-v1-header,
  .tax-v1-controls,
  .tax-v1-bar-section,
  .tax-v1-results-wrap,
  .tax-v1-footer {
    padding-left: 12px;
    padding-right: 12px;
  }

  .tax-v1-disclaimer {
    padding-left: 12px;
    padding-right: 12px;
  }

  .tax-v1-hero-amount {
    font-size: 1.35rem;
  }

  .tax-v1-type-sub {
    display: none;
  }
}
