/* === Tool Details Panel === */

/* Overlay backdrop (mobile) */
#panel-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 199;
}

#panel-overlay.visible {
  display: block;
  pointer-events: none;
}

/* Panel container */
#tool-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 340px;
  height: 100vh;
  height: 100dvh;
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
  z-index: 200;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 250ms ease;
  will-change: transform;
}

#tool-panel.open {
  transform: translateX(0);
}

/* Header bar */
#panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

#panel-header-text {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
  flex: 1;
}

#panel-title {
  font-size: var(--font-size-lg);
  font-weight: bold;
  color: var(--color-text-primary);
  line-height: 1.3;
  word-break: break-word;
}

#panel-close {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 2px var(--space-1);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

#panel-close:hover {
  color: var(--color-text-primary);
  background: var(--color-bg);
}

/* Panel body sections */
#panel-body {
  flex: 1;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  overflow-y: auto;
}

/* Breadcrumb (lives in panel-header now) */
#panel-breadcrumb {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  line-height: 1.5;
  word-break: break-word;
}

#panel-breadcrumb.empty {
  display: none;
}

/* Badges */
#panel-badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

#panel-badges.empty {
  display: none;
}

/* Description */
#panel-description-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

#panel-description-section.empty {
  display: none;
}

.panel-section-label {
  font-size: var(--font-size-sm);
  font-weight: bold;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#panel-description {
  font-size: var(--font-size-base);
  color: var(--color-text-primary);
  line-height: 1.5;
}

/* Usage context */
#panel-usage-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

#panel-usage-section.empty {
  display: none;
}

#panel-usage {
  font-size: var(--font-size-base);
  color: var(--color-text-primary);
  line-height: 1.5;
}

/* Input → Output */
#panel-io-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

#panel-io-section.empty {
  display: none;
}

#panel-io {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

/* OPSEC notes */
#panel-opsec-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

#panel-opsec-section.empty {
  display: none;
}

#panel-opsec {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* Community rating */
#panel-rating-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

#panel-rating-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

#star-rating {
  display: flex;
  align-items: center;
  gap: 2px;
}

.star-zero-btn {
  background: none;
  border: 1px solid var(--color-text-secondary);
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  color: var(--color-text-secondary);
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 2px;
  transition: color 100ms ease, border-color 100ms ease, transform 100ms ease;
}

.star-zero-btn:hover {
  transform: scale(1.15);
  color: #e8960f;
  border-color: #e8960f;
}

.star-zero-btn.active {
  color: #e8960f;
  border-color: #e8960f;
  background: rgba(232, 150, 15, 0.1);
}

.star-pos {
  position: relative;
  display: inline-block;
  cursor: pointer;
}

.star-icon {
  font-size: 22px;
  line-height: 1;
  color: var(--color-text-secondary);
  pointer-events: none;
  transition: color 100ms ease, transform 100ms ease;
}

.star-pos:hover .star-icon {
  transform: scale(1.15);
}

.star-icon.filled {
  color: #f5a623;
}

.star-icon.half-filled {
  background: linear-gradient(to right, #f5a623 50%, var(--color-text-secondary) 50%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.star-icon.user-rated {
  color: #e8960f;
}

.star-icon.user-rated.half-filled {
  background: linear-gradient(to right, #e8960f 50%, var(--color-text-secondary) 50%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.star-click {
  position: absolute;
  top: 0;
  height: 100%;
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0;
  padding: 0;
  margin: 0;
}

.star-click.star-left {
  left: 0;
  width: 50%;
}

.star-click.star-right {
  left: 50%;
  width: 50%;
}

#rating-avg {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  white-space: nowrap;
}

/* Footer (sticky, always visible) */
#panel-footer {
  flex-shrink: 0;
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
}

/* Report buttons */
#panel-report-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

#panel-report-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.report-btn {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-3);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  cursor: pointer;
  font-family: var(--font-family);
  transition: background 150ms ease, color 150ms ease;
}

.report-btn:hover {
  background: var(--color-bg);
  color: var(--color-text-primary);
}

/* Dividers */
.panel-divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 0;
}

