/* ================================================================
   TOOL PAGE STYLES
   ================================================================ */

/* ── BREADCRUMB ── */
.breadcrumb { display: flex; align-items: center; gap: 6px; padding: 0 0 20px; }
.breadcrumb-item { font-size: .8rem; color: var(--text-3); }
.breadcrumb-item a { color: var(--text-3); transition: color var(--t-fast); }
.breadcrumb-item a:hover { color: var(--violet-light); }
.breadcrumb-sep { color: var(--text-3); font-size: .75rem; }
.breadcrumb-item.current { color: var(--text-1); font-weight: 500; }

/* ── TOOL HEADER ── */
.tool-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 32px; gap: 20px; flex-wrap: wrap;
}
.tool-header-left { display: flex; align-items: center; gap: 18px; min-width: 0; overflow: hidden; }
/* The bare <div> wrapping title+desc inside .tool-header-left */
.tool-header-left > div { min-width: 0; overflow: hidden; }
.tool-header-icon {
  width: 60px; height: 60px; border-radius: var(--r-lg);
  background: var(--bg-3); border: 1px solid var(--border-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem; flex-shrink: 0;
}
.tool-header-icon svg { width: 1em; height: 1em; }
.tool-header-title { font-size: clamp(1.4rem, 3vw, 2rem); font-weight: 800; letter-spacing: -.04em; color: var(--text-0); margin-bottom: 6px; }
.tool-header-desc { font-size: .9rem; color: var(--text-2); max-width: 520px; line-height: 1.6; word-wrap: break-word; overflow-wrap: break-word; }
.tool-header-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ── TOOL LAYOUT ── */
.tool-layout { display: grid; grid-template-columns: 1fr 280px; gap: 28px; align-items: start; padding-top: 28px; }
.tool-main-col { min-width: 0; overflow: hidden; }

/* ── TOOL WIDGET ── */
.tool-widget {
  background: var(--bg-2); border: 1px solid var(--border-1);
  border-radius: var(--r-lg); padding: 24px; margin-bottom: 24px;
  max-width: 100%; overflow-x: auto;
}
.widget-title { font-size: 1rem; font-weight: 700; color: var(--text-0); margin-bottom: 20px; padding-bottom: 14px; border-bottom: 1px solid var(--border-1); }

/* IO areas */
.io-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 16px; }
.io-col { display: flex; flex-direction: column; gap: 8px; }
.io-label {
  display: flex; align-items: center; justify-content: space-between;
  font-size: .78rem; font-weight: 600; color: var(--text-2);
}
.io-textarea {
  background: var(--bg-1); border: 1px solid var(--border-2); border-radius: var(--r-md);
  padding: 14px; font-size: .88rem; color: var(--text-0); outline: none;
  resize: vertical; min-height: 160px; width: 100%; line-height: 1.65;
  transition: border-color var(--t-fast), box-shadow var(--t-fast); font-family: inherit;
}
.io-textarea.mono { font-family: 'JetBrains Mono', monospace; font-size: .82rem; }
.io-textarea:focus { border-color: var(--violet); box-shadow: 0 0 0 3px var(--violet-glow2); }
.io-textarea::placeholder { color: var(--text-3); }

.mode-toggle {
  display: flex; background: var(--bg-1); border: 1px solid var(--border-2);
  border-radius: var(--r-md); padding: 4px; gap: 4px; width: fit-content;
  max-width: 100%; flex-wrap: wrap;
}
.mode-btn {
  padding: 7px 18px; border-radius: var(--r-sm); font-size: .85rem; font-weight: 600;
  color: var(--text-2); cursor: pointer; border: none; background: transparent;
  transition: all var(--t-fast);
}
.mode-btn.active {
  background: #5a4fcc; /* Darker violet — WCAG AA contrast on dark bg */
  color: #ffffff;
  font-weight: 700;
  box-shadow: var(--sh-sm);
}

/* Result cards */
.result-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.result-card {
  background: var(--bg-1); border: 1px solid var(--border-2);
  border-radius: var(--r-md); padding: 14px 16px; text-align: center;
}
.result-card-val { font-size: 1.5rem; font-weight: 800; letter-spacing: -.03em; color: var(--text-0); }
.result-card-label { font-size: .72rem; color: var(--text-2); margin-top: 4px; font-weight: 500; }

/* Strength meter */
.strength-bar { height: 4px; border-radius: 99px; background: var(--bg-4); overflow: hidden; margin: 8px 0; }
.strength-fill { height: 100%; border-radius: 99px; transition: width var(--t-base), background var(--t-base); }

