/* style.css - BNPL Stacking Drain */

:root {
  /* Design Token Compliance */
  --teal-primary: #0d9488;
  --teal-hover: #0f766e;
  --teal-focus: rgba(13, 148, 136, 0.2);
  
  --warning-red: #dc2626;
  --warning-bg: #fef2f2;
  --warning-border: #fee2e2;
  
  --text-charcoal: #111827;
  --text-muted: #4b5563;
  --border-light: #e2e8f0;
  --card-bg: #ffffff;
  
  --canvas-bg: #f8fafc;
}

body.bnpl-stacking-body {
  background-color: var(--canvas-bg);
  color: var(--text-charcoal);
}

.bnpl-wrapper {
  max-width: 1024px;
  margin: 2rem auto;
  padding: 0 1.5rem;
  box-sizing: border-box;
}

.bnpl-title-section {
  text-align: center;
  margin-bottom: 2.5rem;
}

.bnpl-title-section h1 {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--text-charcoal);
  margin-bottom: 0.5rem;
  letter-spacing: -0.03em;
}

.bnpl-title-section .subtitle {
  font-size: 1.1rem;
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 auto;
}

.bnpl-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 2rem;
  align-items: start;
}

/* Card Containers */
.bnpl-card {
  background-color: var(--card-bg);
  border-radius: 12px;
  border: 1px solid var(--border-light);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.02);
  padding: 2rem;
  box-sizing: border-box;
  transition: all 0.2s ease;
}

.bnpl-card h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: var(--text-charcoal);
  border-bottom: 2px solid var(--border-light);
  padding-bottom: 0.5rem;
}

/* Input Fields & Groups */
.input-group {
  margin-bottom: 1.25rem;
}

.input-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-charcoal);
}

.input-container input,
.input-container select {
  width: 100%;
  padding: 0.8rem;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  background-color: #f8fafc;
  transition: all 0.15s ease;
  color: var(--text-charcoal);
  box-sizing: border-box;
  height: 2.75rem;
}

.input-container select {
  padding: 0 0.8rem;
  line-height: normal;
}


.input-container input:focus,
.input-container select:focus {
  outline: none;
  border-color: var(--teal-primary);
  box-shadow: 0 0 0 3px var(--teal-focus);
  background-color: #ffffff;
}

/* Divider Title for Subsections */
.divider-title {
  display: flex;
  align-items: center;
  margin: 2rem 0 1rem 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-charcoal);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.divider-title::after {
  content: "";
  flex: 1;
  height: 2px;
  background-color: var(--border-light);
  margin-left: 0.75rem;
}

/* Dynamic Rows Styling */
.bnpl-rows {
  margin-bottom: 1.25rem;
  min-height: 50px;
}

.bnpl-row {
  display: grid;
  grid-template-columns: 1.1fr 1fr 2.4fr 40px;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
  animation: rowFadeIn 0.25s ease-out;
}

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

.bnpl-row input {
  width: 100%;
  padding: 0.6rem 0.5rem;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  font-size: 0.9rem;
  background-color: #f8fafc;
  color: var(--text-charcoal);
  box-sizing: border-box;
  height: 2.5rem;
}

.bnpl-row select {
  width: 100%;
  padding: 0.6rem 1rem 0.6rem 0.25rem;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  font-size: 0.85rem;
  background-color: #f8fafc;
  color: var(--text-charcoal);
  box-sizing: border-box;
  height: 2.5rem;
}

.bnpl-row input:focus,
.bnpl-row select:focus {
  outline: none;
  border-color: var(--teal-primary);
  box-shadow: 0 0 0 3px var(--teal-focus);
  background-color: #ffffff;
}

/* Action Buttons */
.btn-primary-teal {
  width: 100%;
  padding: 0.8rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid #0d9488 !important;
  background-color: #0d9488 !important;
  color: #ffffff !important;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-primary-teal:hover {
  background-color: #0f766e !important;
  border-color: #0f766e !important;
}

