/* ===========================================================
   Package Lock Inspector — Styles
   Theme: Dark mode · Glassmorphism · Premium feel
   =========================================================== */

/* ── Reset & Variables ─────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #6C5CE7;
  --primary-light: #A29BFE;
  --accent: #00CEC9;
  --bg: #0B0E11;
  --bg-card: rgba(20, 24, 32, 0.7);
  --bg-card-solid: #141820;
  --bg-hover: rgba(108, 92, 231, 0.08);
  --border: rgba(108, 92, 231, 0.15);
  --border-hover: rgba(108, 92, 231, 0.35);
  --text: #E8E6F0;
  --text-muted: #8B8A9E;
  --text-dim: #5A5872;
  --success: #00B894;
  --warning: #FDCB6E;
  --danger: #FF6B6B;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --transition: 220ms ease;
  --glass: rgba(255, 255, 255, 0.04);
  --glass-border: rgba(255, 255, 255, 0.06);
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

/* ── Utilities ─────────────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden {
  display: none !important;
}

code {
  background: rgba(108, 92, 231, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.875em;
  color: var(--primary-light);
}

/* ── App Container ─────────────────────────────────────────── */
.app-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* ── Header ────────────────────────────────────────────────── */
.app-header {
  margin-bottom: 32px;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-icon {
  flex-shrink: 0;
}

.app-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}

.tagline {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Upload Section ────────────────────────────────────────── */
.upload-section {
  max-width: 640px;
  margin: 60px auto;
}

.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 32px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
  background: var(--glass);
}

.upload-area:hover,
.upload-area:focus-visible,
.upload-area.drag-over {
  border-color: var(--primary);
  background: var(--bg-hover);
  transform: translateY(-2px);
}

.upload-area:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.upload-icon {
  margin-bottom: 16px;
  opacity: 0.8;
}

.upload-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.upload-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.paste-area {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.paste-area textarea {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  color: var(--text);
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.8rem;
  resize: vertical;
  transition: border-color var(--transition);
  line-height: 1.5;
}

.paste-area textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.paste-area textarea::placeholder {
  color: var(--text-dim);
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #7f6cf7);
  color: #fff;
  box-shadow: 0 4px 14px rgba(108, 92, 231, 0.3);
}

.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(108, 92, 231, 0.45);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--border-hover);
  background: var(--bg-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

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

/* ── Dashboard ─────────────────────────────────────────────── */
.dashboard {
  animation: fadeIn 0.4s ease;
}

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

/* ── Stats Bar ─────────────────────────────────────────────── */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 18px 16px;
  text-align: center;
  transition: border-color var(--transition), transform var(--transition);
}

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

.stat-value {
  display: block;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary-light);
  line-height: 1.2;
}

.stat-conflicts .stat-value {
  color: var(--warning);
}

.stat-duplicates .stat-value {
  color: var(--danger);
}

.stat-bloat .stat-value {
  color: var(--accent);
}

.stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Toolbar ───────────────────────────────────────────────── */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 8px 12px 8px 38px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.85rem;
  transition: border-color var(--transition);
}

.search-box input:focus {
  outline: none;
  border-color: var(--primary);
}

.search-box input::placeholder {
  color: var(--text-dim);
}

.filter-group {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 6px 14px;
  border-radius: 999px;
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  transition: all var(--transition);
}

.filter-btn:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

.filter-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.toolbar-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

/* ── Main Content ──────────────────────────────────────────── */
.main-content {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  margin-bottom: 24px;
}

/* ── Tree Panel ────────────────────────────────────────────── */
.tree-panel {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 20px;
  backdrop-filter: blur(12px);
  overflow: auto;
  min-height: 400px;
  max-height: 70vh;
}

.panel-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tree-container {
  font-size: 0.82rem;
}

/* Tree Item */
.tree-item {
  list-style: none;
}

.tree-node {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: background var(--transition);
  user-select: none;
}

.tree-node:hover {
  background: var(--bg-hover);
}

.tree-node:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.tree-node.selected {
  background: rgba(108, 92, 231, 0.15);
}

.tree-toggle {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-dim);
  transition: transform var(--transition);
}

.tree-toggle.expanded {
  transform: rotate(90deg);
}

.tree-toggle.empty {
  visibility: hidden;
}

.tree-name {
  font-weight: 500;
  color: var(--text);
}

.tree-version {
  color: var(--text-dim);
  font-size: 0.78em;
}

.tree-badge {
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 600;
  line-height: 1.5;
  flex-shrink: 0;
}

.badge-conflict {
  background: rgba(253, 203, 110, 0.15);
  color: var(--warning);
  border: 1px solid rgba(253, 203, 110, 0.25);
}

.badge-duplicate {
  background: rgba(255, 107, 107, 0.15);
  color: var(--danger);
  border: 1px solid rgba(255, 107, 107, 0.25);
}

.badge-direct {
  background: rgba(0, 206, 201, 0.12);
  color: var(--accent);
  border: 1px solid rgba(0, 206, 201, 0.2);
}

.tree-children {
  padding-left: 20px;
  list-style: none;
  overflow: hidden;
}

.tree-children.collapsed {
  display: none;
}

/* Highlight match */
.highlight-match {
  background: rgba(108, 92, 231, 0.3);
  border-radius: 2px;
}

/* ── Detail Panel ──────────────────────────────────────────── */
.detail-panel {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 20px;
  backdrop-filter: blur(12px);
  max-height: 70vh;
  overflow-y: auto;
  position: sticky;
  top: 24px;
}

.detail-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.85rem;
}

.detail-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  word-break: break-all;
  margin-bottom: 10px;
}

.detail-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.detail-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 12px;
  font-size: 0.82rem;
}

.detail-list dt {
  color: var(--text-muted);
  font-weight: 500;
}

.detail-list dd {
  color: var(--text);
  word-break: break-all;
}

/* ── License Panel ─────────────────────────────────────────── */
.license-panel {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 20px;
  backdrop-filter: blur(12px);
}

.license-chart {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.license-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.license-label {
  font-size: 0.8rem;
  color: var(--text);
  min-width: 110px;
  font-weight: 500;
}

.license-track {
  flex: 1;
  height: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 999px;
  overflow: hidden;
}

.license-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.license-count {
  font-size: 0.78rem;
  color: var(--text-muted);
  min-width: 32px;
  text-align: right;
}

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(108, 92, 231, 0.2);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(108, 92, 231, 0.4);
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 900px) {
  .main-content {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    position: static;
    max-height: none;
  }

  .stats-bar {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 600px) {
  .app-container {
    padding: 16px 12px 40px;
  }

  .upload-area {
    padding: 32px 20px;
  }

  .stats-bar {
    grid-template-columns: repeat(2, 1fr);
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-actions {
    margin-left: 0;
    justify-content: flex-end;
  }

  .filter-group {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
  }

  .app-header h1 {
    font-size: 1.2rem;
  }
}
