/* ============================================================
   Seasonal Income Planner -- RedTree Design System
   ============================================================
   Paleta:
     Page bg:     #FAFAF7
     Panel bg:    #EEF2EC (tint)
     Primary:     #6E8272 (sage)
     Buttons:     #2D2D2D (charcoal)
     Text:        #1A1A1A (charcoal)
     Sec. text:   #5C5C5C (slate)
     Positive:    #E8F0E8 / #4A7A5C
     Zero reds.
   ============================================================ */

/* ---- Container / Layout ---- */

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: #1A1A1A;
  background: #FAFAF7;
}

/* ---- Títulos / Headings ---- */

.tool-title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.8rem;
  font-weight: 600;
  color: #1A1A1A;
  margin: 0 0 0.25rem;
  line-height: 1.2;
}

.tool-subtitle {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.9rem;
  color: #5C5C5C;
  margin: 0 0 0.5rem;
  line-height: 1.5;
}

.tool-subtitle + p {
  font-size: 0.85rem;
  color: #5C5C5C;
  margin-top: 0;
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

/* ---- Section Labels ---- */

.section-label {
  display: block;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #5C5C5C;
  margin: 1.5rem 0 0.75rem;
}

.section-help {
  font-size: 0.85rem;
  color: #5C5C5C;
  line-height: 1.5;
  margin-bottom: 0.75rem;
}

/* ---- Separator ---- */

.separator {
  border: none;
  height: 1px;
  background: #D0D4CC;
  margin: 1.5rem 0;
  text-align: center;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #5C5C5C;
  line-height: 0.1em;
  position: relative;
}

.separator span {
  background: #FAFAF7;
  padding: 0 0.75rem;
}

/* ============================================================
   Month Selector Grid
   ============================================================ */

.month-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.month-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  min-height: 44px;
  padding: 0.5rem 0.25rem;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  color: #5C5C5C;
  background: #FAFAF7;
  border: 1px solid #D0D4CC;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: manipulation;
}

.month-btn:hover {
  border-color: #6E8272;
}

.month-btn.selected {
  color: #ffffff;
  background: #6E8272;
  border-color: #6E8272;
}

.month-btn.selected:hover {
  background: #5D7261;
  border-color: #5D7261;
}

/* Fill button (e.g. "Preencher epoca tipica") */
.fill-btn {
  display: inline-block;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.8rem;
  color: #6E8272;
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0.25rem 0;
  margin-bottom: 0.5rem;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.fill-btn:hover {
  color: #5D7261;
}

/* Month warning text */
.month-warning {
  font-size: 0.78rem;
  color: #5C5C5C;
  background: #EEF2EC;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  margin-bottom: 0.75rem;
  display: none;
}

/* ============================================================
   Sliders
   ============================================================ */

.slider-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.slider-group label {
  font-size: 0.85rem;
  color: #1A1A1A;
  font-weight: 500;
}

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

.slider-row input[type="range"] {
  flex: 1;
}

.slider-value {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1rem;
  font-weight: 600;
  color: #1A1A1A;
  min-width: 5rem;
  text-align: right;
  white-space: nowrap;
}

.slider-suggestion {
  font-size: 0.7rem;
  color: #5C5C5C;
  margin-top: -0.2rem;
}

/* ---- Native Range Input ---- */

input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: #E0E0E0;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
  margin: 0.25rem 0;
  touch-action: manipulation;
}

/* Webkit track */
input[type='range']::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, #6E8272 var(--fill-pct, 0%), #E0E0E0 var(--fill-pct, 0%));
}

/* Mozilla track */
input[type='range']::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: #E0E0E0;
}

input[type='range']::-moz-range-progress {
  height: 6px;
  border-radius: 3px;
  background: #6E8272;
}

/* Webkit thumb */
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #2D2D2D;
  border: none;
  cursor: pointer;
  margin-top: -7px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Mozilla thumb */
input[type='range']::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #2D2D2D;
  border: none;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* MS Edge / IE thumb */
input[type='range']::-ms-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #2D2D2D;
  border: none;
  cursor: pointer;
}

input[type='range']::-ms-track {
  height: 6px;
  border-radius: 3px;
  background: #E0E0E0;
  border: none;
}

input[type='range']::-ms-fill-lower {
  height: 6px;
  border-radius: 3px;
  background: #6E8272;
}

/* Ensure minimum touch target for mobile */
input[type='range'] {
  min-height: 44px;
}

/* ============================================================
   Cash Flow Calendar (output)
   ============================================================ */

#cashflow-calendar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.cashflow-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80px;
  padding: 0.5rem;
  border-radius: 6px;
  text-align: center;
  position: relative;
}

.cashflow-cell.positive {
  background: #E8F0E8;
}

.cashflow-cell.negative {
  background: #EEF2EC;
}

.cashflow-cell.current-month {
  border: 2px solid #6E8272;
}

.cashflow-month-name {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 0.85rem;
  font-weight: 500;
  text-transform: lowercase;
  font-variant: small-caps;
  letter-spacing: 0.3px;
  color: #1A1A1A;
  margin-bottom: 0.15rem;
}

.cashflow-value {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
}

.cashflow-cell.positive .cashflow-value {
  color: #4A7A5C;
}

.cashflow-cell.negative .cashflow-value {
  color: #5C5C5C;
}

