/* ============================================================
   BOLT12 Decoder Website - Dark theme inspired by bolt11.org
   ============================================================ */

:root {
  --bg: #0d0f1b;
  --bg-surface: #141627;
  --bg-card: #1a1d35;
  --text-primary: #e8e9ed;
  --text-secondary: #858692;
  --accent: #2dd4a8;
  --accent-dim: rgba(45, 212, 168, 0.15);
  --border: #2a2d45;
  --mono: 'JetBrains Mono', monospace;
  --sans: 'Inter', -apple-system, system-ui, sans-serif;

  /* TLV field colors */
  --color-chains: rgba(27, 51, 93, 0.7);
  --color-metadata: rgba(92, 25, 75, 0.7);
  --color-currency: rgba(168, 120, 48, 0.7);
  --color-amount: rgba(0, 110, 98, 0.7);
  --color-description: rgba(51, 166, 120, 0.7);
  --color-features: rgba(57, 118, 179, 0.7);
  --color-expiry: rgba(168, 48, 49, 0.7);
  --color-paths: rgba(120, 71, 169, 0.7);
  --color-issuer: rgba(71, 105, 169, 0.7);
  --color-quantity: rgba(125, 144, 25, 0.7);
  --color-issuer-id: rgba(32, 71, 92, 0.7);
  --color-unknown: rgba(80, 80, 80, 0.7);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--sans);
  line-height: 1.6;
  min-height: 100vh;
}

.app {
  max-width: 860px;
  margin: 0 auto;
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 48px;
}

/* ---- Hero ---- */
.hero {
  text-align: center;
  padding: 20px 0;
}

.hero h1 {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}

.subtitle {
  color: var(--accent);
  font-size: 1.05rem;
}

/* ---- Decoder Section ---- */
.decoder-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.decoder-section label {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

#bolt12-input {
  width: 100%;
  min-height: 100px;
  padding: 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--mono);
  font-size: 0.85rem;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
  word-break: break-all;
}

#bolt12-input:focus {
  border-color: var(--accent);
}

#bolt12-input::placeholder {
  color: var(--text-secondary);
  opacity: 0.5;
}

.decoded-display {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  font-family: var(--mono);
  font-size: 0.95rem;
  line-height: 1.7;
  word-break: break-all;
  min-height: 60px;
}

.decoded-display .placeholder-text {
  color: var(--text-secondary);
  font-family: var(--sans);
  font-size: 0.9rem;
}

.decoded-display .tlv-span {
  padding: 2px 1px;
  border-radius: 3px;
  cursor: pointer;
  transition: opacity 0.15s;
}

.decoded-display .tlv-span:hover {
  opacity: 0.8;
  outline: 1px solid rgba(255,255,255,0.3);
}

.decoded-display .tlv-separator {
  color: var(--text-secondary);
  opacity: 0.4;
}

.info-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  min-height: 60px;
  transition: background-color 0.2s;
}

.info-panel .info-placeholder {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.info-panel .info-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.5);
  margin-bottom: 2px;
}

.info-panel .info-value {
  font-family: var(--mono);
  font-size: 0.85rem;
  word-break: break-all;
}

.info-panel .info-name {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 8px;
}

.error-panel {
  background: rgba(168, 48, 49, 0.2);
  border: 1px solid rgba(168, 48, 49, 0.5);
  border-radius: 8px;
  padding: 12px 16px;
  color: #ff8a8a;
  font-family: var(--mono);
  font-size: 0.85rem;
}

/* ---- Fields Table ---- */
.fields-table {
  width: 100%;
}

.fields-table h3 {
  font-size: 1rem;
  margin-bottom: 12px;
  color: var(--text-secondary);
}

.fields-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.fields-table th {
  text-align: left;
  padding: 8px 12px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.fields-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.fields-table td:first-child {
  font-family: var(--mono);
  color: var(--accent);
  white-space: nowrap;
}

.fields-table td:nth-child(2) {
  font-weight: 500;
  white-space: nowrap;
}

.fields-table td:nth-child(3) {
  font-family: var(--mono);
  color: var(--text-secondary);
  white-space: nowrap;
}

.fields-table td:last-child {
  font-family: var(--mono);
  font-size: 0.8rem;
  word-break: break-all;
  max-width: 400px;
}

.fields-table tr:hover td {
  background: rgba(255,255,255,0.02);
}

/* ---- Content Sections ---- */
.content-section {
  width: 100%;
}

.content-section h2 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 12px;
  letter-spacing: -0.01em;
}

.content-section > p {
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.7;
}

.content-section strong {
  color: var(--text-primary);
}

.content-section code {
  background: var(--bg-card);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.85em;
  color: var(--accent);
}

/* ---- Comparison Grid ---- */
.comparison-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.comparison-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
}

.comparison-card h3 {
  font-size: 1.05rem;
  margin-bottom: 12px;
}

