/* ROI Calculator Widget Styles - Waltio Design System */

/* Design System Colors */
:root {
  --waltio-purple: #3B24FC;
  --waltio-purple-hover: #2A1BC7;
  --waltio-text-grey-2: #4A4A4A;
  --waltio-stroke-button: #E5E5E5;
  --waltio-white: #FFFFFF;
  --waltio-error: #E53E3E;
  --waltio-disabled-bg: #F5F5F5;
  --waltio-disabled-text: #9B9B9B;
  --waltio-success: #00A86B;
}

/* Crypto Profit Simulator custom styles */

.profit-assets-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.profit-asset-card {
  border: 1px solid var(--waltio-stroke-button);
  border-radius: 12px;
  background: #F5F7FA;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, transform 0.05s ease;
}

.profit-asset-card:hover {
  border-color: var(--waltio-purple);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06);
}

.profit-asset-card.selected {
  border-color: var(--waltio-purple);
  background: rgba(59, 36, 252, 0.06);
  box-shadow: 0 4px 16px rgba(59, 36, 252, 0.18);
}

.profit-asset-symbol {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--waltio-white);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.profit-asset-logo {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: contain;
  display: block;
}

.profit-asset-label {
  font-size: 12px;
  font-weight: 600;
  color: #1a1a1a;
}

.profit-asset-price {
  font-size: 11px;
  color: var(--waltio-disabled-text);
}

.profit-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--waltio-text-grey-2);
}

.profit-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.profit-meta-label {
  opacity: 0.7;
}

.profit-meta-value {
  font-weight: 600;
}

.profit-currency-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--waltio-stroke-button);
  background: #F5F7FA;
  font-size: 11px;
}

.profit-currency-flag {
  font-size: 13px;
}

.profit-currency-select {
  border: none;
  background: transparent;
  font: inherit;
  padding: 0;
  margin: 0;
  outline: none;
  cursor: pointer;
}

.profit-currency-select option {
  color: #111827;
}

.roi-input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 8px;
}

.profit-output-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 16px;
  color: var(--waltio-white);
}

.profit-output-bar.profit-positive {
  background: #16A34A;
}

.profit-output-bar.profit-negative {
  background: #DC2626;
}

.profit-output-bar.profit-neutral {
  background: #4B5563;
}

.profit-output-label {
  opacity: 0.9;
}

.profit-output-value {
  font-size: 18px;
}

.profit-output-caption {
  margin-top: 8px;
  font-size: 12px;
  color: var(--waltio-disabled-text);
  text-align: center;
}

@media (max-width: 600px) {
  .profit-assets-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .roi-input-row {
    grid-template-columns: 1fr;
  }
}

.roi-calculator-widget {
  font-family: var(--waltio-font-family, 'Roobert', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif);
  max-width: 500px;
  margin: 0 auto;
  padding: 24px;
  background: var(--waltio-white);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  color: var(--waltio-text-grey-2);
  position: relative; /* anchors Share modal inside widget */
  overflow: hidden; /* keeps the share overlay visually inside the card */
}

.roi-header {
  text-align: center;
  margin-bottom: 32px;
}

.roi-header h2 {
  margin: 0 0 8px 0;
  font-size: 24px;
  font-weight: 600;
  color: #1a1a1a;
}

.roi-subtitle {
  margin: 0;
  font-size: 14px;
  color: var(--waltio-text-grey-2);
  opacity: 0.7;
}

.roi-form {
  margin-bottom: 24px;
}

.roi-input-group {
  margin-bottom: 20px;
}

.roi-input-group label {
  display: block;
  margin-bottom: 12px; /* 12px padding entre label et input selon design */
  font-size: 14px;
  font-weight: 500;
  color: var(--waltio-text-grey-2);
}

.roi-input {
  width: 100%;
  padding: 12px 16px;
  font-size: 16px;
  line-height: 1.5;
  border: 1px solid var(--waltio-stroke-button);
  border-radius: 8px;
  box-sizing: border-box;
  background: var(--waltio-white);
  color: #1a1a1a;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  font-family: inherit;
}

.roi-input::placeholder {
  color: var(--waltio-disabled-text);
  opacity: 0.6;
}

/* Default state - already defined above */

/* Focused state - purple border */
.roi-input:focus {
  outline: none;
  border-color: var(--waltio-purple);
  box-shadow: 0 0 0 3px rgba(59, 36, 252, 0.1);
}

/* Error state */
.roi-input.error {
  border-color: var(--waltio-error);
}

.roi-input.error:focus {
  border-color: var(--waltio-error);
  box-shadow: 0 0 0 3px rgba(229, 62, 62, 0.1);
}

.roi-error-message {
  display: none;
  margin-top: 8px;
  font-size: 12px;
  color: var(--waltio-error);
}

.roi-input-group.has-error .roi-error-message {
  display: block;
}