/* Peak tag */
.cashflow-peak-tag {
  position: absolute;
  top: 0.25rem;
  right: 0.35rem;
  font-size: 0.65rem;
  color: #6E8272;
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 500;
  line-height: 1;
}

/* ============================================================
   Summary Panel
   ============================================================ */

#summary-panel {
  background: #EEF2EC;
  border-radius: 8px;
  padding: 1.5rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.summary-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.summary-label {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.75rem;
  color: #5C5C5C;
  line-height: 1.3;
}

.summary-value {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.4rem;
  font-weight: 600;
  color: #1A1A1A;
  line-height: 1.2;
}

/* ============================================================
   Advice / Editorial Text
   ============================================================ */

#advice-text {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.9rem;
  line-height: 1.6;
  color: #1A1A1A;
  background: #EEF2EC;
  padding: 1rem;
  border-radius: 6px;
  margin-bottom: 1.25rem;
}

#advice-text.advice-warning {
  border-left: 3px solid #6E8272;
}

/* ============================================================
   Detail Table (expandable)
   ============================================================ */

.view-table-btn {
  display: inline-block;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.85rem;
  color: #6E8272;
  cursor: pointer;
  border: none;
  background: transparent;
  padding: 0.5rem 0;
  text-decoration: underline;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.view-table-btn:hover {
  color: #5D7261;
}

.detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-top: 0.75rem;
}

.detail-table th {
  background: #EEF2EC;
  text-align: left;
  padding: 0.6rem 0.5rem;
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 600;
  color: #1A1A1A;
  border-bottom: 1px solid #D0D4CC;
}

.detail-table td {
  padding: 0.5rem;
  border-bottom: 1px solid #E0E0E0;
  font-family: 'Inter', system-ui, sans-serif;
  color: #1A1A1A;
}

.detail-table td:first-child,
.detail-table th:first-child {
  text-align: left;
}

.detail-table td:nth-child(n+3),
.detail-table th:nth-child(n+3) {
  text-align: right;
}

.detail-table tr:nth-child(even) {
  background: #FAFAF7;
}

.detail-table .cell-positive {
  color: #4A7A5C;
  font-weight: 600;
}

.detail-table .cell-negative {
  color: #5C5C5C;
  font-weight: 600;
}

/* ============================================================
   Disclaimer
   ============================================================ */

.disclaimer {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.7rem;
  color: #5C5C5C;
  line-height: 1.5;
  margin-top: 1.5rem;
  padding: 0.75rem 0;
  border-top: 1px solid #D0D4CC;
}

/* ============================================================
   Results section (initially hidden until JS renders into it)
   ============================================================ */

#results-section {
  display: block;
}

/* ============================================================
   Responsive -- Mobile (max-width: 480px)
   ============================================================ */

@media (max-width: 480px) {
  .container {
    padding: 1rem 0.75rem;
  }

  .tool-title {
    font-size: 1.4rem;
  }

  .month-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 0.4rem;
  }

  .month-btn {
    min-width: 0;
    min-height: 44px;
    font-size: 0.8rem;
    padding: 0.4rem 0.2rem;
  }

  /* Sliders full width on mobile */
  .slider-row {
    flex-wrap: wrap;
    gap: 0.25rem;
  }

  .slider-value {
    min-width: auto;
  }

  /* Summary panel: 1 column */
  #summary-panel {
    grid-template-columns: 1fr;
    gap: 0.75rem;
    padding: 1rem;
  }

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

  /* Cash flow calendar: 3 columns on mobile */
  #cashflow-calendar {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.35rem;
  }

  .cashflow-cell {
    min-height: 70px;
    padding: 0.4rem;
  }

  .cashflow-value {
    font-size: 0.95rem;
  }

  /* Detail table: scroll horizontally if needed */
  .detail-table {
    font-size: 0.75rem;
  }

  .detail-table th,
  .detail-table td {
    padding: 0.4rem 0.3rem;
  }
}

/* ============================================================
   Responsive -- Tablet (481px - 768px)
   ============================================================ */

@media (min-width: 481px) and (max-width: 768px) {
  .container {
    padding: 1.5rem 1.25rem;
  }

  .month-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  #summary-panel {
    grid-template-columns: 1fr 1fr;
  }

  #cashflow-calendar {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ============================================================
   Responsive -- Desktop (769px+)
   ============================================================ */

@media (min-width: 769px) {
  .container {
    max-width: 720px;
    padding: 2rem 1rem;
  }

  .month-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  #cashflow-calendar {
    grid-template-columns: repeat(3, 1fr);
  }

  #summary-panel {
    grid-template-columns: 1fr 1fr;
  }
}

/* ============================================================
   Utility
   ============================================================ */

.hidden {
  display: none !important;
}

/* Fraunces font-variation-settings fallback */
@supports (font-variation-settings: normal) {
  .tool-title,
  .summary-value,
  .cashflow-month-name,
  .slider-value {
    font-variation-settings: 'wght' 600;
  }
}

/* Print-friendly */
@media print {
  .container {
    max-width: 100%;
    padding: 0;
    color: #000;
    background: #fff;
  }

  .month-btn.selected {
    background: #6E8272 !important;
    color: #fff !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .cashflow-cell.positive,
  .cashflow-cell.negative,
  #summary-panel,
  #advice-text {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
