/* BYN/USD Future Calculator - Refined Design */

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap');

* {
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
}

.byn-usd-future-container {
  max-width: 100%;
  color: #1a1a1a;
}

.byn-usd-future-main {
  width: 100%;
  max-width: 100%;
  background: white;
  overflow: hidden;
  box-sizing: border-box;
}

/* Content */
.byn-usd-future-content {
  padding: 4px;
  max-width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
}

/* Grid Input Fields */
.byn-usd-future-inputs {
  margin-bottom: 1.5rem;
}

.byn-usd-future-grid {
  display: grid;
}

/* Two tiles per row, down to ~320px wide screens */
.byn-usd-future-grid-compact {
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.byn-usd-future-field {
  min-width: 0;
  padding: 0.7rem 0.9rem;
  border-radius: 14px;
  background: #f7f9fc;
  border: 1px solid #e6eaf1;
  transition: border-color 0.2s ease;
  position: relative;
  box-sizing: border-box;
}

.byn-usd-future-field:focus-within {
  border-color: #10b981;
}

.byn-usd-future-field label {
  display: block;
  font-size: 0.72rem;
  font-weight: 500;
  color: #8891a3;
  margin-bottom: 0.35rem;
}

.byn-usd-future-input-group {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
}

.byn-usd-future-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  font-size: 1.05rem;
  font-weight: 700;
  color: #1a1a2e;
  padding: 0;
  outline: none;
  font-family: 'Montserrat', sans-serif;
}

.byn-usd-future-input[type="number"]::-webkit-outer-spin-button,
.byn-usd-future-input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.byn-usd-future-input[type="number"] {
  -moz-appearance: textfield;
}

.byn-usd-future-currency {
  font-size: 0.75rem;
  font-weight: 500;
  color: #8891a3;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Combined amount tile (BYN linked to USD equivalent) */
.byn-usd-future-field-combo {
  margin-bottom: 0.5rem;
}

.byn-usd-future-combo-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.35rem;
  flex-wrap: wrap;
}

.byn-usd-future-combo-hint {
  font-size: 0.7rem;
  color: #a6b0c0;
  white-space: nowrap;
}

.byn-usd-future-combo-value-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.byn-usd-future-combo-group {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}

.byn-usd-future-combo-group .byn-usd-future-input {
  font-size: 1.05rem;
  /* Wide enough for a grouped "1 000 000" without clipping */
  width: 7.5rem;
  flex: 0 0 auto;
}

/* The USD side sits at the right edge, so its digits read better right-aligned */
.byn-usd-future-combo-group-usd .byn-usd-future-input {
  text-align: right;
}

.byn-usd-future-input-accent {
  color: #059669 !important;
}

.byn-usd-future-currency-accent {
  color: #059669 !important;
  font-weight: 600;
}

.byn-usd-future-combo-sep {
  color: #c4cde0;
  font-weight: 600;
  flex-shrink: 0;
}

/* Term Buttons */
.byn-usd-future-terms {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.75rem;
}

.byn-usd-future-terms span {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #a6b0c0;
}

.byn-usd-future-term-buttons {
  display: inline-flex;
  padding: 0.3rem;
  background: #f0f3f7;
  border-radius: 10px;
  gap: 0.3rem;
}

.byn-usd-future-term-btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #8b94a8;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Montserrat', sans-serif;
}

.byn-usd-future-term-btn.active {
  background: white;
  color: #1a1a1a;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  font-weight: 700;
}

.byn-usd-future-term-btn:hover:not(.active) {
  color: #1a1a1a;
  background: rgba(255, 255, 255, 0.5);
}

/* Custom rate forecast (link-style toggle) */
.byn-usd-future-custom-rate {
  margin: 1rem 0;
}

.byn-usd-future-link-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: none;
  padding: 0.3rem 0;
  color: #2563eb;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Montserrat', sans-serif;
  transition: color 0.2s ease;
}

.byn-usd-future-link-toggle:hover {
  color: #1d4ed8;
}

.byn-usd-future-icon-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.3rem;
  height: 1.3rem;
  border-radius: 50%;
  background: #2563eb;
  color: white;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1;
  flex-shrink: 0;
}

.byn-usd-future-link-toggle.open .byn-usd-future-icon-circle {
  background: #1d4ed8;
}

.byn-usd-future-custom-rate-content {
  margin-top: 0.75rem;
  padding: 1rem;
  border-radius: 12px;
  border: 1.5px solid #dbeafe;
  background: #f8fbff;
}

.byn-usd-future-custom-rate-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.byn-usd-future-custom-input {
  width: 90px;
  padding: 0.5rem 0.7rem;
  border: 1.5px solid #dbeafe;
  border-radius: 8px;
  background: white;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: 'Montserrat', sans-serif;
  color: #1a1a1a;
  outline: none;
  transition: border-color 0.2s ease;
}

