/*
  Customer Explainer V2 (Visual) — Resolution-aware extension.

  Builds on top of the ee2-* design system (estimate_explainer_visual.css).
  Adds resolution-specific components:
  - Financial summary dashboard
  - Resolution section badges and status indicators
  - Customer-pay item cards with amounts
  - Shop-absorbs goodwill styling
  - Won't-dispute de-emphasized styling

  Typography: inherits Cormorant Garamond (headings) + DM Sans (body)
  Palette:    inherits garnet / gold / cream / charcoal + resolution colors
*/

/* ── Resolution color tokens ─────────────────────────── */

.ee2-doc {
  --teal: #0D9488;
  --teal-light: #14B8A6;
  --teal-glow: rgba(13, 148, 136, 0.08);
  --emerald: #059669;
  --emerald-glow: rgba(5, 150, 105, 0.08);
  --amber: #D97706;
  --amber-glow: rgba(217, 119, 6, 0.08);
  --muted-rose: #9F7A7A;
  --muted-rose-glow: rgba(159, 122, 122, 0.08);
}

/* ── Financial summary — narrative flow ──────────────── */

.ce2-financial-flow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  margin: 16px 0 8px;
}

.ce2-financial-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  width: 100%;
}

.ce2-financial-card {
  background: white;
  border-radius: var(--radius);
  padding: 22px 24px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  border-top: 3px solid var(--border);
  transition: box-shadow 0.15s ease;
}

.ce2-financial-card:hover {
  box-shadow: var(--shadow-md);
}

/* Wide card spans full row when deductible is missing */
.ce2-financial-card--wide {
  border-top-color: var(--charcoal);
}

.ce2-financial-row:has(.ce2-financial-card--deductible) .ce2-financial-card--wide {
  border-top-color: var(--charcoal);
}

/* Single-card row: span full width */
.ce2-financial-row > .ce2-financial-card:only-child {
  grid-column: 1 / -1;
  max-width: 340px;
  justify-self: center;
}

/* Deductible — subtle, informational */
.ce2-financial-card--deductible {
  background: var(--cream);
  border-top-color: var(--warm-gray);
  box-shadow: none;
  border: 1px solid var(--border);
}

.ce2-financial-card--deductible .ce2-financial-amount {
  color: var(--warm-gray);
  font-size: clamp(1.4rem, 2.5vw, 1.8rem);
}

/* Should pay — the "right" number */
.ce2-financial-card--should-pay {
  border-top-color: var(--teal);
}

.ce2-financial-card--should-pay .ce2-financial-amount {
  color: var(--teal);
}

/* Insurance approved — what they agreed to */
.ce2-financial-card--approved {
  border-top-color: var(--amber);
}

.ce2-financial-card--approved .ce2-financial-amount {
  color: var(--amber);
}

/* Hero: the disputed gap — dark, prominent */
.ce2-financial-card--primary {
  background: linear-gradient(135deg, #1C1C1E, #2C1520);
  color: white;
  border-top-color: var(--garnet);
  box-shadow: var(--shadow-lg);
}

.ce2-financial-card--hero {
  width: 100%;
  max-width: 400px;
  padding: 28px 32px;
}

/* Connector lines between rows */
.ce2-financial-connector {
  display: flex;
  justify-content: center;
  padding: 8px 0;
}

.ce2-financial-connector-line {
  display: block;
  width: 2px;
  height: 20px;
  background: var(--border);
  border-radius: 1px;
}

/* Labels */
.ce2-financial-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--warm-gray);
  margin-bottom: 6px;
}

.ce2-financial-card--primary .ce2-financial-label {
  color: var(--gold);
}

/* Amounts */
.ce2-financial-amount {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 700;
  color: var(--charcoal);
  letter-spacing: -0.5px;
}

.ce2-financial-card--primary .ce2-financial-amount {
  color: white;
  font-size: clamp(2rem, 4vw, 2.8rem);
}

/* Notes beneath amounts */
.ce2-financial-note {
  font-size: 12px;
  color: var(--light-gray);
  margin-top: 4px;
  line-height: 1.4;
}

.ce2-financial-card--primary .ce2-financial-note {
  color: rgba(255, 255, 255, 0.55);
}