.comparison-card ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.comparison-card li {
  color: var(--text-secondary);
  font-size: 0.9rem;
  padding-left: 20px;
  position: relative;
}

.comparison-card li::before {
  position: absolute;
  left: 0;
  font-size: 0.8rem;
}

.bolt11-card {
  border-color: rgba(168, 48, 49, 0.3);
}

.bolt11-card h3 {
  color: #ff8a8a;
}

.bolt11-card li::before {
  content: '\2717';
  color: #ff8a8a;
}

.bolt12-card {
  border-color: rgba(45, 212, 168, 0.3);
}

.bolt12-card h3 {
  color: var(--accent);
}

.bolt12-card li::before {
  content: '\2713';
  color: var(--accent);
}

/* ---- Flow Diagram ---- */
.flow-diagram {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.flow-step {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  width: 100%;
}

.flow-number {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
}

.flow-content h4 {
  font-size: 1rem;
  margin-bottom: 4px;
}

.flow-content h4 code {
  font-weight: 400;
  margin-left: 4px;
}

.flow-content p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.flow-arrow {
  color: var(--accent);
  font-size: 1.4rem;
  padding: 4px 0;
  opacity: 0.6;
}

/* ---- Spec Table ---- */
.spec-table-wrapper {
  overflow-x: auto;
}

.spec-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.spec-table th {
  text-align: left;
  padding: 10px 14px;
  background: var(--bg-card);
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.spec-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.spec-table td:first-child {
  font-family: var(--mono);
  color: var(--accent);
  font-weight: 500;
  white-space: nowrap;
}

.spec-table td:nth-child(2) {
  font-family: var(--mono);
  font-size: 0.85rem;
  white-space: nowrap;
}

.spec-table tr:hover td {
  background: rgba(255,255,255,0.02);
}

/* ---- Concepts Grid ---- */
.concepts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.concept-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
}

.concept-card h3 {
  font-size: 1rem;
  margin-bottom: 8px;
  color: var(--accent);
}

.concept-card p {
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.6;
}

/* ---- Resources Grid ---- */
.resources-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.resource-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s, transform 0.15s;
}

.resource-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.resource-card h3 {
  font-size: 1rem;
  margin-bottom: 8px;
}

.resource-card p {
  color: var(--text-secondary);
  font-size: 0.85rem;
  flex: 1;
  margin-bottom: 16px;
}

.resource-btn {
  display: inline-block;
  padding: 6px 16px;
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  text-align: center;
  transition: background 0.2s;
}

.resource-card:hover .resource-btn {
  background: rgba(45, 212, 168, 0.25);
}

/* ---- Playground ---- */
.playground {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 20px;
}

.playground-tabs {
  display: flex;
  background: #1a1d35;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.playground-tab {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 10px 20px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

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

.playground-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.playground-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 340px;
}

.playground-editor-wrap,
.playground-output-wrap {
  display: flex;
  flex-direction: column;
}

.playground-editor-wrap {
  border-right: 1px solid var(--border);
}

.playground-editor-header,
.playground-output-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 14px;
  background: #1e2140;
  border-bottom: 1px solid var(--border);
}

.code-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

.run-btn {
  background: var(--accent);
  color: #0d0f1b;
  border: none;
  border-radius: 4px;
  padding: 4px 14px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--sans);
  transition: opacity 0.15s;
}

.run-btn:hover {
  opacity: 0.85;
}

.playground-editor {
  flex: 1;
  width: 100%;
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.65;
  padding: 14px 16px;
  border: none;
  outline: none;
  resize: none;
  tab-size: 2;
  white-space: pre;
  overflow: auto;
}

.playground-output {
  flex: 1;
  background: #0a0c16;
  color: #b0b8c4;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.65;
  padding: 14px 16px;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.playground-output .out-error {
  color: #ff8a8a;
}

.playground-output .out-label {
  color: #546e7a;
  font-style: italic;
}

.install-hint {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 20px;
}

.install-hint code {
  background: var(--bg-surface);
  padding: 4px 10px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--accent);
}

/* ---- Footer ---- */
footer {
  text-align: center;
  padding: 20px 0;
  border-top: 1px solid var(--border);
  width: 100%;
}

footer p {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

footer .footer-sub {
  font-size: 0.75rem;
  margin-top: 4px;
}

footer a {
  color: var(--accent);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* ---- Responsive ---- */
@media (max-width: 700px) {
  .hero h1 {
    font-size: 1.8rem;
  }

  .comparison-grid,
  .concepts-grid {
    grid-template-columns: 1fr;
  }

  .resources-grid {
    grid-template-columns: 1fr 1fr;
  }

  .playground-body {
    grid-template-columns: 1fr;
  }

  .playground-editor-wrap {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .playground-editor {
    min-height: 200px;
  }

  .playground-output {
    min-height: 150px;
  }
}

@media (max-width: 480px) {
  .app {
    padding: 24px 12px;
    gap: 32px;
  }

  .resources-grid {
    grid-template-columns: 1fr;
  }
}