.btn-primary-teal:active {
  transform: scale(0.98);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-remove {
  background-color: transparent;
  border: 1px solid var(--border-light);
  color: #ef4444;
  font-size: 1.25rem;
  font-weight: bold;
  height: 2.5rem;
  width: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-remove:hover {
  background-color: #fef2f2;
  border-color: #fee2e2;
}

.btn-remove:active {
  transform: scale(0.92);
}

/* Results Component Details */
.summary-box {
  background-color: #f8fafc;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.summary-text {
  font-size: 1.05rem;
  font-weight: 500;
  line-height: 1.5;
  color: var(--text-charcoal);
  margin-bottom: 0;
}

.counter-highlight {
  font-weight: 700;
  color: var(--teal-primary);
  font-size: 1.15rem;
}

.timeline-title-row {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 0.5rem;
}

/* Visual Timeline Stack */
.timeline-chart {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.timeline-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.timeline-week-label {
  font-size: 0.875rem;
  font-weight: 700;
  width: 54px;
  flex-shrink: 0;
  color: var(--text-charcoal);
}

.payday-badge-container {
  width: 64px;
  flex-shrink: 0;
}

.payday-badge {
  display: inline-block;
  background-color: #ccfbf1;
  color: #0f766e;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  letter-spacing: 0.03em;
  text-align: center;
  width: 100%;
  box-sizing: border-box;
}

.payday-badge.empty-badge {
  background-color: transparent;
  color: transparent;
  border: 1px dashed transparent;
  visibility: hidden;
}

.bar-container {
  flex-grow: 1;
  background-color: #f1f5f9;
  border-radius: 9999px;
  height: 20px;
  overflow: hidden;
  position: relative;
}

.bar-fill {
  height: 100%;
  border-radius: 9999px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s ease;
  width: 0%;
}

.bar-fill.positive-bar {
  background-color: var(--teal-primary);
}

.bar-fill.negative-bar {
  background-color: var(--warning-red);
  animation: pulseNegative 2s infinite ease-in-out;
}

@keyframes pulseNegative {
  0% { opacity: 1; }
  50% { opacity: 0.75; }
  100% { opacity: 1; }
}

.timeline-value {
  font-size: 0.875rem;
  font-weight: 700;
  width: 90px;
  text-align: right;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.timeline-value.positive-value {
  color: var(--text-charcoal);
}

.timeline-value.negative-value {
  color: var(--warning-red);
}

/* Legend Styling */
.legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
  margin-top: 1rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.legend-dot.teal-dot {
  background-color: #0d9488 !important;
}

.legend-dot.red-dot {
  background-color: var(--warning-red);
}

.legend-badge {
  background-color: #ccfbf1;
  color: #0f766e;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.3rem;
  border-radius: 3px;
  text-transform: uppercase;
}

/* Mobile Locks (390px compliant) */
@media (max-width: 768px) {
  .bnpl-wrapper {
    padding: 0 1rem;
    margin: 1rem auto;
  }
  
  .bnpl-title-section h1 {
    font-size: 1.85rem;
  }
  
  .bnpl-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  /* Centering card layouts and locking them strictly to 390px */
  .input-card,
  .results-card {
    max-width: 390px !important;
    width: 100% !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding: 1.25rem !important;
  }

  .bnpl-row {
    grid-template-columns: 1.1fr 1fr 2.2fr 36px;
    gap: 0.35rem;
  }

  .bnpl-row input {
    padding: 0.5rem 0.4rem;
    font-size: 0.8rem;
    height: 2.25rem;
  }

  .bnpl-row select {
    padding: 0.5rem 0.8rem 0.5rem 0.2rem;
    font-size: 0.78rem;
    height: 2.25rem;
  }

  .btn-remove {
    height: 2.25rem;
    width: 2.25rem;
    font-size: 1.1rem;
  }

  .timeline-week-label {
    width: 44px;
    font-size: 0.8rem;
  }
  
  .payday-badge-container {
    width: 50px;
  }
  
  .payday-badge {
    font-size: 0.6rem;
    padding: 0.15rem 0.25rem;
  }

  .timeline-value {
    width: 78px;
    font-size: 0.8rem;
  }
}

/* Breakdown Panel in Summary Box */
.breakdown-container {
  margin-top: 1.25rem;
  border-top: 1px solid var(--border-light);
  padding-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.breakdown-container.hidden {
  display: none;
}

.breakdown-section {
  display: flex;
  flex-direction: column;
}

.breakdown-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-charcoal);
  margin-bottom: 0.5rem;
}

.plan-breakdown {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.plan-breakdown li {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 0.25rem;
  padding-left: 0.75rem;
  position: relative;
}

.plan-breakdown li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: #0d9488;
  font-weight: bold;
}

.weekly-breakdown-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

.weekly-breakdown-item {
  background-color: #f8fafc;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 0.4rem 0.25rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.breakdown-week {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.breakdown-amount {
  font-size: 0.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.breakdown-amount.active-drain {
  color: var(--warning-red);
}

.breakdown-amount.no-drain {
  color: #9ca3af;
}

@media (max-width: 768px) {
  .weekly-breakdown-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