.ce2-financial-card--deductible .ce2-financial-note {
  color: var(--warm-gray);
  font-size: 11px;
}

/* ── Resolution section badges ───────────────────────── */

.ce2-section-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 6px 14px;
  border-radius: 100px;
  margin-bottom: 12px;
}

.ce2-section-badge--disputed {
  background: var(--teal-glow);
  color: var(--teal);
  border: 1px solid rgba(13, 148, 136, 0.15);
}

.ce2-section-badge--customer-pay {
  background: var(--amber-glow);
  color: var(--amber);
  border: 1px solid rgba(217, 119, 6, 0.15);
}

.ce2-section-badge--absorbed {
  background: var(--emerald-glow);
  color: var(--emerald);
  border: 1px solid rgba(5, 150, 105, 0.15);
}

.ce2-section-badge--dropped {
  background: var(--muted-rose-glow);
  color: var(--muted-rose);
  border: 1px solid rgba(159, 122, 122, 0.15);
}

.ce2-section-badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

/* ── Customer-pay item cards (with amounts) ──────────── */

.ce2-item-card {
  background: white;
  border-radius: var(--radius);
  padding: 28px 32px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  border-left: 4px solid var(--gold);
}

.ce2-item-card:last-child {
  margin-bottom: 0;
}

.ce2-item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.ce2-item-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--charcoal);
  line-height: 1.25;
  flex: 1;
}

.ce2-item-amount {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--garnet);
  white-space: nowrap;
  flex-shrink: 0;
}

.ce2-item-reason {
  font-size: 14px;
  color: var(--warm-gray);
  font-style: italic;
  margin-bottom: 14px;
  padding-left: 16px;
  border-left: 2px solid var(--gold-muted);
}

.ce2-item-explanation p {
  font-size: 15.5px;
  line-height: 1.7;
  color: var(--slate);
  margin: 0 0 12px 0;
}

.ce2-item-explanation p:last-child {
  margin-bottom: 0;
}

.ce2-item-why {
  background: var(--garnet-glow);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-top: 14px;
}

.ce2-item-why-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--garnet);
  margin-bottom: 6px;
}

.ce2-item-why p {
  font-size: 15px;
  line-height: 1.65;
  color: var(--slate);
  margin: 0;
}

/* ── Disputed items (still fighting) ─────────────────── */

.ce2-disputed-item {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 18px 22px;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border-left: 3px solid var(--teal);
  margin-bottom: 12px;
}

.ce2-disputed-item:last-child {
  margin-bottom: 0;
}

.ce2-disputed-item-content {
  flex: 1;
}

.ce2-disputed-item-title {
  font-weight: 600;
  font-size: 15.5px;
  color: var(--charcoal);
  margin-bottom: 4px;
}

.ce2-disputed-item-amount {
  font-size: 14px;
  font-weight: 600;
  color: var(--teal);
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 2px;
}

.ce2-disputed-item-text {
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--warm-gray);
}

/* ── Shop absorbs items (goodwill) ───────────────────── */

.ce2-goodwill-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 12px;
}

.ce2-goodwill-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 20px;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border-left: 3px solid var(--emerald);
}

.ce2-goodwill-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  background: var(--emerald-glow);
  border: 1px solid rgba(5, 150, 105, 0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
  color: var(--emerald);
  font-size: 12px;
  font-weight: 700;
}

.ce2-goodwill-content {
  flex: 1;
}

.ce2-goodwill-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--charcoal);
  margin-bottom: 2px;
}

.ce2-goodwill-amount {
  font-size: 13px;
  color: var(--emerald);
  font-weight: 600;
}

.ce2-goodwill-text {
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--warm-gray);
  margin-top: 4px;
}

/* ── Won't dispute items (de-emphasized) ─────────────── */

.ce2-dropped-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.ce2-dropped-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  font-size: 14.5px;
  color: var(--warm-gray);
  background: rgba(255, 255, 255, 0.6);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.ce2-dropped-item-title {
  font-weight: 500;
  color: var(--slate);
}

.ce2-dropped-item-note {
  font-size: 13px;
  color: var(--light-gray);
  margin-left: auto;
  flex-shrink: 0;
}

/* ── Additional (uncovered) items — accordion ───────── */