.byn-usd-future-custom-input:focus {
  border-color: #2563eb;
}

.byn-usd-future-custom-input[type="number"]::-webkit-outer-spin-button,
.byn-usd-future-custom-input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.byn-usd-future-custom-label {
  font-size: 0.8rem;
  color: #64748b;
  font-weight: 500;
}

.byn-usd-future-custom-or {
  font-size: 0.8rem;
  color: #94a3b8;
  font-weight: 600;
  padding: 0 0.2rem;
}

.byn-usd-future-custom-add-btn {
  padding: 0.5rem 1rem;
  border: 1.5px solid #2563eb;
  border-radius: 8px;
  background: white;
  color: #2563eb;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Montserrat', sans-serif;
  transition: all 0.2s ease;
  margin-left: auto;
}

.byn-usd-future-custom-add-btn:hover {
  background: #2563eb;
  color: white;
}

.byn-usd-future-custom-hint {
  margin: 0.6rem 0 0;
  font-size: 0.75rem;
  color: #94a3b8;
}

/* Insight Box */
.byn-usd-future-insight {
  border-radius: 12px;
  background: #ecf9f5;
  border: 1.5px solid #b3e5d3;
  color: #0f5c3c;
  padding: 0.75rem 1.25rem;
  margin: 1.25rem 0;
  min-height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.byn-usd-future-insight p {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.5;
}

#insightTermLabel {
  font-weight: 700;
  color: #0f5c3c;
}

#breakEvenDisplay {
  font-weight: 700;
  color: #047857;
  text-decoration: underline;
  text-decoration-color: #10b981;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

/* Scenarios table */
.byn-usd-future-scenarios {
  margin: 2rem 0;
}

.byn-usd-future-scenarios h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0 0 1rem 0;
  color: #1a1a1a;
}

.byn-usd-future-table-wrap {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid #eef1f5;
}

.byn-usd-future-table {
  min-width: 620px;
}

.byn-usd-future-table-header,
.byn-usd-future-table-row {
  display: grid;
  grid-template-columns: 2fr 1.2fr 0.9fr 0.9fr;
  gap: 1rem;
  align-items: center;
  padding: 0.9rem 1.25rem;
}

.byn-usd-future-table-header {
  background: #f7f9fc;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #a6b0c0;
}

.byn-usd-future-table-header > div:nth-child(3),
.byn-usd-future-table-header > div:nth-child(4) {
  text-align: right;
}

.byn-usd-future-table-row {
  border-top: 1px solid #f0f3f7;
  transition: background-color 0.2s ease;
}

.byn-usd-future-table-row:hover {
  background: #fafbfd;
}

.byn-usd-future-table-row.custom {
  background: #fdf8e8;
}

.byn-usd-future-table-row.custom:hover {
  background: #fbf3d9;
}

.byn-usd-future-col-rate {
  min-width: 0;
}

.byn-usd-future-row-label {
  font-weight: 700;
  font-size: 0.9rem;
  color: #1a1a2e;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
}

/* The raw percent, demoted to a caption next to "в 2,7 раза" */
.byn-usd-future-row-sub {
  font-weight: 500;
  font-size: 0.8rem;
  color: #a6b0c0;
}

/* Ties an abstract percent to something the reader remembers */
.byn-usd-future-note-badge {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 5px;
  white-space: nowrap;
}

.byn-usd-future-note-warn {
  background: #fef3c7;
  color: #92700e;
}

.byn-usd-future-note-danger {
  background: #fee2e2;
  color: #c02626;
}

/* Rate-level note: blue keeps it apart from the growth notes above,
   which use amber and red to signal severity. */
.byn-usd-future-note-level {
  background: #eef1f5;
  color: #5b6478;
  /* Lighter than the growth notes: this one is context, not a warning */
  font-weight: 500;
  margin-left: 0.4rem;
}

.byn-usd-future-custom-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: #1a1a2e;
  color: white;
}