/* Disabled state */
.roi-input:disabled {
  background: var(--waltio-disabled-bg);
  border-color: var(--waltio-stroke-button);
  color: var(--waltio-disabled-text);
  cursor: not-allowed;
}

.roi-input:disabled::placeholder {
  color: var(--waltio-disabled-text);
  opacity: 1;
}

/* Read-only state */
.roi-input[readonly] {
  border-color: #E3F2FD;
  background: #F5F9FF;
}

/* CoinStats-like mode (gb-en): hide Amount field, compute it from Investment + Buy price */
.profit-investment-mode .roi-amount-group {
  display: none;
}

/* Share button + modal (CoinStats-like, non-customizable) */
.roi-share-row {
  display: flex;
  justify-content: center;
  margin-top: 14px;
}

/* Feature flag: hide Share UI unless explicitly enabled */
.roi-calculator-widget:not([data-share-enabled="true"]) .roi-share-row {
  display: none;
}

.roi-calculator-widget:not([data-share-enabled="true"]) .roi-share-modal {
  display: none !important;
}

.roi-share-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: auto;
  height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid rgba(17, 24, 39, 0.18);
  background: #ffffff;
  color: #111827;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.roi-share-icon {
  display: inline-flex;
  width: 18px;
  height: 18px;
}

.roi-share-button:hover {
  background: #f3f4f6;
  border-color: rgba(17, 24, 39, 0.26);
}

.roi-share-button:active {
  transform: scale(0.99);
}

.roi-share-modal {
  position: absolute;
  inset: 12px; /* leave visible widget contours */
  z-index: 50;
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
}

.roi-share-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  border-radius: inherit;
}

.roi-share-dialog {
  position: relative;
  width: min(520px, 100%);
  margin: 0;
  border-radius: 16px;
  background: #ffffff;
  color: #111827;
  border: 1px solid rgba(17, 24, 39, 0.12);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  padding: 18px 18px 18px 18px;
  max-height: calc(100% - 24px);
  overflow: hidden; /* keep it clean: no internal scroll */
  display: flex;
  flex-direction: column;
  align-items: center; /* center content */
  box-sizing: border-box;
}

.roi-share-header {
  width: 100%;
  display: grid;
  grid-template-columns: 40px 1fr 40px; /* symmetric: left spacer + centered title + close */
  align-items: center;
  margin-bottom: 14px;
}

.roi-share-header-spacer {
  width: 40px;
  height: 40px;
}

.roi-share-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  text-align: center;
}

.roi-share-close {
  position: static;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: rgba(17, 24, 39, 0.65);
  font-size: 28px;
  line-height: 40px;
  cursor: pointer;
  justify-self: end;
}

.roi-share-close:hover {
  color: #111827;
}

.roi-share-box {
  position: relative;
  width: 100%;
  max-width: 100%;
  width: min(460px, 100%);
  margin: 0 auto;
  box-sizing: border-box;
}

.roi-share-snippet {
  width: 100%;
  min-height: 92px;
  padding: 16px 64px 16px 16px; /* room for copy icon inside */
  border-radius: 14px;
  border: 1px solid rgba(17, 24, 39, 0.12);
  background: #f9fafb;
  color: #111827;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 13px;
  line-height: 1.5;
  resize: none;
  overflow: hidden; /* we auto-size via JS, so no internal scrollbar */
  scrollbar-width: none; /* Firefox */
  white-space: pre-wrap; /* wrap long lines so no horizontal scroll */
  overflow-wrap: anywhere;
  box-sizing: border-box;
  display: block;
}

.roi-share-snippet:focus {
  outline: none;
  border-color: rgba(17, 24, 39, 0.18);
  box-shadow: none;
}

.roi-share-snippet::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.roi-share-copy {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 14px;
  border: 1px solid rgba(17, 24, 39, 0.14);
  background: #ffffff;
  color: #111827;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(17, 24, 39, 0.08);
  z-index: 2; /* always above snippet content */
}

.roi-share-copy:hover {
  background: #f3f4f6;
}

.roi-share-copy[data-copied="true"]::after {
  content: "Copied";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%, -110%);
  background: #111827;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  padding: 6px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

