/* TreeDock.css — панель переключения деревьев */
#tree-dock {
  position: fixed;
  left: 0;
  top: 62px;
  bottom: 0;
  width: 190px;
  background: linear-gradient(180deg, #2a1f14 0%, #3d2b1a 50%, #2e2116 100%);
  border-right: 1px solid #5a3e28;
  display: flex;
  flex-direction: column;
  z-index: 500;
  box-shadow: 4px 0 20px rgba(0,0,0,0.35);
  transition: width 0.3s cubic-bezier(0.4,0,0.2,1);
  overflow: hidden;
}
#tree-dock.collapsed { width: 44px; }
#tree-dock.collapsed .dock-title-full,
#tree-dock.collapsed .dock-card-info { opacity: 0; pointer-events: none; }
#tree-dock.collapsed .dock-card { padding: 8px 4px; justify-content: center; }
#tree-dock.collapsed .dock-card-preview { width: 30px; height: 30px; }
.dock-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px 8px;
  border-bottom: 1px solid rgba(201,169,110,0.2);
  flex-shrink: 0;
}
.dock-title { font-size: 1.1rem; flex-shrink: 0; }
.dock-title-full {
  font-size: 0.82rem;
  color: #c9a96e;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  flex: 1;
  transition: opacity 0.2s ease;
  font-family: Georgia, serif;
}
.dock-toggle {
  background: rgba(201,169,110,0.12);
  border: 1px solid rgba(201,169,110,0.25);
  color: #c9a96e;
  border-radius: 4px;
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 0.65rem;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.2s;
}
.dock-toggle:hover { background: rgba(201,169,110,0.28); }
.dock-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  scrollbar-width: thin;
  scrollbar-color: #5a3e28 transparent;
}
.dock-scroll::-webkit-scrollbar { width: 4px; }
.dock-scroll::-webkit-scrollbar-thumb { background: #5a3e28; border-radius: 2px; }
.dock-card {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 7px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  background: rgba(255,255,255,0.04);
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
  position: relative;
  overflow: hidden;
}
.dock-card:hover {
  background: rgba(201,169,110,0.1);
  border-color: rgba(201,169,110,0.3);
  transform: translateX(2px);
}
.dock-card.active {
  background: rgba(201,169,110,0.15);
  border-color: rgba(201,169,110,0.55);
}
.dock-card.active::before {
  content: '';
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 3px;
  background: linear-gradient(180deg, #e8c97a, #c9a96e);
  border-radius: 0 2px 2px 0;
}
.dock-card-num {
  font-size: 0.68rem;
  color: rgba(201,169,110,0.45);
  min-width: 13px;
  text-align: center;
  flex-shrink: 0;
  font-family: Georgia, serif;
}
.dock-card.active .dock-card-num { color: #c9a96e; font-weight: 700; }
.dock-card-preview {
  width: 52px; height: 36px;
  flex-shrink: 0;
  border-radius: 5px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  transition: width 0.3s, height 0.3s;
}
.dock-card-preview svg { width: 100%; height: 100%; }
.dock-card.active .dock-card-preview { border-color: rgba(201,169,110,0.45); }
.dock-card-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: opacity 0.2s;
}
.dock-card-name {
  font-size: 0.8rem;
  font-weight: 500;
  color: #e8ddd0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
  font-family: Georgia, serif;
}
.dock-card.active .dock-card-name { color: #f5ead8; }
.dock-card-count {
  font-size: 0.7rem;
  color: rgba(201,169,110,0.55);
  font-style: italic;
  font-family: Georgia, serif;
}
.dock-card.active .dock-card-count { color: #c9a96e; }
/* Tooltip при свёрнутом dock */
#tree-dock.collapsed .dock-card {
  position: relative;
}
#tree-dock.collapsed .dock-card:hover::after {
  content: attr(title);
  position: absolute;
  left: 46px; top: 50%;
  transform: translateY(-50%);
  background: #2a1f14;
  color: #e8ddd0;
  border: 1px solid rgba(201,169,110,0.45);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.8rem;
  white-space: nowrap;
  z-index: 1000;
  box-shadow: 4px 4px 12px rgba(0,0,0,0.45);
  pointer-events: none;
  font-family: Georgia, serif;
}
/* Сдвиг основного layout вправо */
body:has(#tree-dock:not(.collapsed)) .app-main {
  margin-left: 190px;
  transition: margin-left 0.3s cubic-bezier(0.4,0,0.2,1);
}
body:has(#tree-dock.collapsed) .app-main {
  margin-left: 44px;
  transition: margin-left 0.3s cubic-bezier(0.4,0,0.2,1);
}
/* fallback */
.app-main.dock-open { margin-left: 190px; transition: margin-left 0.3s cubic-bezier(0.4,0,0.2,1); }
.app-main.dock-collapsed { margin-left: 44px; transition: margin-left 0.3s cubic-bezier(0.4,0,0.2,1); }

/* =====================================================
   Мобильный — исправлен горизонтальный скролл
   ===================================================== */
@media (max-width: 768px) {
  #tree-dock {
    top: auto; bottom: 0; left: 0; right: 0;
    width: 100% !important;
    height: 76px;
    flex-direction: row;
    border-right: none;
    border-top: 1px solid #5a3e28;
    overflow: visible; /* ← fix: было hidden — блокировало скролл */
  }
  .dock-header {
    width: 44px;
    flex-shrink: 0; /* ← fix: не сжимается */
    flex-direction: column;
    justify-content: center;
    border-bottom: none;
    border-right: 1px solid rgba(201,169,110,0.2);
    padding: 4px;
  }
  .dock-title-full, .dock-toggle { display: none; }
  .dock-scroll {
    flex-direction: row;
    padding: 5px;
    gap: 5px;
    overflow-x: auto;   /* ← fix: горизонтальный скролл */
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch; /* ← fix: плавный скролл iOS */
    scrollbar-width: none;
  }
  .dock-scroll::-webkit-scrollbar { display: none; }
  .dock-card {
    flex-direction: column;
    padding: 4px 5px;
    gap: 2px;
    min-width: 54px;
    flex-shrink: 0; /* ← fix: карточки не сжимаются, выходят за край */
    align-items: center;
  }
  .dock-card-num, .dock-card-count { display: none; }
  .dock-card-info { align-items: center; }
  .dock-card-name { font-size: 0.68rem; }
  .dock-card.active::before {
    left: 5px; right: 5px; top: 0; bottom: auto;
    width: auto; height: 2px;
  }
  body:has(#tree-dock) .app-main,
  .app-main.dock-open { margin-left: 0 !important; margin-bottom: 76px; }
}

/* =====================================================
   Каскадный попап при hover
   ===================================================== */
.dock-popup {
  position: fixed;
  z-index: 600;
  width: 320px;
  background: linear-gradient(160deg, #2e2116 0%, #3d2b1a 60%, #2a1f14 100%);
  border: 1px solid rgba(201,169,110,0.4);
  border-radius: 12px;
  box-shadow: 6px 6px 32px rgba(0,0,0,0.55), 0 0 0 1px rgba(201,169,110,0.1) inset;
  padding: 0;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transform: translateX(-8px) scale(0.97);
  transform-origin: left center;
  transition: opacity 0.22s cubic-bezier(0.4,0,0.2,1),
              transform 0.22s cubic-bezier(0.4,0,0.2,1);
}
.dock-popup.visible {
  opacity: 1;
  transform: translateX(0) scale(1);
  pointer-events: auto;
}
/* Стрелка-указатель влево */
.dock-popup::before {
  content: '';
  position: absolute;
  left: -7px;
  top: 50%;
  transform: translateY(-50%);
  width: 0; height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-right: 7px solid rgba(201,169,110,0.45);
}
.dock-popup::after {
  content: '';
  position: absolute;
  left: -5px;
  top: 50%;
  transform: translateY(-50%);
  width: 0; height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 6px solid #3d2b1a;
}
.dock-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 10px 14px 6px;
  border-bottom: 1px solid rgba(201,169,110,0.2);
}
.dock-popup-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 0.88rem;
  font-weight: 600;
  color: #f0e6d0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}
.dock-popup-count {
  font-size: 0.72rem;
  color: #c9a96e;
  font-style: italic;
  font-family: Georgia, serif;
  white-space: nowrap;
}
.dock-popup-svg-wrap {
  padding: 8px 10px 6px;
  height: 230px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dock-popup-svg {
  width: 100%;
  height: 100%;
}
.dock-popup-hint {
  text-align: center;
  padding: 4px 0 8px;
  font-size: 0.68rem;
  color: rgba(201,169,110,0.45);
  font-family: Georgia, serif;
  font-style: italic;
  letter-spacing: 0.04em;
}