/* CTA button */
#panel-cta-section {
  flex-shrink: 0;
  text-align: center;
}

#panel-cta-section.empty {
  display: none;
}

#panel-open-tool {
  display: inline-block;
  padding: var(--space-3) var(--space-5);
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  font-family: var(--font-family);
  font-weight: bold;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
}

#panel-open-tool:hover {
  opacity: 0.88;
}


/* Enrichment badge pills (status, pricing, opsec) */
.badge-pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: var(--font-size-sm);
  font-weight: bold;
  color: #fff;
  text-transform: capitalize;
  white-space: nowrap;
}

/* Status badges */
.badge-live      { background: #2d9e2d; }
.badge-down      { background: #c84040; }
.badge-degraded  { background: #b87800; }

/* Pricing badges */
.badge-free      { background: #2d9e2d; }
.badge-freemium  { background: #b87800; }
.badge-paid      { background: #c84040; }

/* OPSEC badges */
.badge-passive   { background: #2d9e2d; }
.badge-active    { background: #c84040; }

/* Unknown / fallback */
.badge-unknown          { background: #606060; }

/* Boolean feature badges */
.badge-api              { background: #1e90cc; }
.badge-invitation-only  { background: #b87800; }
.badge-deprecated       { background: #8b3030; }
.badge-nsfw             { background: #9b2b9b; }
.badge-region           { background: #2e7d32; }

/* OPSEC row layout */
.opsec-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.opsec-note {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  line-height: 1.5;
}

/* Usage context sub-fields */
.usage-best-for {
  margin-bottom: var(--space-2);
}

.usage-io {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

/* Description placeholder */
.panel-placeholder {
  font-style: italic;
  color: var(--color-text-secondary);
}

/* Node selection ring */
.node circle.selected-ring {
  stroke: var(--color-accent);
  stroke-width: 3px;
}

/* Mobile: full-screen overlay */
@media (max-width: 768px) {
  #tool-panel {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    top: 0;
    right: 0;
    border-left: none;
    border-radius: 0;
  }

  #panel-overlay.visible {
    pointer-events: auto;
  }
}


/* =====================================================
   ADVANCED CYBER PANEL UPGRADE
   ===================================================== */

#tool-panel{
  background:
    rgba(11,16,32,.92) !important;

  backdrop-filter:
    blur(30px);

  border-left:
    1px solid rgba(255,255,255,.08);

  box-shadow:
    -20px 0 60px rgba(0,0,0,.55);

  overflow:hidden;
}

#tool-panel::before{
  content:"";

  position:absolute;

  top:-150px;
  right:-150px;

  width:300px;
  height:300px;

  background:
    radial-gradient(
      circle,
      rgba(108,99,255,.30),
      transparent 70%
    );

  filter:blur(40px);

  pointer-events:none;
}

#tool-panel::after{
  content:"";

  position:absolute;

  bottom:-150px;
  left:-150px;

  width:300px;
  height:300px;

  background:
    radial-gradient(
      circle,
      rgba(0,212,255,.20),
      transparent 70%
    );

  filter:blur(40px);

  pointer-events:none;
}

/* =====================================================
   HEADER
   ===================================================== */

#panel-header{

  background:
    rgba(255,255,255,.03);

  backdrop-filter:
    blur(20px);

  border-bottom:
    1px solid rgba(255,255,255,.08);

  padding:20px;
}

#panel-title{

  font-size:20px;

  font-weight:700;

  color:#fff;

  letter-spacing:.3px;
}

#panel-breadcrumb{

  color:#94a3b8;

  font-size:12px;
}

#panel-close{

  width:36px;
  height:36px;

  display:flex;
  align-items:center;
  justify-content:center;

  border-radius:12px;

  transition:.3s;
}

#panel-close:hover{

  background:
    rgba(255,255,255,.08);

  transform:rotate(90deg);
}

/* =====================================================
   BODY
   ===================================================== */

#panel-body{

  padding:24px;

  gap:22px;

  scrollbar-width:thin;
}

#panel-body::-webkit-scrollbar{
  width:6px;
}

#panel-body::-webkit-scrollbar-thumb{
  background:#334155;
  border-radius:10px;
}

/* =====================================================
   SECTION CARDS
   ===================================================== */

#panel-description-section,
#panel-usage-section,
#panel-opsec-section,
#panel-rating-section,
#panel-io-section{

  background:
    rgba(255,255,255,.03);

  border:
    1px solid rgba(255,255,255,.05);

  border-radius:18px;

  padding:16px;
}

.panel-section-label{

  color:#00d4ff;

  font-size:11px;

  letter-spacing:1px;

  margin-bottom:6px;
}

/* =====================================================
   TEXT
   ===================================================== */

#panel-description,
#panel-usage,
#panel-opsec,
#panel-io{

  color:#d1d5db;

  line-height:1.7;
}