/* Button Styles */
 .roi-button {
  width: 100%;
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 600;
  color: var(--waltio-white);
  background: var(--waltio-purple);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  font-family: inherit;
  position: relative;
  min-height: 48px; /* Taille fixe pour éviter le changement de taille lors du loading */
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

@keyframes roiPulseGlow {
  0%, 100% {
    box-shadow:
      0 0 0 0 rgba(59, 36, 252, 0.45),
      0 0 0 0 rgba(59, 36, 252, 0.35),
      0 6px 18px rgba(59, 36, 252, 0.35);
  }
  50% {
    box-shadow:
      0 0 0 6px rgba(59, 36, 252, 0.35),
      0 0 0 12px rgba(59, 36, 252, 0.22),
      0 10px 26px rgba(59, 36, 252, 0.5);
  }
}

.roi-button:hover:not(:disabled) {
  background: var(--waltio-purple-hover);
}

.roi-button:active:not(:disabled) {
  background: var(--waltio-purple-hover);
}

.roi-button:disabled {
  background: var(--waltio-disabled-bg);
  color: var(--waltio-disabled-text);
  cursor: not-allowed;
  border: 1px solid var(--waltio-stroke-button);
}

/* CTA-like visual effect for Crypto Profit primary button */
.roi-primary-button {
  background: linear-gradient(135deg, #3b24fc 0%, #2b1bb8 100%);
  box-shadow: 0 4px 12px rgba(59, 36, 252, 0.3);
  position: relative;
  overflow: visible; /* allow halo to be visible around the button */
  isolation: isolate;
  animation: roiPulseGlow 2s ease-in-out infinite;
}

.roi-primary-button:hover:not(:disabled) {
  background: linear-gradient(135deg, #4a35ff 0%, #3b24fc 100%);
  box-shadow: 0 6px 16px rgba(59, 36, 252, 0.4);
  transform: translateY(-2px);
  animation: none;
}

.roi-primary-button:active:not(:disabled) {
  transform: translateY(0);
}

/* Ripple hover/active effect intentionally removed to keep a softer CTA */

/* Loading state - keep visual stability (avoid “white/blank” flash on click) */
.roi-button.loading {
  color: var(--waltio-white);
  pointer-events: none;
  background: var(--waltio-purple-hover);
  animation: none;
  transform: none;
}

.roi-button.loading::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  top: 50%;
  left: 50%;
  margin-left: -10px;
  margin-top: -10px;
  border: 2px solid var(--waltio-white);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Results */
.roi-result {
  margin-top: 24px;
  padding: 20px;
  background: #F5F7FA;
  border-radius: 8px;
  animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.roi-result-header h3 {
  margin: 0 0 16px 0;
  font-size: 18px;
  font-weight: 600;
  color: #1a1a1a;
}

.roi-result-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.roi-metric {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--waltio-white);
  border-radius: 8px;
  border: 1px solid var(--waltio-stroke-button);
}

.roi-metric-label {
  font-size: 14px;
  color: var(--waltio-text-grey-2);
}

.roi-metric-value {
  font-size: 18px;
  font-weight: 600;
  color: #1a1a1a;
}

.roi-metric-value.roi-gain {
  color: var(--waltio-success);
}

.roi-metric-value.roi-percentage {
  color: var(--waltio-purple);
}

.roi-footer {
  margin-top: 20px;
  text-align: center;
}

.roi-powered-by {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--waltio-stroke-button);
}

.roi-powered-by-text {
  font-size: 12px;
  color: var(--waltio-disabled-text);
  opacity: 0.6;
  text-transform: lowercase;
  font-weight: 400;
}

.roi-powered-by-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.roi-powered-by-link:hover {
  opacity: 0.8;
}

.roi-powered-by-logo {
  height: 20px;
  width: auto;
  display: block;
}

/* Dark theme support */
[data-theme="dark"] .roi-calculator-widget {
  background: #1a1a1a;
  color: #e0e0e0;
}

[data-theme="dark"] .roi-header h2 {
  color: #ffffff;
}

[data-theme="dark"] .roi-subtitle {
  color: #b0b0b0;
}

[data-theme="dark"] .roi-input-group label {
  color: #e0e0e0;
}

[data-theme="dark"] .roi-input {
  background: #2a2a2a;
  border-color: #404040;
  color: #e0e0e0;
}

[data-theme="dark"] .roi-input:focus {
  border-color: var(--waltio-purple);
  box-shadow: 0 0 0 3px rgba(59, 36, 252, 0.2);
}

[data-theme="dark"] .roi-input:disabled {
  background: #1a1a1a;
  border-color: #404040;
  color: #666;
}

[data-theme="dark"] .roi-result {
  background: #2a2a2a;
}

[data-theme="dark"] .roi-result-header h3 {
  color: #ffffff;
}

[data-theme="dark"] .roi-metric {
  background: #1a1a1a;
  border-color: #404040;
}

[data-theme="dark"] .roi-metric-label {
  color: #b0b0b0;
}

[data-theme="dark"] .roi-metric-value {
  color: #e0e0e0;
}


[data-theme="dark"] .roi-powered-by {
  border-top-color: #404040;
}

[data-theme="dark"] .roi-powered-by-text {
  color: #808080;
}

/* Responsive */
@media (max-width: 600px) {
  .roi-calculator-widget {
    padding: 20px;
    border-radius: 8px;
  }

  .roi-header h2 {
    font-size: 20px;
  }

  .roi-result-content {
    gap: 8px;
  }

  .roi-metric {
    padding: 10px 12px;
  }
}
