/* css/shared-features.css — shared styles for theme, favorites, share, search, badges */

/* ── LIGHT/DARK THEME ───────────────────────────────────────── */
body.light-theme {
  --primary-bg: #f5f5f0;
  --secondary-bg: #ffffff;
  --card-bg: #ffffff;
  --text-primary: #1a1a2e;
  --text-secondary: #4a4a6a;
  --border-color: #d0d0e0;
  --gold: #b8860b;
  --shadow: rgba(0,0,0,0.1);
}

body.light-theme {
  background: linear-gradient(135deg, #f5f5f0 0%, #e8e8f0 100%) !important;
}

body.light-theme header {
  background: rgba(255,255,255,0.97) !important;
  color: #1a1a2e;
}

body.light-theme .node-box {
  border-color: var(--border-color) !important;
}

/* Legend has its own dark background — keep text always white */
.legend,
.legend-item {
  color: #ecf0f1 !important;
}

body.light-theme .stats,
body.light-theme .info-panel,
body.light-theme .list-item,
body.light-theme .list-panel {
  background: var(--secondary-bg) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-color) !important;
}

body.light-theme .info-section,
body.light-theme .info-header {
  color: var(--text-primary) !important;
}

/* ── THEME TOGGLE BUTTON ─────────────────────────────────────── */
.theme-toggle-btn {
  background: rgba(255,255,255,0.1);
  border: 1px solid var(--gold);
  color: var(--gold);
  border-radius: 20px;
  padding: 0.3rem 0.75rem;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.3s;
  white-space: nowrap;
  font-family: inherit;
}
.theme-toggle-btn:hover { background: var(--gold); color: #000; }
body.light-theme .theme-toggle-btn { background: rgba(0,0,0,0.05); }

/* ── FAVORITES TOGGLE BUTTON ─────────────────────────────────── */
.fav-toggle-btn {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(241,196,15,0.4);
  color: var(--text-secondary);
  border-radius: 20px;
  padding: 0.3rem 0.75rem;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.3s;
  font-family: inherit;
  position: relative;
}
.fav-toggle-btn:hover { border-color: var(--gold); color: var(--gold); }
.fav-toggle-btn.has-favs { color: #f1c40f; border-color: #f1c40f; }

/* ── FAVORITES PANEL ─────────────────────────────────────────── */
.favorites-panel {
  position: fixed;
  top: 75px;
  right: 16px;
  background: var(--secondary-bg, #1a1f2e);
  border: 1px solid var(--gold, #f1c40f);
  border-radius: 12px;
  padding: 14px;
  min-width: 230px;
  max-width: 300px;
  z-index: 1050;
  box-shadow: 0 6px 24px rgba(0,0,0,0.5);
  display: none;
}
.favorites-panel.open { display: block; }
.favorites-panel h4 {
  color: var(--gold, #f1c40f);
  margin: 0 0 10px;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border-color, #34495e);
  padding-bottom: 8px;
}
.fav-item {
  padding: 7px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-primary, #ecf0f1);
  transition: background 0.15s;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}
.fav-item:hover { background: rgba(241,196,15,0.1); }
.fav-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fav-item-remove {
  color: var(--text-secondary, #bdc3c7);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  flex-shrink: 0;
}
.fav-item-remove:hover { color: #e74c3c; background: rgba(231,76,60,0.1); }
.fav-empty {
  color: var(--text-secondary, #bdc3c7);
  font-size: 0.82rem;
  text-align: center;
  padding: 10px 0;
}

/* ── STAR BUTTON (on info panel) ─────────────────────────────── */
.star-btn {
  background: transparent;
  border: 1px solid rgba(241,196,15,0.3);
  border-radius: 16px;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.3rem 0.75rem;
  transition: all 0.2s;
  color: var(--text-secondary, #bdc3c7);
  font-family: inherit;
}
.star-btn:hover { border-color: var(--gold, #f1c40f); color: var(--gold, #f1c40f); }
.star-btn.active { color: #f1c40f; border-color: #f1c40f; background: rgba(241,196,15,0.1); }

/* ── SHARE BUTTON ────────────────────────────────────────────── */
.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(52,152,219,0.1);
  border: 1px solid rgba(52,152,219,0.5);
  color: #3498db;
  border-radius: 16px;
  padding: 0.3rem 0.9rem;
  cursor: pointer;
  font-size: 0.82rem;
  transition: all 0.25s;
  font-family: inherit;
}
.share-btn:hover { background: #3498db; color: #fff; border-color: #3498db; }

.share-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: #27ae60;
  color: #fff;
  padding: 0.6rem 1.4rem;
  border-radius: 20px;
  font-size: 0.88rem;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 9999;
  pointer-events: none;
  white-space: nowrap;
}
.share-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── ACTION BAR (share + star) ───────────────────────────────── */
.node-action-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px 0 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color, #34495e);
}

/* ── TAMGA SVG ───────────────────────────────────────────────── */
.tamga-svg-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 6px 0 4px;
}
.tamga-svg-wrap svg {
  filter: drop-shadow(0 0 8px rgba(231,76,60,0.4));
  transition: filter 0.3s;
}
.tamga-svg-wrap svg:hover {
  filter: drop-shadow(0 0 12px rgba(231,76,60,0.7));
}

/* ── EMPTY STATE ─────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 14px 12px;
  border: 1px dashed var(--border-color, #34495e);
  border-radius: 10px;
  margin: 10px 0;
  color: var(--text-secondary, #bdc3c7);
  font-size: 0.82rem;
  line-height: 1.5;
}
.empty-state a {
  color: var(--gold, #f1c40f);
  text-decoration: none;
  font-size: 0.8rem;
  display: inline-block;
  margin-top: 6px;
  padding: 3px 10px;
  border: 1px solid rgba(241,196,15,0.3);
  border-radius: 10px;
  transition: all 0.2s;
}
.empty-state a:hover { background: rgba(241,196,15,0.1); }

/* ── SEARCH DROPDOWN ─────────────────────────────────────────── */
.search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--secondary-bg, #1a1f2e);
  border: 1px solid var(--gold, #f1c40f);
  border-top: none;
  border-radius: 0 0 12px 12px;
  max-height: 300px;
  overflow-y: auto;
  z-index: 1200;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  display: none;
}
.search-dropdown.open { display: block; }
.search-result-item {
  padding: 9px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-color, #34495e);
  transition: background 0.15s;
}
.search-result-item:last-child { border-bottom: none; border-radius: 0 0 12px 12px; }
.search-result-item:hover { background: rgba(241,196,15,0.1); }
.search-result-name {
  font-size: 0.9rem;
  color: var(--text-primary, #ecf0f1);
  font-weight: 600;
}
.search-result-name mark {
  background: rgba(241,196,15,0.3);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}
.search-result-path {
  font-size: 0.73rem;
  color: var(--text-secondary, #bdc3c7);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── BREADCRUMBS ─────────────────────────────────────────────── */
.breadcrumb-bar {
  position: fixed;
  top: 70px;
  left: 0;
  right: 0;
  background: rgba(10,12,16,0.93);
  border-bottom: 1px solid var(--border-color, #34495e);
  padding: 5px 20px;
  font-size: 0.78rem;
  color: var(--text-secondary, #bdc3c7);
  z-index: 990;
  display: none;
  align-items: center;
  gap: 5px;
  backdrop-filter: blur(8px);
  overflow-x: auto;
  scrollbar-width: none;
}
.breadcrumb-bar::-webkit-scrollbar { display: none; }
.breadcrumb-bar.visible { display: flex; }
body.light-theme .breadcrumb-bar { background: rgba(245,245,240,0.96); }
.breadcrumb-sep { opacity: 0.45; flex-shrink: 0; }
.breadcrumb-crumb {
  color: var(--gold, #f1c40f);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: opacity 0.2s;
}
.breadcrumb-crumb:hover { opacity: 0.75; }
.breadcrumb-crumb.current {
  color: var(--text-primary, #ecf0f1);
  cursor: default;
  font-weight: 600;
}
.breadcrumb-crumb.current:hover { opacity: 1; }

/* ── LIST FILTER CHIPS ───────────────────────────────────────── */
.list-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 10px 16px;
  background: var(--secondary-bg, #1a1f2e);
  border-bottom: 1px solid var(--border-color, #34495e);
  position: sticky;
  top: 70px;
  z-index: 100;
}
.filter-chip {
  padding: 4px 13px;
  border-radius: 14px;
  border: 1px solid var(--border-color, #34495e);
  background: transparent;
  color: var(--text-secondary, #bdc3c7);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  white-space: nowrap;
}
.filter-chip:hover { border-color: var(--gold, #f1c40f); color: var(--gold, #f1c40f); }
.filter-chip.active {
  background: var(--gold, #f1c40f);
  color: #000;
  border-color: var(--gold, #f1c40f);
  font-weight: 600;
}

.list-item.hidden-by-filter { display: none !important; }

/* ── LIST ITEM BADGES ────────────────────────────────────────── */
.list-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 5px;
}
.list-badge {
  font-size: 0.71rem;
  padding: 2px 8px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.badge-tamga {
  background: rgba(231,76,60,0.12);
  color: #e74c3c;
  border: 1px solid rgba(231,76,60,0.25);
}
.badge-uran {
  background: rgba(46,204,113,0.12);
  color: #2ecc71;
  border: 1px solid rgba(46,204,113,0.25);
}
.badge-pop {
  background: rgba(52,152,219,0.12);
  color: #3498db;
  border: 1px solid rgba(52,152,219,0.25);
}

/* ── PDF / PRINT BUTTON ──────────────────────────────────────── */
.print-btn {
  background: rgba(155,89,182,0.1);
  border: 1px solid rgba(155,89,182,0.5);
  color: #9b59b6;
  border-radius: 16px;
  padding: 0.3rem 0.9rem;
  cursor: pointer;
  font-size: 0.82rem;
  transition: all 0.25s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: inherit;
}
.print-btn:hover { background: #9b59b6; color: #fff; border-color: #9b59b6; }

/* ── PRINT STYLESHEET ────────────────────────────────────────── */
@media print {
  header,
  .list-filters,
  .print-btn,
  .theme-toggle-btn,
  .fav-toggle-btn,
  .favorites-panel,
  .share-btn,
  .star-btn,
  .node-action-bar,
  .breadcrumb-bar,
  .view-switch,
  .lang-switch,
  .burger-menu,
  .scroll-top-btn,
  .open-panel-btn,
  .close-panel-btn,
  .stats,
  .legend-box { display: none !important; }

  body {
    background: #fff !important;
    color: #000 !important;
    padding-top: 0 !important;
  }
  .list-panel { width: 100% !important; max-width: none !important; }
  .info-panel  { display: none !important; }
  .list-item   { break-inside: avoid; page-break-inside: avoid; }
  .list-item.hidden-by-filter { display: block !important; }
  .list-badge  { border: 1px solid #ccc !important; color: #333 !important; background: none !important; }
}

/* ── STATS PAGE ──────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
  padding: 24px;
  max-width: 1200px;
  margin: 0 auto;
}
.stats-card {
  background: var(--secondary-bg, #1a1f2e);
  border: 1px solid var(--border-color, #34495e);
  border-radius: 16px;
  padding: 20px;
}
.stats-card h3 {
  color: var(--gold, #f1c40f);
  font-size: 0.95rem;
  margin-bottom: 16px;
  text-align: center;
  font-weight: 600;
}
.kpi-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 24px 24px 0;
  max-width: 1200px;
  margin: 0 auto;
}
.kpi-card {
  flex: 1;
  min-width: 130px;
  background: var(--secondary-bg, #1a1f2e);
  border: 1px solid var(--border-color, #34495e);
  border-radius: 12px;
  padding: 16px 12px;
  text-align: center;
}
.kpi-value {
  font-size: 1.9rem;
  font-weight: bold;
  color: var(--gold, #f1c40f);
  line-height: 1;
}
.kpi-label {
  font-size: 0.78rem;
  color: var(--text-secondary, #bdc3c7);
  margin-top: 5px;
}

/* ── RESPONSIVE ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .favorites-panel { right: 8px; min-width: 200px; top: 72px; }
  .breadcrumb-bar  { font-size: 0.72rem; padding: 4px 12px; }
  .list-filters    { padding: 8px 12px; gap: 5px; }
  .kpi-row         { padding: 16px 16px 0; gap: 8px; }
  .stats-grid      { padding: 16px; gap: 16px; }
}
