/* ============================================
   CRYPTO CALCULATOR — .cc-* component styles
   ============================================ */

.cc-affiliate-layout {
  display: grid;
  grid-template-columns: minmax(0, 820px) 152px;
  gap: 1.5rem;
  align-items: start;
  justify-content: center;
}

.crypto-tool {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
}

.crypto-tool [hidden] {
  display: none !important;
}

/* ── Sidebar ── */
.cc-ledger-sidebar {
  position: sticky;
  top: 1rem;
}

.cc-ledger-card {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 0.75rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  transition: border-color 0.18s, box-shadow 0.18s;
}

.cc-ledger-card:hover {
  border-color: var(--primary);
  box-shadow: 0 6px 24px rgba(var(--shadow-color-rgb), 0.22);
}

.cc-ledger-card a {
  display: block;
  line-height: 0;
  border-radius: 6px;
  overflow: hidden;
}

.cc-ledger-card img {
  display: block;
  width: 120px;
  height: auto;
}

/* Shared badge */
.cc-ledger-badge {
  display: inline-block;
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 0.62rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.6;
}

.cc-ledger-badge--sm {
  font-size: 0.58rem;
  padding: 1px 6px;
}


/* ── Mobile image ── */
.cc-ledger-mobile a {
  display: block;
  line-height: 0;
}

.cc-ledger-mobile img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.cc-ledger-mobile {
  display: none;
}

.cc-ledger-mobile[hidden] {
  display: none !important;
}

/* ===== Top tab bar ===== */
.cc-tabs {
  display: flex;
  gap: 0.5rem;
  padding: 0.3rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.75rem;
}

.cc-tab {
  flex: 1;
  padding: 0.7rem 1rem;
  min-height: 44px;
  background: transparent;
  border: none;
  border-radius: calc(var(--radius) - 4px);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  white-space: nowrap;
}

.cc-tab:hover { color: var(--text); }

.cc-tab.active {
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(var(--primary-rgb), 0.3);
}

/* ===== Sections (tab panels) ===== */
.cc-section { display: none; }
.cc-section.active { display: block; animation: fadeUp 0.2s ease; }

/* ===== Currency row ===== */
.cc-currency-row {
  margin-bottom: 1.25rem;
}

.cc-currency-row .input-group {
  max-width: 280px;
  margin-bottom: 0;
}

/* ===== Input with currency prefix ===== */
.cc-input-prefix {
  display: flex;
  align-items: stretch;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: var(--transition);
  background: var(--bg);
}

.cc-input-prefix:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.cc-prefix {
  padding: 0 0.875rem;
  display: flex;
  align-items: center;
  background: var(--surface);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.95rem;
  border-right: 1px solid var(--border);
  user-select: none;
  white-space: nowrap;
}

.cc-input-prefix .input-field {
  border: none;
  background: transparent;
  flex: 1;
  min-width: 0;
  box-shadow: none;
}

.cc-input-prefix .input-field:focus {
  outline: none;
  box-shadow: none;
}

/* ===== Input with suffix (%) ===== */
.cc-input-suffix {
  display: flex;
  align-items: stretch;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: var(--transition);
  background: var(--bg);
}

.cc-input-suffix:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.cc-suffix {
  padding: 0 0.875rem;
  display: flex;
  align-items: center;
  background: var(--surface);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9rem;
  border-left: 1px solid var(--border);
  user-select: none;
}

.cc-input-suffix .input-field {
  border: none;
  background: transparent;
  flex: 1;
  min-width: 0;
  box-shadow: none;
}

.cc-input-suffix .input-field:focus {
  outline: none;
  box-shadow: none;
}

/* ===== Hint text ===== */
.cc-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* ===== Market Cap direction + inputs ===== */
.cc-mc-mode-toggle {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.3rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.cc-mc-mode-btn {
  flex: 1;
  padding: 0.65rem 0.75rem;
  min-height: 44px;
  background: transparent;
  border: none;
  border-radius: calc(var(--radius) - 4px);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  line-height: 1.3;
}

.cc-mc-mode-btn:hover { color: var(--text); }

.cc-mc-mode-btn.active {
  background: var(--bg);
  color: var(--primary);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(var(--shadow-color-rgb), 0.1);
}

[data-theme="dark"] .cc-mc-mode-btn.active {
  background: var(--border);
  color: var(--primary);
}

.cc-mc-mode-help {
  margin: -0.35rem 0 1rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.5;
}

.cc-method-help {
  margin: -1rem 0 1.5rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.5;
}

.cc-mc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.cc-mc-grid .input-group { margin-bottom: 0; }

.cc-mc-mode-price-cap #mc-target-price-group,
.cc-mc-mode-cap-price #mc-marketcap-group {
  order: 1;
}