/* Color swatch */
.color-swatch { width: 100%; height: 100px; border-radius: var(--r-md); border: 1px solid var(--border-2); cursor: pointer; }
.color-preview { border-radius: var(--r-md); height: 140px; border: 1px solid var(--border-2); transition: background var(--t-fast); }

/* CSS preview box */
.css-preview-box {
  border-radius: var(--r-md); border: 1px solid var(--border-2);
  min-height: 120px; display: flex; align-items: center; justify-content: center;
  font-size: .8rem; color: var(--text-3); overflow: hidden;
}

/* Options row */
.options-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 16px 0; }
.options-row .form-group { flex: 1; min-width: 120px; }

/* QR / Barcode output */
#qr-output, #barcode-output { display: flex; justify-content: center; padding: 20px; background: #fff; border-radius: var(--r-md); }

/* JWT panels */
.jwt-section { background: var(--bg-1); border: 1px solid var(--border-1); border-radius: var(--r-md); margin-bottom: 12px; overflow: hidden; }
.jwt-section-head { padding: 10px 16px; font-size: .78rem; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: .08em; border-bottom: 1px solid var(--border-1); background: var(--bg-2); }
.jwt-section-body { padding: 14px 16px; font-family: 'JetBrains Mono', monospace; font-size: .8rem; white-space: pre-wrap; word-break: break-all; color: var(--text-0); line-height: 1.7; overflow-x: auto; }

/* ── LIGHT THEME: universal fixes for hardcoded dark-only colours ── */
/* Privacy / offline badges — #4ade80 is invisible on white backgrounds */
[data-theme="light"] [class*="-privacy-badge"],
[data-theme="light"] [class*="-offline-badge"],
[data-theme="light"] [class*="-static-badge"],
[data-theme="light"] .qr-static-badge {
  color: #15803d !important;
  background: #dcfce720 !important;
  border-color: #16a34a50 !important;
}
/* Error blocks — #450a0a black bg is too dark for light mode */
[data-theme="light"] [id$="-error"] {
  color: #b91c1c !important;
  background: #fee2e2 !important;
}
/* Single-display big numbers — dark gradients should use theme bg */
[data-theme="light"] #rn-single-display,
[data-theme="light"] #ts-now,
[data-theme="light"] #ts-ms-now {
  background: var(--bg-3) !important;
  border-color: var(--border-2) !important;
}

/* ── SEO CONTENT SECTION ── */
.seo-content { display: flex; flex-direction: column; gap: 28px; }
.seo-block {
  background: var(--bg-2); border: 1px solid var(--border-1);
  border-radius: var(--r-lg); padding: 24px;
  max-width: 100%; overflow-x: hidden;
}
.seo-block-title {
  font-size: 1.1rem; font-weight: 800; letter-spacing: -.03em;
  color: var(--text-0); margin-bottom: 14px;
  display: flex; align-items: center; gap: 10px;
}
.seo-block-title .seo-title-icon { font-size: 1.3rem; width: 1em; height: 1em; flex-shrink: 0; }
.seo-block-text {
  font-size: .9rem; color: var(--text-1); line-height: 1.8;
}
[data-theme="light"] .seo-block-text { color: var(--text-2); }

/* How-to steps */
.howto-steps { display: flex; flex-direction: column; gap: 14px; margin-top: 4px; }
.howto-step { display: flex; align-items: flex-start; gap: 14px; }
.step-num {
  width: 26px; height: 26px; border-radius: var(--r-xs); flex-shrink: 0;
  background: rgba(124,111,255,.12); border: 1px solid rgba(124,111,255,.3);
  display: flex; align-items: center; justify-content: center;
  font-size: .76rem; font-weight: 800; color: var(--violet); flex-shrink: 0;
}
[data-theme="light"] .step-num {
  background: rgba(124,111,255,.1); border-color: rgba(124,111,255,.35);
  color: #5a4fcc; /* violet-dark, solid for contrast on white */
}
.step-text { font-size: .88rem; color: var(--text-1); padding-top: 3px; line-height: 1.6; }