.byn-usd-future-row-rate {
  font-size: 0.8rem;
  color: #a6b0c0;
  margin-top: 0.15rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

.byn-usd-future-col-roi {
  min-width: 0;
}

.byn-usd-future-roi-value {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.4rem;
}

.byn-usd-future-table-row.win .byn-usd-future-roi-value {
  color: #059669;
}

.byn-usd-future-table-row.loss .byn-usd-future-roi-value {
  color: #dc2626;
}

.byn-usd-future-roi-bar {
  width: 100%;
  max-width: 140px;
  height: 6px;
  background: #e8ecf1;
  border-radius: 99px;
  overflow: hidden;
}

.byn-usd-future-roi-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.byn-usd-future-table-row.win .byn-usd-future-roi-bar-fill {
  background: linear-gradient(90deg, #10b981, #059669);
}

.byn-usd-future-table-row.loss .byn-usd-future-roi-bar-fill {
  background: linear-gradient(90deg, #dc2626, #991b1b);
}

/* Sizing is scoped to rows: in the header these classes are just column
   labels and must keep the header's own small uppercase type. */
.byn-usd-future-col-final,
.byn-usd-future-col-profit {
  text-align: right;
}

.byn-usd-future-table-row .byn-usd-future-col-final {
  font-weight: 700;
  font-size: 0.95rem;
  color: #1a1a2e;
}

.byn-usd-future-table-row.win .byn-usd-future-col-final {
  color: #059669;
}

.byn-usd-future-table-row .byn-usd-future-col-profit {
  font-weight: 700;
  font-size: 0.95rem;
}

.byn-usd-future-table-row.win .byn-usd-future-col-profit {
  color: #059669;
}

.byn-usd-future-table-row.loss .byn-usd-future-col-profit {
  color: #dc2626;
}

 /* Reads like the values in the neighbouring tiles; the native arrow is
    what marks it as a control. */
.byn-usd-future-select {
  width: 100%;
  max-width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  font-size: 1.05rem;
  font-weight: 700;
  color: #1a1a2e;
  cursor: pointer;
  font-family: 'Montserrat', sans-serif;
  outline: none;
}

.byn-usd-future-select:focus-visible {
  outline: 2px solid #10b981;
  outline-offset: 2px;
  border-radius: 4px;
}

/* Footer */
.byn-usd-future-footer {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid #f0f3f7;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.byn-usd-future-share-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  border: 1.5px solid #10b981;
  border-radius: 10px;
  background: white;
  color: #059669;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Montserrat', sans-serif;
  transition: all 0.2s ease;
}

.byn-usd-future-share-btn:hover {
  background: #10b981;
  color: white;
}

.byn-usd-future-share-icon {
  flex-shrink: 0;
}

.byn-usd-future-reset-btn {
  padding: 0.55rem 0.5rem;
  background: transparent;
  border: none;
  color: #8891a3;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: color 0.2s ease;
  font-family: 'Montserrat', sans-serif;
}

.byn-usd-future-reset-btn:hover {
  color: #1a1a2e;
}

/* Desktop: settings tiles are too eye-catching at mobile sizing, shrink them down */
@media (min-width: 640px) {
  .byn-usd-future-field {
    padding: 0.4rem 0.7rem;
  }

  .byn-usd-future-field label {
    font-size: 0.65rem;
    margin-bottom: 0.2rem;
  }

  .byn-usd-future-input,
  .byn-usd-future-select {
    font-size: 0.9rem;
  }

  .byn-usd-future-combo-group .byn-usd-future-input {
    font-size: 0.9rem;
    width: 6.5rem;
  }

  .byn-usd-future-currency {
    font-size: 0.7rem;
  }

  .byn-usd-future-combo-hint {
    font-size: 0.65rem;
  }
}

/* Responsive */
@media (max-width: 768px) {
  .byn-usd-future-content {
    padding: 4px;
  }

  .byn-usd-future-terms {
    flex-direction: column;
    align-items: flex-start;
  }

  .byn-usd-future-combo-value-row {
    gap: 0.5rem 1rem;
  }

  .byn-usd-future-custom-rate-row {
    flex-direction: column;
    align-items: stretch;
  }

  .byn-usd-future-custom-input {
    width: 100%;
  }

  .byn-usd-future-custom-add-btn {
    margin-left: 0;
  }
}

/* Narrow screens: keep BYN and USD side by side, but as two equal halves with
   fluid fields — the desktop sizing (fixed wide fields plus a separator) is
   what used to overflow and wrap the pair apart. */
@media (max-width: 639.98px) {
  .byn-usd-future-combo-value-row {
    flex-wrap: nowrap;
    /* Keeps the BYN unit from butting up against the USD figure next to it */
    gap: 1rem;
  }

  .byn-usd-future-combo-sep {
    display: none;
  }

  .byn-usd-future-combo-group {
    flex: 1 1 0;
    min-width: 0;
    justify-content: space-between;
  }

  .byn-usd-future-combo-group .byn-usd-future-input {
    width: auto;
    flex: 1 1 auto;
    min-width: 0;
  }

  /* Each half reads value-then-unit, like every other tile */
  .byn-usd-future-combo-group-usd .byn-usd-future-input {
    text-align: left;
  }
}

@media (max-width: 480px) {
  .byn-usd-future-main {
    border-radius: 16px;
  }

  .byn-usd-future-content {
    padding: 4px;
  }

  .byn-usd-future-input {
    font-size: 1rem;
  }
}