#mc-circulating-group {
  order: 2;
}

#mc-maxsupply-group {
  order: 3;
}

/* ===== Market Cap hero result ===== */
.cc-mc-results {
  margin-top: 0.5rem;
}

.cc-mc-hero {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: var(--on-primary);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  text-align: center;
  margin-bottom: 1rem;
  box-shadow: 0 6px 20px rgba(var(--primary-rgb), 0.25);
}

.cc-mc-hero-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  opacity: 0.85;
  margin-bottom: 0.5rem;
}

.cc-mc-hero-value {
  display: block;
  font-size: 2.6rem;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}

/* ===== Secondary result cards ===== */
.cc-mc-secondary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.cc-mc-card,
.cc-pl-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  transition: var(--transition);
}

.cc-mc-card:hover,
.cc-pl-card:hover {
  border-color: var(--primary);
}

.cc-card-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.cc-card-value {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}

/* ===== Supply bar ===== */
.cc-supply-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}

.cc-supply-bar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.cc-supply-bar-header strong {
  color: var(--primary);
  font-weight: 700;
}

.cc-supply-bar-track {
  background: var(--border);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.cc-supply-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 999px;
  transition: width 0.4s ease;
}

.cc-supply-bar-footer {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ===== P&L input method toggle ===== */
.cc-method-toggle {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.3rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
}

.cc-method-btn {
  flex: 1;
  padding: 0.65rem 0.75rem;
  min-height: 44px;
  background: transparent;
  border: none;
  border-radius: calc(var(--radius) - 4px);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  line-height: 1.3;
}

.cc-method-btn:hover { color: var(--text); }

.cc-method-btn.active {
  background: var(--bg);
  color: var(--primary);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(var(--shadow-color-rgb), 0.1);
}

[data-theme="dark"] .cc-method-btn.active {
  background: var(--border);
  color: var(--primary);
}

/* ===== P&L inputs grid ===== */
.cc-pl-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.cc-pl-inputs .input-group { margin-bottom: 0; }

.cc-pl-method-tokens-price #pl-tokens-group,
.cc-pl-method-invested-price #pl-invested-group,
.cc-pl-method-tokens-invested #pl-tokens-group {
  order: 1;
}

.cc-pl-method-tokens-price #pl-buyprice-group,
.cc-pl-method-invested-price #pl-buyprice-group,
.cc-pl-method-tokens-invested #pl-invested-group {
  order: 2;
}

#pl-sellprice-group {
  order: 3;
}

/* ===== Computed value display ===== */
.cc-computed {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: rgba(var(--primary-rgb), 0.08);
  border: 1px solid rgba(var(--primary-rgb), 0.25);
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.cc-computed-label {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.cc-computed-value {
  font-weight: 700;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  font-size: 1rem;
}

/* ===== Fees collapsible ===== */
.cc-fees-details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.cc-fees-details summary {
  padding: 0.85rem 1.1rem;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  user-select: none;
  gap: 0.75rem;
}

.cc-fees-details summary::-webkit-details-marker { display: none; }

.cc-fees-details summary::after {
  content: '+';
  font-size: 1.3rem;
  color: var(--text-muted);
  font-weight: 300;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.cc-fees-details[open] summary::after { content: '−'; }

.cc-fees-summary-label {
  font-weight: 600;
  color: var(--text);
  font-size: 0.9rem;
}

.cc-fees-summary-status {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-left: auto;
  margin-right: 0.5rem;
}

.cc-fees-body {
  padding: 0.5rem 1.1rem 1.1rem;
  border-top: 1px solid var(--border);
}

.cc-fees-help {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.85rem;
  line-height: 1.5;
}

/* ===== P&L hero result ===== */
.cc-pl-results {
  margin-top: 0.25rem;
}

.cc-pl-hero {
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  text-align: center;
  margin-bottom: 1rem;
  background: var(--surface);
  border: 2px solid var(--border);
  transition: var(--transition);
}

.cc-pl-hero-profit {
  background: linear-gradient(135deg, var(--success), var(--success));
  border-color: transparent;
  box-shadow: 0 6px 20px rgba(var(--success-rgb), 0.25);
  color: var(--on-primary);
}

.cc-pl-hero-loss {
  background: linear-gradient(135deg, var(--danger), var(--danger));
  border-color: transparent;
  box-shadow: 0 6px 20px rgba(var(--danger-rgb), 0.25);
  color: var(--on-primary);
}

.cc-pl-hero-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  opacity: 0.8;
  margin-bottom: 0.4rem;
  color: inherit;
}

.cc-pl-hero-value {
  display: block;
  font-size: 2.6rem;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
  color: inherit;
}

.cc-pl-hero-pct {
  display: block;
  font-size: 1.15rem;
  font-weight: 600;
  margin-top: 0.4rem;
  opacity: 0.9;
  color: inherit;
  font-variant-numeric: tabular-nums;
}

/* ===== P&L secondary grid ===== */
.cc-pl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

/* ===== Target multiplier helper ===== */
.cc-target-details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.cc-target-details summary {
  padding: 0.85rem 1.1rem;
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
  font-size: 0.9rem;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  user-select: none;
}

.cc-target-details summary::-webkit-details-marker { display: none; }

.cc-target-details summary::after {
  content: '+';
  font-size: 1.3rem;
  color: var(--text-muted);
  font-weight: 300;
  margin-left: auto;
  transition: transform 0.2s ease;
}

.cc-target-details[open] summary::after { content: '−'; }

.cc-target-body {
  padding: 0.5rem 1.1rem 1.1rem;
  border-top: 1px solid var(--border);
}

.cc-target-help {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.85rem;
  line-height: 1.5;
}

.cc-target-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.cc-target-row label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
}

.cc-target-row .input-field {
  width: 100px;
  flex-shrink: 0;
  margin-bottom: 0;
}

.cc-target-row span {
  font-weight: 600;
  color: var(--text-muted);
}

.cc-target-result {
  margin-top: 0.85rem;
  padding: 0.75rem 1rem;
  background: rgba(var(--primary-rgb), 0.08);
  border: 1px solid rgba(var(--primary-rgb), 0.25);
  border-radius: var(--radius);
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.6;
}

.cc-target-error {
  background: rgba(var(--danger-rgb), 0.08);
  border-color: rgba(var(--danger-rgb), 0.3);
  color: var(--text);
}

/* ===== Action buttons row ===== */
.cc-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
  max-width: 520px;
  margin-top: 1.5rem;
  margin-right: auto;
  margin-left: auto;
}