/* Fields table */
.fields-table-wrap { width: 100%; overflow-x: auto; }
.fields-table { width: 100%; border-collapse: collapse; margin-top: 4px; min-width: 400px; }
.fields-table th {
  text-align: left; padding: 9px 14px; font-size: .72rem; font-weight: 700;
  color: var(--text-2); text-transform: uppercase; letter-spacing: .07em;
  border-bottom: 1px solid var(--border-2); background: var(--bg-1);
}
[data-theme="light"] .fields-table th {
  color: var(--text-1); /* darker on light bg */
  background: var(--bg-0);
  border-bottom-color: var(--border-2);
}
.fields-table td { padding: 11px 14px; font-size: .875rem; color: var(--text-1); border-bottom: 1px solid var(--border-1); vertical-align: top; }
.fields-table td strong { color: var(--text-0); font-weight: 600; }
.fields-table td .mono { font-family: 'JetBrains Mono', monospace; font-size: .78rem; color: var(--cyan-light); background: var(--bg-3); padding: 2px 6px; border-radius: var(--r-xs); }
[data-theme="light"] .fields-table td .mono { color: #0e6fa8; background: #e8eef8; } /* visible cyan on light bg */
.fields-table tr:last-child td { border-bottom: none; }

/* Use cases */
.usecases-list { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.usecase-item { display: flex; align-items: flex-start; gap: 10px; }
.usecase-dot {
  width: 5px; height: 5px; border-radius: 50%; background: var(--violet-light);
  margin-top: 9px; flex-shrink: 0; opacity: .7;
}
.usecase-text { font-size: .88rem; color: var(--text-1); line-height: 1.65; }

/* FAQ */
.faq-list { display: flex; flex-direction: column; gap: 0; }
.faq-item { border-bottom: 1px solid var(--border-1); }
.faq-item:last-child { border-bottom: none; }
.faq-q {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 0; font-size: .9rem; font-weight: 600; color: var(--text-0);
  cursor: pointer; gap: 12px; user-select: none;
}
.faq-q svg { width: 16px; height: 16px; color: var(--text-3); transition: transform var(--t-fast); flex-shrink: 0; }
.faq-item.open .faq-q svg { transform: rotate(180deg); }
.faq-a { font-size: .875rem; color: var(--text-1); line-height: 1.75; max-height: 0; overflow: hidden; transition: max-height 0.35s ease, padding var(--t-base); }
.faq-item.open .faq-a { max-height: 600px; padding-bottom: 16px; }

/* ── SIDEBAR ── */
.tool-sidebar { display: flex; flex-direction: column; gap: 20px; }
.sidebar-card {
  background: var(--bg-2); border: 1px solid var(--border-1);
  border-radius: var(--r-lg); padding: 18px;
}
.sidebar-card-title { font-size: .75rem; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 14px; }

.sidebar-related-list { display: flex; flex-direction: column; gap: 4px; }

.related-tool-link {
  display: flex; flex-direction: column; gap: 4px;
  padding: 10px 0; border-bottom: 1px solid var(--border-1);
  transition: all var(--t-fast);
}
.related-tool-link:last-child { border-bottom: none; padding-bottom: 0; }
.related-tool-link:hover { opacity: .8; }

.related-tool-header { display: flex; align-items: center; gap: 8px; color: var(--text-1); font-size: .875rem; }
.related-tool-header .link-icon { font-size: 1rem; width: 20px; text-align: center; color: var(--violet); }
.related-tool-header .link-name { font-weight: 600; }
.related-tool-context { font-size: .78rem; color: var(--text-3); padding-left: 28px; line-height: 1.4; }

.tech-specs-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 16px;
  background: var(--bg-2); border: 1px solid var(--border-2); border-radius: var(--r-md); padding: 18px;
  margin-top: 10px;
}
.tech-spec-item { font-size: .82rem; color: var(--text-2); }
.tech-spec-item strong { color: var(--text-1); display: block; margin-bottom: 4px; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; }

/* ── TOOL PAGE RESPONSIVE ── */
.toc-mobile { display: none; margin-bottom: 24px; padding-bottom: 12px; border-bottom: 1px solid var(--border-2); }

/* ── Tablet ≤1024px ── */
@media (max-width: 1024px) {
  .tool-layout { grid-template-columns: 1fr; }
  .tool-sidebar { position: static; }
  .toc-desktop { display: none !important; }
  .toc-mobile { display: block; }
}

/* ── Large phone ≤768px ── */
@media (max-width: 768px) {
  /* Breadcrumb: truncate middle items, keep compact */
  .breadcrumb {
    display: flex;
    flex-wrap: nowrap;
    overflow: hidden;   /* clip instead of scroll to prevent any bleed */
    padding-bottom: 10px;
    margin-bottom: 4px;
    gap: 4px;
  }
  .breadcrumb-item {
    font-size: .7rem;
    flex-shrink: 1;      /* allow shrinking */
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .breadcrumb-item.current {
    flex-shrink: 1;
    max-width: 45%;
  }
  .breadcrumb-sep { flex-shrink: 0; font-size: .6rem; }

  /* Tool header: compact but no overflow */
  .tool-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 16px;
  }
  .tool-header-left {
    gap: 10px;
    min-width: 0;
    overflow: hidden;
  }
  .tool-header-icon {
    width: 40px; height: 40px;
    font-size: 1.3rem;
    flex-shrink: 0;
  }
  .tool-header-info {
    min-width: 0;
    overflow: hidden;
  }
  .tool-header-title {
    font-size: 1.15rem;
    letter-spacing: -.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .tool-header-desc {
    font-size: .8rem;
    max-width: 100%;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .tool-header-right {
    width: 100%;
    flex-wrap: wrap;
    gap: 6px;
  }
  /* Badge: truncate long category names */
  .tool-header-right .badge {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Mode buttons: wrap and shrink */
  .mode-toggle { flex-wrap: wrap; }
  .mode-btn { padding: 6px 12px; font-size: .8rem; flex-shrink: 1; min-width: 0; }

  /* Options row: ensure wrapping */
  .options-row { gap: 8px; }
  .options-row .form-group { min-width: 100px; flex-basis: calc(50% - 8px); }

  /* Textarea / IO must not be wider than parent */
  .io-textarea { min-height: 120px; }

  /* IO areas: stack columns */
  .io-row { grid-template-columns: 1fr; }

  /* Tech specs */
  .tech-specs-grid { grid-template-columns: 1fr; }
}

/* ── Small phone ≤480px ── */
@media (max-width: 480px) {
  .tool-widget { padding: 14px; }
  .seo-block { padding: 16px; }
  .result-grid { grid-template-columns: 1fr 1fr; }

  /* Header: even more compact */
  .tool-header-icon { width: 34px; height: 34px; font-size: 1.1rem; }
  .tool-header-title { font-size: 1rem; }
  .tool-header-desc { font-size: .75rem; -webkit-line-clamp: 1; line-clamp: 1; }
  .tool-header-left { gap: 8px; }
  .breadcrumb-item { font-size: .65rem; }
  .breadcrumb-item.current { max-width: 35%; }

  /* Mode/options buttons: tighter on 360px to prevent overflow */
  .mode-btn { padding: 6px 8px; font-size: .76rem; }
  .options-row .btn { padding: 7px 10px; font-size: .78rem; }
  .options-row { gap: 6px; }
}



/* ── SEO MEDIA SLIDER ── */
.media-slider {
  display: flex; gap: 16px; overflow-x: auto;
  padding-bottom: 12px;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin; scrollbar-color: var(--border-2) transparent;
}
.media-slider::-webkit-scrollbar { height: 6px; }
.media-slider::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 4px; }
.slide {
  flex: 0 0 calc(100% - 32px); max-width: 600px;
  scroll-snap-align: center; border-radius: var(--r-md); overflow: hidden;
  border: 1px solid var(--border-2); background: #000;
  aspect-ratio: 16 / 9;
}
.slide img { width: 100%; height: auto; display: block; aspect-ratio: 16 / 9; object-fit: cover; }
@media (min-width: 640px) { .slide { flex: 0 0 85%; } }
@media (min-width: 900px) { .slide { flex: 0 0 calc(50% - 8px); } }

/* ── COLLAPSIBLE TOOL SECTIONS (native <details>) ── */
.tool-collapse {
  border: 1px solid var(--border-1);
  border-radius: var(--r-md);
  margin-bottom: 10px;
  background: var(--bg-3);
  overflow: hidden;
}
.tool-collapse > summary {
  padding: 9px 14px;
  font-size: .78rem;
  font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .06em;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
  list-style: none;          /* hide default triangle */
}
.tool-collapse > summary::-webkit-details-marker { display: none; }
.tool-collapse > summary::before {
  content: '▸';
  font-size: .7rem;
  transition: transform .2s;
  display: inline-block;
}
.tool-collapse[open] > summary::before { transform: rotate(90deg); }
.tool-collapse > .tool-collapse-body {
  padding: 10px 14px 14px;
  border-top: 1px solid var(--border-1);
}

/* ── COMPACT ACTION TOOLBAR ── */
.tool-action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.tool-action-bar .btn-sm {
  padding: 4px 10px;
  font-size: .72rem;
}
@media (max-width: 480px) {
  .tool-action-bar .btn-sm {
    padding: 4px 8px;
    font-size: .68rem;
  }
}