/* =====================================================
   BADGES
   ===================================================== */

.badge-pill{

  border-radius:999px;

  padding:6px 12px;

  font-size:11px;

  font-weight:700;

  box-shadow:
    0 5px 15px rgba(0,0,0,.15);
}

.badge-live{
  background:linear-gradient(135deg,#16a34a,#22c55e);
}

.badge-down{
  background:linear-gradient(135deg,#dc2626,#ef4444);
}

.badge-degraded{
  background:linear-gradient(135deg,#ca8a04,#facc15);
}

.badge-free{
  background:linear-gradient(135deg,#16a34a,#22c55e);
}

.badge-paid{
  background:linear-gradient(135deg,#dc2626,#ef4444);
}

.badge-freemium{
  background:linear-gradient(135deg,#ca8a04,#facc15);
}

.badge-api{
  background:linear-gradient(135deg,#2563eb,#38bdf8);
}

.badge-active{
  background:linear-gradient(135deg,#ef4444,#f87171);
}

.badge-passive{
  background:linear-gradient(135deg,#16a34a,#4ade80);
}

/* =====================================================
   STARS
   ===================================================== */

#panel-rating-row{
  gap:15px;
}

.star-icon{

  transition:
    transform .2s ease,
    color .2s ease;
}

.star-pos:hover .star-icon{

  transform:scale(1.25);
}

.star-icon.filled{
  color:#fbbf24;
}

.star-icon.user-rated{
  color:#f59e0b;
}

/* =====================================================
   REPORT BUTTONS
   ===================================================== */

.report-btn{

  border:none;

  background:
    rgba(255,255,255,.05);

  color:#cbd5e1;

  border-radius:12px;

  transition:.3s;
}

.report-btn:hover{

  background:
    rgba(0,212,255,.12);

  color:#fff;

  transform:
    translateY(-2px);
}

/* =====================================================
   FOOTER
   ===================================================== */

#panel-footer{

  background:
    rgba(255,255,255,.03);

  backdrop-filter:
    blur(20px);

  border-top:
    1px solid rgba(255,255,255,.08);

  padding:20px;
}

/* =====================================================
   CTA BUTTON
   ===================================================== */

#panel-open-tool{

  width:100%;

  padding:15px;

  border-radius:16px;

  background:
    linear-gradient(
      135deg,
      #6c63ff,
      #00d4ff
    );

  font-size:15px;

  font-weight:700;

  transition:.35s;

  box-shadow:
    0 10px 25px rgba(0,212,255,.20);
}

#panel-open-tool:hover{

  transform:
    translateY(-3px);

  box-shadow:
    0 15px 35px rgba(0,212,255,.35);
}

/* =====================================================
   PANEL OPEN ANIMATION
   ===================================================== */

@keyframes panelSlide{

  from{
    transform:
      translateX(100%);
    opacity:0;
  }

  to{
    transform:
      translateX(0);
    opacity:1;
  }
}

#tool-panel.open{
  animation:
    panelSlide .35s ease;
}

/* =====================================================
   MOBILE
   ===================================================== */

@media (max-width:768px){

  #tool-panel{

    width:100vw;

    border-left:none;
  }

  #panel-header{
    padding:18px;
  }

  #panel-body{
    padding:18px;
  }

  #panel-open-tool{
    font-size:14px;
  }
}