.cc-actions .btn {
  min-height: 44px;
  flex: 1 1 0;
  min-width: 180px;
  max-width: 240px;
  padding-right: 1.15rem;
  padding-left: 1.15rem;
}

/* ===== Mobile ===== */
@media (max-width: 640px) {
  .cc-tabs {
    flex-direction: column;
    gap: 0.25rem;
  }

  .cc-method-toggle {
    flex-direction: column;
    gap: 0.25rem;
  }

  .cc-mc-mode-toggle {
    flex-direction: column;
    gap: 0.25rem;
  }

  .cc-method-btn { flex: none; }

  .cc-mc-secondary {
    grid-template-columns: 1fr 1fr;
  }

  .cc-mc-hero-value,
  .cc-pl-hero-value {
    font-size: 2rem;
  }

  .cc-pl-grid {
    grid-template-columns: 1fr 1fr;
  }

  .cc-currency-row .input-group {
    max-width: 100%;
  }

  .cc-target-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .cc-target-row .input-field { width: 100%; }

  .cc-actions .btn { flex: 1 1 100%; }
}

@media (max-width: 860px) {
  .ledger-mobile-ad-active .tool-page {
    padding-bottom: calc(5.75rem + env(safe-area-inset-bottom));
  }

  .cc-affiliate-layout {
    display: block;
  }

  .cc-ledger-sidebar {
    display: none;
  }

  .cc-ledger-mobile {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 80;
    display: grid;
    grid-template-columns: minmax(0, 320px) 44px;
    grid-template-areas:
      "label close"
      "ad close";
    justify-content: center;
    align-items: center;
    column-gap: 0.55rem;
    row-gap: 0.25rem;
    width: 100%;
    padding: 0.45rem 0.75rem calc(0.45rem + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    background: var(--bg);
    box-shadow: 0 -14px 32px rgba(var(--shadow-color-rgb), 0.18);
    transform: translateY(0);
    transition: transform 0.18s ease, opacity 0.18s ease;
  }

  .cc-ledger-mobile.is-near-footer {
    opacity: 0;
    pointer-events: none;
    transform: translateY(100%);
  }

  .cc-ledger-mobile a {
    grid-area: ad;
    justify-self: center;
    min-width: 0;
    width: 100%;
    max-width: 320px;
    overflow: hidden;
    border-radius: 6px;
  }

  .cc-ledger-mobile-label {
    grid-area: label;
    justify-self: start;
    width: 100%;
    max-width: 320px;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
  }

  .cc-ledger-mobile-brand {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.2;
  }

  .cc-ledger-mobile img {
    width: 100%;
    max-height: 50px;
    object-fit: contain;
  }

  .cc-ledger-mobile button {
    grid-area: close;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    transition: color 0.15s;
  }

  .cc-ledger-mobile button:hover,
  .cc-ledger-mobile button:focus-visible {
    color: var(--text);
    outline: none;
  }
}

