/* Scoped styling for Coast FIRE Calculator */
.coast-root {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #083141;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem;
  box-sizing: border-box;
}

.coast-app {
  border: 1px solid #083141;
  border-radius: 12px;
  padding: 20px;
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.coast-loading {
  padding: 1rem;
  text-align: center;
}

/* Header */
.coast-header {
  margin-bottom: 1.5rem;
}

.coast-title {
  font-size: 1.6rem;
  margin: 0 0 0.25rem 0;
}

.coast-subtitle {
  margin: 0;
  font-size: 0.95rem;
  color: #47616b;
}

/* Steps */
.coast-step {
  border-top: 1px solid #ebf2f4;
  padding-top: 1rem;
  margin-top: 1rem;
}

.coast-step-title {
  font-size: 1.2rem;
  margin: 0 0 0.25rem 0;
}

.coast-step-help {
  margin: 0 0 0.75rem 0;
  font-size: 0.9rem;
  color: #526b75;
}

/* Grid */
.coast-grid {
  display: grid;
  grid-gap: 12px;
}

.coast-grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 720px) {
  .coast-grid-2 {
    grid-template-columns: 1fr;
  }

  .coast-app {
    padding: 15px;
  }

  .coast-title {
    font-size: 1.4rem;
  }

  .coast-step-title {
    font-size: 1.1rem;
  }

  .coast-chart-wrapper {
    height: 250px;
    padding: 8px;
  }

  .coast-chart-canvas {
    width: 100% !important;
    height: 100% !important;
  }

  .coast-table-wrapper {
    font-size: 0.75rem;
  }

  .coast-table th,
  .coast-table td {
    padding: 4px 6px;
  }

  .coast-tooltip-text {
    width: 180px;
    font-size: 0.8rem;
    padding: 6px 10px;
  }
}

/* Fields & inputs */
.coast-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.coast-field label {
  font-weight: 600;
  font-size: 0.9rem;
}

.coast-input {
  border-radius: 8px;
  border: 1px solid #c7d6db;
  padding: 6px 10px;
  font-size: 0.95rem;
  outline: none;
}

.coast-input:focus {
  border-color: #59747c;
  box-shadow: 0 0 0 1px rgba(89, 116, 124, 0.3);
}

.coast-input-money {
  text-align: left;
}

.coast-input-inline {
  margin-top: 6px;
  max-width: 120px;
}

.coast-help-inline {
  font-size: 0.8rem;
  color: #6b7e87;
}

/* Inline tags */
.coast-inline {
  margin-top: 4px;
  font-size: 0.85rem;
}

.coast-tag {
  background: #ebf2f4;
  border-radius: 999px;
  padding: 2px 8px;
  margin-right: 4px;
}

.coast-tag-bold {
  font-weight: 600;
}

/* Toggle switch */
.coast-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.coast-toggle input[type="checkbox"] {
  width: 40px;
  height: 20px;
  appearance: none;
  background: #c7d6db;
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
}

.coast-toggle input[type="checkbox"]:checked {
  background: #59747c;
}

.coast-toggle input[type="checkbox"]::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  top: 2px;
  left: 2px;
  transition: left 0.2s;
}

.coast-toggle input[type="checkbox"]:checked::before {
  left: 22px;
}

.coast-toggle-label {
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}

/* Additional income sources */
.coast-income-source {
  border: 1px solid #ebf2f4;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
  background: #f9fbfc;
}

.coast-income-source-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.coast-income-source-title {
  font-weight: 600;
  font-size: 0.9rem;
}

.coast-btn-remove {
  background: #fecaca;
  color: #7f1d1d;
  border: 1px solid #fca5a5;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.8rem;
  cursor: pointer;
}

.coast-btn-remove:hover {
  background: #fca5a5;
}

.coast-btn-add {
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #93c5fd;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.85rem;
  cursor: pointer;
  margin-top: 8px;
}

.coast-btn-add:hover {
  background: #bfdbfe;
}

/* Download CSV – front and centre, prominent CTA */
.coast-export-section {
  margin-top: 2rem;
  padding: 28px 24px;
  border-top: 3px solid #2563eb;
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.08) 0%, rgba(37, 99, 235, 0.02) 100%);
  border-radius: 16px;
  text-align: center;
}