.ce2-additional-items {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 2px dashed var(--border);
}

.ce2-additional-accordion {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--cream);
}

.ce2-additional-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.ce2-additional-summary::-webkit-details-marker {
  display: none;
}

.ce2-additional-summary-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--warm-gray);
}

.ce2-additional-chevron {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  background: var(--warm-gray);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
  transition: transform 0.2s ease;
}

.ce2-additional-accordion[open] .ce2-additional-chevron {
  transform: rotate(180deg);
}

.ce2-additional-items-list {
  display: grid;
  gap: 4px;
  padding: 0 14px 14px;
}

.ce2-additional-item {
  padding: 8px 14px;
  font-size: 14px;
  color: var(--warm-gray);
  background: rgba(255, 255, 255, 0.6);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.ce2-additional-item-desc {
  font-weight: 400;
  color: var(--slate);
}

/* ── Section subtotal row ────────────────────────────── */

.ce2-section-subtotal {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  margin-top: 20px;
  border-top: 2px solid var(--border);
  font-size: 15px;
}

.ce2-section-subtotal-label {
  font-weight: 600;
  color: var(--charcoal);
  letter-spacing: 0.5px;
}

.ce2-section-subtotal-amount {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--garnet);
}

/* ── Source reference callout ────────────────────────── */

.ce2-source-callout {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  padding: 12px 16px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  font-size: 13px;
}

.ce2-source-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  background: #dcfce7;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #166534;
  margin-top: 1px;
}

.ce2-source-body {
  flex: 1;
  min-width: 0;
}

.ce2-source-label {
  color: #166534;
  line-height: 1.4;
}

.ce2-source-excerpt {
  color: #475569;
  font-style: italic;
  margin-top: 4px;
  line-height: 1.5;
}

.ce2-source-link {
  color: var(--teal);
  font-weight: 600;
  text-decoration: none;
  margin-top: 6px;
  display: inline-block;
  font-size: 13px;
}

.ce2-source-link:hover {
  text-decoration: underline;
}

/* ── Responsive (mobile) ─────────────────────────────── */

@media (max-width: 640px) {
  .ce2-financial-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .ce2-financial-card {
    padding: 16px 18px;
  }

  .ce2-financial-card--hero {
    max-width: none;
    padding: 22px 24px;
  }

  .ce2-financial-amount {
    font-size: 1.3rem;
  }

  .ce2-financial-connector {
    padding: 4px 0;
  }

  .ce2-financial-connector-line {
    height: 14px;
  }

  .ce2-item-card {
    padding: 20px 22px;
  }

  .ce2-item-header {
    flex-direction: column;
    gap: 8px;
  }

  .ce2-item-amount {
    font-size: 1.15rem;
  }

  .ce2-disputed-item {
    flex-direction: column;
    gap: 8px;
  }

  .ce2-additional-summary {
    padding: 12px 14px;
  }

  .ce2-additional-item {
    font-size: 13px;
    padding: 6px 12px;
  }

  .ce2-section-subtotal {
    flex-direction: column;
    gap: 6px;
    text-align: center;
  }
}

/* ── Print ───────────────────────────────────────────── */

@media print {
  .ce2-financial-flow {
    gap: 0;
  }

  .ce2-financial-row {
    gap: 8px;
  }

  .ce2-financial-card {
    box-shadow: none;
    border: 1px solid #eee;
    padding: 12px 14px;
  }

  .ce2-financial-card--primary {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .ce2-financial-card--deductible {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .ce2-financial-connector-line {
    height: 12px;
  }

  .ce2-item-card,
  .ce2-disputed-item,
  .ce2-goodwill-item {
    box-shadow: none;
    border: 1px solid #eee;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .ce2-item-why {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .ce2-section-badge {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .ce2-source-callout {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .ce2-source-link {
    display: none;
  }

  .ce2-additional-items {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .ce2-additional-accordion {
    /* Force open in print */
    open: true;
  }

  .ce2-additional-accordion .ce2-additional-items-list {
    display: grid !important;
  }

  .ce2-additional-chevron {
    display: none;
  }

  .ce2-additional-item {
    box-shadow: none;
    border: 1px solid #eee;
  }
}