.coast-btn-export {
  background: #2563eb;
  color: #fff;
  border: 3px solid #2563eb;
  border-radius: 14px;
  padding: 18px 36px;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  margin-top: 0;
  transition: all 0.2s;
  width: 100%;
  max-width: 420px;
  min-height: 56px;
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.35);
  -webkit-tap-highlight-color: transparent;
}

.coast-btn-export:hover {
  background: #1e40af;
  border-color: #1e40af;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.4);
}

.coast-btn-export:active {
  transform: translateY(0);
}

/* Tooltips */
.coast-tooltip {
  position: relative;
  display: inline-block;
  cursor: help;
}

.coast-tooltip-icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #59747c;
  color: #ffffff;
  font-size: 11px;
  line-height: 16px;
  text-align: center;
  margin-left: 4px;
  vertical-align: middle;
  font-weight: bold;
}

.coast-tooltip-text {
  visibility: hidden;
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  background-color: #083141;
  color: #ffffff;
  text-align: left;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  white-space: normal;
  width: 200px;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.coast-tooltip-text::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #083141;
}

.coast-tooltip:hover .coast-tooltip-text {
  visibility: visible;
  opacity: 1;
}

/* Badges */
.coast-badges {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 1rem;
}

.coast-badge {
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  max-width: 100%;
}

.coast-badge-success {
  background: #e6f4ea;
  color: #114b26;
  border: 1px solid #a4d7b2;
}

.coast-badge-warning {
  background: #fff4e5;
  color: #8a4700;
  border: 1px solid #f6c78b;
}

.coast-badge-text {
  margin: 0;
  font-size: 0.9rem;
}

/* Summary cards */
.coast-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-gap: 12px;
  margin-bottom: 1rem;
}

@media (max-width: 720px) {
  .coast-summary-grid {
    grid-template-columns: 1fr;
  }
}

.coast-summary-card {
  border-radius: 10px;
  border: 1px solid #ebf2f4;
  background: #f9fbfc;
  padding: 10px 12px;
}

.coast-summary-title {
  margin: 0 0 4px 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.coast-summary-value {
  margin: 0 0 4px 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.coast-summary-caption {
  margin: 0;
  font-size: 0.8rem;
  color: #5b717a;
}

/* Results section */
.coast-results {
  border-top: 1px solid #ebf2f4;
  padding-top: 1rem;
  margin-top: 1rem;
}

/* Chart section */
.coast-chart-section {
  margin-top: 1.5rem;
  margin-bottom: 1rem;
}

.coast-chart-wrapper {
  position: relative;
  width: 100%;
  height: 300px;
  margin-top: 1rem;
  border: 1px solid #ebf2f4;
  border-radius: 8px;
  padding: 10px;
  background: #ffffff;
  box-sizing: border-box;
  overflow: hidden;
}

.coast-chart-canvas {
  width: 100%;
  height: 100%;
  max-width: 100%;
  display: block;
}

.coast-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
  font-size: 0.85rem;
}

.coast-chart-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.coast-chart-legend-color {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

.coast-chart-tooltip {
  position: absolute;
  background: rgba(8, 49, 65, 0.95);
  color: #ffffff;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 0.8rem;
  pointer-events: none;
  display: none;
  z-index: 1000;
}

/* Table */
.coast-table-wrapper {
  margin-top: 0.75rem;
  overflow-x: auto;
}

.coast-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.coast-table th,
.coast-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #ebf2f4;
  white-space: nowrap;
}

.coast-table th {
  background: #ebf2f4;
  text-align: left;
  font-weight: 600;
}

.coast-table tr:nth-child(even) td {
  background: #f8fbfc;
}

/* Print styles */
@media print {
  .coast-app {
    box-shadow: none;
    border-radius: 0;
    border: none;
    max-width: 100%;
    padding: 0;
  }

  .coast-root {
    color: #000000;
  }

  .coast-table-wrapper {
    overflow: visible;
  }

  .coast-chart-wrapper {
    display: none;
  }
}
